Package co.elastic.apm.agent.impl
Class GlobalTracer
- java.lang.Object
-
- co.elastic.apm.agent.impl.GlobalTracer
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface co.elastic.apm.agent.impl.Tracer
Tracer.TracerState
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringcaptureAndReportException(long epochMicros, java.lang.Throwable e, AbstractSpan<?> parent)voidcaptureAndReportException(java.lang.Throwable e, java.lang.ClassLoader initiatingClassLoader)Captures an exception without providing an explicit reference to a parentAbstractSpanErrorCapturecaptureException(java.lang.Throwable e, AbstractSpan<?> parent, java.lang.ClassLoader initiatingClassLoader)SpancreateExitChildSpan()TransactioncurrentTransaction()static Tracerget()AbstractSpan<?>getActive()SpangetActiveExitSpan()SpangetActiveSpan()Tracer.TracerStategetState()static ElasticApmTracergetTracerImpl()static voidinit(Tracer tracer)static booleanisNoop()booleanisRunning()voidoverrideServiceNameForClassLoader(java.lang.ClassLoader classLoader, java.lang.String serviceName)Overrides the service name for allTransactions,Spans andErrorCaptures which are created by the service which corresponds to the providedClassLoader.static ElasticApmTracerrequireTracerImpl()static voidsetNoop()<C> TransactionstartChildTransaction(C headerCarrier, BinaryHeaderGetter<C> binaryHeadersGetter, Sampler sampler, long epochMicros, java.lang.ClassLoader initiatingClassLoader)Starts a transaction as a child of the context headers obtained through the providedHeaderGetter.<C> TransactionstartChildTransaction(C headerCarrier, BinaryHeaderGetter<C> binaryHeadersGetter, java.lang.ClassLoader initiatingClassLoader)Starts a transaction as a child of the context headers obtained through the providedHeaderGetter.<C> TransactionstartChildTransaction(C headerCarrier, TextHeaderGetter<C> textHeadersGetter, Sampler sampler, long epochMicros, java.lang.ClassLoader initiatingClassLoader)Starts a transaction as a child of the context headers obtained through the providedHeaderGetter.<C> TransactionstartChildTransaction(C headerCarrier, TextHeaderGetter<C> textHeadersGetter, java.lang.ClassLoader initiatingClassLoader)Starts a transaction as a child of the context headers obtained through the providedHeaderGetter.<C> TransactionstartChildTransaction(C headerCarrier, TextHeaderGetter<C> textHeadersGetter, java.lang.ClassLoader initiatingClassLoader, long epochMicros)TransactionstartRootTransaction(Sampler sampler, long epochMicros, java.lang.ClassLoader initiatingClassLoader)Starts a trace-root transaction with a specified sampler and start timestampTransactionstartRootTransaction(java.lang.ClassLoader initiatingClassLoader)Starts a trace-root transactionTransactionstartRootTransaction(java.lang.ClassLoader initiatingClassLoader, long epochMicro)voidstop()Called when the container shuts down.
-
-
-
Method Detail
-
get
public static Tracer get()
-
getTracerImpl
@Nullable public static ElasticApmTracer getTracerImpl()
-
requireTracerImpl
public static ElasticApmTracer requireTracerImpl()
-
setNoop
public static void setNoop()
-
init
public static void init(Tracer tracer)
-
isNoop
public static boolean isNoop()
-
startRootTransaction
@Nullable public Transaction startRootTransaction(@Nullable java.lang.ClassLoader initiatingClassLoader)
Description copied from interface:TracerStarts a trace-root transaction- Specified by:
startRootTransactionin interfaceTracer- Parameters:
initiatingClassLoader- the class loader corresponding to the service which initiated the creation of the transaction. Used to determine the service name.- Returns:
- a transaction that will be the root of the current trace if the agent is currently RUNNING; null otherwise
-
startRootTransaction
@Nullable public Transaction startRootTransaction(@Nullable java.lang.ClassLoader initiatingClassLoader, long epochMicro)
- Specified by:
startRootTransactionin interfaceTracer
-
startRootTransaction
@Nullable public Transaction startRootTransaction(Sampler sampler, long epochMicros, @Nullable java.lang.ClassLoader initiatingClassLoader)
Description copied from interface:TracerStarts a trace-root transaction with a specified sampler and start timestamp- Specified by:
startRootTransactionin interfaceTracer- Parameters:
sampler- theSamplerinstance which is responsible for determining the sampling decision if this is a root transactionepochMicros- the start timestampinitiatingClassLoader- the class loader corresponding to the service which initiated the creation of the transaction. Used to determine the service name and to load application-scoped classes like theMDC, for log correlation.- Returns:
- a transaction that will be the root of the current trace if the agent is currently RUNNING; null otherwise
-
startChildTransaction
@Nullable public <C> Transaction startChildTransaction(@Nullable C headerCarrier, TextHeaderGetter<C> textHeadersGetter, @Nullable java.lang.ClassLoader initiatingClassLoader)
Description copied from interface:TracerStarts a transaction as a child of the context headers obtained through the providedHeaderGetter. If the created transaction cannot be started as a child transaction (for example - if no parent context header is available), then it will be started as the root transaction of the trace.- Specified by:
startChildTransactionin interfaceTracer- Parameters:
headerCarrier- the Object from which context headers can be obtained, typically a request or a messagetextHeadersGetter- provides the trace context headers required in order to create a child transactioninitiatingClassLoader- the class loader corresponding to the service which initiated the creation of the transaction. Used to determine the service name.- Returns:
- a transaction which is a child of the provided parent if the agent is currently RUNNING; null otherwise
-
startChildTransaction
@Nullable public <C> Transaction startChildTransaction(@Nullable C headerCarrier, TextHeaderGetter<C> textHeadersGetter, @Nullable java.lang.ClassLoader initiatingClassLoader, long epochMicros)
- Specified by:
startChildTransactionin interfaceTracer
-
startChildTransaction
@Nullable public <C> Transaction startChildTransaction(@Nullable C headerCarrier, TextHeaderGetter<C> textHeadersGetter, Sampler sampler, long epochMicros, @Nullable java.lang.ClassLoader initiatingClassLoader)
Description copied from interface:TracerStarts a transaction as a child of the context headers obtained through the providedHeaderGetter. If the created transaction cannot be started as a child transaction (for example - if no parent context header is available), then it will be started as the root transaction of the trace.- Specified by:
startChildTransactionin interfaceTracer- Parameters:
headerCarrier- the Object from which context headers can be obtained, typically a request or a messagetextHeadersGetter- provides the trace context headers required in order to create a child transactionsampler- theSamplerinstance which is responsible for determining the sampling decision if this is a root transactionepochMicros- the start timestampinitiatingClassLoader- the class loader corresponding to the service which initiated the creation of the transaction. Used to determine the service name and to load application-scoped classes like theMDC, for log correlation.- Returns:
- a transaction which is a child of the provided parent if the agent is currently RUNNING; null otherwise
-
startChildTransaction
@Nullable public <C> Transaction startChildTransaction(@Nullable C headerCarrier, BinaryHeaderGetter<C> binaryHeadersGetter, @Nullable java.lang.ClassLoader initiatingClassLoader)
Description copied from interface:TracerStarts a transaction as a child of the context headers obtained through the providedHeaderGetter. If the created transaction cannot be started as a child transaction (for example - if no parent context header is available), then it will be started as the root transaction of the trace.- Specified by:
startChildTransactionin interfaceTracer- Parameters:
headerCarrier- the Object from which context headers can be obtained, typically a request or a messagebinaryHeadersGetter- provides the trace context headers required in order to create a child transactioninitiatingClassLoader- the class loader corresponding to the service which initiated the creation of the transaction. Used to determine the service name.- Returns:
- a transaction which is a child of the provided parent if the agent is currently RUNNING; null otherwise
-
startChildTransaction
@Nullable public <C> Transaction startChildTransaction(@Nullable C headerCarrier, BinaryHeaderGetter<C> binaryHeadersGetter, Sampler sampler, long epochMicros, @Nullable java.lang.ClassLoader initiatingClassLoader)
Description copied from interface:TracerStarts a transaction as a child of the context headers obtained through the providedHeaderGetter. If the created transaction cannot be started as a child transaction (for example - if no parent context header is available), then it will be started as the root transaction of the trace.- Specified by:
startChildTransactionin interfaceTracer- Parameters:
headerCarrier- the Object from which context headers can be obtained, typically a request or a messagebinaryHeadersGetter- provides the trace context headers required in order to create a child transactionsampler- theSamplerinstance which is responsible for determining the sampling decision if this is a root transactionepochMicros- the start timestampinitiatingClassLoader- the class loader corresponding to the service which initiated the creation of the transaction. Used to determine the service name and to load application-scoped classes like theMDC, for log correlation.- Returns:
- a transaction which is a child of the provided parent if the agent is currently RUNNING; null otherwise
-
currentTransaction
@Nullable public Transaction currentTransaction()
- Specified by:
currentTransactionin interfaceTracer
-
getActive
@Nullable public AbstractSpan<?> getActive()
-
getActiveSpan
@Nullable public Span getActiveSpan()
- Specified by:
getActiveSpanin interfaceTracer
-
captureAndReportException
public void captureAndReportException(@Nullable java.lang.Throwable e, java.lang.ClassLoader initiatingClassLoader)Description copied from interface:TracerCaptures an exception without providing an explicit reference to a parentAbstractSpan- Specified by:
captureAndReportExceptionin interfaceTracer- Parameters:
e- the exception to captureinitiatingClassLoader- the class
-
captureAndReportException
@Nullable public java.lang.String captureAndReportException(long epochMicros, @Nullable java.lang.Throwable e, @Nullable AbstractSpan<?> parent)- Specified by:
captureAndReportExceptionin interfaceTracer
-
captureException
@Nullable public ErrorCapture captureException(@Nullable java.lang.Throwable e, @Nullable AbstractSpan<?> parent, @Nullable java.lang.ClassLoader initiatingClassLoader)
- Specified by:
captureExceptionin interfaceTracer
-
getActiveExitSpan
@Nullable public Span getActiveExitSpan()
- Specified by:
getActiveExitSpanin interfaceTracer
-
getState
public Tracer.TracerState getState()
-
overrideServiceNameForClassLoader
public void overrideServiceNameForClassLoader(@Nullable java.lang.ClassLoader classLoader, @Nullable java.lang.String serviceName)Description copied from interface:TracerOverrides the service name for allTransactions,Spans andErrorCaptures which are created by the service which corresponds to the providedClassLoader.The main use case is being able to differentiate between multiple services deployed to the same application server.
- Specified by:
overrideServiceNameForClassLoaderin interfaceTracer- Parameters:
classLoader- the class loader which corresponds to a particular serviceserviceName- the service name for this class loader
-
stop
public void stop()
Description copied from interface:TracerCalled when the container shuts down. Cleans up thread pools and other resources.
-
createExitChildSpan
@Nullable public Span createExitChildSpan()
- Specified by:
createExitChildSpanin interfaceTracer
-
-