@@ -52,8 +52,7 @@ def setUp(self):
5252 def test_constructor (self ):
5353 """Test the constructor."""
5454 with self ._registry_register_patch :
55- exporter = PrometheusMetricReader (prefix = "testprefix" )
56- self .assertEqual (exporter ._collector ._prefix , "testprefix" )
55+ _ = PrometheusMetricReader ()
5756 self .assertTrue (self ._mock_registry_register .called )
5857
5958 def test_shutdown (self ):
@@ -102,21 +101,21 @@ def test_histogram_to_prometheus(self):
102101 ]
103102 )
104103
105- collector = _CustomCollector ("testprefix" )
104+ collector = _CustomCollector ()
106105 collector .add_metrics_data (metrics_data )
107106 result_bytes = generate_latest (collector )
108107 result = result_bytes .decode ("utf-8" )
109108 self .assertEqual (
110109 result ,
111110 dedent (
112111 """\
113- # HELP testprefix_test_name_s foo
114- # TYPE testprefix_test_name_s histogram
115- testprefix_test_name_s_bucket {histo="1",le="123.0"} 1.0
116- testprefix_test_name_s_bucket {histo="1",le="456.0"} 4.0
117- testprefix_test_name_s_bucket {histo="1",le="+Inf"} 6.0
118- testprefix_test_name_s_count {histo="1"} 6.0
119- testprefix_test_name_s_sum {histo="1"} 579.0
112+ # HELP test_name_s foo
113+ # TYPE test_name_s histogram
114+ test_name_s_bucket {histo="1",le="123.0"} 1.0
115+ test_name_s_bucket {histo="1",le="456.0"} 4.0
116+ test_name_s_bucket {histo="1",le="+Inf"} 6.0
117+ test_name_s_count {histo="1"} 6.0
118+ test_name_s_sum {histo="1"} 579.0
120119 """
121120 ),
122121 )
@@ -147,14 +146,12 @@ def test_sum_to_prometheus(self):
147146 ]
148147 )
149148
150- collector = _CustomCollector ("testprefix" )
149+ collector = _CustomCollector ()
151150 collector .add_metrics_data (metrics_data )
152151
153152 for prometheus_metric in collector .collect ():
154153 self .assertEqual (type (prometheus_metric ), CounterMetricFamily )
155- self .assertEqual (
156- prometheus_metric .name , "testprefix_test_sum_testunit"
157- )
154+ self .assertEqual (prometheus_metric .name , "test_sum_testunit" )
158155 self .assertEqual (prometheus_metric .documentation , "testdesc" )
159156 self .assertTrue (len (prometheus_metric .samples ) == 1 )
160157 self .assertEqual (prometheus_metric .samples [0 ].value , 123 )
@@ -192,14 +189,12 @@ def test_gauge_to_prometheus(self):
192189 ]
193190 )
194191
195- collector = _CustomCollector ("testprefix" )
192+ collector = _CustomCollector ()
196193 collector .add_metrics_data (metrics_data )
197194
198195 for prometheus_metric in collector .collect ():
199196 self .assertEqual (type (prometheus_metric ), GaugeMetricFamily )
200- self .assertEqual (
201- prometheus_metric .name , "testprefix_test_gauge_testunit"
202- )
197+ self .assertEqual (prometheus_metric .name , "test_gauge_testunit" )
203198 self .assertEqual (prometheus_metric .documentation , "testdesc" )
204199 self .assertTrue (len (prometheus_metric .samples ) == 1 )
205200 self .assertEqual (prometheus_metric .samples [0 ].value , 123 )
@@ -217,13 +212,13 @@ def test_invalid_metric(self):
217212 description = "testdesc" ,
218213 unit = "testunit" ,
219214 )
220- collector = _CustomCollector ("testprefix" )
215+ collector = _CustomCollector ()
221216 collector .add_metrics_data ([record ])
222217 collector .collect ()
223218 self .assertLogs ("opentelemetry.exporter.prometheus" , level = "WARNING" )
224219
225220 def test_sanitize (self ):
226- collector = _CustomCollector ("testprefix" )
221+ collector = _CustomCollector ()
227222 self .assertEqual (
228223 collector ._sanitize ("1!2@3#4$5%6^7&8*9(0)_-" ),
229224 "1_2_3_4_5_6_7_8_9_0___" ,
@@ -256,14 +251,12 @@ def test_list_labels(self):
256251 )
257252 ]
258253 )
259- collector = _CustomCollector ("testprefix" )
254+ collector = _CustomCollector ()
260255 collector .add_metrics_data (metrics_data )
261256
262257 for prometheus_metric in collector .collect ():
263258 self .assertEqual (type (prometheus_metric ), GaugeMetricFamily )
264- self .assertEqual (
265- prometheus_metric .name , "testprefix_test_gauge_testunit"
266- )
259+ self .assertEqual (prometheus_metric .name , "test_gauge_testunit" )
267260 self .assertEqual (prometheus_metric .documentation , "testdesc" )
268261 self .assertTrue (len (prometheus_metric .samples ) == 1 )
269262 self .assertEqual (prometheus_metric .samples [0 ].value , 123 )
@@ -276,7 +269,7 @@ def test_list_labels(self):
276269
277270 def test_check_value (self ):
278271
279- collector = _CustomCollector ("" )
272+ collector = _CustomCollector ()
280273
281274 self .assertEqual (collector ._check_value (1 ), "1" )
282275 self .assertEqual (collector ._check_value (1.0 ), "1.0" )
@@ -290,7 +283,7 @@ def test_check_value(self):
290283
291284 def test_multiple_collection_calls (self ):
292285
293- metric_reader = PrometheusMetricReader (prefix = "prefix" )
286+ metric_reader = PrometheusMetricReader ()
294287 provider = MeterProvider (metric_readers = [metric_reader ])
295288 meter = provider .get_meter ("getting-started" , "0.1.2" )
296289 counter = meter .create_counter ("counter" )
0 commit comments