-
-
Notifications
You must be signed in to change notification settings - Fork 58
fix: Active scene change no longer refreshes trace ID #2502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| if (!_options.AutoSessionTracking) | ||
| { | ||
| sentryOptions.LogDebug("AutoSessionTracking is disabled. Skipping {0}.", nameof(LifeCycleIntegration)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing log when Register actually skips registering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing log when Register actually skips registering. Following the pattern everywhere else in the SDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing log when Register actually skips registering. Following the pattern everywhere else in the SDK.
|
|
||
| // Set up scene change handling if tracing is disabled or auto scene load traces are disabled | ||
| if (!isTracingEnabled || !unityOptions.AutoSceneLoadTraces) | ||
| { | ||
| _sceneManager.ActiveSceneChanged += (_, _) => | ||
| { | ||
| options.DiagnosticLogger?.LogDebug("Active Scene changed. Creating new Trace."); | ||
| hub.ConfigureScope(scope => scope.SetPropagationContext(new SentryPropagationContext())); | ||
| }; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the actually relevant change.
| } | ||
| else if (options is SentryUnityOptions unityOptions) | ||
| { | ||
| options.LogDebug("Skipping registering '{0}'. Either 'TracesSampleRate' set to '0' or 'AutoStartupTraces' is set to 'false'", nameof(StartupTracingIntegration)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The code calls LogDebug() and LogWarning() directly on SentryOptions objects. These methods do not exist and will cause a runtime crash.
Severity: HIGH
Suggested Fix
Replace direct calls like options.LogDebug(...) with the correct pattern used elsewhere in the codebase: options.DiagnosticLogger?.LogDebug(...). This applies to all instances of LogDebug and LogWarning called directly on the options object.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/Sentry.Unity/Integrations/StartupTracingIntegration.cs#L46
Potential issue: The code in `StartupTracingIntegration`, `LifeCycleIntegration`, and
`SceneManagerTracingIntegration` incorrectly calls `options.LogDebug(...)` and
`options.LogWarning(...)`. These methods are not defined on the `SentryOptions` or
`SentryUnityOptions` classes. This will result in a `MissingMethodException` at runtime
when these logging statements are executed. For example, in `StartupTracingIntegration`,
the application will crash if `TracesSampleRate <= 0` or `AutoStartupTraces` is false.
Similar crashes will occur in other integrations under specific, common configuration
scenarios.
Did we get this right? 👍 / 👎 to inform future reviews.
Followup on #2496 and #2374
The SDK refrains from creating a new propagation context due to lifecycle events, see #2374
But it still does so on active scene change, leading to fragmentation of logs over the lifespan of the game.