feat(otel): OpenTelemetry integration across all framework levels - #3
Merged
Conversation
Real OTel SDK (@opentelemetry/* 2.x) on every level, traces + metrics over OTLP/HTTP: - @youneed/otel: shared core — startNodeOtel/startWebOtel, W3C propagation, instrumentedFetch, useGlobalCounter/useGlobalHistogram (lazy-binding global metrics), createOtelApi (shared this.otel surface) - @youneed/server-plugin-otel: otel() plugin + otelMiddleware() (SERVER spans, http.server.* metrics, ctx.state.span facade) + otelProvider() for controllers - @youneed/cli-plugin-otel: otelPlugin() + otelCommand() (span per command, flushed before exit) - @youneed/dom-provider-otel: initDomOtel() + otelProvider() (render/effect/event spans, flush on pagehide) - @youneed/test-plugin-otel: otel() TestPlugin (span per test) + OtelFixture - @youneed/logger-plugin-otel: trace_id/span_id/trace_flags on every record - @youneed/ssr-plugin-otel: otelModule() (ssr.render spans for static pages) - examples/otel end-to-end demo (client+server share one traceId) - fix(server-middleware-metrics): histogram buckets double-counting + global useGlobalCounter/useGlobalHistogram for the Prometheus exposition Changesets: otel-all-levels, global-metrics-api, otel-providers (all minor)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…land web.ts → ext.ts → flow.tsx (@xyflow/react) is esbuild-bundled at build time, but the root tsc typecheck still resolves the import chain and needs a jsx mode to parse it. Set "jsx": "react-jsx" in the typecheck-only root config (noEmit; package builds extend tsconfig.base.json directly and are unaffected). flow.tsx now gets real typecheck coverage as a side effect.
devtools-protocol/src/server.ts imports @youneed/server-plugin-jsonrpc (+ /devtools) but the specifier was in neither tsconfig.base.json paths nor the package deps — it only resolved locally via a stale node_modules symlink, so CI (fresh install) failed with TS2307. Register both paths entries (the repo-wide convention for cross-package imports) and fix the /devtools import to be the side-effect import it always was (the module only registers renderers; it has no default export).
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
Real OpenTelemetry SDK (
@opentelemetry/*2.x, traces + metrics over OTLP/HTTP) on every framework level, built around a single shared core so level packages never import OTel directly.New packages
@youneed/otel— core:startNodeOtel()/startWebOtel()(OTLP/HTTP traces+metrics, W3C+baggage propagators, flush on pagehide), env-aware config (OTEL_SERVICE_NAME,OTEL_EXPORTER_OTLP_ENDPOINT,OTEL_SDK_DISABLED),injectHeaders/extractHeaders,instrumentedFetch()(plugs into@youneed/http-client), global metricsuseGlobalCounter/useGlobalHistogram(same name = one process-wide instrument, lazily bound after SDK start), andcreateOtelApi()— the sharedthis.otelsurface.@youneed/server-plugin-otel—otel()plugin +otelMiddleware(): SERVER span per request with remote-parent extraction,http.server.request.duration/http.server.active_requestsmetrics,ctx.state.spanfacade (logger correlation keeps working);otelProvider()— typedthis.otelin controllers with per-requesttraceId/spanId(works for HTTP + WS JSON-RPC).@youneed/cli-plugin-otel—otelPlugin()+otelCommand(): span per command execution,cli.command.*metrics, flush+shutdown inafterCommandbefore exit.@youneed/dom-provider-otel—initDomOtel()+otelProvider():dom.render/effect/eventspans in the browser via the Web SDK; Node SDK never enters the browser bundle (subpath exports).@youneed/test-plugin-otel—otel()TestPlugin: span per test with steps and failure status,test.*metrics, trace-id inmetadata.otel;OtelFixtureinjectsthis.otelinto test classes.@youneed/logger-plugin-otel—trace_id/span_id/trace_flagsof the active span stamped on every log record.@youneed/ssr-plugin-otel—otelModule():ssr.render <url>spans + metrics for static page renders, nesting under server-plugin-otel.Every contributed
this.otel(server/dom/cli/test) exposescounter(name)/histogram(name)— the process-wide global metrics, so a metric likeurl_callsis shared by app code and all tests.Also
server-middleware-metrics:useGlobalCounter/useGlobalHistogramfor the Prometheus exposition, plus a fix for a pre-existing histogram-bucket double-counting bug (values were stored AND rendered cumulatively).examples/otelend-to-end demo: stub OTLP receiver + server plugin +instrumentedFetch— client and server spans share one traceId (pnpm examples:otel).server-middleware-trace+server-plugin-otlpremain untouched as the SDK-free alternative.Verification
pnpm typecheckshows only the pre-existingserver-plugin-devtools--jsxerror (unrelated, exists on main).Changesets
otel-all-levels,global-metrics-api,otel-providers— minor for all new/changed packages.