1313#define MAX_BUFFER_SIZE 256
1414
1515PROMETHEUS_COUNTER_DEFINE (test_counter , "Test counter" ,
16- ({ .key = "test" , .value = "counter" }));
16+ ({ .key = "test" , .value = "counter" }), NULL );
17+ PROMETHEUS_COUNTER_DEFINE (test_counter2 , "Test counter 2" ,
18+ ({ .key = "test" , .value = "counter" }), NULL );
1719
1820PROMETHEUS_COLLECTOR_DEFINE (test_custom_collector );
1921
@@ -28,11 +30,15 @@ ZTEST(test_formatter, test_prometheus_formatter_simple)
2830 int ret ;
2931 char formatted [MAX_BUFFER_SIZE ] = { 0 };
3032 struct prometheus_counter * counter ;
31- char exposed [] = "# HELP test_counter Test counter\n"
33+ char exposed [] = "# HELP test_counter2 Test counter 2\n"
34+ "# TYPE test_counter2 counter\n"
35+ "test_counter2{test=\"counter\"} 1\n"
36+ "# HELP test_counter Test counter\n"
3237 "# TYPE test_counter counter\n"
3338 "test_counter{test=\"counter\"} 1\n" ;
3439
3540 prometheus_collector_register_metric (& test_custom_collector , & test_counter .base );
41+ prometheus_collector_register_metric (& test_custom_collector , & test_counter2 .base );
3642
3743 counter = (struct prometheus_counter * )prometheus_collector_get_metric (
3844 & test_custom_collector , "test_counter" );
@@ -44,13 +50,16 @@ ZTEST(test_formatter, test_prometheus_formatter_simple)
4450 ret = prometheus_counter_inc (& test_counter );
4551 zassert_ok (ret , "Error incrementing counter" );
4652
53+ ret = prometheus_counter_inc (& test_counter2 );
54+ zassert_ok (ret , "Error incrementing counter 2" );
55+
4756 zassert_equal (counter -> value , 1 , "Counter value is not 1" );
4857
4958 ret = prometheus_format_exposition (& test_custom_collector , formatted , sizeof (formatted ));
5059 zassert_ok (ret , "Error formatting exposition data" );
5160
5261 zassert_equal (strcmp (formatted , exposed ), 0 ,
53- "Exposition format is not as expected (expected \ "%s\", got \"%s\")" ,
62+ "Exposition format is not as expected (expected\n\ "%s\", got\n \"%s\")" ,
5463 exposed , formatted );
5564}
5665
0 commit comments