Remove AddGlobalEventProcessor and globalEventProcessors
I propose removing the undocumented exported function AddGlobalEventProcessor together with the unexported global value it operates on globalEventProcessors.
https://github.com/getsentry/sentry-go/blob/763dc7f49323f467d4c62ec15804723ec5350b37/client.go#L28-L32
Rationale
All Event Processors that ship with the SDK are wrapped as an Integration and are attached to a Client. Namely:
- contextifyFramesIntegration: adds context to stacktrace frames
- environmentIntegration: adds environment information to events
- modulesIntegration: adds modules list to events
- ignoreErrorsIntegration: filters out errors that match ClientOptions.IgnoreErrors
This is in agreement with our decision to instead of exposing EventProcessors in the SDKs to hide them behind an Integration. The reason for this was that users don't have to deal with EventProcessors themselves, they only need to enable/disable Integrations.
I have checked 169 of the public packages that import sentry-go and none uses AddGlobalEventProcessor.
After removing AddGlobalEventProcessor, the same effect can be obtained with Scope.AddEventProcessor or Client.AddEventProcessor.
Note that an EventProcessor may still have its own global state if it desires so.
Pros:
- Smaller API surface for a future v1.
- Less global state.
- Less room for concurrency issues (data races):
AddGlobalEventProcessormust not be called from multiple goroutines concurrently. - API easier to be composed/wrapped (there are users trying to do that, see example).
Cons:
- Potentially breaking closed-source users, however those have a very easy replacement.
@kamilogorek @bruno-garcia @HazAT for comments, if any.
I'd like to see this change land.
Sounds good to me. I followed the implementation of JS SDK to the T at first, thus why some parts might be unnecessary now.
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀