com.mysql.cj.telemetry

## Interface TelemetrySpan

All Superinterfaces:
  AutoCloseable

All Known Implementing Classes:
  NoopTelemetrySpan

    public interface TelemetrySpan
    extends AutoCloseable

A telemetry span wrapper that hides all specific details from the underlying telemetry library. A default no-op implementation is provided so that telemetry may be turned off with minimal impact on the driver code.

### Method Summary

All Methods Instance Methods Abstract Methods Default Methods
`default void` `close()` `AutoCloseable.close()` that can be used to end this span and, making it possible to create new span within the try-with-resources blocks.
`default void` `end()` Marks the end of the execution of this span.
`TelemetryScope` `makeCurrent()` Takes this telemetry span and makes it current in the global telemetry context.
`default void` `setAttribute(TelemetryAttribute key, long value)` Adds the specified long attribute to this telemetry span.
`default void` `setAttribute(TelemetryAttribute key, String value)` Adds the specified String attribute to this telemetry span.
`default void` `setError(Throwable cause)` Sets the status code of this telemetry span as ERROR and records the stack trace of the specified exception.

### Method Detail

#### makeCurrent

    TelemetryScope makeCurrent()

Takes this telemetry span and makes it current in the global telemetry context.

Returns:
  an `AutoCloseable` telemetry scope that represents the current telemetry context.

#### setAttribute

    default void setAttribute(TelemetryAttribute key,
                              String value)

Adds the specified String attribute to this telemetry span.

Parameters:
  `key` - the key for this attribute
  `value` - the value for this attribute

#### setAttribute

    default void setAttribute(TelemetryAttribute key,
                              long value)

Adds the specified long attribute to this telemetry span.

Parameters:
  `key` - the key for this attribute
  `value` - the value for this attribute

#### setError

    default void setError(Throwable cause)

Sets the status code of this telemetry span as ERROR and records the stack trace of the specified exception.

Parameters:
  `cause` - the cause for setting this span status code to ERROR

#### end

    default void end()

Marks the end of the execution of this span.

#### close

    default void close()

`AutoCloseable.close()` that can be used to end this span and, making it possible to create new span within the try-with-resources blocks.

Specified by:
  `close` in interface `AutoCloseable`

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