Class Tracing
SERVER span per admitted request without adding
a dependency or an SPI to axiom-core. The span's parent comes from the caller's W3C
traceparent and tracestate, extracted by the OpenTelemetry API propagator; a request
without a valid header starts a root span.
Span names are METHOD route-template for a matched route and the method alone for a
router-generated answer. Attributes use the stable HTTP semantic conventions
http.request.method, http.route and http.response.status_code; raw paths, query
strings, headers and identities are never attributes. The tracer and meter of this module use the
instrumentation scope "com.jsgalactic.axiom.otel".
A successful response's status is recorded on the span before it ends. An exception is
recorded with Span.recordException(Throwable), sets StatusCode.ERROR, and gets
the failing status of an AxiomException or 500 for any other exception; the span ends
before the exception leaves the middleware. Responses produced from exceptions do not flow back
through the chain, so Middleware.afterError(com.jsgalactic.axiom.context.Context, com.jsgalactic.axiom.http.Response) adds a traceresponse header carrying
the span's identity to a mapped error response. A failure with no mapped error response has no
header to decorate.
The returned middleware is thread-safe: per-request state stays in local variables and one confined thread-local slot. It makes the created span current while the chain runs, so OpenTelemetry instrumentation on the same thread uses it as the parent.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringInstrumentation scope name of every tracer and meter this module creates. -
Method Summary
Modifier and TypeMethodDescriptionstatic Middlewarecreate(io.opentelemetry.api.OpenTelemetry openTelemetry) Creates middleware using the tracer ofSCOPE_NAMEfrom the supplied instance.static Middlewarecreate(io.opentelemetry.api.trace.Tracer tracer) Creates middleware around a caller-supplied tracer.
-
Field Details
-
SCOPE_NAME
Instrumentation scope name of every tracer and meter this module creates.- See Also:
-
-
Method Details
-
create
Creates middleware using the tracer ofSCOPE_NAMEfrom the supplied instance. The caller owns that instance, its SDK, its sampler and its exporters; this module never installs or configures them.- Parameters:
openTelemetry- tracer and propagator source, usually the application's SDK orOpenTelemetry.noop()- Returns:
- thread-safe tracing middleware
-
create
Creates middleware around a caller-supplied tracer. Use this overload when the caller chooses the instrumentation scope;create(OpenTelemetry)supplies the scope of this module.- Parameters:
tracer- tracer that creates the SERVER spans- Returns:
- thread-safe tracing middleware
-