feat: add support for capture_parameters to Psycopg2Instrumentor#4212
feat: add support for capture_parameters to Psycopg2Instrumentor#4212gregoiredx wants to merge 3 commits intoopen-telemetry:mainfrom
Conversation
dcf0111 to
b63472b
Compare
There was a problem hiding this comment.
Thanks for the contribution @gregoiredx 🚀
capture_parameters is already exposed in psycopg, aiopg, asyncpg, and tortoiseorm using the same underlying db.statement.parameters attribute, so this is consistent with the existing pattern in the repo.
However, it's worth noting the current attribute name (db.statement.parameters) and format (stringified tuple) diverges from the latest OTel semconv, which defines db.query.parameter.<key>] as individual per-parameter attributes (e.g. db.query.parameter.0, db.query.parameter.1, etc), with db.statement deprecated in favour of db.query. This PR doesn't introduce that problem though — it's pre-existing across all dbapi-based instrumentations.
Related issues:
|
Thanks for this! A few suggestions: Please do Please also update test_psycopg2_integration.py to assert span attributes with the memory exporter, similar to the psycopg(3) PR. |
Description
Add support for dbapi
capture_parametersparam toPsycopg2Instrumentor.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
I used a similar change on our stack, here is the result as seen in Grafana

Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.