Interface DatastoreMetricsRecorder (2.40.0)

public interface DatastoreMetricsRecorder extends MetricsRecorder

Interface to record Datastore-specific and standard RPC metrics.

This interface extends MetricsRecorder from the GAX library to provide a unified recording contract that covers both generic RPC metrics (like latency and attempt counts) and Datastore-specific operations (like transactions).

Warning: This is intended to be an internal API and is not intended for external use. This is public solely for implementation purposes and does not promise any backwards compatibility.

Implements

MetricsRecorder

Static Methods

getInstance(DatastoreOptions datastoreOptions)

public static DatastoreMetricsRecorder getInstance(DatastoreOptions datastoreOptions)

Returns a DatastoreMetricsRecorder instance based on the provided DatastoreOptions.

If the user has enabled metrics and provided an OpenTelemetry instance (or GlobalOpenTelemetry is used as fallback), an OpenTelemetryDatastoreMetricsRecorder is returned. Otherwise a NoOpDatastoreMetricsRecorder is returned.

Parameter
Name Description
datastoreOptions DatastoreOptions

the DatastoreOptions configuring the Datastore client

Returns
Type Description
DatastoreMetricsRecorder

a DatastoreMetricsRecorder for the configured backend

Methods

recordTransactionAttemptCount(long count, Map<String,String> attributes)

public abstract void recordTransactionAttemptCount(long count, Map<String,String> attributes)

Records the number of attempts a transaction took.

Parameters
Name Description
count long
attributes Map<String,String>

recordTransactionLatency(double latencyMs, Map<String,String> attributes)

public abstract void recordTransactionLatency(double latencyMs, Map<String,String> attributes)

Records the total latency of a transaction in milliseconds.

Parameters
Name Description
latencyMs double
attributes Map<String,String>