Expand description
Everything needed to set up telemetry (logs, traces, metrics) for both clients and servers.
§Logging strategy
-
All our logs go through the structured
tracing
macros. -
We always log from
tracing
directly into stdio: we never involve theOpenTelemetry
logging API. Production is expected to read the logs from the pod’s output. There is never any internal buffering going on, besides the buffering of stdio itself. -
All logs that happen as part of the larger trace/span will automatically be uploaded with that trace/span. This makes our traces a very powerful debugging tool, in addition to a profiler.
§Tracing strategy
-
All our traces go through the structured
tracing
macros. We never use theOpenTelemetry
macros. -
The traces go through a first layer of filtering based on the value of
RUST_TRACE
, which functions similarly to aRUST_LOG
filter. -
The traces are then sent to the
OpenTelemetry
SDK, where they will go through a pass of sampling before being sent to the OTLP endpoint. The sampling mechanism is controlled by the official OTEL environment variables. -
Spans that contains error logs will properly be marked as failed, and easily findable.
§Metric strategy
-
Our metric strategy is basically the opposite of our logging strategy: everything goes through
OpenTelemetry
directly,tracing
is never involved. -
Metrics are uploaded (as opposed to scrapped!) using the OTLP protocol, on a fixed interval defined by the
OTEL_METRIC_EXPORT_INTERVAL
environment variable.
Modules§
Structs§
- Grpc
Make Span - Implements
tower_http::trace::MakeSpan
where the trace name is the gRPC method name. - Grpc
OnEos - Implements a
tower_http::trace::OnEos
middleware. - Grpc
OnFirst Body Chunk - Implements a
tower_http::trace::OnBodyChunk
middleware, but only accounts for the first one. - Grpc
OnRequest - Implements a
tower_http::trace::OnRequest
middleware. - Grpc
OnResponse - Implements a
tower_http::trace::OnResponse
middleware. - Telemetry
- The Redap telemetry pipeline.
- Telemetry
Args - Complete configuration for all things telemetry.
- Trace
Headers - Tracing
Extractor Interceptor - This implements a
tonic::service::Interceptor
that extracts trace/span metadata from the request headers, according to W3C standards. - Tracing
Injector Interceptor - This implements a
tonic::service::Interceptor
that injects trace/span metadata into the request headers, according to W3C standards.
Enums§
Traits§
Functions§
- current_
trace_ headers - Export the active trace in the current context as the W3C trace headers, if any.
- current_
trace_ id - Returns the active
TraceId
in the current context, if any. - new_
client_ telemetry_ layer - Creates a new
tower::Layer
middleware that automatically: - new_
server_ telemetry_ layer - Creates a new
tower::Layer
middleware that automatically: - to_
short_ str - Displays a possibly long list of items to a length limited list of items.