Skip to content

Conversation

kirs
Copy link
Contributor

@kirs kirs commented Sep 15, 2025

This is a very useful field if your app is in progress of switching in between isolation levels.

tracer.in_span('ActiveRecord.transaction', attributes: { 'code.namespace' => name }) do
super
def transaction(*args, **kwargs, &block)
attributes = { 'code.namespace' => name }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

attributes = {
  'code.namespace' => name,
  'db.transaction_isolation' => kwargs[:isolation]
}.compact!

Copy link
Contributor

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

compact! → self or nil
Returns self with all its nil-valued entries removed (in place):
Returns nil if no entries were removed.

attributes['db.transaction_isolation'] = kwargs[:isolation].to_s
end
tracer.in_span('ActiveRecord.transaction', attributes: attributes) do
super(*args, **kwargs, &block)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super is enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants