1
1
from http .server import BaseHTTPRequestHandler , HTTPServer
2
+ import pandas as pd
3
+ import pytest
2
4
import threading
3
5
import time
4
6
import unittest
5
7
6
- import pandas as pd
7
- import pytest
8
-
9
8
from prometheus_client import (
10
9
CollectorRegistry , CONTENT_TYPE_LATEST , core , Counter , delete_from_gateway ,
11
10
Enum , Gauge , generate_latest , Histogram , Info , instance_ip_grouping_key ,
@@ -208,37 +207,37 @@ def test_gauge_pandas(self):
208
207
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
208
PandasGauge ('report_pandas' , 'metric description' , df = df , columns = ['a' , 'b' , 'value' ], registry = self .registry )
210
209
g2 = PandasGauge ('report_panda2s' , 'metric description2' , df = df2 , registry = self .registry )
211
-
210
+
212
211
self .assertEqual (
213
212
b'# HELP report_pandas metric description\n '
214
213
b'# TYPE report_pandas gauge\n '
215
- b'report_pandas( a="1.1" ,b="5.1" ) 1.0 \n '
216
- b'report_pandas( a="2.2" ,b="6.2" ) 2.0 \n '
217
- b'report_pandas( a="3.3" ,b="7.3" ) 3.0 \n '
218
- b'report_pandas( a="4.4" ,b="8.4" ) 4.0 \n '
214
+ b'report_pandas{ a="1.1" ,b="5.1" } 1.0 \n '
215
+ b'report_pandas{ a="2.2" ,b="6.2" } 2.0 \n '
216
+ b'report_pandas{ a="3.3" ,b="7.3" } 3.0 \n '
217
+ b'report_pandas{ a="4.4" ,b="8.4" } 4.0 \n '
219
218
b'# HELP report_panda2s metric description2\n '
220
219
b'# TYPE report_panda2s gauge\n '
221
- b'report_panda2s( c="1.1" ,d="5.1" ) 5.0 \n '
222
- b'report_panda2s( c="2.2" ,d="6.2" ) 6.0 \n '
223
- b'report_panda2s( c="3.3" ,d="7.3" ) 7.0 \n '
224
- b'report_panda2s( c="4.4" ,d="8.4" ) 8.0 \n ' ,
220
+ b'report_panda2s{ c="1.1" ,d="5.1" } 5.0 \n '
221
+ b'report_panda2s{ c="2.2" ,d="6.2" } 6.0 \n '
222
+ b'report_panda2s{ c="3.3" ,d="7.3" } 7.0 \n '
223
+ b'report_panda2s{ c="4.4" ,d="8.4" } 8.0 \n ' ,
225
224
generate_latest (self .registry )
226
225
)
227
226
228
227
g2 .set_metric (df2 )
229
228
self .assertEqual (
230
229
b'# HELP report_pandas metric description\n '
231
230
b'# TYPE report_pandas gauge\n '
232
- b'report_pandas( a="1.1" ,b="5.1" ) 1.0 \n '
233
- b'report_pandas( a="2.2" ,b="6.2" ) 2.0 \n '
234
- b'report_pandas( a="3.3" ,b="7.3" ) 3.0 \n '
235
- b'report_pandas( a="4.4" ,b="8.4" ) 4.0 \n '
231
+ b'report_pandas{ a="1.1" ,b="5.1" } 1.0 \n '
232
+ b'report_pandas{ a="2.2" ,b="6.2" } 2.0 \n '
233
+ b'report_pandas{ a="3.3" ,b="7.3" } 3.0 \n '
234
+ b'report_pandas{ a="4.4" ,b="8.4" } 4.0 \n '
236
235
b'# HELP report_panda2s metric description2\n '
237
236
b'# TYPE report_panda2s gauge\n '
238
- b'report_panda2s( c="1.1" ,d="5.1" ) 5 \n '
239
- b'report_panda2s( c="2.2" ,d="6.2" ) 6 \n '
240
- b'report_panda2s( c="3.3" ,d="7.3" ) 7 \n '
241
- b'report_panda2s( c="4.4" ,d="8.4" ) 8 \n ' ,
237
+ b'report_panda2s{ c="1.1" ,d="5.1" } 5 \n '
238
+ b'report_panda2s{ c="2.2" ,d="6.2" } 6 \n '
239
+ b'report_panda2s{ c="3.3" ,d="7.3" } 7 \n '
240
+ b'report_panda2s{ c="4.4" ,d="8.4" } 8 \n ' ,
242
241
generate_latest (self .registry )
243
242
)
244
243
@@ -261,16 +260,16 @@ def test_gauge_pandas_columns(self):
261
260
self .assertEqual (
262
261
b'# HELP report_pandas metric description\n '
263
262
b'# TYPE report_pandas gauge\n '
264
- b'report_pandas( a="1.1" ) 1.0 \n '
265
- b'report_pandas( a="2.2" ) 2.0 \n '
266
- b'report_pandas( a="3.3" ) 3.0 \n '
267
- b'report_pandas( a="4.4" ) 4.0 \n '
263
+ b'report_pandas{ a="1.1" } 1.0 \n '
264
+ b'report_pandas{ a="2.2" } 2.0 \n '
265
+ b'report_pandas{ a="3.3" } 3.0 \n '
266
+ b'report_pandas{ a="4.4" } 4.0 \n '
268
267
b'# HELP report_panda2s metric description2\n '
269
268
b'# TYPE report_panda2s gauge\n '
270
- b'report_panda2s( d="5.1" ) 5.0 \n '
271
- b'report_panda2s( d="6.2" ) 6.0 \n '
272
- b'report_panda2s( d="7.3" ) 7.0 \n '
273
- b'report_panda2s( d="8.4" ) 8.0 \n ' ,
269
+ b'report_panda2s{ d="5.1" } 5.0 \n '
270
+ b'report_panda2s{ d="6.2" } 6.0 \n '
271
+ b'report_panda2s{ d="7.3" } 7.0 \n '
272
+ b'report_panda2s{ d="8.4" } 8.0 \n ' ,
274
273
generate_latest (self .registry )
275
274
)
276
275
0 commit comments