Class TelemetryUtils (2.37.0)

public final class TelemetryUtils

Utility class for common telemetry operations in Datastore.

WARNING: This class is intended for internal use only.

Inheritance

java.lang.Object > TelemetryUtils

Static Methods

<T>attemptMetricsCallable(Callable<T> callable, MetricsRecorder metricsRecorder, DatastoreOptions datastoreOptions, boolean isHttpTransport, String methodName)

public static Callable<T> <T>attemptMetricsCallable(Callable<T> callable, MetricsRecorder metricsRecorder, DatastoreOptions datastoreOptions, boolean isHttpTransport, String methodName)

Wraps a callable with logic to record attempt-level metrics for HttpJson transport. Attempt metrics are recorded for each individual execution of the callable, regardless of whether it succeeds or fails.

Parameters
Name Description
callable Callable<T>

The original callable to execute.

metricsRecorder MetricsRecorder

The metrics recorder.

datastoreOptions DatastoreOptions

The DatastoreOptions object.

isHttpTransport boolean

Whether the current transport is HTTP.

methodName String

The name of the API method.

Returns
Type Description
Callable<T>

A wrapped callable that includes attempt-level metrics recording.

buildMetricAttributes(DatastoreOptions datastoreOptions, String methodName, String status)

public static Map<String,String> buildMetricAttributes(DatastoreOptions datastoreOptions, String methodName, String status)

Method to build a map of attributes to be used across both operation and attempt level metrics.

Parameters
Name Description
datastoreOptions DatastoreOptions

The DatastoreOptions object.

methodName String

The name of the API method.

status String

The status of the operation or attempt.

Returns
Type Description
Map<String,String>

The map of attributes.

recordOperationMetrics(MetricsRecorder metricsRecorder, DatastoreOptions datastoreOptions, boolean isHttpTransport, Stopwatch operationStopwatch, String methodName, String status)

public static void recordOperationMetrics(MetricsRecorder metricsRecorder, DatastoreOptions datastoreOptions, boolean isHttpTransport, Stopwatch operationStopwatch, String methodName, String status)

Method to record operation level metrics for HttpJson transport. This method should be called after the entire operation across all retry attempts has completed.

Parameters
Name Description
metricsRecorder MetricsRecorder

The metrics recorder.

datastoreOptions DatastoreOptions

The DatastoreOptions object.

isHttpTransport boolean

Whether the current transport is HTTP.

operationStopwatch com.google.common.base.Stopwatch

The stopwatch tracking the duration of the entire operation.

methodName String

The name of the API method.

status String

The final status of the operation after all retries.