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, DatastoreMetricsRecorder metricsRecorder, String methodName)
public static Callable<T> <T>attemptMetricsCallable(Callable<T> callable, DatastoreMetricsRecorder metricsRecorder, String methodName)Wraps a callable with logic to record attempt-level metrics. Attempt metrics are recorded for each individual execution of the callable, regardless of whether it succeeds or fails.
Metrics are recorded for both transport types (gRPC and HTTP).
| Parameters | |
|---|---|
| Name | Description |
callable |
Callable<T>The original callable to execute. |
metricsRecorder |
DatastoreMetricsRecorderThe metrics recorder. |
methodName |
StringThe name of the API method. |
| Returns | |
|---|---|
| Type | Description |
Callable<T> |
A wrapped callable that includes attempt-level metrics recording. |
buildMetricAttributes(String methodName, String status)
public static Map<String,String> buildMetricAttributes(String methodName, String status)Method to build a map of attributes to be used across both operation and attempt level metrics.
| Parameters | |
|---|---|
| Name | Description |
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(DatastoreMetricsRecorder metricsRecorder, Stopwatch operationStopwatch, String methodName, String status)
public static void recordOperationMetrics(DatastoreMetricsRecorder metricsRecorder, Stopwatch operationStopwatch, String methodName, String status)Records operation-level metrics. This method should be called after the entire operation across all retry attempts has completed.
Metrics are recorded for both transport types (gRPC and HTTP).
| Parameters | |
|---|---|
| Name | Description |
metricsRecorder |
DatastoreMetricsRecorderThe metrics recorder. |
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. |