Change all instruments to only handle doubles

This commit is contained in:
Tim Wojtulewicz 2024-05-24 14:51:19 -07:00
parent 6eab954fd2
commit 46ff48c29a
35 changed files with 635 additions and 1148 deletions

View file

@ -1,25 +1,23 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
### zeek_session_metrics |2|
Telemetry::INT_COUNTER, zeek, zeek_total_sessions_total, [protocol], [tcp], 500.0
count_value, 500
Telemetry::INT_GAUGE, zeek, zeek_active_sessions, [protocol], [tcp], 500.0
count_value, 500
Telemetry::COUNTER, zeek, zeek_total_sessions_total, [protocol], [tcp], 500.0
Telemetry::GAUGE, zeek, zeek_active_sessions, [protocol], [tcp], 500.0
### bt* metrics |5|
Telemetry::DOUBLE_COUNTER, btest, btest_a_test_total, [x, y], [a, b], 1.0
Telemetry::DOUBLE_COUNTER, btest, btest_b_test_total, [x, y], [a, b], 10.0
Telemetry::DOUBLE_COUNTER, btest, btest_c_test_total, [x, y], [a, b], 200.0
Telemetry::DOUBLE_COUNTER, btest, btest_a_test_total, [x, y], [a, c], 2.0
Telemetry::DOUBLE_COUNTER, btest, btest_b_test_total, [x, y], [a, c], 20.0
Telemetry::COUNTER, btest, btest_a_test_total, [x, y], [a, b], 1.0
Telemetry::COUNTER, btest, btest_b_test_total, [x, y], [a, b], 10.0
Telemetry::COUNTER, btest, btest_c_test_total, [x, y], [a, b], 200.0
Telemetry::COUNTER, btest, btest_a_test_total, [x, y], [a, c], 2.0
Telemetry::COUNTER, btest, btest_b_test_total, [x, y], [a, c], 20.0
### btest_a_metrics |2|
Telemetry::DOUBLE_COUNTER, btest, btest_a_test_total, [x, y], [a, b], 1.0
Telemetry::DOUBLE_COUNTER, btest, btest_a_test_total, [x, y], [a, c], 2.0
Telemetry::COUNTER, btest, btest_a_test_total, [x, y], [a, b], 1.0
Telemetry::COUNTER, btest, btest_a_test_total, [x, y], [a, c], 2.0
### btest_b_metrics |2|
Telemetry::DOUBLE_COUNTER, btest, btest_b_test_total, [x, y], [a, b], 10.0
Telemetry::DOUBLE_COUNTER, btest, btest_b_test_total, [x, y], [a, c], 20.0
Telemetry::COUNTER, btest, btest_b_test_total, [x, y], [a, b], 10.0
Telemetry::COUNTER, btest, btest_b_test_total, [x, y], [a, c], 20.0
### system_metrics |3|
Telemetry::DOUBLE_GAUGE, system, system_sensor_temperature_celsius, [name], [cpu0], 43.0
Telemetry::DOUBLE_GAUGE, system, system_sensor_temperature_celsius, [name], [cpu1], 44.1
Telemetry::DOUBLE_GAUGE, system, system_sensor_temperature_celsius, [name], [cpu3], 42.2
Telemetry::GAUGE, system, system_sensor_temperature_celsius, [name], [cpu0], 43.0
Telemetry::GAUGE, system, system_sensor_temperature_celsius, [name], [cpu1], 44.1
Telemetry::GAUGE, system, system_sensor_temperature_celsius, [name], [cpu3], 42.2
### btest_histogram_metrics |2|
Telemetry::DOUBLE_HISTOGRAM, btest, btest_sample_histogram, [1.0, 2.0, 3.0, 4.0, 5.0, inf], [dim], [a], [2.0, 2.0, 0.0, 0.0, 0.0, 1.0], 11.5, 5.0
Telemetry::DOUBLE_HISTOGRAM, btest, btest_sample_histogram, [1.0, 2.0, 3.0, 4.0, 5.0, inf], [dim], [b], [1.0, 0.0, 0.0, 0.0, 0.0, 1.0], 7.5, 2.0
Telemetry::HISTOGRAM, btest, btest_sample_histogram, [1.0, 2.0, 3.0, 4.0, 5.0, inf], [dim], [a], [2.0, 2.0, 0.0, 0.0, 0.0, 1.0], 11.5, 5.0
Telemetry::HISTOGRAM, btest, btest_sample_histogram, [1.0, 2.0, 3.0, 4.0, 5.0, inf], [dim], [b], [1.0, 0.0, 0.0, 0.0, 0.0, 1.0], 7.5, 2.0

View file

@ -1,11 +1,11 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
Telemetry::DOUBLE_HISTOGRAM, zeek, zeek_connection_duration_seconds
Telemetry::HISTOGRAM, zeek, zeek_connection_duration_seconds
[]
[]
[2.0, 3.0, 4.0, 5.0, 6.0, 10.0, inf]
[0.0, 322.0, 90.0, 5.0, 76.0, 7.0, 0.0]
500.0, 1650.264644
Telemetry::DOUBLE_HISTOGRAM, zeek, zeek_realistic_connection_duration_seconds
Telemetry::HISTOGRAM, zeek, zeek_realistic_connection_duration_seconds
[proto]
[tcp]
[0.1, 1.0, 10.0, 30.0, 60.0, 120.0, 300.0, 900.0, 1800.0, inf]

View file

@ -1,4 +1,4 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
zeek, zeek_event_handler_invocations_total, [connection_state_remove], 500
zeek, zeek_event_handler_invocations_total, [zeek_done], 1
zeek, zeek_event_handler_invocations_total, [zeek_init], 1
zeek, zeek_event_handler_invocations_total, [connection_state_remove], 500.0
zeek, zeek_event_handler_invocations_total, [zeek_done], 1.0
zeek, zeek_event_handler_invocations_total, [zeek_init], 1.0

View file

@ -42,7 +42,7 @@ XXXXXXXXXX.XXXXXX
{"10.1.1.1":[1,2],"10.2.2.2":[3,5]}
{"1":{"s":"test"}}
{"opaque_type":"TopkVal"}
{"_metric":{"opaque_type":"DblGaugeMetricVal"}}
{"_family":{"opaque_type":"DblGaugeMetricFamilyVal"},"_labels":["dim_1"]}
{"_metric":{"opaque_type":"DblCounterMetricVal"}}
{"_family":{"opaque_type":"DblCounterMetricFamilyVal"},"_labels":["dim_1"]}
{"_metric":{"opaque_type":"GaugeMetricVal"}}
{"_family":{"opaque_type":"GaugeMetricFamilyVal"},"_labels":["dim_1"]}
{"_metric":{"opaque_type":"CounterMetricVal"}}
{"_family":{"opaque_type":"CounterMetricFamilyVal"},"_labels":["dim_1"]}

View file

@ -1,5 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
cnt1_bar: 1
cnt2_bar: 42
cnt3_bar: 1.000000
cnt4_bar: 42.000000
cnt1_bar: 1.000000
cnt2_bar: 42.000000

View file

@ -1,5 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
gg1_bar: 1
gg2_bar: 23
gg3_bar: 1.000000
gg4_bar: 23.000000
gg1_bar: 1.000000
gg2_bar: 23.000000

View file

@ -1,5 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
hst1_bar: 12
hst2_bar: 31337
hst3_bar: 6.000000
hst4_bar: 64.000000
hst1_bar: 6.000000
hst2_bar: 64.000000

View file

@ -58,9 +58,6 @@ function print_metrics(what: string, metrics: vector of Telemetry::Metric)
{
local m = metrics[i];
print m$opts$metric_type, m$opts$prefix, m$opts$name, m$opts$labels, m$labels, m$value;
if (m?$count_value)
print "count_value", m$count_value;
}
}

View file

@ -17,6 +17,6 @@ event zeek_done() &priority=-100
for ( _, m in ms )
{
if ( /zeek_.*|connection_.*/ in cat(m$labels))
print m$opts$prefix, m$opts$name, m$labels, m$count_value;
print m$opts$prefix, m$opts$name, m$labels, m$value;
}
}

View file

@ -3,25 +3,16 @@
# @TEST-EXEC: zeek -b %INPUT >output
# @TEST-EXEC: btest-diff output
global cnt1 = Telemetry::__int_counter_family("cnt1", "bar", vector("dim1", "dim2"));
global cnt2 = Telemetry::__int_counter_family("cnt2", "bar", vector());
global cnt3 = Telemetry::__dbl_counter_family("cnt3", "bar", vector("dim1", "dim2"));
global cnt4 = Telemetry::__dbl_counter_family("cnt4", "bar", vector());
global cnt1 = Telemetry::__counter_family("cnt1", "bar", vector("dim1", "dim2"));
global cnt2 = Telemetry::__counter_family("cnt2", "bar", vector());
event zeek_init()
{
local cnt1_bar = Telemetry::__int_counter_metric_get_or_add(cnt1, table(["dim1"] = "val1", ["dim2"] = "val2"));
Telemetry::__int_counter_inc(cnt1_bar);
local cnt2_bar = Telemetry::__int_counter_metric_get_or_add(cnt2, table());
Telemetry::__int_counter_inc(cnt2_bar);
Telemetry::__int_counter_inc(cnt2_bar, 41);
print fmt("cnt1_bar: %d", Telemetry::__int_counter_value(cnt1_bar));
print fmt("cnt2_bar: %d", Telemetry::__int_counter_value(cnt2_bar));
local cnt3_bar = Telemetry::__dbl_counter_metric_get_or_add(cnt3, table(["dim1"] = "val1", ["dim2"] = "val2"));
Telemetry::__dbl_counter_inc(cnt3_bar);
local cnt4_bar = Telemetry::__dbl_counter_metric_get_or_add(cnt4, table());
Telemetry::__dbl_counter_inc(cnt4_bar);
Telemetry::__dbl_counter_inc(cnt4_bar, 41.0);
print fmt("cnt3_bar: %f", Telemetry::__dbl_counter_value(cnt3_bar));
print fmt("cnt4_bar: %f", Telemetry::__dbl_counter_value(cnt4_bar));
local cnt1_bar = Telemetry::__counter_metric_get_or_add(cnt1, table(["dim1"] = "val1", ["dim2"] = "val2"));
Telemetry::__counter_inc(cnt1_bar);
local cnt2_bar = Telemetry::__counter_metric_get_or_add(cnt2, table());
Telemetry::__counter_inc(cnt2_bar);
Telemetry::__counter_inc(cnt2_bar, 41);
print fmt("cnt1_bar: %f", Telemetry::__counter_value(cnt1_bar));
print fmt("cnt2_bar: %f", Telemetry::__counter_value(cnt2_bar));
}

View file

@ -3,30 +3,18 @@
# @TEST-EXEC: zeek -b %INPUT >output
# @TEST-EXEC: btest-diff output
global gg1 = Telemetry::__int_gauge_family("gg1", "bar", vector("dim1", "dim2"));
global gg2 = Telemetry::__int_gauge_family("gg2", "bar", vector());
global gg3 = Telemetry::__dbl_gauge_family("gg3", "bar", vector("dim1", "dim2"));
global gg4 = Telemetry::__dbl_gauge_family("gg4", "bar", vector());
global gg1 = Telemetry::__gauge_family("gg1", "bar", vector("dim1", "dim2"));
global gg2 = Telemetry::__gauge_family("gg2", "bar", vector());
event zeek_init()
{
local gg1_bar = Telemetry::__int_gauge_metric_get_or_add(gg1, table(["dim1"] = "val1", ["dim2"] = "val2"));
Telemetry::__int_gauge_inc(gg1_bar);
local gg2_bar = Telemetry::__int_gauge_metric_get_or_add(gg2, table());
Telemetry::__int_gauge_inc(gg2_bar);
Telemetry::__int_gauge_inc(gg2_bar, 41);
Telemetry::__int_gauge_dec(gg2_bar);
Telemetry::__int_gauge_dec(gg2_bar, 18);
print fmt("gg1_bar: %d", Telemetry::__int_gauge_value(gg1_bar));
print fmt("gg2_bar: %d", Telemetry::__int_gauge_value(gg2_bar));
local gg3_bar = Telemetry::__dbl_gauge_metric_get_or_add(gg3, table(["dim1"] = "val1", ["dim2"] = "val2"));
Telemetry::__dbl_gauge_inc(gg3_bar);
local gg4_bar = Telemetry::__dbl_gauge_metric_get_or_add(gg4, table());
Telemetry::__dbl_gauge_inc(gg4_bar);
Telemetry::__dbl_gauge_inc(gg4_bar, 41.0);
Telemetry::__dbl_gauge_dec(gg4_bar);
Telemetry::__dbl_gauge_dec(gg4_bar, 18.0);
print fmt("gg3_bar: %f", Telemetry::__dbl_gauge_value(gg3_bar));
print fmt("gg4_bar: %f", Telemetry::__dbl_gauge_value(gg4_bar));
local gg1_bar = Telemetry::__gauge_metric_get_or_add(gg1, table(["dim1"] = "val1", ["dim2"] = "val2"));
Telemetry::__gauge_inc(gg1_bar);
local gg2_bar = Telemetry::__gauge_metric_get_or_add(gg2, table());
Telemetry::__gauge_inc(gg2_bar);
Telemetry::__gauge_inc(gg2_bar, 41.0);
Telemetry::__gauge_dec(gg2_bar);
Telemetry::__gauge_dec(gg2_bar, 18.0);
print fmt("gg1_bar: %f", Telemetry::__gauge_value(gg1_bar));
print fmt("gg2_bar: %f", Telemetry::__gauge_value(gg2_bar));
}

View file

@ -3,28 +3,18 @@
# @TEST-EXEC: zeek -b %INPUT >output
# @TEST-EXEC: btest-diff output
const int_bounds = vector(+10, +20);
const dbl_bounds = vector(10.0, 20.0);
global hst1 = Telemetry::__int_histogram_family("hst1", "bar", vector("dim1", "dim2"), int_bounds);
global hst2 = Telemetry::__int_histogram_family("hst2", "bar", vector(), int_bounds);
global hst3 = Telemetry::__dbl_histogram_family("hst3", "bar", vector("dim1", "dim2"), dbl_bounds);
global hst4 = Telemetry::__dbl_histogram_family("hst4", "bar", vector(), dbl_bounds);
global hst1 = Telemetry::__histogram_family("hst1", "bar", vector("dim1", "dim2"), dbl_bounds);
global hst2 = Telemetry::__histogram_family("hst2", "bar", vector(), dbl_bounds);
event zeek_init()
{
local hst1_bar = Telemetry::__int_histogram_metric_get_or_add(hst1, table(["dim1"] = "val1", ["dim2"] = "val2"));
Telemetry::__int_histogram_observe(hst1_bar, 1);
Telemetry::__int_histogram_observe(hst1_bar, 11);
local hst2_bar = Telemetry::__int_histogram_metric_get_or_add(hst2, table());
Telemetry::__int_histogram_observe(hst2_bar, 31337);
print fmt("hst1_bar: %d", Telemetry::__int_histogram_sum(hst1_bar));
print fmt("hst2_bar: %d", Telemetry::__int_histogram_sum(hst2_bar));
local hst3_bar = Telemetry::__dbl_histogram_metric_get_or_add(hst3, table(["dim1"] = "val1", ["dim2"] = "val2"));
Telemetry::__dbl_histogram_observe(hst3_bar, 2.0);
Telemetry::__dbl_histogram_observe(hst3_bar, 4.0);
local hst4_bar = Telemetry::__dbl_histogram_metric_get_or_add(hst4, table());
Telemetry::__dbl_histogram_observe(hst4_bar, 64.0);
print fmt("hst3_bar: %f", Telemetry::__dbl_histogram_sum(hst3_bar));
print fmt("hst4_bar: %f", Telemetry::__dbl_histogram_sum(hst4_bar));
local hst1_bar = Telemetry::__histogram_metric_get_or_add(hst1, table(["dim1"] = "val1", ["dim2"] = "val2"));
Telemetry::__histogram_observe(hst1_bar, 2.0);
Telemetry::__histogram_observe(hst1_bar, 4.0);
local hst2_bar = Telemetry::__histogram_metric_get_or_add(hst2, table());
Telemetry::__histogram_observe(hst2_bar, 64.0);
print fmt("hst1_bar: %f", Telemetry::__histogram_sum(hst1_bar));
print fmt("hst2_bar: %f", Telemetry::__histogram_sum(hst2_bar));
}