Skip to content

Refactor Sentry.close#2207

Merged
st0012 merged 1 commit intomasterfrom
refactor-sentry-close
Dec 22, 2023
Merged

Refactor Sentry.close#2207
st0012 merged 1 commit intomasterfrom
refactor-sentry-close

Conversation

@st0012
Copy link
Copy Markdown
Contributor

@st0012 st0012 commented Dec 22, 2023

When reviewing #2206, I spotted 2 things that could be improved:

  • When closing the SDK, we shouldn't need to enqueue the last client report sending to background worker again. This makes the behaviour of close more difficult to predict.
  • Since the session flusher can still enqueue a job to background worker when flushing, we should postpone background worker's shutdown instead.

#skip-changelog

When reviewing #2206, I spotted 2 things that could be improved:

- When closing the SDK, we shouldn't need to enqueue the last client report
  sending to background worker again. This makes the behaviour of `close`
  more difficult to predict.
- Since the session flusher can still enqueue a job to background worker
  when flushing, we should postpone background worker's shutdown instead.
@st0012 st0012 requested a review from sl0thentr0py December 22, 2023 12:48
@codecov
Copy link
Copy Markdown

codecov bot commented Dec 22, 2023

Codecov Report

Merging #2207 (9fb2a55) into master (dd2d617) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2207   +/-   ##
=======================================
  Coverage   97.36%   97.36%           
=======================================
  Files         101      101           
  Lines        3798     3799    +1     
=======================================
+ Hits         3698     3699    +1     
  Misses        100      100           
Components Coverage Δ
sentry-ruby 98.07% <100.00%> (+<0.01%) ⬆️
sentry-rails 94.98% <ø> (ø)
sentry-sidekiq 94.53% <ø> (ø)
sentry-resque 92.06% <ø> (ø)
sentry-delayed_job 94.44% <ø> (ø)
sentry-opentelemetry 100.00% <ø> (ø)
Files Coverage Δ
sentry-ruby/lib/sentry-ruby.rb 96.44% <100.00%> (+0.01%) ⬆️

Copy link
Copy Markdown
Member

@sl0thentr0py sl0thentr0py left a comment

Choose a reason for hiding this comment

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

the client reports are sent only once every interval, so we need to flush the pending stats on close. This was the main point of my change.

edit: ah you mean send them in the main thread, hmm

@st0012
Copy link
Copy Markdown
Contributor Author

st0012 commented Dec 22, 2023

ah you mean send them in the main thread

Yeah. I don't see a reason to send it async at that stage while waiting to shutdown the worker right away.


if configuration&.include_local_variables
exception_locals_tp.disable
if client = get_current_client
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@sl0thentr0py Another "concern" I have is that we currently only focus on the main hub's top client, but not other clients. Ideally we should do that for all clients of the main hub, as well as other hubs' (which we don't track AFAIK) clients?

I think the former is probably fine as a hub is unlikely to have more than 1 client. But I do recall some customers tried doing multi-hub setup in the past (also rare tho).

I know both are fairly rare. I just want to raise it so we keep that in mind.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yea both valid concerns but as a heads up, sometime next year we'll move to removing the Hub and only having a Scope (which will be closer to opentelemetry's context).
rfc here - getsentry/rfcs#122

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the context! I just gave it a first pass and got confused around different types of scopes too, as raised by you and many other comments.

But yeah if I understand it correctly, there will only be 1 client in the future and no hubs, which means this won't be a concern anymore.

@st0012 st0012 merged commit d02cf27 into master Dec 22, 2023
@st0012 st0012 deleted the refactor-sentry-close branch December 22, 2023 13:22
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.

2 participants