Skip to content

Commit

Permalink
Sentry.with_child_span should check SDK's initialization state (#1819)
Browse files Browse the repository at this point in the history
* Sentry.with_child_span should check SDK's initialization state

* Update changelog
  • Loading branch information
st0012 authored May 14, 2022
1 parent 0fe8d27 commit 8bd4054
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- Don't require a DB connection, but release one if it is acquired [#1812](https://github.com/getsentry/sentry-ruby/pull/1812)
- Fixes [#1808](https://github.com/getsentry/sentry-ruby/issues/1808)
- `Sentry.with_child_span` should check SDK's initialization state [#1819](https://github.com/getsentry/sentry-ruby/pull/1819)
- Fixes [#1818](https://github.com/getsentry/sentry-ruby/issues/1818)

### Miscellaneous

Expand Down
4 changes: 1 addition & 3 deletions sentry-ruby/lib/sentry-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,7 @@ def start_transaction(**options)
# end
#
def with_child_span(**attributes, &block)
current_span = get_current_scope.get_span

if current_span
if Sentry.initialized? && current_span = get_current_scope.get_span
result = nil

begin
Expand Down
5 changes: 5 additions & 0 deletions sentry-ruby/spec/initialization_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@
it do
expect { Sentry.with_scope { raise "foo" } }.not_to raise_error(RuntimeError)
end

it do
result = Sentry.with_child_span { "foo" }
expect(result).to eq("foo")
end
end

0 comments on commit 8bd4054

Please sign in to comment.