Skip to content

Don't dispose of backpressure monitor when disposing the Hub #4635

@jamescrosswell

Description

@jamescrosswell

Description

We currently dispose the backpressure monitor here:

_backpressureMonitor?.Dispose();

That gets passed into the Client:

client ??= new SentryClient(options, randomValuesFactory: _randomValuesFactory, sessionManager: _sessionManager, backpressureMonitor: _backpressureMonitor);

... and thus eventually into the Transport:

var transport = _options.Transport ?? new LazyHttpTransport(_options, _backpressureMonitor);

However we intentionally leave the client dangling when we dispose of the Hub... so that it can continue to receive requests from things that are wrapping up during application shutdown.

But if the Client and the Transport don't get disposed of when the Hub is, that could result in an ObjectDisposedException here:

var downsampledRate = sampleRate * _backpressureMonitor.GetDownsampleFactor();

Instead, we should maybe tell the worker task to exit by cancelling it's token and then just let the backpressure monitor dangle and hang out with the client until GC decides to nuke them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETPull requests that update .net code

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions