-
Notifications
You must be signed in to change notification settings - Fork 252
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
feat: add untraced ctx method #1634
Conversation
@@ -93,6 +93,10 @@ def untraced | |||
end | |||
end | |||
|
|||
def untraced_context(parent_context: Context.current) |
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.
Alternate considered is that we can instead amend the existing interface to support block structure or not depending if a block is provided.
# Disables tracing within the provided block.
def untraced
if block_given?
Context.with_value(UNTRACED_KEY, true) do |ctx, _|
yield ctx
end
else
Context.set_value(UNTRACED_KEY, true)
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.
Can we modify untraced
to take an optional context arg and optional block? I.e.
def untraced(context = Context.current)
context = context.set_value(UNTRACED_KEY, true)
if block_given?
Context.with_current(context) { |ctx| yield ctx }
else
context
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.
Updated
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.
LGTM, once you've appeased the cop.
Support untraced usage in a non block structure open-telemetry/opentelemetry-ruby-contrib#965 (comment)