Add optional distributed tracing (MoonlightTracer)#30
Open
Add optional distributed tracing (MoonlightTracer)#30
Conversation
Defines MoonlightTracer, MoonlightSpan, NOOP_TRACER, withTrace, and withTraceSync — a framework-agnostic tracing contract that consumers can bridge to any OpenTelemetry backend. Zero runtime dependency on @opentelemetry/api.
Adds optional tracer to PrivacyChannel constructor and wraps read, invoke, and invokeRaw with withTrace for span-level observability.
Adds tracer to account options, wraps deriveBatch and batchLoad with withTrace, wraps selectUTXOsForTransfer with withTraceSync. Factory method fromPrivacyChannel propagates tracer from the channel instance.
Wraps addOperation with withTraceSync and sign methods (signWithProvider, signWithSpendUtxo, signExtWithEd25519) with withTrace. Factory method fromPrivacyChannel propagates tracer from the channel instance.
Adds Promise<void> return types to signWithProvider, signWithSpendUtxo, signExtWithEd25519. Adds await to all withTrace calls in async methods to satisfy require-await lint rule.
Cover all branches in withTrace and withTraceSync including success/error paths, withActiveSpan delegation, non-Error throws, and NOOP_TRACER behavior.
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
MoonlightTracer,MoonlightSpan,NOOP_TRACER) with zero runtime dependency on@opentelemetry/apiwithTrace(async) andwithTraceSync(sync) helpers with guaranteed span lifecycle, error recording, andexit_with_erroreventswithActiveSpanmethod enables W3Ctraceparentpropagation for distributed tracing — consumers bridge to their own OTel backendPrivacyChannel(read/invoke/invokeRaw),UtxoBasedAccount(deriveBatch/batchLoad/selectUTXOsForTransfer), andMoonlightTransactionBuilder(addOperation/sign methods)NOOP_TRACER)How to verify
Run the full E2E flow with Jaeger locally — see the step-by-step Jaeger guide in
local-dev.Test plan
deno task testpasses (no breaking changes — tracing is optional)deno task e2e+deno task verify-otelpasses 16/16 checks