mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 03:28:19 +00:00
telemetry: Remove singleton BIFs and the C++ pieces
The low-level singleton Telemetry BIFs have been removed with the that there haven't been any users. Singleton metrics can be instantiated by providing an empty label vector instead and aren't in any way a special concept. Closes #2262.
This commit is contained in:
parent
686e740bbe
commit
acacc6b6c2
7 changed files with 16 additions and 357 deletions
|
@ -515,60 +515,6 @@ template <class T> auto toVector(zeek::Span<T> xs)
|
|||
|
||||
} // namespace
|
||||
|
||||
SCENARIO("telemetry managers provide access to counter singletons")
|
||||
{
|
||||
GIVEN("a telemetry manager")
|
||||
{
|
||||
Manager mgr;
|
||||
WHEN("retrieving an IntCounter singleton")
|
||||
{
|
||||
auto first = mgr.CounterSingleton("zeek", "int-count", "test");
|
||||
THEN("its initial value is zero") { CHECK_EQ(first.Value(), 0); }
|
||||
AND_THEN("calling Inc() or operator++ changes the value")
|
||||
{
|
||||
first.Inc();
|
||||
CHECK_EQ(first.Value(), 1);
|
||||
first.Inc(2);
|
||||
CHECK_EQ(first.Value(), 3);
|
||||
CHECK_EQ(++first, 4);
|
||||
CHECK_EQ(first.Value(), 4);
|
||||
}
|
||||
AND_THEN("calling counterSingleton again for the same name returns the same handle")
|
||||
{
|
||||
auto second = mgr.CounterSingleton("zeek", "int-count", "test");
|
||||
CHECK_EQ(first, second);
|
||||
}
|
||||
AND_THEN("calling counterSingleton for a different name returns another handle")
|
||||
{
|
||||
auto third = mgr.CounterSingleton("zeek", "int-count-2", "test");
|
||||
CHECK_NE(first, third);
|
||||
}
|
||||
}
|
||||
WHEN("retrieving a DblCounter singleton")
|
||||
{
|
||||
auto first = mgr.CounterSingleton<double>("zeek", "dbl-count", "test");
|
||||
THEN("its initial value is zero") { CHECK_EQ(first.Value(), 0.0); }
|
||||
AND_THEN("calling Inc() changes the value")
|
||||
{
|
||||
first.Inc();
|
||||
CHECK_EQ(first.Value(), 1.0);
|
||||
first.Inc(3.0);
|
||||
CHECK_EQ(first.Value(), 4.0);
|
||||
}
|
||||
AND_THEN("calling counterSingleton again for the same name returns the same handle")
|
||||
{
|
||||
auto second = mgr.CounterSingleton<double>("zeek", "dbl-count", "test");
|
||||
CHECK_EQ(first, second);
|
||||
}
|
||||
AND_THEN("calling counterSingleton for a different name returns another handle")
|
||||
{
|
||||
auto third = mgr.CounterSingleton<double>("zeek", "dbl-count-2", "test");
|
||||
CHECK_NE(first, third);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SCENARIO("telemetry managers provide access to counter families")
|
||||
{
|
||||
GIVEN("a telemetry manager")
|
||||
|
@ -628,70 +574,6 @@ SCENARIO("telemetry managers provide access to counter families")
|
|||
}
|
||||
}
|
||||
|
||||
SCENARIO("telemetry managers provide access to gauge singletons")
|
||||
{
|
||||
GIVEN("a telemetry manager")
|
||||
{
|
||||
Manager mgr;
|
||||
WHEN("retrieving an IntGauge singleton")
|
||||
{
|
||||
auto first = mgr.GaugeSingleton("zeek", "int-gauge", "test");
|
||||
THEN("its initial value is zero") { CHECK_EQ(first.Value(), 0); }
|
||||
AND_THEN("calling Inc(), Dec(), operator++ or operator-- changes the value")
|
||||
{
|
||||
first.Inc();
|
||||
CHECK_EQ(first.Value(), 1);
|
||||
first.Inc(2);
|
||||
CHECK_EQ(first.Value(), 3);
|
||||
first.Dec();
|
||||
CHECK_EQ(first.Value(), 2);
|
||||
CHECK_EQ(++first, 3);
|
||||
CHECK_EQ(first.Value(), 3);
|
||||
CHECK_EQ(--first, 2);
|
||||
CHECK_EQ(first.Value(), 2);
|
||||
first.Dec(2);
|
||||
CHECK_EQ(first.Value(), 0);
|
||||
}
|
||||
AND_THEN("calling gaugeSingleton again for the same name returns the same handle")
|
||||
{
|
||||
auto second = mgr.GaugeSingleton("zeek", "int-gauge", "test");
|
||||
CHECK_EQ(first, second);
|
||||
}
|
||||
AND_THEN("calling gaugeSingleton for a different name returns another handle")
|
||||
{
|
||||
auto third = mgr.GaugeSingleton("zeek", "int-gauge-2", "test");
|
||||
CHECK_NE(first, third);
|
||||
}
|
||||
}
|
||||
WHEN("retrieving a DblGauge singleton")
|
||||
{
|
||||
auto first = mgr.GaugeSingleton<double>("zeek", "dbl-gauge", "test");
|
||||
THEN("its initial value is zero") { CHECK_EQ(first.Value(), 0.0); }
|
||||
AND_THEN("calling Inc() or Dec() changes the value")
|
||||
{
|
||||
first.Inc();
|
||||
CHECK_EQ(first.Value(), 1.0);
|
||||
first.Inc(3.0);
|
||||
CHECK_EQ(first.Value(), 4.0);
|
||||
first.Dec(2.0);
|
||||
CHECK_EQ(first.Value(), 2.0);
|
||||
first.Dec();
|
||||
CHECK_EQ(first.Value(), 1.0);
|
||||
}
|
||||
AND_THEN("calling gaugeSingleton again for the same name returns the same handle")
|
||||
{
|
||||
auto second = mgr.GaugeSingleton<double>("zeek", "dbl-gauge", "test");
|
||||
CHECK_EQ(first, second);
|
||||
}
|
||||
AND_THEN("calling gaugeSingleton for a different name returns another handle")
|
||||
{
|
||||
auto third = mgr.GaugeSingleton<double>("zeek", "dbl-gauge-2", "test");
|
||||
CHECK_NE(first, third);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SCENARIO("telemetry managers provide access to gauge families")
|
||||
{
|
||||
GIVEN("a telemetry manager")
|
||||
|
@ -751,92 +633,6 @@ SCENARIO("telemetry managers provide access to gauge families")
|
|||
}
|
||||
}
|
||||
|
||||
SCENARIO("telemetry managers provide access to histogram singletons")
|
||||
{
|
||||
GIVEN("a telemetry manager")
|
||||
{
|
||||
Manager mgr;
|
||||
WHEN("retrieving an IntHistogram singleton")
|
||||
{
|
||||
const auto max_int = std::numeric_limits<int64_t>::max();
|
||||
int64_t buckets[] = {10, 20};
|
||||
auto first = mgr.HistogramSingleton("zeek", "int-hist", buckets, "test");
|
||||
THEN("it initially has no observations")
|
||||
{
|
||||
REQUIRE_EQ(first.NumBuckets(), 3u);
|
||||
CHECK_EQ(first.Sum(), 0);
|
||||
CHECK_EQ(first.CountAt(0), 0);
|
||||
CHECK_EQ(first.CountAt(1), 0);
|
||||
CHECK_EQ(first.CountAt(2), 0);
|
||||
CHECK_EQ(first.UpperBoundAt(0), 10);
|
||||
CHECK_EQ(first.UpperBoundAt(1), 20);
|
||||
CHECK_EQ(first.UpperBoundAt(2), max_int);
|
||||
}
|
||||
AND_THEN("calling Observe() increments bucket counters")
|
||||
{
|
||||
first.Observe(1);
|
||||
first.Observe(9);
|
||||
first.Observe(10);
|
||||
first.Observe(11);
|
||||
first.Observe(19);
|
||||
first.Observe(20);
|
||||
first.Observe(21);
|
||||
CHECK_EQ(first.Sum(), 91);
|
||||
CHECK_EQ(first.CountAt(0), 3);
|
||||
CHECK_EQ(first.CountAt(1), 3);
|
||||
CHECK_EQ(first.CountAt(2), 1);
|
||||
}
|
||||
AND_THEN("calling HistogramSingleton again for the same name returns the same handle")
|
||||
{
|
||||
auto second = mgr.HistogramSingleton("zeek", "int-hist", buckets, "test");
|
||||
CHECK_EQ(first, second);
|
||||
}
|
||||
AND_THEN("calling HistogramSingleton for a different name returns another handle")
|
||||
{
|
||||
auto third = mgr.HistogramSingleton("zeek", "int-hist-2", buckets, "test");
|
||||
CHECK_NE(first, third);
|
||||
}
|
||||
}
|
||||
WHEN("retrieving a DblHistogram singleton")
|
||||
{
|
||||
double buckets[] = {10.0, 20.0};
|
||||
auto first = mgr.HistogramSingleton<double>("zeek", "dbl-count", buckets, "test");
|
||||
THEN("it initially has no observations")
|
||||
{
|
||||
REQUIRE_EQ(first.NumBuckets(), 3u);
|
||||
CHECK_EQ(first.Sum(), 0.0);
|
||||
CHECK_EQ(first.CountAt(0), 0);
|
||||
CHECK_EQ(first.CountAt(1), 0);
|
||||
CHECK_EQ(first.CountAt(2), 0);
|
||||
CHECK_EQ(first.UpperBoundAt(0), 10.0);
|
||||
CHECK_EQ(first.UpperBoundAt(1), 20.0);
|
||||
}
|
||||
AND_THEN("calling Observe() increments bucket counters")
|
||||
{
|
||||
first.Observe(2.0);
|
||||
first.Observe(4.0);
|
||||
first.Observe(8.0);
|
||||
first.Observe(16.0);
|
||||
first.Observe(32.0);
|
||||
CHECK_EQ(first.Sum(), 62.0);
|
||||
CHECK_EQ(first.CountAt(0), 3);
|
||||
CHECK_EQ(first.CountAt(1), 1);
|
||||
CHECK_EQ(first.CountAt(2), 1);
|
||||
}
|
||||
AND_THEN("calling histogramSingleton again for the same name returns the same handle")
|
||||
{
|
||||
auto second = mgr.HistogramSingleton<double>("zeek", "dbl-count", buckets, "test");
|
||||
CHECK_EQ(first, second);
|
||||
}
|
||||
AND_THEN("calling histogramSingleton for a different name returns another handle")
|
||||
{
|
||||
auto third = mgr.HistogramSingleton<double>("zeek", "dbl-count-2", buckets, "test");
|
||||
CHECK_NE(first, third);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SCENARIO("telemetry managers provide access to histogram families")
|
||||
{
|
||||
GIVEN("a telemetry manager")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue