Class OpenTelemetryMetricsCollector

java.lang.Object
com.soklet.otel.OpenTelemetryMetricsCollector
All Implemented Interfaces:
MetricsCollector

OpenTelemetry-backed MetricsCollector for Soklet HTTP, SSE, and MCP telemetry.

This implementation records counters/histograms via OpenTelemetry's metrics API and is designed to be lightweight, thread-safe, and non-blocking in request hot paths.

By default, standard HTTP metrics use OpenTelemetry Semantic Convention names. Soklet-specific concepts (for example SSE queue/drop/broadcast details) are emitted with soklet.* names. For request-body size, the default semantic-convention strategy records the encoded payload size as transferred, while the OpenTelemetryMetricsCollector.MetricNamingStrategy.SOKLET strategy records the handler-visible body size. If an oversized request is rejected before its complete encoded payload size is known, the semantic-convention body-size sample is omitted instead of recording an inaccurate zero. Response-body size is based on the finalized MarshaledResponse; if the HTTP transport applies dynamic gzip afterward, that metric remains the pre-compression size.

If inbound requests include W3C trace context, Soklet exposes it via Request.getTraceContext() to custom metrics collectors and application code. This metrics-only implementation intentionally does not emit trace IDs, parent IDs, or tracestate values as metric attributes because those values are high-cardinality and belong in logs, spans, or exemplar-aware tracing integrations instead.

See https://soklet.com/docs/metrics-collection for Soklet's metrics/telemetry documentation.

Author:
Mark Allen