Package com.google.api.gax.tracing
Class OpenTelemetryTracingFactory
java.lang.Object
com.google.api.gax.tracing.OpenTelemetryTracingFactory
- All Implemented Interfaces:
ApiTracerFactory
A
ApiTracerFactory to build instances of OpenTelemetryTracingTracer.
This class wraps the Tracer and pass it to OpenTelemetryTracingTracer. It will
be used to record traces in OpenTelemetryTracingTracer.
This class is expected to be initialized once during client initialization.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.api.gax.tracing.ApiTracerFactory
ApiTracerFactory.OperationType -
Constructor Summary
ConstructorsConstructorDescriptionOpenTelemetryTracingFactory(io.opentelemetry.api.OpenTelemetry openTelemetry) Warning: Traces may contain sensitive data such as resource names, full URLs, and error messages. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether this factory requires anApiTracerContextto be injected viaApiTracerFactory.withContext(ApiTracerContext)before creating tracers.newTracer(ApiTracer parent, ApiTracerContext apiTracerContext) Create a newApiTracerthat will be a child of the current context.newTracer(ApiTracer parent, SpanName spanName, ApiTracerFactory.OperationType operationType) Create a newApiTracerthat will be a child of the current context.withContext(ApiTracerContext context) Returns a new OpenTelemetryTracingFactory with the provided context.
-
Constructor Details
-
OpenTelemetryTracingFactory
public OpenTelemetryTracingFactory(io.opentelemetry.api.OpenTelemetry openTelemetry) Warning: Traces may contain sensitive data such as resource names, full URLs, and error messages.Before configuring subscribers or exporters for traces, review the contents of the spans and consult the OpenTelemetry documentation to set up filters and formatters to prevent leaking sensitive information, depending on your intended use case.
See also the OpenTelemetry Semantic Conventions.
-
-
Method Details
-
newTracer
public ApiTracer newTracer(ApiTracer parent, SpanName spanName, ApiTracerFactory.OperationType operationType) Description copied from interface:ApiTracerFactoryCreate a newApiTracerthat will be a child of the current context.- Specified by:
newTracerin interfaceApiTracerFactory- Parameters:
parent- the parent of this tracerspanName- the name of the new spanoperationType- the type of operation that the tracer will trace
-
newTracer
Description copied from interface:ApiTracerFactoryCreate a newApiTracerthat will be a child of the current context.- Specified by:
newTracerin interfaceApiTracerFactory- Parameters:
parent- the parent of this tracerapiTracerContext- the method-definition-specific tracer context
-
needsContext
public boolean needsContext()Description copied from interface:ApiTracerFactoryIndicates whether this factory requires anApiTracerContextto be injected viaApiTracerFactory.withContext(ApiTracerContext)before creating tracers.- Specified by:
needsContextin interfaceApiTracerFactory- Returns:
trueif anApiTracerContextshould be injected,falseotherwise.
-
withContext
Returns a new OpenTelemetryTracingFactory with the provided context. The Tracer is re-initialized using the artifact name and version from the library metadata.- Specified by:
withContextin interfaceApiTracerFactory- Parameters:
context- anApiTracerContextobject containing information to construct attributes
-