Top Description Methods
com.mysql.cj.telemetry

public Interface TelemetryHandler

Known Direct Implementers
com.mysql.cj.otel.OpenTelemetryHandler, com.mysql.cj.telemetry.NoopTelemetryHandler
Imports
java.util.function.BiConsumer

A handler for telemetry operations. Implementations must forward each operation to an underlying telemetry API or SDK. A default no-op implementation is provided so that telemetry may be turned off with minimal impact to the driver code.

Method Summary

Modifier and TypeMethod and Description
public default void
addLinkTarget(TelemetrySpan
the TelemetrySpan to be registered as a link target for subsequent new spans
span
)

Registers the specified TelemetrySpan as a link target for subsequent new spans.

public default String

Returns:

the default name of the key used in telemetry context propagation
getContextPropagationKey
()

The telemetry context propagation default key name.

public default void
propagateContext(BiConsumer<String, String>
the consumer that will process the telemetry context propagation information
traceparentConsumer
)

Injects telemetry context propagation information into the specified consumer.

public default void
removeLinkTarget(TelemetrySpan
the TelemetrySpan to be removed from the list of registered link targets
span
)

Removes the specified span from the list of registered link targets.

public TelemetrySpan

Returns:

the newly-created span object
startSpan
(TelemetrySpanName
the span name that identifies this telemetry span
spanName
,
Object...
arguments used for interpolating the specified span name via String#format(String, Object...)
args
)

Start a telemetry span.

Method Detail

addLinkTargetback to summary
public default void addLinkTarget(TelemetrySpan span)

Registers the specified TelemetrySpan as a link target for subsequent new spans. Spans created after will include links to all registered link target spans in the order they were added.

Parameters
span:TelemetrySpan

the TelemetrySpan to be registered as a link target for subsequent new spans

getContextPropagationKeyback to summary
public default String getContextPropagationKey()

The telemetry context propagation default key name.

Returns:String

the default name of the key used in telemetry context propagation

propagateContextback to summary
public default void propagateContext(BiConsumer<String, String> traceparentConsumer)

Injects telemetry context propagation information into the specified consumer.

Parameters
traceparentConsumer:BiConsumer<String, String>

the consumer that will process the telemetry context propagation information

removeLinkTargetback to summary
public default void removeLinkTarget(TelemetrySpan span)

Removes the specified span from the list of registered link targets.

Parameters
span:TelemetrySpan

the TelemetrySpan to be removed from the list of registered link targets

startSpanback to summary
public TelemetrySpan startSpan(TelemetrySpanName spanName, Object... args)

Start a telemetry span. Additionally, the returned TelemetrySpan object must be made current so that it gets recorded by the telemetry tracer. A TelemetrySpan object must be closed in a finally block after being made current, e.g.:

TelemetrySpan span = telemetryHandler.startSpan(TelemetrySpanName.PING);
try (TelemetryScope scope = span.makeCurrent()) {
    // your code goes here
} finally {
    span.end();
}
Parameters
spanName:TelemetrySpanName

the span name that identifies this telemetry span

args:Object[]

arguments used for interpolating the specified span name via String#format(String, Object...)

Returns:TelemetrySpan

the newly-created span object