-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Describe the bug
When otel_span_attr directives are declared at both the http level and the server (or location) level, only one group of attributes is reported in the span—not both. The attributes are not merged; instead, the child context's attributes completely replace the parent's.
To reproduce
- Configure nginx with
otel_span_attrat bothhttpandserverlevels:
http {
otel_exporter {
endpoint localhost:4317;
}
otel_trace on;
otel_span_attr http.level "from-http";
server {
listen 8080;
otel_span_attr server.level "from-server";
location / {
return 200 "ok";
}
}
}- Send a request to the server
- Inspect the exported span attributes
Actual result: Only server.level attribute is present.
Expected behavior
Both http.level and server.level attributes should be present in the span. Attributes declared at different configuration levels should be merged, with child levels potentially overriding parent values for the same attribute name.
Your environment
- Version/release: nginx/1.29.4
- Target deployment platform: container base on alpine:3.22
Additional context
The issue is in mergeLocationConf in src/http_module.cpp:
if (conf->spanAttrs.elts == NULL) {
conf->spanAttrs = prev->spanAttrs;
}This logic only inherits parent attributes when the child has none. If the child has any otel_span_attr directives, the parent's attributes are silently discarded rather than merged.