public final class TelemetryUtilsUtility class for common telemetry operations in Datastore.
WARNING: This class is intended for internal use only.
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 |
MetricsRecorderThe metrics recorder. |
datastoreOptions |
DatastoreOptionsThe DatastoreOptions object. |
isHttpTransport |
booleanWhether the current transport is HTTP. |
methodName |
StringThe 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 |
DatastoreOptionsThe DatastoreOptions object. |
methodName |
StringThe name of the API method. |
status |
StringThe 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 |
MetricsRecorderThe metrics recorder. |
datastoreOptions |
DatastoreOptionsThe DatastoreOptions object. |
isHttpTransport |
booleanWhether the current transport is HTTP. |
operationStopwatch |
com.google.common.base.StopwatchThe stopwatch tracking the duration of the entire operation. |
methodName |
StringThe name of the API method. |
status |
StringThe final status of the operation after all retries. |