com.mysql.cj.telemetry

## Interface TelemetryHandler

All Known Implementing Classes:
  NoopTelemetryHandler

    public interface TelemetryHandler

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

All Methods Instance Methods Abstract Methods Default Methods
`default void` `addLinkTarget(TelemetrySpan span)` Registers the specified `TelemetrySpan` as a link target for subsequent new spans.
`default String` `getContextPropagationKey()` The telemetry context propagation default key name.
`default void` `propagateContext(BiConsumer<String,String> traceparentConsumer)` Injects telemetry context propagation information into the specified consumer.
`default void` `removeLinkTarget(TelemetrySpan span)` Removes the specified span from the list of registered link targets.
`TelemetrySpan` `startSpan(TelemetrySpanName spanName, Object... args)` Start a telemetry span.

### Method Detail

#### startSpan

    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` - the span name that identifies this telemetry span
  `args` - arguments used for interpolating the specified span name via `String.format(String, Object...)`
Returns:
  the newly-created span object

#### addLinkTarget

    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` - the `TelemetrySpan` to be registered as a link target for subsequent new spans

#### removeLinkTarget

    default void removeLinkTarget(TelemetrySpan span)

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

Parameters:
  `span` - the `TelemetrySpan` to be removed from the list of registered link targets

#### propagateContext

    default void propagateContext(BiConsumer<String,String> traceparentConsumer)

Injects telemetry context propagation information into the specified consumer.

Parameters:
  `traceparentConsumer` - the consumer that will process the telemetry context propagation information

#### getContextPropagationKey

    default String getContextPropagationKey()

The telemetry context propagation default key name.

Returns:
  the default name of the key used in telemetry context propagation

Copyright © 2016, 2024, Oracle and/or its affiliates.