The custom metric exporter, as defined in metrics_exporter.py, is designed to work in conjunction with OpenTelemetry and the Spanner client. It converts data into its protobuf equivalent and sends it to Google Cloud Monitoring.
The exporter filters metrics based on the following conditions, utilizing values defined in constants.py:
- Metrics with a scope set to
gax-python. - Metrics with one of the following predefined names:
attempt_latenciesattempt_countoperation_latenciesoperation_countgfe_latenciesgfe_connectivity_error_countafe_latenciesafe_connectivity_error_count
The exporter sends metrics to the Google Cloud Monitoring service endpoint, distinct from the regular client endpoint. This service endpoint operates under a different quota limit than the user endpoint and features an additional server-side filter that only permits a predefined set of metrics to pass through.
When introducing new service metrics, it is essential to ensure they are allowed through by the server-side filter as well.