Package com.jsgalactic.axiom.otel
Class OtelMetrics
java.lang.Object
com.jsgalactic.axiom.otel.OtelMetrics
- All Implemented Interfaces:
Metrics
Maps the dependency-free
Metrics SPI to OpenTelemetry API instruments. Counters become
dimensionless LongCounters, gauges become LongUpDownCounters and timers become
DoubleHistograms in seconds with the explicit bucket boundaries of DEFAULT_BUCKETS, which match the bounds of the in-memory registry in axiom-metrics.
Instruments come from the instrumentation scope "com.jsgalactic.axiom.otel". A lookup resolves
and caches one instrument per name and tag set; recording methods are thread-safe and use the
attributes captured at lookup. A name always has one kind and one set of tag keys: using it
otherwise throws IllegalArgumentException, as the registry does. Tag values remain the
caller's responsibility: keep them to route templates, methods and other fixed sets, because
neither this adapter nor the OTel API bounds cardinality.
The adapter owns no SDK, reader or exporter. It is safe to share one instance across requests,
and several adapters can write to the same MeterProvider.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.jsgalactic.axiom.observability.Metrics
Metrics.Counter, Metrics.Gauge, Metrics.Timer -
Field Summary
FieldsModifier and TypeFieldDescriptionHistogram bounds in seconds: 1 ms, 5 ms, 10 ms, 25 ms, 50 ms, 100 ms, 250 ms, 500 ms, 1 s, 2.5 s, 5 s and 10 s. -
Method Summary
Modifier and TypeMethodDescriptionReturns the monotonically increasing counter for a series, creating it if needed.static OtelMetricscreate(io.opentelemetry.api.metrics.MeterProvider meterProvider) Creates an adapter using the meter ofTracing.SCOPE_NAMEfrom the supplied provider.static OtelMetricscreate(io.opentelemetry.api.OpenTelemetry openTelemetry) Creates an adapter using the meter ofTracing.SCOPE_NAMEfrom the supplied instance.Returns the gauge for a series, creating it if needed.Returns the timer for a series, creating it if needed.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.jsgalactic.axiom.observability.Metrics
prometheusText
-
Field Details
-
DEFAULT_BUCKETS
Histogram bounds in seconds: 1 ms, 5 ms, 10 ms, 25 ms, 50 ms, 100 ms, 250 ms, 500 ms, 1 s, 2.5 s, 5 s and 10 s. The last bucket is open-ended.
-
-
Method Details
-
create
Creates an adapter using the meter ofTracing.SCOPE_NAMEfrom the supplied instance. The caller owns the SDK and any metric readers or exporters.- Parameters:
openTelemetry- meter source, orOpenTelemetry.noop()to discard measurements- Returns:
- an empty adapter
-
create
Creates an adapter using the meter ofTracing.SCOPE_NAMEfrom the supplied provider.- Parameters:
meterProvider- provider that creates the instruments- Returns:
- an empty adapter
-
counter
Description copied from interface:MetricsReturns the monotonically increasing counter for a series, creating it if needed. -
gauge
Description copied from interface:MetricsReturns the gauge for a series, creating it if needed. A gauge is a value that moves both ways, such as a queue depth. It is changed by deltas, so several components can share one series and the value stays the sum of their contributions. -
timer
Description copied from interface:MetricsReturns the timer for a series, creating it if needed. A timer records durations and keeps their distribution, so latency percentiles can be derived from it.
-