@@ -40,6 +40,7 @@ gauge_metric_test() ->
4040 LName = <<" label" >>,
4141 LValue = <<" value" >>,
4242 Labels = [{LName , LValue }],
43+ LabelsMap = #{LName => LValue },
4344 ? assertMatch (
4445 # 'Metric' {
4546 label = NoLabels ,
@@ -79,6 +80,32 @@ gauge_metric_test() ->
7980 }
8081 ],
8182 prometheus_model_helpers :gauge_metrics ([{Labels , Value }])
83+ ),
84+ ? assertMatch (
85+ # 'Metric' {
86+ label = [
87+ # 'LabelPair' {
88+ name = LName ,
89+ value = LValue
90+ }
91+ ],
92+ gauge = # 'Gauge' {value = Value }
93+ },
94+ prometheus_model_helpers :gauge_metric (LabelsMap , Value )
95+ ),
96+ ? assertMatch (
97+ [
98+ # 'Metric' {
99+ label = [
100+ # 'LabelPair' {
101+ name = LName ,
102+ value = LValue
103+ }
104+ ],
105+ gauge = # 'Gauge' {value = Value }
106+ }
107+ ],
108+ prometheus_model_helpers :gauge_metrics ([{LabelsMap , Value }])
82109 ).
83110
84111untyped_metric_test () ->
@@ -238,6 +265,7 @@ counter_metric_test() ->
238265 LName = <<" label" >>,
239266 LValue = <<" value" >>,
240267 Labels = [{LName , LValue }],
268+ LabelsMap = #{LName => LValue },
241269 ? assertMatch (
242270 # 'Metric' {
243271 label = NoLabels ,
@@ -277,6 +305,18 @@ counter_metric_test() ->
277305 }
278306 ],
279307 prometheus_model_helpers :counter_metrics ([{Labels , Value }])
308+ ),
309+ ? assertMatch (
310+ # 'Metric' {
311+ label = [
312+ # 'LabelPair' {
313+ name = LName ,
314+ value = LValue
315+ }
316+ ],
317+ counter = # 'Counter' {value = Value }
318+ },
319+ prometheus_model_helpers :counter_metric (LabelsMap , Value )
280320 ).
281321
282322summary_metric_test () ->
@@ -286,6 +326,7 @@ summary_metric_test() ->
286326 LName = <<" label" >>,
287327 LValue = <<" value" >>,
288328 Labels = [{LName , LValue }],
329+ LabelsMap = #{LName => LValue },
289330 ? assertMatch (
290331 # 'Metric' {
291332 label = NoLabels ,
@@ -337,6 +378,21 @@ summary_metric_test() ->
337378 }
338379 ],
339380 prometheus_model_helpers :summary_metrics ([{Labels , Count , Sum }])
381+ ),
382+ ? assertMatch (
383+ # 'Metric' {
384+ label = [
385+ # 'LabelPair' {
386+ name = LName ,
387+ value = LValue
388+ }
389+ ],
390+ summary = # 'Summary' {
391+ sample_sum = Sum ,
392+ sample_count = Count
393+ }
394+ },
395+ prometheus_model_helpers :summary_metric (LabelsMap , Count , Sum )
340396 ).
341397
342398histogram_metric_test () ->
@@ -347,6 +403,7 @@ histogram_metric_test() ->
347403 LName = <<" label" >>,
348404 LValue = <<" value" >>,
349405 Labels = [{LName , LValue }],
406+ LabelsMap = #{LName => LValue },
350407 ? assertMatch (
351408 # 'Metric' {
352409 label = NoLabels ,
@@ -470,6 +527,39 @@ histogram_metric_test() ->
470527 }
471528 ],
472529 prometheus_model_helpers :histogram_metrics ([{Labels , Buckets , Count , Sum }])
530+ ),
531+ ? assertMatch (
532+ # 'Metric' {
533+ label = [
534+ # 'LabelPair' {
535+ name = LName ,
536+ value = LValue
537+ }
538+ ],
539+ histogram = # 'Histogram' {
540+ sample_sum = Sum ,
541+ sample_count = Count ,
542+ bucket = [
543+ # 'Bucket' {
544+ cumulative_count = 1 ,
545+ upper_bound = 1
546+ },
547+ # 'Bucket' {
548+ cumulative_count = 3 ,
549+ upper_bound = 2
550+ },
551+ # 'Bucket' {
552+ cumulative_count = 4 ,
553+ upper_bound = 3
554+ },
555+ # 'Bucket' {
556+ cumulative_count = 10 ,
557+ upper_bound = infinity
558+ }
559+ ]
560+ }
561+ },
562+ prometheus_model_helpers :histogram_metric (LabelsMap , Buckets , Count , Sum )
473563 ).
474564
475565fitler_undefined_metrics_test () ->
0 commit comments