Conversation
|
Caution Review failedFailed to post review comments 📝 WalkthroughWalkthroughThis PR integrates OpenTelemetry instrumentation across the API and TRPC packages by adding SDK dependencies, configuring exporters via environment variables, implementing the instrumentation initialization logic, wiring up tracing middleware in TRPC, and updating relevant documentation. ChangesOpenTelemetry Instrumentation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
| }), | ||
| ); | ||
|
|
||
| export const publicProcedure = t.procedure.use(tracingMiddleware); |
There was a problem hiding this comment.
This one isn't strictly required for tracing to work in the API, but without this we won't see which trpc procedure is called in the traces. You can see in my demo that this will add a sub-span for each trpc proc so it's clear which query this is coming from.
| LOG_LEVEL=info | ||
|
|
||
| # OpenTelemetry (optional) | ||
| # OpenTelemetry (optional) - To fully disable OTEL, set OTEL_SDK_DISABLED=true |
There was a problem hiding this comment.
For both workspace-engine and now api, we have localhost as the default so if OTEL is not disabled it'll keep trying to send traces to a non-existent local service. This is the standard env var to disable OTEL but just calling out out here in the docs.
| "build": "tsc && tsc-alias", | ||
| "clean": "rm -rf .turbo node_modules", | ||
| "dev": "pnpm with-env tsx watch --clear-screen=false src/index.ts", | ||
| "dev": "pnpm with-env tsx watch --clear-screen=false --import ./src/instrumentation.ts src/index.ts", |
There was a problem hiding this comment.
We need this imported before express. Alternative to adding it here is to make it the first require in the server file, but I figured this was cleaner. Open to changing it though because I'm not super crazy about it here either.
This PR adds OTEL tracing and metrics instrumentation to the API. We already have it in the workspace-engine, but this will give us tracing and o11y on our API layer.
Screen.Recording.2026-05-06.at.12.50.35.PM.mov
Summary by CodeRabbit
New Features
Documentation