feat(telemetry): add OpenTelemetry-compatible instrumentation hooks - #191
Open
collinsezedike wants to merge 3 commits into
Open
feat(telemetry): add OpenTelemetry-compatible instrumentation hooks#191collinsezedike wants to merge 3 commits into
collinsezedike wants to merge 3 commits into
Conversation
collinsezedike
force-pushed
the
feat/otel-instrumentation-hooks
branch
from
August 26, 2026 16:23
457e61f to
4171b1a
Compare
|
@collinsezedike Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Thanks @collinsezedike. Exporting the Everything else is green, including all the examples jobs, so that single commit should clear it. This gate has now caught five PRs across two waves, so it is us, not you. I am going to make it print the fix command directly. |
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
Tracer/Spaninterface (src/telemetry.ts) plussetTracer()/getTracer(), exported from the package root. Zero runtime dependency on@opentelemetry/*or any tracing library — every instrumented call site defaults to a no-op tracer untilsetTracer()is called.deriveStealthKeys()/deriveStealthKeysFromSigner()(stellar.deriveStealthKeys)scanAnnouncementsStream()— onestellar.scanspan per call with aggregate counts, plus astellar.scan.matchspan per (comparatively rare) match, deliberately not per-candidate to avoid dwarfing scan cost with span overheadRpcClient.request()(stellar.rpc.request, covering internal retries/failover)ClaudeAgentToolsmethod (agent.tool.*)traceroption that overrides the global tracer for that one call.scanAnnouncementsStreamwas never exported from the public@wraith-protocol/sdk/chains/stellarentry point (only reachable via a relative import) — needed to make its newtraceroption actually usable.docs/observability.mddocuments every instrumented span and its stable attribute names.examples/otel/ships a reference adapter targeting@opentelemetry/api'sTracer/Spanshape. It's written against local structural types (not an import of@opentelemetry/api), so it has no dependency on the package — a real OTel tracer already satisfies the shape. A tiny console-based stand-in tracer lets the example run standalone end-to-end (key derivation → stealth address generation → scan) without installing any tracing library. Added to the Examples CI matrix.Closes #177.
Semver
Additive-only: new
src/telemetry.tsmodule and root exports (setTracer,getTracer,withSpan,NOOP_TRACER,Tracer,Span), new optionaltracer/optsparameters on existing functions (all optional, existing call sites unaffected), andscanAnnouncementsStreambecoming a public export it previously wasn't. No existing signature or behavior changes.Test plan
pnpm buildandpnpm test— full suite passes (1136 tests, 0 failures)test/telemetry.test.ts—Tracer/Span/setTracer/getTracer/withSpanunit coverage (no-op default, sync/async success and failure paths, per-call override, attribute mutation)test/bench/telemetry.bench.ts— no-op tracer overhead vs. uninstrumented calltest/chains/stellar/keys.test.ts,test/chains/stellar/scan.test.ts,test/chains/stellar/rpc.test.ts,test/agent/tools.test.ts— span emission, per-call override precedence, global tracer fallbackpnpm-lock.yamldiff is scoped to exactly the newexamples/otelworkspace importer (verified against the pinned[email protected])pnpm format:checkNote on CI
The Examples CI type-check step for
otel(like all CLI-style examples) runs withcontinue-on-error: true, matching the existing convention for examples that lag the SDK API slightly — non-blocking either way.