opentelemetry-ruby-contrib
opentelemetry-ruby-contrib copied to clipboard
feat: Adding trace context in sql query as the comments
When executing sql through ORM (e.g. active_record and sequel), I'd like to inject some comments (e.g. trace context) into sql query before hitting the sql database server.
The most important comment is the traceparent that is consisted of trace context information (i.e. 00-%<trace_id>s-%<span_id>s-%<trace_flags>.2d), which is for trace correlation.
# uninjected query
SELECT "posts".* FROM "posts"
# injected query
SELECT "posts".* FROM "posts" /*action='index',application='SqlcommenterRailsDemo',controller='posts',db_driver='ActiveRecord::ConnectionAdapters::SQLite3Adapter',framework='rails_v6.0.0.rc1',route='/posts',traceparent='00-828f28f7fb3df3dd07ee6478b2016b2a-a52cad0a8d1425ab-01'*/
# example from https://github.com/open-telemetry/opentelemetry-sqlcommenter/tree/main/ruby/sqlcommenter-ruby/sqlcommenter_rails_demo#get-posts
Marginalia and sqlcommenter should handle the case if both marginalia and sqlcommenter is required from end user.
Will opentelemetry-ruby integrate the marginalia and sqlcommenter into the codebase in the future so that end user doesn't need to require in their side (as automatic as possible)?
I created the pr for opentelemtery integration with marginalia here (i.e. extension of marginalia).
Thanks for taking the time to create the PR.
I've never incorporated the SQL commenter into Ruby SQL instrumentations because I wasn't aware of its existence. We aren't maintainers of that repo and I believe this is the first request to include it as part of contrib.
We'd need time to review and understand the commenter repo to see how to best leverage or participate in discussions there. I find it unusual that there is a cross language repo with all implementations in a single repo since most language specific implementations are in their own repositories.
I'll add it to our agenda for our upcoming SIG
I find it unusual that there is a cross language repo with all implementations in a single repo since most language specific implementations are in their own repositories.
I agree, btw, As of Rails 7, Marginalia is a part of Rails itself and does not need to be separately included. (from marginalia).
👋 This issue has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the keep label to hold stale off permanently, or do nothing. If you do nothing this issue will be closed eventually by the stale bot.