Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,14 @@
try:
from opentelemetry.propagate import inject
from opentelemetry.propagators.textmap import Setter
from opentelemetry.resourcedetector import gcp_resource_detector
from opentelemetry.resourcedetector.gcp_resource_detector import (
GoogleCloudResourceDetector,
)
from opentelemetry.resource.detector.gcp import GoogleCloudResourceDetector
from opentelemetry.resource.detector.gcp import _metadata as gcp_metadata
from opentelemetry.semconv.resource import ResourceAttributes

# Overwrite the requests timeout for the detector.
# This is necessary as the client will wait the full timeout if the
# code is not run in a GCP environment, with the location endpoints available.
gcp_resource_detector._TIMEOUT_SEC = 0.2
gcp_metadata._TIMEOUT = 0.2

HAS_OPENTELEMETRY_INSTALLED = True
except ImportError:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Custom Metric Exporter
# Custom Metric Exporter
The custom metric exporter, as defined in [metrics_exporter.py](./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.

## Filtering Criteria
Expand All @@ -10,8 +10,10 @@ The exporter filters metrics based on the following conditions, utilizing values
* `attempt_count`
* `operation_latencies`
* `operation_count`
* `gfe_latency`
* `gfe_missing_header_count`
* `gfe_latencies`
* `gfe_connectivity_error_count`
* `afe_latencies`
* `afe_connectivity_error_count`

## Service Endpoint
The exporter sends metrics to the Google Cloud Monitoring [service endpoint](https://cloud.google.com/python/docs/reference/monitoring/latest/google.cloud.monitoring_v3.services.metric_service.MetricServiceClient#google_cloud_monitoring_v3_services_metric_service_MetricServiceClient_create_service_time_series), 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,19 @@
METRIC_NAME_ATTEMPT_LATENCIES = "attempt_latencies"
METRIC_NAME_OPERATION_COUNT = "operation_count"
METRIC_NAME_ATTEMPT_COUNT = "attempt_count"
METRIC_NAME_GFE_LATENCY = "gfe_latency"
METRIC_NAME_GFE_MISSING_HEADER_COUNT = "gfe_missing_header_count"
METRIC_NAME_GFE_LATENCY = "gfe_latencies"
METRIC_NAME_GFE_CONNECTIVITY_ERROR_COUNT = "gfe_connectivity_error_count"
METRIC_NAME_AFE_LATENCY = "afe_latencies"
METRIC_NAME_AFE_CONNECTIVITY_ERROR_COUNT = "afe_connectivity_error_count"
METRIC_NAMES = [
METRIC_NAME_OPERATION_LATENCIES,
METRIC_NAME_ATTEMPT_LATENCIES,
METRIC_NAME_OPERATION_COUNT,
METRIC_NAME_ATTEMPT_COUNT,
METRIC_NAME_GFE_LATENCY,
METRIC_NAME_GFE_CONNECTIVITY_ERROR_COUNT,
METRIC_NAME_AFE_LATENCY,
METRIC_NAME_AFE_CONNECTIVITY_ERROR_COUNT,
]

METRIC_EXPORT_INTERVAL_MS = 60000 # 1 Minute
Loading
Loading