Skip to content
Merged
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
11 changes: 11 additions & 0 deletions src/tracing_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ dd::Expected<dd::Tracer> 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) {
Expand Down
4 changes: 4 additions & 0 deletions test/cases/ingress-nginx/conf/main.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ http {
location /is-dynamic-lb-initialized {
proxy_pass http://http:8080;
}

location /nginx_status {
proxy_pass http://http:8080;
}
}
}
23 changes: 23 additions & 0 deletions test/cases/ingress-nginx/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
7 changes: 7 additions & 0 deletions test/cases/opentelemetry/test_otel_drop_in_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down