Class OpenTelemetryConnection
- java.lang.Object
-
- com.avioconsulting.mule.opentelemetry.internal.connection.OpenTelemetryConnection
-
- All Implemented Interfaces:
TraceContextHandler
public class OpenTelemetryConnection extends Object implements TraceContextHandler
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOpenTelemetryConnection.HashMapTextMapSetter
-
Field Summary
Fields Modifier and Type Field Description Map<String,String>OTEL_SYSTEM_PROPERTIES_MAPCollect all otel specific system properties and cache them in a map.static StringSPAN_ID_LONGstatic StringTRACE_ID_LONG_LOW_PART
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddProcessorSpan(TraceComponent traceComponent, String rootContainerName)Creates aSpanfor givenTraceComponentand adds it to theTraceComponent.getTransactionId()transaction.SpanMetaendProcessorSpan(TraceComponent traceComponent, org.mule.runtime.api.message.Error error)TransactionMetaendTransaction(TraceComponent traceComponent, Exception exception)io.opentelemetry.api.metrics.Meterget(String instrumentationScopeName)AppIdentifiergetAppIdentifier()static OpenTelemetryConnectiongetInstance()static OpenTelemetryConnectiongetInstance(OpenTelemetryConfigWrapper openTelemetryConfigWrapper)OpenTelemetryMetricsProviderCollectiongetMetricsProviders()Map<String,String>getTraceContext(String transactionId)Get the trace context information for a given transaction id.Map<String,String>getTraceContext(String transactionId, org.mule.runtime.api.component.location.ComponentLocation componentLocation)Get the trace context information for a given transaction id.<T> io.opentelemetry.context.ContextgetTraceContext(T carrier, io.opentelemetry.context.propagation.TextMapGetter<T> textMapGetter)TransactionStoregetTransactionStore()<T> voidinjectTraceContext(T carrier, io.opentelemetry.context.propagation.TextMapSetter<T> textMapSetter)voidinvalidate()booleanisTurnOffTracing()static voidresetForTest()This is for tests to reset the static instance in-between the tests.voidsetSpanStatus(TraceComponent traceComponent, io.opentelemetry.api.trace.Span span)io.opentelemetry.api.trace.SpanBuilderspanBuilder(String spanName)voidstartTransaction(TraceComponent traceComponent)static Supplier<OpenTelemetryConnection>supplier()Supplierto use withConnectionProviderwhere lazy initialization is required.
-
-
-
Field Detail
-
TRACE_ID_LONG_LOW_PART
public static final String TRACE_ID_LONG_LOW_PART
- See Also:
- Constant Field Values
-
SPAN_ID_LONG
public static final String SPAN_ID_LONG
- See Also:
- Constant Field Values
-
-
Method Detail
-
getAppIdentifier
public AppIdentifier getAppIdentifier()
-
isTurnOffTracing
public boolean isTurnOffTracing()
-
getMetricsProviders
public OpenTelemetryMetricsProviderCollection getMetricsProviders()
-
supplier
public static Supplier<OpenTelemetryConnection> supplier()
Supplierto use withConnectionProviderwhere lazy initialization is required.- Returns:
- a non-null
Supplier<OpenTelemetryConnection>
-
resetForTest
public static void resetForTest()
This is for tests to reset the static instance in-between the tests. Reset Global OpenTelemetry instances.
-
getInstance
public static OpenTelemetryConnection getInstance(OpenTelemetryConfigWrapper openTelemetryConfigWrapper)
-
getInstance
public static OpenTelemetryConnection getInstance()
-
spanBuilder
public io.opentelemetry.api.trace.SpanBuilder spanBuilder(String spanName)
-
getTraceContext
public <T> io.opentelemetry.context.Context getTraceContext(T carrier, io.opentelemetry.context.propagation.TextMapGetter<T> textMapGetter)- Specified by:
getTraceContextin interfaceTraceContextHandler
-
getTraceContext
public Map<String,String> getTraceContext(String transactionId)
Get the trace context information for a given transaction id. This returns aMapwith at least one entry with keyTransactionStore.TRACE_TRANSACTION_IDand transactionId as value. The other entries in the map depends on the propagator used. For W3C Trace Context Propagator, it can contain entries for `traceparent` and optionally `tracestate`.- Parameters:
transactionId- Local transaction id- Returns:
- Map
-
getTraceContext
public Map<String,String> getTraceContext(String transactionId, org.mule.runtime.api.component.location.ComponentLocation componentLocation)
Get the trace context information for a given transaction id. This returns aMapwith at least one entry with keyTransactionStore.TRACE_TRANSACTION_IDand transactionId as value. The other entries in the map depends on the propagator used.For W3C Trace Context Propagator, it can contain entries for `traceparent` and optionally `tracestate`.
- Parameters:
transactionId- Local transaction idcomponentLocation-ComponentLocationto get context for- Returns:
- Map
-
injectTraceContext
public <T> void injectTraceContext(T carrier, io.opentelemetry.context.propagation.TextMapSetter<T> textMapSetter)- Specified by:
injectTraceContextin interfaceTraceContextHandler
-
getTransactionStore
public TransactionStore getTransactionStore()
-
invalidate
public void invalidate()
-
get
public io.opentelemetry.api.metrics.Meter get(String instrumentationScopeName)
-
addProcessorSpan
public void addProcessorSpan(TraceComponent traceComponent, String rootContainerName)
Creates aSpanfor givenTraceComponentand adds it to theTraceComponent.getTransactionId()transaction.- Parameters:
traceComponent-TraceComponentrootContainerName-Stringname of the container such as flow that holds this component
-
endProcessorSpan
public SpanMeta endProcessorSpan(TraceComponent traceComponent, org.mule.runtime.api.message.Error error)
-
startTransaction
public void startTransaction(TraceComponent traceComponent)
-
endTransaction
public TransactionMeta endTransaction(TraceComponent traceComponent, Exception exception)
-
setSpanStatus
public void setSpanStatus(TraceComponent traceComponent, io.opentelemetry.api.trace.Span span)
-
-