We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OS: (e.g, Windows) Python version: (e.g., Python 3.10.16) Package version: (e.g., 0.51b0)
With OTEL_SEMCONV_STABILITY_OPT_IN=http, the client.address in server span is wrongly set to server address.
It it because the middleware calls _set_http_host_server and the client.address is set for the first time to server address here:
_set_http_host_server
client.address
opentelemetry-python-contrib/opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py
Line 357 in 3708604
When it calls _set_http_peer_ip_server later on, since the client.address is already set, this has no effect:
_set_http_peer_ip_server
Lines 368 to 371 in 3708604
This was changed in #2814.
Tested with a minimal FastAPI application: https://github.com/y-young/opentelemetry-fastapi-test
The client address should be correct.
OTEL_SEMCONV_STABILITY_OPT_IN
Scope: {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 8000), 'client': ('127.0.0.1', 54737), 'scheme': 'http', 'root_path': ''}
Span:
{ "name": "GET /", "context": { "trace_id": "0x3d94c2edf94a8c68e66a261883939a70", "span_id": "0x26a8e38e79afe0ae", "trace_state": "[]" }, "kind": "SpanKind.SERVER", "parent_id": null, "start_time": "2025-03-11T14:42:33.575716Z", "end_time": "2025-03-11T14:42:33.582507Z", "status": { "status_code": "UNSET" }, "attributes": { "http.scheme": "http", "http.host": "127.0.0.1:8000", "net.host.port": 8000, "http.flavor": "1.1", "http.target": "/", "http.url": "http://127.0.0.1:8000/", "http.method": "GET", "http.server_name": "127.0.0.1:8000", "http.user_agent": "", "net.peer.ip": "127.0.0.1", "net.peer.port": 54737, "http.route": "/", "http.status_code": 200 }, "events": [], "links": [], "resource": { "attributes": { "service.name": "test-app" }, "schema_url": "" } }
The net.peer.ip and net.peer.port here is correct.
net.peer.ip
net.peer.port
Set os.environ["OTEL_SEMCONV_STABILITY_OPT_IN"] = "http" and restart the app:
os.environ["OTEL_SEMCONV_STABILITY_OPT_IN"] = "http"
Scope: {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 8000), 'client': ('127.0.0.1', 50644), 'scheme': 'http', 'root_path': ''}
{ "name": "GET /", "context": { "trace_id": "0xc37fa0f9c920df31a3f6966771f70ce4", "span_id": "0x8799fdefa09e60b1", "trace_state": "[]" }, "kind": "SpanKind.SERVER", "parent_id": null, "start_time": "2025-03-11T14:39:09.180212Z", "end_time": "2025-03-11T14:39:09.185639Z", "status": { "status_code": "UNSET" }, "attributes": { "url.scheme": "http", "client.address": "127.0.0.1:8000", "server.port": 8000, "network.protocol.version": "1.1", "url.path": "/", "http.request.method": "GET", "user_agent.original": "", "client.port": 50644, "http.route": "/", "http.response.status_code": 200 }, "events": [], "links": [], "resource": { "attributes": { "service.name": "test-app" }, "schema_url": "" } }
The client.address is set to 127.0.0.1:8000, which is the server address.
127.0.0.1:8000
No response
Yes
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Describe your environment
OS: (e.g, Windows)
Python version: (e.g., Python 3.10.16)
Package version: (e.g., 0.51b0)
What happened?
With OTEL_SEMCONV_STABILITY_OPT_IN=http, the client.address in server span is wrongly set to server address.
It it because the middleware calls
_set_http_host_server
and theclient.address
is set for the first time to server address here:opentelemetry-python-contrib/opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py
Line 357 in 3708604
When it calls
_set_http_peer_ip_server
later on, since theclient.address
is already set, this has no effect:opentelemetry-python-contrib/opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py
Lines 368 to 371 in 3708604
This was changed in #2814.
Steps to Reproduce
Tested with a minimal FastAPI application: https://github.com/y-young/opentelemetry-fastapi-test
Expected Result
The client address should be correct.
Actual Result
Without
OTEL_SEMCONV_STABILITY_OPT_IN
Span:
The
net.peer.ip
andnet.peer.port
here is correct.With
OTEL_SEMCONV_STABILITY_OPT_IN
Set
os.environ["OTEL_SEMCONV_STABILITY_OPT_IN"] = "http"
and restart the app:Span:
The
client.address
is set to127.0.0.1:8000
, which is the server address.Additional context
No response
Would you like to implement a fix?
Yes
The text was updated successfully, but these errors were encountered: