Skip to content
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

Sentry.with_child_span didn't handle current scope is nil #1818

Closed
elct9620 opened this issue May 13, 2022 · 1 comment · Fixed by #1819
Closed

Sentry.with_child_span didn't handle current scope is nil #1818

elct9620 opened this issue May 13, 2022 · 1 comment · Fixed by #1819
Assignees
Milestone

Comments

@elct9620
Copy link

Issue Description

def with_child_span(**attributes, &block)
current_span = get_current_scope.get_span
if current_span
result = nil
begin
current_span.with_child_span(**attributes) do |child_span|
get_current_scope.set_span(child_span)
result = yield(child_span)
end
ensure
get_current_scope.set_span(current_span)
end
result
else
yield(nil)
end
end

The get_current_scope will return nil before initialized then the with_child_span will failed.

Reproduction Steps

require 'sentry-ruby'

# May raise exception if Sentry not ready
Sentry.with_child_span do |child_span|
  # ...
end

Expected Behavior

Ignore the span until Sentry is ready.

Actual Behavior

Raised UndefinedMethod error

Ruby Version

2.7.6

SDK Version

5.3.0

Integration and Its Version

Sequel

Sentry Config

No response

@st0012
Copy link
Collaborator

st0012 commented May 14, 2022

@elct9620 Thanks for reporting this 😄 I've added #1819 to address it.

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

Successfully merging a pull request may close this issue.

2 participants