feat: Trace Generation Integration#2123
Conversation
|
| return; | ||
| } | ||
|
|
||
| options.DiagnosticLogger?.LogDebug("Registering Session integration."); |
There was a problem hiding this comment.
The hub already logs which integration get registered. This is redundant.
|
|
||
| namespace Sentry.Unity; | ||
|
|
||
| internal interface ISentryMonoBehaviour |
There was a problem hiding this comment.
I'm creating an internal interface to be able to mock this in the tests.
| // For now, we're creating a new trace after initializing to be able to tie errors and crashes together on all | ||
| // layers. To be able to regenerate new traces based on some mechanism, this will move into some sort of | ||
| // integration i.e. scene manager. | ||
| SentrySdk.SetTrace(SentryId.Create(), SpanId.Create()); | ||
|
|
There was a problem hiding this comment.
This is the part that is getting replaced by the integration.
There was a problem hiding this comment.
The changes here contain: InternalsVisibleTo for the tests and removing the internal SentrySdk.SetTrace that got replaced by accessing the scope directly.
…try/sentry-unity into feat/trace-id-integration
…try/sentry-unity into feat/trace-id-integration
| public void Register(IHub hub, SentryOptions options) | ||
| { | ||
| hub.ConfigureScope(scope => | ||
| scope.SetPropagationContext(new SentryPropagationContext(SentryId.Create(), SpanId.Create()))); |
There was a problem hiding this comment.
This constructor feels like a lot of boiler plate. In fact even having to pass a new propagation context feels redundant as it seems it's the main use case we have, just setting a new propagation context.
Could also be solved with an extension method like ResetPropagationContext() that calls SetPropagationContext(new SentryPropagationContext(SentryId.Create(), SpanId.Create())))
This PR adds an integration that is responsible for generating a new trace based
on already existing mechanisms using in the
SceneManagerIntegrationand theSessionIntegrationIn practical terms this translates into the following flow:
TraceGenerationIntegrationgets registered and starts a new traceTraceGenerationIntegrationkicks in and creates a new traceLogically, this separates the startup from the actual game. During gameplay the trace gets re-generated every time the game gains focus. This can/might/should/could get updated in the future by different lifecycle events. I.e. touches on mobile (like Android does it).