-
Notifications
You must be signed in to change notification settings - Fork 672
New issue
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
Fix client address is set to server address in new semconv #3354
Conversation
Thanks @y-young for the description and sample app. I think the change makes sense based on semconv for CLIENT_ADDRESS and SERVER_ADDRESS. The detail addressed by the change is just not covered in the migration guide. The ASGI unit tests are failing as the expected are also missing |
Also, for paper trail please could you create a new bugfix Issue and link to this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opentelemetry-instrumentation/src/opentelemetry/instrumentation/_semconv.py
Outdated
Show resolved
Hide resolved
I can't remember the reasoning for having |
I remember the deprecation notice; that's why I thought it made sense. Thanks @lzchen for the double-check |
Description
With
OTEL_SEMCONV_STABILITY_OPT_IN=http
, theclient.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.
Fixes #3356.
Type of change
How Has This Been Tested?
Tested with a minimal FastAPI application: https://github.com/y-young/opentelemetry-fastapi-test
Without patch
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.Install patched local version
uv add ../opentelemetry-python-contrib
Span:
The
client.address
is correct now.Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.