Skip to content

Observability

Atmosphere provides built-in support for Micrometer metrics, OpenTelemetry tracing, backpressure management, and cache configuration.

MeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
AtmosphereMetrics metrics = AtmosphereMetrics.install(framework, registry);
metrics.instrumentRoomManager(roomManager);
MetricTypeDescription
atmosphere.connections.activeGaugeActive connections
atmosphere.broadcasters.activeGaugeActive broadcasters
atmosphere.connections.totalCounterTotal connections opened
atmosphere.messages.broadcastCounterMessages broadcast
atmosphere.broadcast.timerTimerBroadcast latency
atmosphere.rooms.activeGaugeActive rooms
atmosphere.rooms.membersGaugeMembers per room (tagged)

With the Spring Boot starter, metrics are auto-configured when micrometer-core and MeterRegistry are on the classpath.

framework.interceptor(new AtmosphereTracing(GlobalOpenTelemetry.get()));

Creates spans for every request with the following attributes:

AttributeDescription
atmosphere.resource.uuidResource UUID
atmosphere.transportTransport type (WEBSOCKET, SSE, LONG_POLLING)
atmosphere.actionAction result (CONTINUE, SUSPEND, RESUME)
atmosphere.broadcasterBroadcaster ID
atmosphere.roomRoom name (if applicable)

With the Spring Boot starter, tracing is auto-configured when an OpenTelemetry bean is present. Disable with atmosphere.tracing.enabled=false.

When atmosphere-ai is in use, Atmosphere emits the OpenTelemetry GenAI semantic conventions — a spec OpenTelemetry still marks experimentaladditively — the existing ai.tokens.* metadata and the atmosphere.ai.* Micrometer series are emitted unchanged alongside the gen_ai.* signals, so token and latency data lands in Langfuse / LangSmith / Grafana GenAI dashboards with no per-metric remapping.

OpenTelemetry spec status. The OpenTelemetry GenAI semantic convention is not stable; attribute and metric names may change in a future OTel release. (Atmosphere’s emitter is production code — only the upstream convention it follows is experimental.) Treat the gen_ai.* signals below as additive and subject to change, and keep building dashboards on the stable atmosphere.ai.* series where you need long-term stability.

Span attributes. When io.opentelemetry.api is on the classpath and a live span is active (an AtmosphereTracing SERVER span, for example), GenAiTracer tags that current span with the OpenTelemetry GenAI span attributes. Emission is via a reflection-based helper with no hard OpenTelemetry dependency — absent OTel, or absent a current span, it is a no-op and no orphan span is ever created.

Span attributeTypeSource
gen_ai.usage.input_tokenslongTokenUsage.input()
gen_ai.usage.output_tokenslongTokenUsage.output()
gen_ai.usage.total_tokenslongTokenUsage.total()
gen_ai.request.modelstringthe request model
gen_ai.response.modelstringTokenUsage.model()omitted when the runtime did not report a model (Runtime Truth: no placeholder)
gen_ai.operation.namestringchat
gen_ai.provider.namestringthe resolved AgentRuntime.name() (the real runtime name — e.g. built-in, anthropic — never a hardcoded value)

Attributes are written only when TokenUsage.hasCounts() is true and a valid current span exists.

Metrics. Alongside the atmosphere.ai.* series, MicrometerAiMetrics also emits the GenAI convention instruments. This applies to any runtime that reports usage through StreamingSession.usage(TokenUsage) — the capture point is the pipeline-level MetricsCapturingSession, not a single adapter.

MetricTypeDescription
gen_ai.client.token.usageDistributionToken counts, split by gen_ai.token.type (input / output)
gen_ai.client.operation.durationTimerFull operation wall-clock time

These instruments carry the gen_ai.operation.name, gen_ai.provider.name, and gen_ai.request.model attributes; gen_ai.provider.name is the resolved runtime name (AgentRuntime.name()), and gen_ai.response.model is added when the runtime reported one.

When atmosphere-mcp is on the classpath, McpTracing adds spans for tool, resource, and prompt invocations:

AttributeDescription
mcp.tool.nameTool/resource/prompt name
mcp.tool.type"tool", "resource", or "prompt"
mcp.tool.arg_countNumber of arguments
mcp.tool.errortrue if invocation failed
framework.interceptor(new BackpressureInterceptor());
ParameterDefaultDescription
org.atmosphere.backpressure.highWaterMark1000Max pending messages per client
org.atmosphere.backpressure.policydrop-oldestdrop-oldest, drop-newest, or disconnect
ParameterDefaultDescription
org.atmosphere.cache.UUIDBroadcasterCache.maxPerClient1000Max cached messages per client
org.atmosphere.cache.UUIDBroadcasterCache.messageTTL300Per-message TTL in seconds
org.atmosphere.cache.UUIDBroadcasterCache.maxTotal100000Global cache size limit