File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 2222#include <cmetrics/cmt_encode_msgpack.h>
2323#include <cmetrics/cmt_decode_msgpack.h>
2424#include <cmetrics/cmt_encode_text.h>
25+ #include <cmetrics/cmt_decode_prometheus.h>
26+ #include <cmetrics/cmt_encode_prometheus.h>
2527
2628#include "cmt_tests.h"
2729
@@ -89,7 +91,34 @@ void test_issue_54()
8991 cmt_destroy (cmt1 );
9092}
9193
94+ /* issue: https://github.com/fluent/fluent-bit/issues/10761 */
95+ void test_prometheus_metric_no_subsystem ()
96+ {
97+ const char text [] =
98+ "# HELP up A simple example metric no subsystem\n"
99+ "# TYPE up gauge\n"
100+ "up{job=\"42\"} 1\n" ;
101+ struct cmt * cmt ;
102+ cfl_sds_t result ;
103+ int ret ;
104+
105+ cmt_initialize ();
106+
107+ ret = cmt_decode_prometheus_create (& cmt , text , strlen (text ), NULL );
108+ TEST_CHECK (ret == CMT_DECODE_PROMETHEUS_SUCCESS );
109+ if (ret == CMT_DECODE_PROMETHEUS_SUCCESS ) {
110+ result = cmt_encode_prometheus_create (cmt , CMT_TRUE );
111+ TEST_CHECK (result != NULL );
112+ if (result ) {
113+ TEST_CHECK (strstr (result , "up{job=\"42\"} 1" ) != NULL );
114+ cmt_encode_prometheus_destroy (result );
115+ }
116+ cmt_decode_prometheus_destroy (cmt );
117+ }
118+ }
119+
92120TEST_LIST = {
93121 {"issue_54" , test_issue_54 },
122+ {"prometheus_metric_no_subsystem" , test_prometheus_metric_no_subsystem },
94123 { 0 }
95124};
You can’t perform that action at this time.
0 commit comments