opentelemetry-js-contrib icon indicating copy to clipboard operation
opentelemetry-js-contrib copied to clipboard

Add custom attributes to SQLCommenter comments in pg instrumentation

Open joelmukuthu opened this issue 2 years ago • 5 comments

Is your feature request related to a problem? Please describe

Support for attaching SQLComment comments to SQL statements handled by the pg module was recently added in https://github.com/open-telemetry/opentelemetry-js-contrib/pull/1286. This issue proposes adding support for custom attributes to the SQL comments, besides tracestate and traceparent, which are now automatically generated by pg instrumentation (if the addSqlCommenterCommentToQueries config is enabled).

Examples of the custom attributes (as suggested by the spec) are action, controller, framework and route.

Describe the solution you'd like to see

As suggested in https://github.com/open-telemetry/opentelemetry-js-contrib/pull/1286#issuecomment-1375196941, one approach would be to allow the instrumentation to extract the custom attributes from the active context when a query is run (perhaps controlled by another config option). With this approach, one question that comes to mind is whether or not the attributes should be changeable from span to span.

Describe alternatives you've considered

Not using pg instrumentation to handle SQLCommenter comments, and instead appending the comments myself, where I can add whichever attributes I'd like.

Additional context

I'm creating this issue to get some thoughts on:

  1. whether or not this makes sense for pg instrumentation
  2. if 1, what approach would be best for implementing this
  3. if 1 and 2, pointers on where to get started so I or someone else can get started on a PR

joelmukuthu avatar Jan 12 '23 07:01 joelmukuthu

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] avatar Mar 20 '23 06:03 github-actions[bot]

Don't close.

joelmukuthu avatar Apr 03 '23 08:04 joelmukuthu

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] avatar Jun 12 '23 06:06 github-actions[bot]

This issue was closed because it has been stale for 14 days with no activity.

github-actions[bot] avatar Jun 26 '23 06:06 github-actions[bot]

@joelmukuthu did you ever find a solution to this?

alphashuro avatar Mar 21 '25 09:03 alphashuro