feat(otlptracegrpc,otlpmetricgrpc): support zstd compression
LI
2mo ago+1836+1836+0123456789012345678901234567890123456789-181-181-012345678901234567890123456789
Fixes #8984.
WithCompressor/WithCompression in otlptracegrpc, otlpmetricgrpc, otlptracehttp, and otlpmetricgrpc only recognized gzip; any other value silently fell back to no compression (gRPC) or, on HTTP, wasn't wired into the request builder at all (WithCompression(ZstdCompression) left bodyReader nil and panicked on first export). This adds zstd as a first-class value across all four exporters, following the zstd OTEP that came out of review on this PR.
- All four transports:
zstdis now handled end-to-end (gRPC already worked; HTTP request builders previously had nocasefor it at all, andotlptracehttpnever even exported aZstdCompressionconstant). - gzip fallback on rejection:
UNIMPLEMENTED(gRPC) /415/400(HTTP) for a zstd-compressed export are non-retryable under OTLP's existing retry semantics, so a receiver that doesn't support zstd would otherwise drop the batch outright, even though both sides are spec-compliant. The exporter now retries once withgzip, which every conformant OTLP receiver is required to support, and logs a warning viaotel.Handlewhen it does. nozstdbuild tag: excludes theklauspost/compressdependency and codec registration entirely. A build with the tag fails fast at exporter construction/Startifzstdis still configured, rather than an opaque runtime error at first export.- Wire format: pooled
zstd.Encoder/Decoder, mirroringgzip's existing streamingCompress/Decompressshape (not a different shape just for zstd), with the window capped at 8 MB per RFC 9659 §3's HTTP interoperability recommendation. - Added a
default:case to both HTTP compression switches, fixing the general silent-nil-bodyReaderfailure mode, not just the zstd instance of it.
Verified beyond go build/go test:
- Wire-level tests in all four packages: happy-path (asserting the actual negotiated codec / decoded frame, not just that export succeeds), fallback-on-rejection, and
nozstdfail-fast. - Round-tripped against a real Collector (
otel/opentelemetry-collector-contrib, not just this PR's own mocks) for both gRPC and HTTP zstd payloads.
Still open
- The sibling bug this issue also flagged — an unrecognized
WithCompressorvalue silently falls back to no compression instead of erroring — is intentionally left out of this PR; it's a separate, SDK-specific behavior change from the spec-following work here. - Whether
opentelemetry-configuration's schema needs a companion PR before the OTEP (and by extension this PR) can merge is still being discussed on the OTEP thread.