Package io.grpc.opentelemetry
Class OpenTelemetryMetricsModule
- java.lang.Object
-
- io.grpc.opentelemetry.OpenTelemetryMetricsModule
-
final class OpenTelemetryMetricsModule extends java.lang.ObjectProvides factories forStreamTracerthat records metrics to OpenTelemetry.On the client-side, a factory is created for each call, and the factory creates a stream tracer for each attempt. If there is no stream created when the call is ended, we still create a tracer. It's the tracer that reports per-attempt stats, and the factory that reports the stats of the overall RPC, such as RETRIES_PER_CALL, to OpenTelemetry.
On the server-side, there is only one ServerStream per each ServerCall, and ServerStream starts earlier than the ServerCall. Therefore, only one tracer is created per stream/call, and it's the tracer that reports the summary to OpenTelemetry.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classOpenTelemetryMetricsModule.CallAttemptsTracerFactoryprivate static classOpenTelemetryMetricsModule.ClientTracer(package private) classOpenTelemetryMetricsModule.MetricsClientInterceptorprivate static classOpenTelemetryMetricsModule.ServerTracer(package private) classOpenTelemetryMetricsModule.ServerTracerFactory
-
Field Summary
Fields Modifier and Type Field Description static com.google.common.collect.ImmutableSet<java.lang.String>DEFAULT_PER_CALL_METRICS_SETprivate static java.lang.StringLOCALITY_LABEL_NAMEprivate booleanlocalityEnabledprivate static java.util.logging.Loggerloggerprivate com.google.common.collect.ImmutableList<OpenTelemetryPlugin>pluginsprivate OpenTelemetryMetricsResourceresourceprivate static doubleSECONDS_PER_NANOprivate com.google.common.base.Supplier<com.google.common.base.Stopwatch>stopwatchSupplier
-
Constructor Summary
Constructors Constructor Description OpenTelemetryMetricsModule(com.google.common.base.Supplier<com.google.common.base.Stopwatch> stopwatchSupplier, OpenTelemetryMetricsResource resource, java.util.Collection<java.lang.String> optionalLabels, java.util.List<OpenTelemetryPlugin> plugins)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) io.grpc.ClientInterceptorgetClientInterceptor(java.lang.String target)Returns the client interceptor that facilitates OpenTelemetry metrics reporting.(package private) io.grpc.ServerStreamTracer.FactorygetServerTracerFactory()Returns the server tracer factory.(package private) static java.lang.StringrecordMethodName(java.lang.String fullMethodName, boolean isGeneratedMethod)
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
LOCALITY_LABEL_NAME
private static final java.lang.String LOCALITY_LABEL_NAME
- See Also:
- Constant Field Values
-
DEFAULT_PER_CALL_METRICS_SET
public static final com.google.common.collect.ImmutableSet<java.lang.String> DEFAULT_PER_CALL_METRICS_SET
-
SECONDS_PER_NANO
private static final double SECONDS_PER_NANO
- See Also:
- Constant Field Values
-
resource
private final OpenTelemetryMetricsResource resource
-
stopwatchSupplier
private final com.google.common.base.Supplier<com.google.common.base.Stopwatch> stopwatchSupplier
-
localityEnabled
private final boolean localityEnabled
-
plugins
private final com.google.common.collect.ImmutableList<OpenTelemetryPlugin> plugins
-
-
Constructor Detail
-
OpenTelemetryMetricsModule
OpenTelemetryMetricsModule(com.google.common.base.Supplier<com.google.common.base.Stopwatch> stopwatchSupplier, OpenTelemetryMetricsResource resource, java.util.Collection<java.lang.String> optionalLabels, java.util.List<OpenTelemetryPlugin> plugins)
-
-
Method Detail
-
getServerTracerFactory
io.grpc.ServerStreamTracer.Factory getServerTracerFactory()
Returns the server tracer factory.
-
getClientInterceptor
io.grpc.ClientInterceptor getClientInterceptor(java.lang.String target)
Returns the client interceptor that facilitates OpenTelemetry metrics reporting.
-
recordMethodName
static java.lang.String recordMethodName(java.lang.String fullMethodName, boolean isGeneratedMethod)
-
-