Skip to main content

Module codec

Module codec 

Source
Expand description

OTLP/HTTP payloads: decoding an export request into the summary the model sees, and encoding every response the receiver sends.

Pure functions, shared by the server, the tests and nothing else. The model never sees a payload: it gets counts, the service name, a few resource attributes and the first few span names, metric names or log bodies, each truncated. It never writes one either: every response body — the empty full-success message, a partial success, a google.rpc.Status — is encoded here, in the encoding the request used.

Protobuf is decoded with the OpenTelemetry project’s own generated types (opentelemetry-proto, prost). prost stops at 100 levels of nesting, so a depth bomb in an AnyValue is a decode error, not a stack overflow. JSON is parsed as a serde_json::Value (recursion limit 128) and walked by hand rather than through the crate’s serde types, because OTLP/JSON senders differ in ways a strict typed decode would refuse (64-bit integers as numbers or strings, enum values as numbers or names); keys are accepted in lowerCamelCase, as the specification writes them, and in the proto’s own snake_case. Neither walk recurses into attribute values: an array or map is summarised by its length.

Structs§

RpcStatus
google.rpc.Status, the body of every OTLP/HTTP failure response.
Summary
What the model is told about one export.

Enums§

BodyError
Why a body could not be read.
Encoding
The two encodings OTLP/HTTP defines.
Signal
The three signals and their paths.

Constants§

MAX_ATTRIBUTES
MAX_BODY_BYTES
The largest request body the receiver reads, after decompression: 4 MiB, the default message limit of the gRPC servers OTLP receivers are built on and what SDK exporters batch under. A gzip body is held to the same number once inflated, so a small compressed body cannot expand past it.
MAX_LOG_BODIES
MAX_NAMES
How much of an export the model is shown.
MAX_SERVICES
REJECT_STATUSES
The statuses a model may refuse with. 429, 502, 503 and 504 are the ones OTLP clients retry.

Functions§

export_response
The export response: full success when partial is None, else a partial success naming how many items were rejected and why.
grpc_code
The gRPC code an HTTP failure status corresponds to, per the OTLP specification’s mapping.
gunzip_bounded
Inflate a gzip body, refusing it as soon as it passes limit bytes. Never allocates more than limit + 1 bytes of output.
retryable
Whether an OTLP client retries after this status.
status_body
A failure body in the request’s encoding.
summarize
Decode a request in either encoding.
summarize_json
Decode an OTLP/JSON export request.
summarize_protobuf
Decode a protobuf export request.