Add JavaScript span transform plugins - #28
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
af6b477 to
41bd374
Compare
e8b28fa to
3a20d75
Compare
Andrew Kent (realark)
left a comment
There was a problem hiding this comment.
nice!
we should consider making the fail state configurable in the future. secret-scrubbing plugins that fail may wish to trigger a data drop instead, etc
|
Good point. I had went for failing plugins just get skipped, since we don't really have a way to surface errors immediately, only logs. But in some cases a failure may actually be a critical thing that should block reporting. 🤔 |
3a20d75 to
41f9673
Compare
|
Addressed the redaction-failure concern: plugin processing now fails closed for every plugin error, so the affected span operation is withheld rather than sent unredacted. The raw QuickJS exception is stored in a bounded, deduplicated local diagnostics registry and shown by |
Summary
rquickjs-serde, using strict result decoding without intermediate JSON textbt trace doctorExample
Create a synchronous ES module:
Choose the scope when registering it:
Each function receives the previous plugin's returned span plus
{ operation, source, session_id, env }. Plugins may change span content but notspan_id,root_span_id, orparent_span_ids.Raw input events are journaled before transformation. On recovery, an ordinary session uses the current globally configured plugin chain, while an isolated managed session continues using its invocation-local chain. Import and attach are separate from journal recovery and use only their command-line plugins.
If any plugin throws, times out, returns a promise, or returns an invalid span, that span operation is discarded instead of being sent unredacted. The raw exception is stored locally in a bounded, deduplicated diagnostics registry and can be inspected with:
The failed plugin remains quarantined on that worker while its file is unchanged. Editing the plugin retries it; restarting the daemon then replays withheld journal operations through the repaired current plugin chain.
See the README examples for redaction, environment handling, chaining, replay, failure diagnostics, and security guidance.
Validation
cargo test --manifest-path bt-daemon/Cargo.toml --all-features --lockedcargo clippy --manifest-path bt-daemon/Cargo.toml --all-targets --all-features --locked -- -D warningscargo fmt --manifest-path bt-daemon/Cargo.toml -- --checkcargo metadata --manifest-path bt-daemon/Cargo.toml --locked --no-deps --format-version 1make testgit diff --check