Repository navigation
feat: add built-in client metrics flags and upgrade cloudsqlconn to v1.26.0 (BETA) - #2714
Merged
Merged
Conversation
…1.26.0 (BETA) Upgrade cloud.google.com/go/cloudsqlconn to v1.26.0, which exports built-in client metrics (cloudsql.googleapis.com/client/connector/*) to Cloud Monitoring in the Cloud SQL instance's project by default (BETA). Expose the corresponding CLI flags and environment variables: - --enable-builtin-metrics (default true; CSQL_PROXY_ENABLE_BUILTIN_METRICS): pass =false to disable built-in client metrics (or =true to explicitly enable in non-default Cloud universes). Unset leaves the connector's own default in effect. Independent of --telemetry-project / --disable-metrics, which control the Proxy's OpenCensus metrics. - --compute-platform (CSQL_PROXY_COMPUTE_PLATFORM): overrides the auto-detected compute_platform label; validated at startup with cloudsqlconn.ParseComputePlatform. - --application-name (CSQL_PROXY_APPLICATION_NAME): sets the optional application_name label (empty by default). When impersonating a service account (--impersonate-service-account), request the monitoring.write scope alongside sqlservice.admin whenever built-in metrics are enabled so the impersonated token can export metrics. Updates README and generated CLI reference docs.
panavenue
force-pushed
the
builtin-metrics-flags
branch
from
October 29, 2026 18:44
7e49cf8 to
0057ff4
Compare
hessjcg
approved these changes
Oct 29, 2026
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upgrades
cloud.google.com/go/cloudsqlconnto v1.26.0, which exports built-in client metrics to Cloud Monitoring by default (BETA) undercloudsql.googleapis.com/client/connector/*using thecloudsql.googleapis.com/InstanceClientmonitored resource, and exposes the CLI flags and environment variables to configure or disable them.New Flags & Environment Variables
--enable-builtin-metrics(CSQL_PROXY_ENABLE_BUILTIN_METRICS, defaulttrue):--enable-builtin-metrics=false(orCSQL_PROXY_ENABLE_BUILTIN_METRICS=false) to disable built-in client metrics.googleapis.com, disabled in non-default Cloud universes unless--enable-builtin-metrics=trueis explicitly passed).--telemetry-project/--disable-metrics, which control the Proxy's OpenCensus metrics and traces.--compute-platform(CSQL_PROXY_COMPUTE_PLATFORM):compute_platformlabel (e.g.ai_studio). Validated at startup withcloudsqlconn.ParseComputePlatform; help text is populated fromcloudsqlconn.ComputePlatforms().--application-name(CSQL_PROXY_APPLICATION_NAME):application_namelabel to identify an application across its instances (empty by default).Service Account Impersonation Scope & Shutdown Ordering
--impersonate-service-accountis used and built-in metrics are enabled, the Proxy automatically requestshttps://www.googleapis.com/auth/monitoring.writealongsidesqlservice.adminon the impersonated token source so that metric exports succeed.Client.Close()): Movedc.dialer.Close()to run after--max-sigterm-delayconnection draining (WaitOnClose) and after closing instance socket listeners (m.Close()/ FUSE unmount). This ensures local TCP/Unix sockets release immediately without waiting on the final Cloud Monitoring flush RPC, and ensures in-flight connections draining duringSIGTERMremain open and are included in the final metrics flush.roles/monitoring.metricWriteron that project. If missing, the Proxy logs one warning per process explaining what to grant (or how to disable) and backs off exponentially.Performance & E2E Verification
Benchmarked a Go
pgx/v5client application connecting throughcloud-sql-proxy --auto-iam-authnto a live Cloud SQL for PostgreSQL 18 instance (us-west1) across 2 interleaved rounds comparingmain(v2.26.3), PR (--enable-builtin-metrics=false), and PR (metrics enabled,--compute-platform=ai_studio --application-name=proxy-perf-app):SELECT 1+ close (caches ephemeral TLS cert and IAM DB authn token).SELECT 1+ close per round (exercises Proxy accept,cloudsqlconndial + metric recording, TLS handshake, Postgres startup, query, and close).SELECT repeat('x', 4096)queries over an 8-connectiondatabase/sqlpool per round (exercises steady-state Proxy bidirectionalio.Copythroughput)./debug/pprof/goroutine,/debug/pprof/heap?gc=1(Alloc), OSVmRSS, startup-to-ready time, andSIGTERM-to-exit time.SELECT 1(p50 / p90 / p99)SIGTERMExitmain(v2.26.3)--enable-builtin-metrics=false)main, metrics off, and metrics on.--enable-builtin-metrics=false), 0 extra goroutines and 0 heap overhead vsmain. When enabled, +10 background OTel/Cloud Monitoring exporter goroutines, +0.14 MB Go heap after GC, and ~118 ms onSIGTERMfor the final Cloud Monitoring flush RPC (after local listeners have already closed).cloudsql.googleapis.com/client/connector/*byclient_uidand confirmed exact counts of 41 (3warmup +30unpooled +8pooled) acrossopen_connection_count,connect_latencies,closed_connection_count, andconnection_durations, and 0open_connectionsafter exit, withconnector_type=auth_proxy,compute_platform=ai_studio,application_name=proxy-perf-app,database_engine_type=postgresql,instance_auth_type=iam,instance_ip_type=public. With--enable-builtin-metrics=false, confirmed 0 time series exported.