Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions test/histograms/histograms_to_cw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,49 +151,49 @@ func (t *OtlpHistogramTestRunner) validateHistogramMetric(metricName string) []s
},
{
stat: types.StatisticMaximum,
value: 2,
value: 4,
},
{
stat: types.StatisticSum,
value: 24,
value: 36,
},
{
stat: types.StatisticAverage,
value: 2,
value: 1.5,
},
{
stat: types.StatisticSampleCount,
value: 12,
value: 24,
},
{
stat: "p90",
value: 2.0,
value: 3.9,
},
},
"my.cumulative.histogram": {
{
stat: types.StatisticMinimum,
value: 0,
value: 0.5,
},
{
stat: types.StatisticMaximum,
value: 2,
},
{
stat: types.StatisticSum,
value: 24,
value: 12,
},
{
stat: types.StatisticAverage,
value: 2,
value: 1,
},
{
stat: types.StatisticSampleCount,
value: 12,
},
{
stat: "p90",
value: 2.0,
value: 1.3,
},
},
"my.delta.exponential.histogram": {
Expand Down
14 changes: 7 additions & 7 deletions test/histograms/histograms_to_emf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ func TestOTLPMetrics(t *testing.T) {
},
{
stat: types.StatisticMaximum,
value: 2,
value: 4,
},
{
stat: types.StatisticSum,
value: 12, // we send Sum=2 six times in one minute
value: 36,
},
{
stat: types.StatisticAverage,
value: 1, // sum / samplecount = 2/2
value: 1.5,
},
{
stat: types.StatisticSampleCount,
value: 12, // we send Count=2 six times in one minute
value: 24,
},
},
},
Expand Down Expand Up @@ -114,7 +114,7 @@ func TestOTLPMetrics(t *testing.T) {
},
{
stat: types.StatisticAverage,
value: 1,
value: 1, // we send Sum=2, Count=2 every time
},
{
stat: types.StatisticSampleCount,
Expand Down Expand Up @@ -216,12 +216,12 @@ func TestOTLPMetrics(t *testing.T) {
for _, e := range m.expected {
values, err := fetcher.Fetch(namespace, m.name, m.dimensions, e.stat, metric.MinuteStatPeriod)
require.NoError(t, err)
require.GreaterOrEqual(t, len(values), 3, "Not enough metrics retrieved for namespace {%s} metric Name {%s} stat {%s}", namespace, m.name, e.stat)
assert.GreaterOrEqual(t, len(values), 3, "Not enough metrics retrieved for namespace {%s} metric Name {%s} stat {%s}", namespace, m.name, e.stat)

// omit first/last metric as the 1m collection intervals may be missing data points from when the agent was started/stopped
middleValues := values[1 : len(values)-1]
err = metric.IsAllValuesGreaterThanOrEqualToExpectedValueWithError(m.name, middleValues, e.value)
require.NoError(t, err)
assert.NoError(t, err)
}
})
}
Expand Down
16 changes: 8 additions & 8 deletions test/histograms/resources/otlp_emf_metrics.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
{
"startTimeUnixNano": METRIC_TIME,
"timeUnixNano": METRIC_TIME,
"count": 2,
"sum": 2,
"bucketCounts": [0,2],
"explicitBounds": [1,2],
"count": 4,
"sum": 6,
"bucketCounts": [1,2,1],
"explicitBounds": [0.5,2],
"min": 0,
"max": 2,
"max": 4,
"attributes": [
{
"key": "my.delta.histogram.attr",
Expand Down Expand Up @@ -72,10 +72,10 @@
"timeUnixNano": METRIC_TIME,
"count": CUMULATIVE_HIST_COUNT,
"sum": CUMULATIVE_HIST_SUM,
"bucketCounts": [0,CUMULATIVE_HIST_COUNT],
"explicitBounds": [1, 2],
"bucketCounts": [1,CUMULATIVE_HIST_COUNT,1],
"explicitBounds": [0.5,2],
"min": 0,
"max": 2,
"max": 4,
"attributes": [
{
"key": "my.cumulative.histogram.attr",
Expand Down
6 changes: 4 additions & 2 deletions test/histograms/resources/otlp_emf_pusher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ fi
echo "Starting with INSTANCE_ID: $INSTANCE_ID"

INITIAL_METRIC_TIME=$(date +%s%N)
COUNT=0
COUNT=2

# Initialize the file
cat ./resources/otlp_emf_metrics.json | sed -e "s/INITIAL_METRIC_TIME/$INITIAL_METRIC_TIME/" \
-e "s/\$INSTANCE_ID/$INSTANCE_ID/g" > ./resources/otlp_emf_metrics_initial.json

while true; do
METRIC_TIME=$(date +%s%N)

# Simulating a histogram with datapoints 0 and 4, and then adding 2 counts of value 1 for each iteration
COUNT=$((COUNT + 2))
SUM=$((COUNT))
SUM=$((COUNT+4))

cat ./resources/otlp_emf_metrics_initial.json | \
sed -e "s/METRIC_TIME/$METRIC_TIME/" \
Expand Down
16 changes: 8 additions & 8 deletions test/histograms/resources/otlp_metrics.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@
{
"startTimeUnixNano": INITIAL_METRIC_TIME,
"timeUnixNano": METRIC_TIME,
"count": 2,
"sum": 2,
"bucketCounts": [0,2],
"explicitBounds": [1,2],
"count": 4,
"sum": 6,
"bucketCounts": [1,2,1],
"explicitBounds": [0.5,2],
"min": 0,
"max": 2,
"max": 4,
"attributes": [
{
"key": "my.delta.histogram.attr",
Expand All @@ -135,10 +135,10 @@
"timeUnixNano": METRIC_TIME,
"count": CUMULATIVE_HIST_COUNT,
"sum": CUMULATIVE_HIST_SUM,
"bucketCounts": [0,CUMULATIVE_HIST_COUNT],
"explicitBounds": [1, 2],
"bucketCounts": [1,CUMULATIVE_HIST_COUNT,1],
"explicitBounds": [0.5,2],
"min": 0,
"max": 2,
"max": 3,
"attributes": [
{
"key": "my.cumulative.histogram.attr",
Expand Down
8 changes: 5 additions & 3 deletions test/histograms/resources/otlp_pusher.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
INITIAL_METRIC_TIME=$(date +%s%N)
COUNT=0
COUNT=2

# Initialize the file
cat ./resources/otlp_metrics.json | sed -e "s/INITIAL_METRIC_TIME/$INITIAL_METRIC_TIME/" > ./resources/otlp_metrics_initial.json;

while true; do
METRIC_TIME=$(date +%s%N)
COUNT=$((COUNT + 2)) # Increment count by 2 each iteration
SUM=$((COUNT))

# Simulating a histogram with datapoints 0 and 3, and then adding 2 counts of value 1 for each iteration
COUNT=$((COUNT + 2))
SUM=$((COUNT+4))

cat ./resources/otlp_metrics_initial.json | sed -e "s/METRIC_TIME/$METRIC_TIME/" > otlp_metrics.json;
sed -i -e "s/CUMULATIVE_HIST_COUNT/$COUNT/" otlp_metrics.json;
Expand Down
Loading