diff --git a/core/unittest/prometheus/ScrapeSchedulerUnittest.cpp b/core/unittest/prometheus/ScrapeSchedulerUnittest.cpp index d1cdcef3ab..2c5138768b 100644 --- a/core/unittest/prometheus/ScrapeSchedulerUnittest.cpp +++ b/core/unittest/prometheus/ScrapeSchedulerUnittest.cpp @@ -21,6 +21,7 @@ #include "common/StringTools.h" #include "common/http/HttpResponse.h" #include "common/timer/Timer.h" +#include "models/RawEvent.h" #include "prometheus/Constants.h" #include "prometheus/async/PromFuture.h" #include "prometheus/labels/Labels.h" @@ -154,33 +155,27 @@ void ScrapeSchedulerUnittest::TestStreamMetricWriteCallback() { auto& res = httpResponse.GetBody()->mEventGroup; APSARA_TEST_EQUAL(7UL, res.GetEvents().size()); APSARA_TEST_EQUAL("go_gc_duration_seconds{quantile=\"0\"} 1.5531e-05", - res.GetEvents()[0].Cast().GetContent(prometheus::PROMETHEUS).to_string()); + res.GetEvents()[0].Cast().GetContent()); APSARA_TEST_EQUAL("go_gc_duration_seconds{quantile=\"0.25\"} 3.9357e-05", - res.GetEvents()[1].Cast().GetContent(prometheus::PROMETHEUS).to_string()); + res.GetEvents()[1].Cast().GetContent()); APSARA_TEST_EQUAL("go_gc_duration_seconds{quantile=\"0.5\"} 4.1114e-05", - res.GetEvents()[2].Cast().GetContent(prometheus::PROMETHEUS).to_string()); + res.GetEvents()[2].Cast().GetContent()); APSARA_TEST_EQUAL("go_gc_duration_seconds{quantile=\"0.75\"} 4.3372e-05", - res.GetEvents()[3].Cast().GetContent(prometheus::PROMETHEUS).to_string()); + res.GetEvents()[3].Cast().GetContent()); APSARA_TEST_EQUAL("go_gc_duration_seconds{quantile=\"1\"} 0.000112326", - res.GetEvents()[4].Cast().GetContent(prometheus::PROMETHEUS).to_string()); - APSARA_TEST_EQUAL("go_gc_duration_seconds_sum 0.034885631", - res.GetEvents()[5].Cast().GetContent(prometheus::PROMETHEUS).to_string()); - APSARA_TEST_EQUAL("go_gc_duration_seconds_count 850", - res.GetEvents()[6].Cast().GetContent(prometheus::PROMETHEUS).to_string()); + res.GetEvents()[4].Cast().GetContent()); + APSARA_TEST_EQUAL("go_gc_duration_seconds_sum 0.034885631", res.GetEvents()[5].Cast().GetContent()); + APSARA_TEST_EQUAL("go_gc_duration_seconds_count 850", res.GetEvents()[6].Cast().GetContent()); // httpResponse.GetBody()->mEventGroup = PipelineEventGroup(std::make_shared()); PromMetricWriteCallback( body2.data(), (size_t)1, (size_t)body2.length(), (void*)httpResponse.GetBody()); httpResponse.GetBody()->FlushCache(); APSARA_TEST_EQUAL(11UL, res.GetEvents().size()); - APSARA_TEST_EQUAL("go_goroutines 7", - res.GetEvents()[7].Cast().GetContent(prometheus::PROMETHEUS).to_string()); - APSARA_TEST_EQUAL("go_info{version=\"go1.22.3\"} 1", - res.GetEvents()[8].Cast().GetContent(prometheus::PROMETHEUS).to_string()); - APSARA_TEST_EQUAL("go_memstats_alloc_bytes 6.742688e+06", - res.GetEvents()[9].Cast().GetContent(prometheus::PROMETHEUS).to_string()); - APSARA_TEST_EQUAL("go_memstats_alloc_bytes_total 1.5159292e+08", - res.GetEvents()[10].Cast().GetContent(prometheus::PROMETHEUS).to_string()); + APSARA_TEST_EQUAL("go_goroutines 7", res.GetEvents()[7].Cast().GetContent()); + APSARA_TEST_EQUAL("go_info{version=\"go1.22.3\"} 1", res.GetEvents()[8].Cast().GetContent()); + APSARA_TEST_EQUAL("go_memstats_alloc_bytes 6.742688e+06", res.GetEvents()[9].Cast().GetContent()); + APSARA_TEST_EQUAL("go_memstats_alloc_bytes_total 1.5159292e+08", res.GetEvents()[10].Cast().GetContent()); } void ScrapeSchedulerUnittest::TestReceiveMessage() {