diff --git a/src/tracing_library.cpp b/src/tracing_library.cpp index 71b0a866..bce4ca3b 100644 --- a/src/tracing_library.cpp +++ b/src/tracing_library.cpp @@ -119,6 +119,17 @@ dd::Expected TracingLibrary::make_tracer( .resource = "GET /is-dynamic-lb-initialized", .tags = {}}, .mechanism = datadog::tracing::SamplingMechanism::RULE}); + + // TODO(@dmehala): Disable tracing if `stub_status on;`. + final_config->trace_sampler.rules.emplace_back( + datadog::tracing::TraceSamplerRule{ + .rate = datadog::tracing::Rate::zero(), + .matcher = + datadog::tracing::SpanMatcher{.service = "*", + .name = "*", + .resource = "GET /nginx_status", + .tags = {}}, + .mechanism = datadog::tracing::SamplingMechanism::RULE}); } if (!final_config) { diff --git a/test/cases/ingress-nginx/conf/main.conf b/test/cases/ingress-nginx/conf/main.conf index c61ac85c..61287194 100644 --- a/test/cases/ingress-nginx/conf/main.conf +++ b/test/cases/ingress-nginx/conf/main.conf @@ -21,5 +21,9 @@ http { location /is-dynamic-lb-initialized { proxy_pass http://http:8080; } + + location /nginx_status { + proxy_pass http://http:8080; + } } } diff --git a/test/cases/ingress-nginx/test_rules.py b/test/cases/ingress-nginx/test_rules.py index 0e1452ee..81236d0c 100644 --- a/test/cases/ingress-nginx/test_rules.py +++ b/test/cases/ingress-nginx/test_rules.py @@ -35,3 +35,26 @@ def test_healthcheck(self): response = json.loads(body) self.assertEqual(response["headers"]["x-datadog-sampling-priority"], "1") + + def test_healthcheck_stubstatus(self): + # Healthcheck request MUST not be generated traces. + conf_path = Path(__file__).parent / "conf" / "main.conf" + conf_text = conf_path.read_text() + + status, log_lines = self.orch.nginx_replace_config( + conf_text, conf_path.name) + self.assertEqual(status, 0, log_lines) + + status, _, body = self.orch.send_nginx_http_request("/nginx_status") + self.assertEqual(status, 200) + + response = json.loads(body) + self.assertEqual(response["headers"]["x-datadog-sampling-priority"], + "-1") + + status, _, body = self.orch.send_nginx_http_request("/") + self.assertEqual(status, 200) + + response = json.loads(body) + self.assertEqual(response["headers"]["x-datadog-sampling-priority"], + "1") diff --git a/test/cases/opentelemetry/test_otel_drop_in_support.py b/test/cases/opentelemetry/test_otel_drop_in_support.py index 92f07663..db3f399a 100644 --- a/test/cases/opentelemetry/test_otel_drop_in_support.py +++ b/test/cases/opentelemetry/test_otel_drop_in_support.py @@ -137,6 +137,13 @@ def test_directives(self): "service": "*", "tags": {}, }) + rules.append({ + "name": "*", + "resource": "GET /nginx_status", + "sample_rate": 0.0, + "service": "*", + "tags": {}, + }) pattern = { "service": "foo",