From 0e7f3f4e43352c9814f2a2bf34dd13af3e702d3c Mon Sep 17 00:00:00 2001 From: Raghuram Kannan <78465537+FlamingSaint@users.noreply.github.com> Date: Wed, 17 Jul 2024 21:18:27 +0530 Subject: [PATCH 1/2] Add a threshold for expected zero values in the SPM script (#5753) ## Which problem is this PR solving? - Makes sure the SPM CI doesn't fail if the first value received is zero. ## Description of the changes - The script now waits until the threshold (Currently set to 3) number of zero values are received before throwing an error ## How was this change tested? - Manually ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [ ] I have added unit tests for the new functionality - [ ] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: FlamingSaint --- scripts/spm-integration-test.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/spm-integration-test.sh b/scripts/spm-integration-test.sh index a0270586130..61e99911206 100755 --- a/scripts/spm-integration-test.sh +++ b/scripts/spm-integration-test.sh @@ -61,17 +61,24 @@ validate_service_metrics() { # Store the values in an array mapfile -t metric_points < <(echo "$response" | jq -r '.metrics[0].metricPoints[].gaugeValue.doubleValue') echo "Metric datapoints found for service '$service': " "${metric_points[@]}" - # Check that all values are non-zero + # Check that atleast some values are non-zero after the threshold local non_zero_count=0 + local expected_non_zero_count=3 + local zero_count=0 + local expected_max_zero_count=3 for value in "${metric_points[@]}"; do if [[ $(echo "$value > 0.0" | bc) == "1" ]]; then non_zero_count=$((non_zero_count + 1)) else - echo "❌ ERROR: Zero values not expected" + zero_count=$((zero_count + 1)) + fi + + if [[ $zero_count -gt $expected_max_zero_count ]]; then + echo "❌ ERROR: Zero values crossing threshold limit not expected (Threshold limit - '$expected_max_zero_count')" return 1 fi done - if [ $non_zero_count -lt 3 ]; then + if [ $non_zero_count -lt $expected_non_zero_count ]; then echo "⏳ Expecting at least 3 non-zero data points" return 1 fi From c68136e6fceaa6c00e1b4b6ce618414b18f78a26 Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Wed, 17 Jul 2024 12:53:10 -0300 Subject: [PATCH 2/2] [bug] [hotrod] Delay env var mapping until logger is initialized (#5760) ## Which problem is this PR solving? - Resolves #5759 ## Description of the changes - Invoke mapping function (which takes logger) after the logger is initialized - It is safe to do because none of the env vars control the logic for logger initialization ## How was this change tested? - `$ JAEGER_AGENT_PORT=xyz go run ./examples/hotrod all` - Before the change this command would cause a panic Signed-off-by: Yuri Shkuro --- examples/hotrod/cmd/root.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/hotrod/cmd/root.go b/examples/hotrod/cmd/root.go index 7db0b0bda83..1a6a0d22211 100644 --- a/examples/hotrod/cmd/root.go +++ b/examples/hotrod/cmd/root.go @@ -56,8 +56,6 @@ func init() { // onInitialize is called before the command is executed. func onInitialize() { - jaegerclientenv2otel.MapJaegerToOtelEnvVars(logger) - zapOptions := []zap.Option{ zap.AddStacktrace(zapcore.FatalLevel), zap.AddCallerSkip(1), @@ -68,6 +66,9 @@ func onInitialize() { ) } logger, _ = zap.NewDevelopment(zapOptions...) + + jaegerclientenv2otel.MapJaegerToOtelEnvVars(logger) + metricsFactory = prometheus.New().Namespace(metrics.NSOptions{Name: "hotrod", Tags: nil}) if config.MySQLGetDelay != fixDBConnDelay {