public interface Tracer
Tracer abstraction.
Tracer is the central point that collects tracing spans, and (probably) pushes them to backend.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanenabled()Whether this tracer is enabled or not.extract(HeaderProvider headersProvider) Extract parent span context from inbound request, such as from HTTP headers.static Tracerglobal()Deprecated, for removal: This API element is subject to removal in a future version.static voidDeprecated, for removal: This API element is subject to removal in a future version.we are switching to Service registry for global instances, kindly useServices.set(Class, Object[])before using tracing instead of calling this methodvoidinject(SpanContext spanContext, HeaderProvider inboundHeadersProvider, HeaderConsumer outboundHeadersConsumer) Inject current span as a parent for outbound request, such as when invoking HTTP request from a client.static TracernoOp()Create a no-op tracer.register(SpanListener listener) Registers with the tracer a lifecycle event listener to receive events from span builders, spans, and scopes derived from this tracer.Span.Builder<?> spanBuilder(String name) A new span builder to constructSpan.default <T> TAccess the underlying tracer by specific type.
-
Method Details
-
noOp
Create a no-op tracer. All spans created from this tracer are not doing anything.- Returns:
- no-op tracer
-
global
Deprecated, for removal: This API element is subject to removal in a future version.we are switching to service registry for global instances, kindly useServices.get(Class)insteadGet the currently registered global tracer.- Returns:
- global tracer
-
global
Deprecated, for removal: This API element is subject to removal in a future version.we are switching to Service registry for global instances, kindly useServices.set(Class, Object[])before using tracing instead of calling this methodRegister a global tracer, behavior depends on implementation.- Parameters:
tracer- tracer to use as a global tracer
-
enabled
boolean enabled()Whether this tracer is enabled or not. A no op tracer is disabled.- Returns:
trueif this tracer is enabled
-
spanBuilder
A new span builder to constructSpan.- Parameters:
name- name of the operation- Returns:
- a new span builder
-
extract
Extract parent span context from inbound request, such as from HTTP headers.- Parameters:
headersProvider- provider of headers- Returns:
- span context of inbound parent span, or empty optional if no span context can be found
-
inject
void inject(SpanContext spanContext, HeaderProvider inboundHeadersProvider, HeaderConsumer outboundHeadersConsumer) Inject current span as a parent for outbound request, such as when invoking HTTP request from a client.- Parameters:
spanContext- current span contextinboundHeadersProvider- provider of inbound headers, may beHeaderProvider.empty()or headers from original request (if any)outboundHeadersConsumer- consumer of headers that should be propagated to remote endpoint
-
unwrap
Access the underlying tracer by specific type. This is a dangerous operation that will succeed only if the tracer is of expected type. This practically removes abstraction capabilities of this API.- Type Parameters:
T- type of the tracer- Parameters:
tracerClass- type to access- Returns:
- instance of the tracer
- Throws:
IllegalArgumentException- in case the tracer cannot provide the expected type
-
register
Registers with the tracer a lifecycle event listener to receive events from span builders, spans, and scopes derived from this tracer.- Parameters:
listener- theSpanListenerto register- Returns:
- the updated
Tracer
-
Services.get(Class)instead