feat(server): add OpenTelemetry instrumentation - #36
Open
espetro wants to merge 1 commit into
Open
Conversation
Adds OTLP HTTP trace/metric export via @app/logger/otel, a Prometheus-format
/api/metrics endpoint for pipeline token usage, and graceful shutdown on
SIGTERM/SIGINT. OTel deps pinned to 1.29.0 to avoid version skew across
@opentelemetry/{sdk-metrics,resources,sdk-trace-node}.
Closes #31
Deploying calca with
|
| Latest commit: |
f0c7a91
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://2a5de2f3.calca-5u3.pages.dev |
| Branch Preview URL: | https://feat-otel-instrumentation.calca-5u3.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
initOTel()(@app/logger/otel) wiring OTLP HTTP trace + metric exporters, called at server startup with SIGTERM/SIGINT-triggered graceful shutdown.GET /api/metrics(Prometheus text format) exposing pipeline token usage counters from@calca/pipeline'stokenAggregator.otel-local.yamlfor running a local OTel Collector during development.@opentelemetry/{sdk-metrics,resources,sdk-trace-node}to1.29.0via rootpackage.jsonoverrides to avoid version skew withsdk-node's transitive deps.Stacked on #34 (pipeline-migration) — this branch bases off
feat/pipeline-migrationsince@calca/pipeline(thetokenAggregatorimport in/api/metrics) only exists after that PR.Test plan
packages/logger:tsc --noEmitclean,vitest run— 8 passedapps/server:tsc --noEmitclean,vitest run— 15 passed, 1 pre-existing failure unrelated to this change (workflow.test.tsfails on a zod version mismatch insidepackages/shared/src/schemas/layout.ts, which this PR doesn't touch)otel/opentelemetry-collector+otel-local.yaml), started the server withOTEL_ENABLED=true— SDK initializes without error,/api/metricsreturns valid Prometheus-format output, collector's OTLP HTTP receiver on:4318accepts trace payloads (200 +partialSuccess).@opentelemetry/instrumentation-httppatches Node'snode:httpmodule, which Bun's nativeBun.serve()does not go through — inbound request spans are not auto-instrumented for this reason. This is a Bun-runtime limitation rather than a bug in this PR; outboundfetch()calls remain covered byFetchInstrumentation.