-
Notifications
You must be signed in to change notification settings - Fork 224
Report isolation level on ActiveRecord transaction #1672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,9 +18,13 @@ class << base | |
|
|
||
| # Contains ActiveRecord::Transactions::ClassMethods to be patched | ||
| module ClassMethods | ||
| def transaction(...) | ||
| tracer.in_span('ActiveRecord.transaction', attributes: { 'code.namespace' => name }) do | ||
| super | ||
| def transaction(*args, **kwargs, &block) | ||
| attributes = { 'code.namespace' => name } | ||
| if kwargs[:isolation] | ||
| attributes['db.transaction_isolation'] = kwargs[:isolation].to_s | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: There is no semantic convention for this. In practice only 1 other instrumentation implements it and namespaces it under the specific DB vendor since I believe Isolation Levels are rather specific to ACID SQL style databases. Having said all that, I think that its fine to be under the 🙏🏼 if you would kindly submit a PR to add this semconv attribute upstream. Do you all use db client spans as well? Would you like this attribute to appear on those spans as well or is this span good enough? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would go with the attribute naming |
||
| end | ||
| tracer.in_span('ActiveRecord.transaction', attributes: attributes) do | ||
| super(*args, **kwargs, &block) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| end | ||
| end | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xuan-cao-swi this would potentially set the attributes hash to nil.
https://ruby-doc.org/3.4.1/Hash.html#method-i-compact-21