Capture TortoiseORM query parameters with new DB semconv attributes - #4907
Open
saisharan0103 wants to merge 1 commit into
Conversation
…toiseorm`: capture `db.query.parameter.<key>` Closes open-telemetry#4795
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4795.
TortoiseORM instrumentation already resolves the database semantic convention opt-in mode for core DB attributes, but parameter capture still always wrote the legacy
db.statement.parametersblob whencapture_parameters=True._hydrate_span_from_argsreceived all arguments after the SQL query as a tuple and stringified that tuple without checking semconv mode, without converting positional parameters todb.query.parameter.<index>attributes for the new semconv, and without suppressing parameter capture forexecute_manybatch operations.This change imports
_set_db_query_parametersand_report_old, gates legacydb.statement.parameterson old semconv reporting, and calls_set_db_query_parametersfor new semconv reporting. Non-batch Tortoise parameters are normalized into a mapping before calling the helper: named mappings keep their keys, and positional sequences use zero-based string indexes. The legacy blob value remains unchanged in old/default and database/dup modes._do_executenow passes anis_batchflag based on the wrapped function name soexecute_manyspans skip both legacy and new parameter attributes.Modified files:
instrumentation/opentelemetry-instrumentation-tortoiseorm/src/opentelemetry/instrumentation/tortoiseorm/__init__.pyinstrumentation/opentelemetry-instrumentation-tortoiseorm/tests/test_tortoiseorm_instrumentation.pyruff check instrumentation/opentelemetry-instrumentation-tortoiseorm/src/opentelemetry/instrumentation/tortoiseorm/__init__.py instrumentation/opentelemetry-instrumentation-tortoiseorm/tests/test_tortoiseorm_instrumentation.pyreports no new findings on the changed files.Ran
pytest -xlocally with no new failures.