Repository navigation
Conversation
ax-server cannot join a slow or failed command to the client that issued it, because the CLI sends no trace context. With --trace, a command now starts a sampled root span, prints its trace ID to stderr, and sends a W3C traceparent on every AX RPC, so ax-server and Substrate, which sample ParentBased, record the whole request. - Without --trace the CLI creates no tracer and sends no trace context, so ax-server keeps the sampling decision for CLI traffic. - Each RPC is a client span under the command span, and resolving the ax-server address (which may start a port-forward) is a child span. Only traceparent is propagated, never baggage. - CLI spans are exported over OTLP only when an OTLP endpoint is set. OTEL_TRACES_EXPORTER follows ax-server's rules, and the resource reads OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES. Export waits at most 2 s and warns on failure; OpenTelemetry errors print as warnings. - ax ssh returns the remote exit code instead of exiting the process, so the command span ends and its port-forward is cleaned up.
JeffLuoo
force-pushed
the
cli-trace-propagation
branch
from
November 9, 2026 19:45
099112e to
80cae1b
Compare
erain
approved these changes
Nov 10, 2026
erain
left a comment
Collaborator
There was a problem hiding this comment.
LGTM! Verified at 80cae1b: go build ./cmd/..., go vet ./..., gofmt, go mod tidy, and go test -race -count=3 ./cmd/ax/... all pass cleanly.
- Without
--trace,activeTracestaysnil, creating noTracerProviderand sending notraceparentheader soax-servermakes its own sampling decision. - With
--trace,startCommandTracestarts anAlwaysSampleroot span (ax <cmd>), printsTrace ID: <id>tostderr, wrapstunnel.EnsureServerURLin aresolve ax-server addresschild span, and configuresotelgrpc.NewClientHandlerwithpropagation.TraceContext{}only (no baggage) andmetricnoop.NewMeterProvider(). envSpanExporterandresolveExportersmatch#557's exporter and resource rules while only exporting CLI spans when an OTLP endpoint is set.- Returning
exitCodeErrorfromrunSSHcleanly runsdefer cleanup()and flushes the command span before exiting with the remote exit code.
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.
ax-server cannot join a slow or failed command to the client that issued it, because the CLI sends no trace context. With
--trace, anaxcommand starts a sampled root span, printsTrace ID: <id>to stderr, and sends a W3Ctraceparenton every AX RPC. ax-server (#557) and Substrate sample ParentBased, so they record the whole request.--trace, the CLI creates no tracer and sends no trace context, so ax-server's own sampler decides for CLI traffic, as withkubectl ate.OTEL_EXPORTER_OTLP_ENDPOINTis set;OTEL_TRACES_EXPORTERand the resource follow ax-server: set up OpenTelemetry tracing, metrics, events, and JSON logs #557's rules.ax sshreturns the remote exit code instead of callingos.Exit, so the command span ends and the port-forward is cleaned up.Pins
otel v1.45.0andotelgrpc v0.70.0, as #557 does. It does not depend on #557; the two overlap only ingo.mod/go.sum. Server spans join these traces once ax-server adds theotelgrpcserver handler.Refs #13, #452.
Testing
go test -race ./...,go vet ./..., andgo mod tidyare clean. New tests incmd/ax/trace_test.gocover the header with and without--trace, span parents, resource attributes, export and SDK warnings, streaming RPCs, the exporter rules, and exit codes.