Skip to content

feat(consts): Add updated span convention constants to SPANDATA#6093

Open
ericapisani wants to merge 1 commit intomasterfrom
ep/sentry-conventions-update-4k6
Open

feat(consts): Add updated span convention constants to SPANDATA#6093
ericapisani wants to merge 1 commit intomasterfrom
ep/sentry-conventions-update-4k6

Conversation

@ericapisani
Copy link
Copy Markdown
Member

@ericapisani ericapisani commented Apr 17, 2026

Summary

Aligns sentry_sdk.consts.SPANDATA with the current Sentry conventions at
https://getsentry.github.io/sentry-conventions/attributes/. Several
attribute names the SDK exposed as the canonical constants have been
deprecated upstream, and several active replacements had no SDK constant.

Changes are purely additive:

  • Adds a .. deprecated:: docstring note (matching the existing AI_*
    pattern) to 15 existing SPANDATA constants, naming the replacement.
  • Adds 13 new constants for the replacement attributes, with
    descriptions/examples grounded in the conventions page.
  • Existing string values are preserved byte-for-byte, so current emitters
    and consumers are unaffected.

Deprecation + replacement map

Deprecated constant Value New constant Value
CODE_FILEPATH code.filepath CODE_FILE_PATH code.file.path
CODE_FUNCTION code.function CODE_FUNCTION_NAME code.function.name
CODE_LINENO code.lineno CODE_LINE_NUMBER code.line.number
CODE_NAMESPACE code.namespace CODE_FUNCTION_NAME (consolidated) code.function.name
DB_NAME db.name DB_NAMESPACE db.namespace
DB_OPERATION db.operation DB_OPERATION_NAME db.operation.name
DB_SYSTEM db.system DB_SYSTEM_NAME db.system.name
HTTP_METHOD http.method HTTP_REQUEST_METHOD http.request.method
GEN_AI_REQUEST_AVAILABLE_TOOLS gen_ai.request.available_tools GEN_AI_TOOL_DEFINITIONS gen_ai.tool.definitions
GEN_AI_REQUEST_MESSAGES gen_ai.request.messages GEN_AI_INPUT_MESSAGES gen_ai.input.messages
GEN_AI_RESPONSE_TEXT gen_ai.response.text GEN_AI_OUTPUT_MESSAGES gen_ai.output.messages
GEN_AI_RESPONSE_TOOL_CALLS gen_ai.response.tool_calls GEN_AI_OUTPUT_MESSAGES gen_ai.output.messages
GEN_AI_SYSTEM gen_ai.system GEN_AI_PROVIDER_NAME gen_ai.provider.name
GEN_AI_TOOL_INPUT gen_ai.tool.input GEN_AI_TOOL_CALL_ARGUMENTS gen_ai.tool.call.arguments
GEN_AI_TOOL_OUTPUT gen_ai.tool.output GEN_AI_TOOL_CALL_RESULT gen_ai.tool.call.result

Follow-up (not in this PR)

Integration call sites still reference the deprecated constants; migrating
emitters to the new ones is scoped for follow-up PRs. CODE_NAMESPACE in
particular is a non-1:1 rename (the namespace should be merged into the
function name string at the producer side).

Test plan

  • tox -e ruff passes
  • tox -e mypy passes
  • No behavioral change — existing string values preserved, so no additional runtime tests required

Fixes PY-2380
Fixes #6092

Align sentry_sdk.consts.SPANDATA with the current Sentry conventions at
https://getsentry.github.io/sentry-conventions/attributes/. Upstream has
deprecated a number of attribute names that the SDK still exposes as the
canonical constants, and several replacement attributes had no constant
at all.

Mark the following existing constants as deprecated and add their
replacements:

- code.filepath    -> code.file.path
- code.function    -> code.function.name
- code.lineno      -> code.line.number
- code.namespace   -> code.function.name (consolidated)
- db.name          -> db.namespace
- db.operation     -> db.operation.name
- db.system        -> db.system.name
- http.method      -> http.request.method
- gen_ai.request.available_tools -> gen_ai.tool.definitions
- gen_ai.request.messages        -> gen_ai.input.messages
- gen_ai.response.text           -> gen_ai.output.messages
- gen_ai.response.tool_calls     -> gen_ai.output.messages
- gen_ai.system                  -> gen_ai.provider.name
- gen_ai.tool.input              -> gen_ai.tool.call.arguments
- gen_ai.tool.output             -> gen_ai.tool.call.result

Existing string values are preserved so current emitters are unaffected.
Integration call sites can migrate to the new constants in follow-up
work.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 17, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (ci) Cancel in-progress PR workflows on new commit push by joshuarli in #5994
  • (consts) Add updated span convention constants to SPANDATA by ericapisani in #6093
  • Add db.driver.name spans to database integrations by ericapisani in #6082

Bug Fixes 🐛

  • (google_genai) Redact binary data in inline_data and fix multi-part message extraction by ericapisani in #5977
  • (grpc) Add isolation_scope to async server interceptor by robinvd in #5940
  • (profiler) Stop nulling buffer on teardown by ericapisani in #6075

Internal Changes 🔧

  • (celery) Remove unused NoOpMgr from utils by sentrivana in #6078
  • (ci) Update outdated pinned action version comments by JoshuaMoelans in #6088
  • (pydantic-ai) Remove dead Model.request patch by alexander-alderman-webb in #5956
  • (tests) Replace deprecated enable_tracingwith traces_sample_rate by sentrivana in #6077
  • Set explicit base-branch for codecov action by ericapisani in #5992

🤖 This preview updates automatically when you update the PR.

@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 17, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 17, 2026

Codecov Results 📊

12 passed | Total: 12 | Pass Rate: 100% | Execution Time: 2.21s

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 14336 uncovered lines.

Files with missing lines (1)
File Patch % Lines
consts.py 99.47% ⚠️ 2 Missing

Generated by Codecov Action

@ericapisani ericapisani marked this pull request as ready for review April 17, 2026 19:26
@ericapisani ericapisani requested a review from a team as a code owner April 17, 2026 19:26
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.

Mark deprecated sentry conventions as such within SPANDATA class

1 participant