open-telemetry / open-telemetry/opentelemetry-cpp-contrib
Nginx OpenTelemetry module not setting span status to error when HTTP status_code is in the 5xx range
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 153
- Forks
- 184
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 26
Description
Describe your environment Describe any aspect of your environment relevant to the problem, including your platform, build system, version numbers of installed dependencies, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main branch.
Nginx 1.21.6
opentelemetry module autoinstrumented from this image: registry.k8s.io/ingress-nginx/opentelemetry@sha256:40f766ac4a9832f36f217bb0e98d44c8d38faeccbfe861fbc1a76af7e9ab257f (but the current master branch has the same issue)
When Nginx Open Telemetry instrumentation is enabled using the otel_ngx_module.so module, the spans created from Nginx don't have a status, even if the HTTP status code is 500.
Here is an example location set to return 500:
location = /errorTest/ {
opentelemetry on;
opentelemetry_propagate;
opentelemetry_trust_incoming_spans on;
return 500 'Error !!';
}
And you can see the OpenTelemetry span data:
| Attribute | Value |
|---|---|
| http.flavor | "1.1" |
| http.host | http host |
| http.method | "GET" |
| http.scheme | "http" |
| http.server_name | |
| http.status_code | 500 |
| http.target | "/errorTest/" |
| http.user_agent | "Chrome/111.0.0.0 Safari/537.36" |
| net.host.port | 80 |
| net.peer.ip | peer ip |
| net.peer.port | 54456 |
| otel.library.name | "nginx" |
| span.kind | "server" |
| status.code | 0 |
| Resource | Value |
|---|---|
| service.name | "test_service" |
| telemetry.sdk.language | "cpp" |
| telemetry.sdk.name | "opentelemetry" |
| telemetry.sdk.version | "1.8.1" |
I would expect, per the documentation from here and here to have the span status set as error (status.code = 2) instead of Unset (0).
Steps to reproduce
Start Nginx with OpenTelemetry module enabled, create a location in the default server with the following specs:
location = /errorTest/ {
opentelemetry on;
opentelemetry_propagate;
opentelemetry_trust_incoming_spans on;
return 500 'Error !!';
}
Make a call to the /errorTest location, then look for OpenTelemetry data to see that the span status is not set to Error.
What is the expected behavior?
When the http status is in the 5xx range, the span status to be set to Error.
What is the actual behavior?
Span status is not set in any scenario (regardles of the http status code)
Additional context
We are trying to export the OpenTelemetry data to Instana and due to missing Span status, the erroneous calls are not properly identified.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the otel_ngx_module.so module and the /errorTest/ Nginx location shown in the report, then inspect how the module records span status from the HTTP response. Done means 5xx responses produce status.code = 2 while the existing HTTP status_code attribute remains available; verify this with the described span data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, nginx
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100