♻️ introduce Logs plugin API and assemble hook enrichment - #5014
♻️ introduce Logs plugin API and assemble hook enrichment#5014BenoitZugmeyer wants to merge 4 commits into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
✅ All CI checks and tests passed. 🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 9240f39 | Docs | View more details | Give us feedback! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e58976b0ac
ℹ️ 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".
e58976b to
15886e8
Compare
Bundles Sizes Evolution
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 15886e85dd
ℹ️ 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".
15886e8 to
a72e2c9
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a72e2c9df9
ℹ️ 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".
a72e2c9 to
9a15b57
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9a15b5709c
ℹ️ 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".
9a15b57 to
89f41fa
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bd585658a0
ℹ️ 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".
Apply the same two-hook split to the RUM SDK: - assembleEventDefaults: provides default attributes (existing behavior) - assembleEvent: provides attributes that take precedence over the raw event, so plugins can override fields such as error.source_type The override hook result is merged after the raw RUM event in the combine order, letting plugins enrich/override fields without workarounds.
ad2d986 to
1a3e7a3
Compare
There was a problem hiding this comment.
💡 Codex Review
issue: registerAssembleEventHook is advertised for returning partial enrichments, but reusing DefaultRumEventAttributes makes type mandatory in every callback result. Under strictNullChecks, a plugin returning only { error: { fingerprint: ... } } or { context: ... } is rejected even though the assembly code already preserves the raw event's type; use a separate recursive-partial result type for the override hook so plugins need not redundantly return eventType.
ℹ️ 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".
1a3e7a3 to
1e49051
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1e4905196a
ℹ️ 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".
1e49051 to
765b37b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 765b37b9e3
ℹ️ 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".
765b37b to
ede4866
Compare
Pass the assembleEvent hook register function to plugins' onInit callback as registerAssembleEventHook, so plugins can register callbacks to override RUM event fields before they are sent. Mirrors the Logs SDK plugin API.
ede4866 to
9240f39
Compare
Motivation
This PR introduces plugin-related changes required for creating a wasm plugin, started in #4920. I am opening my own PR for platform work, so #4920 can focus on the wasm plugin itself.
The Browser SDK did not let third-party code enrich or override events before they are sent to Datadog. This makes it impossible for plugins (e.g. a WebAssembly symbolication plugin) to attach metadata such as
source_typeor loaded module build IDs to error events, which downstream tooling needs to symbolicate WASM stack traces.This PR introduces an experimental plugin API on the Logs SDK and extends the existing RUM plugin API so plugins can register assemble callbacks that read the raw event and return enrichments or overrides.
Changes
LogsPlugininterface (name,getConfigurationTelemetry,onInit,onLogsStart), apluginsconfiguration option with schema + telemetry serialization, and thecallPluginsMethodhelper. WireonInitandonLogsStartin the public API.rawLogsEventanddomainContextto the assemble hook so plugins can read the raw event and return enrichments.assemblehook intoassembleEventDefaults(provides default attributes, existing behavior) andassembleEvent(provides attributes that take precedence over the raw event). The override result is merged after the raw event in thecombineorder, so plugins can override fields such aserror.source_typewithout ad-hocmergeIntoworkarounds.registerAssembleEventHookon theonInitoptions so plugins can register override callbacks. Only theregisterfunction is exposed, not the full hook, keeping the API minimal.The plugins API is unstable and experimental, and may change without notice.
Test instructions
yarn dev) and open the sandbox athttp://localhost:8080.DD_LOGS.init/DD_RUM.initthat uses theonInitregisterAssembleEventHookcallback to override an error field (e.g. seterror.fingerprint).setTimeout(() => { throw new Error('boom') })) and flush events.Checklist