feat(consts): Add updated span convention constants to SPANDATA#6093
feat(consts): Add updated span convention constants to SPANDATA#6093ericapisani merged 1 commit intomasterfrom
Conversation
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>
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Codecov Results 📊✅ 2115 passed | ⏭️ 153 skipped | Total: 2268 | Pass Rate: 93.25% | Execution Time: 4m 10s All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 12430 uncovered lines. Files with missing lines (1)
Generated by Codecov Action |
There was a problem hiding this comment.
Nice! The idea is for sure good and I'm not against merging it, but Sentry conventions actually already expose the attributes in Python, so I'd prefer we use those if we can. Then we could just leave SPANDATA as is and remove it with the next major.
That being said, IIRC there was some reason why we didn't adopt the codegen version in the past, but I don't remember exactly. Will check with folks on Slack.
Summary
Aligns
sentry_sdk.consts.SPANDATAwith the current Sentry conventions athttps://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:
.. deprecated::docstring note (matching the existingAI_*pattern) to 15 existing
SPANDATAconstants, naming the replacement.descriptions/examples grounded in the conventions page.
and consumers are unaffected.
Deprecation + replacement map
CODE_FILEPATHcode.filepathCODE_FILE_PATHcode.file.pathCODE_FUNCTIONcode.functionCODE_FUNCTION_NAMEcode.function.nameCODE_LINENOcode.linenoCODE_LINE_NUMBERcode.line.numberCODE_NAMESPACEcode.namespaceCODE_FUNCTION_NAME(consolidated)code.function.nameDB_NAMEdb.nameDB_NAMESPACEdb.namespaceDB_OPERATIONdb.operationDB_OPERATION_NAMEdb.operation.nameDB_SYSTEMdb.systemDB_SYSTEM_NAMEdb.system.nameHTTP_METHODhttp.methodHTTP_REQUEST_METHODhttp.request.methodGEN_AI_REQUEST_AVAILABLE_TOOLSgen_ai.request.available_toolsGEN_AI_TOOL_DEFINITIONSgen_ai.tool.definitionsGEN_AI_REQUEST_MESSAGESgen_ai.request.messagesGEN_AI_INPUT_MESSAGESgen_ai.input.messagesGEN_AI_RESPONSE_TEXTgen_ai.response.textGEN_AI_OUTPUT_MESSAGESgen_ai.output.messagesGEN_AI_RESPONSE_TOOL_CALLSgen_ai.response.tool_callsGEN_AI_OUTPUT_MESSAGESgen_ai.output.messagesGEN_AI_SYSTEMgen_ai.systemGEN_AI_PROVIDER_NAMEgen_ai.provider.nameGEN_AI_TOOL_INPUTgen_ai.tool.inputGEN_AI_TOOL_CALL_ARGUMENTSgen_ai.tool.call.argumentsGEN_AI_TOOL_OUTPUTgen_ai.tool.outputGEN_AI_TOOL_CALL_RESULTgen_ai.tool.call.resultFollow-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_NAMESPACEinparticular is a non-1:1 rename (the namespace should be merged into the
function name string at the producer side).
Test plan
tox -e ruffpassestox -e mypypassesFixes PY-2380
Fixes #6092