Skip to content

feat: Add server.address to transformed spans when stream_gen_ai_spans=True#6307

Draft
alexander-alderman-webb wants to merge 4 commits into
masterfrom
webb/add-server-name
Draft

feat: Add server.address to transformed spans when stream_gen_ai_spans=True#6307
alexander-alderman-webb wants to merge 4 commits into
masterfrom
webb/add-server-name

Conversation

@alexander-alderman-webb
Copy link
Copy Markdown
Contributor

Description

Issues

Reminders

@alexander-alderman-webb alexander-alderman-webb changed the title feat: Add server.name to transformed spans when stream_gen_ai_spans=True feat: Add server.address to transformed spans when stream_gen_ai_spans=True May 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 20, 2026

Codecov Results 📊

13 passed | Total: 13 | Pass Rate: 100% | Execution Time: 3.99s

All tests are passing successfully.

❌ Patch coverage is 0.00%. Project has 15811 uncovered lines.

Files with missing lines (1)
File Patch % Lines
client.py 48.82% ⚠️ 348 Missing and 70 partials

Generated by Codecov Action

Comment thread sentry_sdk/client.py
Comment on lines +228 to +229
if "server_name" in event:
attributes["server.address"] = event["server_name"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

server.address from span data silently overwritten by event server_name

When span.data already contains a server.address attribute (e.g. set by the WSGI integration from SERVER_NAME), this unconditional assignment overwrites it with the event-level server_name (the machine hostname), losing the more specific per-request value.

Evidence
  • attributes.update(span_data) at line 207 merges all span data into attributes, which may include a server.address key (e.g. wsgi.py:402 sets attributes["server.address"] = server_name from environ["SERVER_NAME"]).
  • The new code at line 228-229 then unconditionally does attributes["server.address"] = event["server_name"], overwriting the span-level value with the machine hostname.
  • OTel semantic convention server.address refers to the logical server address the client is connecting to (not the machine hostname), so the overwrite introduces semantically incorrect data.
  • The fix is to only set the fallback when server.address is not already present: if "server_name" in event and "server.address" not in attributes:.

Identified by Warden find-bugs · YPW-2W9

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix attempt detected (commit ed3fc20)

The commit added the exact line at issue (attributes['server.address'] = event['server_name']) unconditionally without the suggested and 'server.address' not in attributes guard, so the overwrite issue persists.

The original issue appears unresolved. Please review and try again.

Evaluated by Warden

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant