Skip to content

Support sqlcomment-in-db.statement as an opt-in for db driver/ORM instrumentors #3107

@tammy-baylis-swi

Description

@tammy-baylis-swi

What problem do you want to solve?

Some platforms that use the Python db client component instrumentors don't need db.statement population with sqlcomment -- see this issue comment. Currently this always happens as long as sqlcommenting is enabled, e.g.:

Attributes:
     -> db.system: Str(postgresql)
     -> db.name: Str(world-db)
     -> db.statement: Str(SELECT * FROM city WHERE id = %s /*db_driver='psycopg2%%3A2.9.9',traceparent='00-acbdad825030e4fc58260b2bd9861eb3-451dac2c63520272-01'*/)
     -> db.user: Str(world)
     -> net.peer.name: Str(postgres-world-db)
     -> net.peer.port: Int(5432)

Describe the solution you'd like

Implement support of a config so that Python db client component instrumentors only add sqlcomment to db.statement when opted in. Default should not include the comment.

Changes are required in:

Describe alternatives you've considered

This is a short-term solution. Longer term, we need to start with a general semconv upgrade of the db driver/ORM instrumentors: #2453. Part of this is moving from assignment of db.statement to db.query.text.

Additional Context

Will append to changes made for #2936 and #2938

Would you like to implement a fix?

Yes

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions