GCPMetricsHandler

GCPMetricsHandler

A metrics handler implementation that uses OpenTelemetry to export metrics to Google Cloud Monitoring. This handler records metrics such as operation latency, attempt latency, retry count, and more, associating them with relevant attributes for detailed analysis in Cloud Monitoring.

Constructor

new GCPMetricsHandler(exporter)

The GCPMetricsHandler is responsible for managing and recording client-side metrics for Google Cloud Bigtable using OpenTelemetry. It handles the creation and configuration of various metric instruments (histograms and counters) and exports them to Google Cloud Monitoring through the provided PushMetricExporter.

Parameters:
Name Type Description
exporter

The PushMetricExporter instance to use for exporting metrics to Google Cloud Monitoring. This exporter is responsible for sending the collected metrics data to the monitoring backend. The provided exporter must be fully configured, for example the projectId must have been set.

Methods

getInstruments()

Initializes the OpenTelemetry metrics instruments if they haven't been already. Creates and registers metric instruments (histograms and counters) for various Bigtable client metrics. Sets up a MeterProvider and configures a PeriodicExportingMetricReader for exporting metrics to Cloud Monitoring.

which will be provided to the exporter in every export call.

onAttemptComplete(data)

Records metrics for a completed attempt of a Bigtable operation. This method records attempt latency, connectivity error count, server latency, along with the provided attributes.

Parameters:
Name Type Description
data OnAttemptCompleteData

Data related to the completed attempt.

onOperationComplete(data)

Records metrics for a completed Bigtable operation. This method records the operation latency and retry count, associating them with provided attributes.

Parameters:
Name Type Description
data OnOperationCompleteData

Data related to the completed operation.