feat(http-server): add OpenTelemetry tracing (Phase 1)#2805
Open
Ignacio-Vidal wants to merge 2 commits into
Open
feat(http-server): add OpenTelemetry tracing (Phase 1)#2805Ignacio-Vidal wants to merge 2 commits into
Ignacio-Vidal wants to merge 2 commits into
Conversation
abfd662 to
15e6161
Compare
ab756b2 to
6abd618
Compare
Add OpenTelemetry tracing to the Prism HTTP service, toggled via a configuration flag with a configurable OTLP/HTTP exporter. - New telemetry module (initTelemetry) sets up the OTel NodeSDK with an OTLP/HTTP trace exporter and HTTP auto-instrumentation; no-op when disabled. - Micri request handler is wrapped in a server span when enabled, recording method, path, response status code, and exceptions. - CLI flags --telemetry, --otel-exporter-url, --otel-service-name on both mock and proxy, with PRISM_TELEMETRY / OTEL_* env-var fallbacks. - Flush and shut down the OTel SDK on SIGINT/SIGTERM so spans buffered by the BatchSpanProcessor are exported instead of dropped on exit. - Unit tests for the telemetry module and the shutdown-flush handler. Single-process only; multiprocess hardening and metrics deferred to later phases. Refs stoplightio#2804
Verifies that enabling OpenTelemetry tracing via --telemetry does not affect the served response: the server span wraps the request handler transparently and the mock response is returned as normal. Refs stoplightio#2804
6abd618 to
89197bd
Compare
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.
Refs #2804
Summary
Adds OpenTelemetry (OTel) tracing to the Prism HTTP service (Phase 1 of #2804). Telemetry is opt-in via a configuration flag, and the OTLP/HTTP exporter endpoint is configurable, so users can point Prism at any remote OTel collector (Jaeger, Grafana Tempo, Datadog, an OpenTelemetry Collector, etc.).
When disabled (the default), Prism behaves exactly as before — the OTel SDK is never started and there is no overhead.
What's included
packages/http-server/src/telemetry.ts):initTelemetry()wires up the OTelNodeSDKwith an OTLP/HTTP trace exporter and HTTP auto-instrumentation. It is a no-op when disabled.mockandproxy:--telemetry(also viaPRISM_TELEMETRYenv var)--otel-exporter-url(also viaOTEL_EXPORTER_OTLP_ENDPOINT)--otel-service-name(also viaOTEL_SERVICE_NAME, defaults toprism)--telemetrydoes not change the served response.Example usage
Checklist
Additional context
packages/http-server/package.json(per CONTRIBUTING):@opentelemetry/sdk-node,@opentelemetry/api,@opentelemetry/exporter-trace-otlp-http,@opentelemetry/instrumentation-http,@opentelemetry/resources,@opentelemetry/semantic-conventions.npm testpasses (full suite). The new harness test passes; the only failing harness tests locally are the pre-existingproxy/*cases that require a reachablehttpbinupstream.