feat: custom span processors in telementry options#3042
feat: custom span processors in telementry options#3042Shaik-Sirajuddin wants to merge 3 commits intotriggerdotdev:mainfrom
Conversation
|
|
Hi @Shaik-Sirajuddin, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details. |
|
Caution Review failedThe pull request is closed. WalkthroughThis pull request introduces optional custom span processor configuration to the OpenTelemetry telemetry setup. The changes add a new Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes ✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Repository UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
✏️ Tip: You can disable this entire section by setting Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🚩 managed-run-worker doesn't check telemetry.instrumentations (pre-existing inconsistency)
In dev-run-worker.ts:207, instrumentations are resolved with config.telemetry?.instrumentations ?? config.instrumentations ?? [], properly supporting both the new telemetry.instrumentations path and the deprecated top-level instrumentations field.
However, managed-run-worker.ts:186 only uses config.instrumentations ?? [], ignoring config.telemetry?.instrumentations entirely. This means users who configure instrumentations under the telemetry key (as the deprecation notice on config.ts:86-87 suggests) will have them silently ignored in managed/production runs while working fine in dev. This is a pre-existing issue not introduced by this PR, but the PR author may want to fix it alongside this change for consistency.
(Refers to line 186)
Was this helpful? React with 👍 or 👎 to provide feedback.
| //add span processor passed via config before adding exporters | ||
| for (const spanProcessor of config.spanProcessors ?? []) { | ||
| spanProcessors.push(spanProcessor); | ||
| } |
There was a problem hiding this comment.
🚩 Custom span processors' onStart won't see task context attributes
Custom span processors are pushed into the array before TaskContextSpanProcessor at packages/core/src/v3/otel/tracingSDK.ts:130-148. The NodeTracerProvider calls each processor's onStart in order, so custom processors' onStart will execute before TaskContextSpanProcessor.onStart adds task context metadata attributes (see packages/core/src/v3/taskContext/otelProcessors.ts:18-31 where span.setAttributes(...) is called).
However, since attributes are mutated on the shared span object, custom processors' onEnd will see the task context attributes (they were already set during the onStart phase). This is likely acceptable for most use cases (the PR's example LogSpanProcessor only logs in onStart and doesn't read attributes), but users writing processors that need task context in onStart would be surprised. The comment on line 125 says this ordering is intentional.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
We're going to be changing how this whole system works shortly which will allow people to define their own custom otel stack and we'll provide a span/log/metric processor that sends them to the trigger.dev instance. |
Closes #2979
✅ Checklist
Testing
1.define a custom otel processor with logging
Changelog
[Short description of what has changed]
telementry options now support passing custom otel span processors
Screenshots
[Screenshots]
💯