Browse Source

Added test ShouldNotFailOnMetricWithoutSensorLabel for prometheus encoder (#4289)

Co-authored-by: Dmitry Razumov <dvrazumov@yandex-team.ru>
Dmitry Razumov 10 months ago
parent
commit
a15355e068
1 changed files with 18 additions and 0 deletions
  1. 18 0
      library/cpp/monlib/encode/prometheus/prometheus_encoder_ut.cpp

+ 18 - 0
library/cpp/monlib/encode/prometheus/prometheus_encoder_ut.cpp

@@ -494,4 +494,22 @@ _99_9 99.9
 
 )");
     }
+
+    Y_UNIT_TEST(ShouldNotFailOnMetricWithoutSensorLabel) {
+        auto result = EncodeToString([](IMetricEncoder* e) {
+            e->OnStreamBegin();
+            e->OnStreamEnd();
+            {
+                e->OnMetricBegin(EMetricType::GAUGE);
+                {
+                    e->OnLabelsBegin();
+                    e->OnLabel("name", "cpuUsage");
+                    e->OnLabelsEnd();
+                }
+                e->OnInt64(TInstant::Zero(), 0);
+                e->OnMetricEnd();
+            }
+        });
+        UNIT_ASSERT_STRINGS_EQUAL(result, "\n");
+    }
 }