From ffab746d22e5500dd06a2fad70f60fe6cb5e714b Mon Sep 17 00:00:00 2001 From: Guido Maria Serra Date: Thu, 21 May 2020 12:24:38 +0200 Subject: [PATCH 1/5] requires to reflect prometheus_client data structure --- .gitignore | 1 + test/test_exporter.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 4144c79..46bdeda 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ build/ dist/ htmlcov/ +.p3 diff --git a/test/test_exporter.py b/test/test_exporter.py index 5cdf91a..42f3e17 100644 --- a/test/test_exporter.py +++ b/test/test_exporter.py @@ -5,6 +5,7 @@ from temper_exporter import temper from temper_exporter.exporter import Collector +from prometheus_client.samples import Sample def test_non_temper_device(): d = mock.create_autospec(pyudev.Device, action=None) @@ -30,10 +31,10 @@ def test_collection(): fams = list(c.collect()) assert fams[0].name == 'temper_temperature_celsius' assert fams[0].type == 'gauge' - assert fams[0].samples == [('temper_temperature_celsius', {'name': 'foo', 'phy': ':phy:', 'version': 'VERSIONSTRING___'}, 22)] + assert fams[0].samples == [Sample(name='temper_temperature_celsius', labels={'name': 'foo', 'phy': ':phy:', 'version': 'VERSIONSTRING___'}, value=22, timestamp=None, exemplar=None)] assert fams[1].name == 'temper_humidity_rh' assert fams[1].type == 'gauge' - assert fams[1].samples == [('temper_humidity_rh', {'name': 'bar', 'phy': ':phy:', 'version': 'VERSIONSTRING___'}, 45)] + assert fams[1].samples == [Sample(name='temper_humidity_rh', labels={'name': 'bar', 'phy': ':phy:', 'version': 'VERSIONSTRING___'}, value=45, timestamp=None, exemplar=None)] assert c.healthy() From ef65d229740e44f26cbf76e69e0679c3d2bfc657 Mon Sep 17 00:00:00 2001 From: Guido Maria Serra Date: Thu, 21 May 2020 12:36:18 +0200 Subject: [PATCH 2/5] tooling --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 46bdeda..451c920 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ build/ dist/ htmlcov/ .p3 +.vscode \ No newline at end of file From f3b34afc7f752e7152b2f7cc5e34e6d6c435b3ac Mon Sep 17 00:00:00 2001 From: Guido Maria Serra Date: Thu, 21 May 2020 15:53:38 +0200 Subject: [PATCH 3/5] it has to fail... otherwise we dont get properly the data --- .gitignore | 2 +- test/test_exporter.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 451c920..47b6a0c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,4 @@ build/ dist/ htmlcov/ .p3 -.vscode \ No newline at end of file +.vscode diff --git a/test/test_exporter.py b/test/test_exporter.py index 42f3e17..5cdf91a 100644 --- a/test/test_exporter.py +++ b/test/test_exporter.py @@ -5,7 +5,6 @@ from temper_exporter import temper from temper_exporter.exporter import Collector -from prometheus_client.samples import Sample def test_non_temper_device(): d = mock.create_autospec(pyudev.Device, action=None) @@ -31,10 +30,10 @@ def test_collection(): fams = list(c.collect()) assert fams[0].name == 'temper_temperature_celsius' assert fams[0].type == 'gauge' - assert fams[0].samples == [Sample(name='temper_temperature_celsius', labels={'name': 'foo', 'phy': ':phy:', 'version': 'VERSIONSTRING___'}, value=22, timestamp=None, exemplar=None)] + assert fams[0].samples == [('temper_temperature_celsius', {'name': 'foo', 'phy': ':phy:', 'version': 'VERSIONSTRING___'}, 22)] assert fams[1].name == 'temper_humidity_rh' assert fams[1].type == 'gauge' - assert fams[1].samples == [Sample(name='temper_humidity_rh', labels={'name': 'bar', 'phy': ':phy:', 'version': 'VERSIONSTRING___'}, value=45, timestamp=None, exemplar=None)] + assert fams[1].samples == [('temper_humidity_rh', {'name': 'bar', 'phy': ':phy:', 'version': 'VERSIONSTRING___'}, 45)] assert c.healthy() From f2c7792d2947055c1d00c72783d8d664fdbd2709 Mon Sep 17 00:00:00 2001 From: Guido Maria Serra Date: Thu, 21 May 2020 16:08:47 +0200 Subject: [PATCH 4/5] we need this specific version of the library --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c5ab2ff..cef0da2 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ keywords = 'prometheus monitoring temperature sensor temper', packages = ['temper_exporter'], install_requires = [ - 'prometheus_client', + 'prometheus_client==0.0.20', 'pyudev', 'setuptools', ], From b8c343a28a87eb052f3564677f4e243ed0253b21 Mon Sep 17 00:00:00 2001 From: Guido Maria Serra Date: Thu, 21 May 2020 16:20:21 +0200 Subject: [PATCH 5/5] they broke it in 0.4.0 (included) onwards --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index cef0da2..ca5c8a5 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ keywords = 'prometheus monitoring temperature sensor temper', packages = ['temper_exporter'], install_requires = [ - 'prometheus_client==0.0.20', + 'prometheus_client==0.3.0', 'pyudev', 'setuptools', ],