Cache global fields in LogsAgent#166
Conversation
This comment has been minimized.
This comment has been minimized.
34e6353 to
199d696
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 34e63533d0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ' 4. Cache the global context locally, kept in sync via observers | ||
| m.global.observeFieldScoped("datadogUserInfo", "onUserInfoChanged") | ||
| m.global.observeFieldScoped("datadogContext", "onContextChanged") | ||
| m.global.observeFieldScoped("datadogRumContext", "onRumContextChanged") |
There was a problem hiding this comment.
Avoid observing the RUM context before it exists
When the first log is emitted immediately after initialize, LogsAgent.setupIfNeeded() can run before the RumAgent task has executed setup() and added datadogRumContext; initialize only adds datadogContext/datadogUserInfo synchronously, while datadogRumContext is added later from the RUM task. In that timing window this observer is not attached to a real field, so m.rumContext stays invalid and subsequent logs miss RUM correlation even after the RUM agent creates/updates the global context. Ensure the field is created synchronously before logs can initialize, or retry/register the observer once the field exists.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
We now create the datadogRumContext synchronously in datadogSdk, wdyt?
There was a problem hiding this comment.
the review is a good call, and the workaround makes sense also
What does this PR do?
LogsAgent.Review checklist (to be filled by reviewers)