[RUM-9335] Fix missing application.id in "Session Ended" telemetry - #3095
Draft
saraSr5 wants to merge 1 commit into
Draft
[RUM-9335] Fix missing application.id in "Session Ended" telemetry#3095saraSr5 wants to merge 1 commit into
saraSr5 wants to merge 1 commit into
Conversation
Contributor
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why?
"Session Ended" telemetry was sometimes missing
application.id. The metric is emitted at the exact moment a RUM session stops existing — after an inactivity timeout, or afterstopSession()— andTelemetryReceiverderivedapplication.idfrom the RUM session context, which isnilonce there is no session.This matters because SDK telemetry is consumed per RUM application: an event without
application.idcannot be attributed to an app. The loss was also not random — it hit exactly the sessions that ended by timeout or bystopSession(), which biases any analysis of how sessions end. It additionally forced "Session Ended" telemetry to stay disabled in the integration test fixtures, now removed.How?
TelemetryReceivernow receivesapplicationIDat init fromRUMFeatureand uses it directly, instead of reading it from the session context.The RUM application ID is SDK configuration — known upfront, immutable for the life of the instance, and not session state. Sourcing it from a per-session context was the original modelling error.
CrashReportReceiver, declared a few lines below in the same receiver list inRUMFeature, already takesapplicationIDat init for exactly the same reason: crash reports are also emitted when no session is active.TelemetryReceiverwas the outlier.RUMCoreContextis unchanged, so the modules that consume it (Logs, Trace, SessionReplay, Profiling, WebViewTracking, Flags, NetworkInstrumentation) are unaffected.The neighbouring fields are deliberately left as they were:
sessionandactionare genuinely session state and must staynilwhen no session exists. Onlyapplicationbecomes unconditional.Relation to #2324. That PR added an
applicationIDOverridemirroringsessionIDOverride, and was closed in favour of "a real fix than a workaround". An override exists to report a value that differs from the current one — necessary forsession.id, because by emission time the context already holds the new session, but meaningless forapplication.id, which never changes. Injection is also harder to get wrong: a future metric cannot forget to set an attribute it does not need.Review checklist
make api-surfacewhen adding new APIs