4
4
import unittest
5
5
6
6
import pytest
7
+ import pandas as pd
7
8
8
9
from prometheus_client import (
9
10
CollectorRegistry , CONTENT_TYPE_LATEST , core , Counter , delete_from_gateway ,
10
11
Enum , Gauge , generate_latest , Histogram , Info , instance_ip_grouping_key ,
11
- Metric , push_to_gateway , pushadd_to_gateway , Summary , PandasGauge
12
+ Metric , PandasGauge , push_to_gateway , pushadd_to_gateway , Summary
12
13
)
13
14
from prometheus_client .core import GaugeHistogramMetricFamily , Timestamp
14
15
from prometheus_client .exposition import (
15
16
basic_auth_handler , default_handler , MetricsHandler ,
16
17
passthrough_redirect_handler ,
17
18
)
18
19
19
- import pandas as pd
20
20
21
21
class TestGenerateText (unittest .TestCase ):
22
22
def setUp (self ):
@@ -204,8 +204,8 @@ def test_gauge_pandas(self):
204
204
ou
205
205
PandasGauge('report_pandas', 'metric description', df=df, columns=['columnn01', 'column02'], registry=self.registry)
206
206
"""
207
- df = pd .DataFrame ({'a' : [1.1 ,2.2 ,3.3 ,4.4 ], 'b' :[5.1 ,6.2 ,7.3 ,8.4 ], 'value' : [1 ,2 , 3 , 4 ]})
208
- df2 = pd .DataFrame ({'c' : [1.1 ,2.2 ,3.3 ,4.4 ], 'd' :[5.1 ,6.2 ,7.3 ,8.4 ], 'value' : [5 ,6 , 7 , 8 ]})
207
+ df = pd .DataFrame ({'a' : [1.1 , 2.2 , 3.3 , 4.4 ], 'b' :[5.1 , 6.2 , 7.3 , 8.4 ], 'value' : [1 , 2 , 3 , 4 ]})
208
+ df2 = pd .DataFrame ({'c' : [1.1 , 2.2 , 3.3 , 4.4 ], 'd' :[5.1 , 6.2 , 7.3 , 8.4 ], 'value' : [5 , 6 , 7 , 8 ]})
209
209
PandasGauge ('report_pandas' , 'metric description' , df = df , columns = ['a' , 'b' , 'value' ], registry = self .registry )
210
210
g2 = PandasGauge ('report_panda2s' , 'metric description2' , df = df2 , registry = self .registry )
211
211
@@ -223,7 +223,7 @@ def test_gauge_pandas(self):
223
223
b'report_panda2s(c=3.3 ,d=7.3 ) 7.0 \n '
224
224
b'report_panda2s(c=4.4 ,d=8.4 ) 8.0 \n ' ,
225
225
generate_latest (self .registry )
226
- )
226
+ )
227
227
228
228
g2 .set_metric (df2 )
229
229
self .assertEqual (
@@ -240,7 +240,7 @@ def test_gauge_pandas(self):
240
240
b'report_panda2s(c=3.3 ,d=7.3 ) 7 \n '
241
241
b'report_panda2s(c=4.4 ,d=8.4 ) 8 \n ' ,
242
242
generate_latest (self .registry )
243
- )
243
+ )
244
244
245
245
def test_gauge_pandas_columns (self ):
246
246
"""
@@ -253,8 +253,8 @@ def test_gauge_pandas_columns(self):
253
253
ou
254
254
PandasGauge('report_pandas', 'metric description', df=df, columns=['columnn01', 'column02'], registry=self.registry)
255
255
"""
256
- df = pd .DataFrame ({'a' : [1.1 ,2.2 ,3.3 ,4.4 ], 'b' :[5.1 ,6.2 ,7.3 ,8.4 ], 'value' : [1 ,2 , 3 , 4 ]})
257
- df2 = pd .DataFrame ({'c' : [1.1 ,2.2 ,3.3 ,4.4 ], 'd' :[5.1 ,6.2 ,7.3 ,8.4 ], 'result' : [5 ,6 , 7 , 8 ]})
256
+ df = pd .DataFrame ({'a' : [1.1 , 2.2 , 3.3 , 4.4 ], 'b' :[5.1 , 6.2 , 7.3 , 8.4 ], 'value' : [1 , 2 , 3 , 4 ]})
257
+ df2 = pd .DataFrame ({'c' : [1.1 , 2.2 , 3.3 , 4.4 ], 'd' :[5.1 , 6.2 , 7.3 , 8.4 ], 'result' : [5 , 6 , 7 , 8 ]})
258
258
PandasGauge ('report_pandas' , 'metric description' , df = df , columns = ['a' , 'value' ], registry = self .registry )
259
259
g2 = PandasGauge ('report_panda2s' , 'metric description2' , df = df2 , columns = ['d' , 'result' ],value = 'result' ,registry = self .registry )
260
260
@@ -272,7 +272,7 @@ def test_gauge_pandas_columns(self):
272
272
b'report_panda2s(d=7.3 ) 7.0 \n '
273
273
b'report_panda2s(d=8.4 ) 8.0 \n ' ,
274
274
generate_latest (self .registry )
275
- )
275
+ )
276
276
277
277
class TestPushGateway (unittest .TestCase ):
278
278
def setUp (self ):
0 commit comments