cloud-sql-go-connector icon indicating copy to clipboard operation
cloud-sql-go-connector copied to clipboard

System metrics setup

Open panavenue opened this issue 1 month ago • 0 comments

Description - This pull request introduces a comprehensive system for collecting and exporting client-side metrics from the Cloud SQL Go Connector, providing valuable insights into the connector's performance and behavior. The key changes include the integration of OpenTelemetry for metrics collection and the introduction of a dedicated telemetry package.

  1. Setup Metric meter and records in tel with new metrics -
  • connect_latencies: A histogram that records the duration of dial operations, providing insight into connection latency.
  • open_connections: An up-down counter that tracks the number of currently open connections to a Cloud SQL instance.
  • closed_connection_count: A counter that records the total number of closed connections, which helps in understanding connection churn.
  1. Dialer Integration
  • A MetricRecorder is now lazily initialized for each Cloud SQL instance when a connection is first established
  • The Dial method has been enhanced to record metrics at various stages of a connection's lifecycle. For example, it records the connection latency upon a successful dial and increments the open connections counter
  • When a connection is closed, the open connections counter is decremented, and the closed connection count is incremented

panavenue avatar Nov 04 '25 23:11 panavenue