{"id":15222007,"url":"https://github.com/googlecloudplatform/cloud-sql-go-connector","last_synced_at":"2025-04-05T02:10:58.800Z","repository":{"id":37181842,"uuid":"292606346","full_name":"GoogleCloudPlatform/cloud-sql-go-connector","owner":"GoogleCloudPlatform","description":"A Go library for connecting securely to your Cloud SQL instances","archived":false,"fork":false,"pushed_at":"2024-10-23T13:39:02.000Z","size":1780,"stargazers_count":110,"open_issues_count":13,"forks_count":29,"subscribers_count":20,"default_branch":"main","last_synced_at":"2024-10-29T18:37:40.423Z","etag":null,"topics":["cloudsql","go","golang","libraries"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GoogleCloudPlatform.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-03T15:18:32.000Z","updated_at":"2024-10-23T13:38:57.000Z","dependencies_parsed_at":"2023-10-04T08:16:05.555Z","dependency_job_id":"44b5134a-0ee4-4ae8-b2cf-c1e90d8a309a","html_url":"https://github.com/GoogleCloudPlatform/cloud-sql-go-connector","commit_stats":{"total_commits":650,"total_committers":18,"mean_commits":"36.111111111111114","dds":"0.45999999999999996","last_synced_commit":"2a3257d403f8d685e487032a545fa186876a8442"},"previous_names":["kurtisvg/cloud-sql-connector-go"],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleCloudPlatform%2Fcloud-sql-go-connector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleCloudPlatform%2Fcloud-sql-go-connector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleCloudPlatform%2Fcloud-sql-go-connector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleCloudPlatform%2Fcloud-sql-go-connector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GoogleCloudPlatform","download_url":"https://codeload.github.com/GoogleCloudPlatform/cloud-sql-go-connector/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276189,"owners_count":20912288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudsql","go","golang","libraries"],"created_at":"2024-09-28T15:09:48.242Z","updated_at":"2025-04-05T02:10:58.782Z","avatar_url":"https://github.com/GoogleCloudPlatform.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://pkg.go.dev/cloud.google.com/go/cloudsqlconn\"\u003e\n        \u003cimg src=\"docs/images/cloud-sql-go-connector.png\" alt=\"cloud-sql-go-connector image\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eCloud SQL Go Connector\u003c/h1\u003e\n\n[![Open In Codelab][codelab-badge]][codelab]\n[![CI][ci-badge]][ci-build]\n[![Go Reference][pkg-badge]][pkg-docs]\n\n[ci-badge]: https://github.com/GoogleCloudPlatform/cloud-sql-go-connector/actions/workflows/tests.yaml/badge.svg?event=push\n[ci-build]: https://github.com/GoogleCloudPlatform/cloud-sql-go-connector/actions/workflows/tests.yaml?query=event%3Apush+branch%3Amain\n[pkg-badge]: https://pkg.go.dev/badge/cloud.google.com/go/cloudsqlconn.svg\n[pkg-docs]: https://pkg.go.dev/cloud.google.com/go/cloudsqlconn\n[codelab-badge]: https://img.shields.io/badge/Open%20In%20Codelab-blue?labelColor=grey\u0026style=flat\u0026logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAyVBMVEX////////////////////////+8/L0oZrrTkHqQzXzlY13yKEPnVgdo2KHzqvw+fX4xMDtWk604MssqWz73NnvcWdKtYHS7eD85+ZowpayncOWapvVS0360MzD5tWW1LZxo/dChfSLaKHfR0FMhe2rY4TyiYBlm/bQ4Pz+7sD7xCPPthRJpkegwvl9q/fn8P7+9+D80VL7vASisCQsoU4spV393YHPwDm40ftNjPX7wBP95qHz9/7/++/b6P3+8tD8zUKIsvj81WJbutStAAAABnRSTlMAIKDw/zDiNY+eAAAA+klEQVR4AbzRRYICMRRF0VB5QLlrO+7uDvvfVKfSv91mnGlunDFWUDh+xJUCE4ocv+JFMZ/jD7zAFPxJYRx/4gz/uGpQKquaDsEwLdv5HrieJriAbwqB/yUII00qA7YpxcmHoKRrJAUSk2QOKLi5vdMk7x7CQ0CF9fgSPFUqlWpN09QyiG1REsugkqs3miW8cTIqHApyrTbedLq9vgzkCoMKGY4gjSdTYTY3F74M0G5VyADCckpWnbd3WG+oaAMdGt7uPj7UfvC2BC2wPIACMspvuzkCp60YPo9/+M328LKHcHiek6EmnRMMAUAw2RPMOASzHsHMSzD7AwCdmyeTDUqFKQAAAABJRU5ErkJggg==\n[codelab]: https://codelabs.developers.google.com/codelabs/cloud-sql-go-connector\n\nThe _Cloud SQL Go Connector_ is a Cloud SQL connector designed for use with the\nGo language. Using a Cloud SQL connector provides a native alternative to the\n[Cloud SQL Auth Proxy][] while providing the following benefits:\n\n* **IAM Authorization:** uses IAM permissions to control who/what can connect to\n  your Cloud SQL instances\n* **Improved Security:** uses robust, updated TLS 1.3 encryption and\n  identity verification between the client connector and the server-side proxy,\n  independent of the database protocol.\n* **Convenience:** removes the requirement to use and distribute SSL\n  certificates, as well as manage firewalls or source/destination IP addresses.\n* (optionally) **IAM DB Authentication:** provides support for\n  [Cloud SQL’s automatic IAM DB AuthN][iam-db-authn] feature.\n\n[iam-db-authn]: https://cloud.google.com/sql/docs/postgres/authentication\n[Cloud SQL Auth Proxy]: https://cloud.google.com/sql/docs/postgres/sql-proxy\n\nFor users migrating from the Cloud SQL Proxy drivers, see the [migration\nguide](./migration-guide.md).\n\nFor a quick example, try out the Go Connector in a [Codelab][codelab].\n\n## Installation\n\nYou can install this repo with `go get`:\n```sh\ngo get cloud.google.com/go/cloudsqlconn\n```\n\n## Usage\n\nThis package provides several functions for authorizing and encrypting\nconnections. These functions can be used with your database driver to connect to\nyour Cloud SQL instance.\n\nThe instance connection name for your Cloud SQL instance is always in the\nformat `project:region:instance`.\n\n### APIs and Services\n\nThis package requires the following to successfully make Cloud SQL Connections:\n\n- IAM principal (user, service account, etc.) with the\n[Cloud SQL Client][client-role] role or equivalent. This IAM principal will\n be used for [credentials](#credentials).\n- The [Cloud SQL Admin API][admin-api] to be enabled within your Google Cloud\nProject. By default, the API will be called in the project associated with\nthe IAM principal.\n\n[admin-api]: https://console.cloud.google.com/apis/api/sqladmin.googleapis.com\n[client-role]: https://cloud.google.com/sql/docs/mysql/roles-and-permissions\n\n### Credentials\n\nThis project uses the [Application Default Credentials (ADC)][adc] strategy for\nresolving credentials. Please see [these instructions for how to set your ADC][set-adc]\n(Google Cloud Application vs Local Development, IAM user vs service account credentials),\nor consult the [golang.org/x/oauth2/google][google-auth] documentation.\n\nTo explicitly set a specific source for the Credentials, see [Using\nOptions](#using-options) below.\n\n[adc]: https://cloud.google.com/docs/authentication#adc\n[set-adc]: https://cloud.google.com/docs/authentication/provide-credentials-adc\n[google-auth]: https://pkg.go.dev/golang.org/x/oauth2/google#hdr-Credentials\n\n### Connecting to a database\n\n#### Postgres\n\nPostgres users have the option of using the `database/sql` interface or\nusing [pgx][] directly. See [pgx's advice on which to choose][pgx-advice].\n\n[pgx]: https://github.com/jackc/pgx\n[pgx-advice]: https://github.com/jackc/pgx#choosing-between-the-pgx-and-databasesql-interfaces\n\n##### Using the dialer with pgx\n\nTo use the dialer with [pgx][], we recommend using connection pooling with\n[pgxpool](https://pkg.go.dev/github.com/jackc/pgx/v5/pgxpool) by configuring\na [Config.DialFunc][dial-func] like so:\n\n``` go\nimport (\n    \"context\"\n    \"net\"\n\n    \"cloud.google.com/go/cloudsqlconn\"\n    \"github.com/jackc/pgx/v5/pgxpool\"\n)\n\nfunc connect() {\n    // Configure the driver to connect to the database\n    dsn := \"user=myuser password=mypass dbname=mydb sslmode=disable\"\n    config, err := pgxpool.ParseConfig(dsn)\n    if err != nil {\n        /* handle error */\n    }\n\n    // Create a new dialer with any options\n    d, err := cloudsqlconn.NewDialer(context.Background())\n    if err != nil {\n        /* handle error */\n    }\n\n    // Tell the driver to use the Cloud SQL Go Connector to create connections\n    config.ConnConfig.DialFunc = func(ctx context.Context, _ string, instance string) (net.Conn, error) {\n        return d.Dial(ctx, \"project:region:instance\")\n    }\n\n    // Interact with the driver directly as you normally would\n    pool, err := pgxpool.NewWithConfig(context.Background(), config)\n    if err != nil {\n        /* handle error */\n    }\n\n    // call cleanup when you're done with the database connection\n    cleanup := func() error { return d.Close() }\n    // ... etc\n}\n```\n\n[dial-func]: https://pkg.go.dev/github.com/jackc/pgconn#Config\n\n##### Using the dialer with `database/sql`\n\nTo use `database/sql`, call `pgxv5.RegisterDriver` with any necessary Dialer\nconfiguration. Note: the connection string must use the keyword/value format\nwith host set to the instance connection name. The returned `cleanup` func\nwill stop the dialer's background refresh goroutine and so should only be called\nwhen you're done with the `Dialer`.\n\n``` go\nimport (\n    \"database/sql\"\n\n    \"cloud.google.com/go/cloudsqlconn\"\n    \"cloud.google.com/go/cloudsqlconn/postgres/pgxv5\"\n)\n\nfunc connect() {\n    cleanup, err := pgxv5.RegisterDriver(\"cloudsql-postgres\", cloudsqlconn.WithIAMAuthN())\n    if err != nil {\n        // ... handle error\n    }\n    // call cleanup when you're done with the database connection\n    defer cleanup()\n\n    db, err := sql.Open(\n        \"cloudsql-postgres\",\n        \"host=project:region:instance user=myuser password=mypass dbname=mydb sslmode=disable\",\n    )\n    // ... etc\n}\n```\n\n#### MySQL\n\nTo use `database/sql`, use `mysql.RegisterDriver` with any necessary Dialer\nconfiguration. The returned `cleanup` func\nwill stop the dialer's background refresh goroutine and so should only be called\nwhen you're done with the `Dialer`.\n\n```go\nimport (\n    \"database/sql\"\n\n    \"cloud.google.com/go/cloudsqlconn\"\n    \"cloud.google.com/go/cloudsqlconn/mysql/mysql\"\n)\n\nfunc connect() {\n    cleanup, err := mysql.RegisterDriver(\"cloudsql-mysql\", cloudsqlconn.WithCredentialsFile(\"key.json\"))\n    if err != nil {\n        // ... handle error\n    }\n    // call cleanup when you're done with the database connection\n    defer cleanup()\n\n    db, err := sql.Open(\n        \"cloudsql-mysql\",\n        \"myuser:mypass@cloudsql-mysql(project:region:instance)/mydb\",\n    )\n    // ... etc\n}\n```\n\n#### SQL Server\n\nTo use `database/sql`, use `mssql.RegisterDriver` with any necessary Dialer\nconfiguration. The returned `cleanup` func\nwill stop the dialer's background refresh goroutine and so should only be called\nwhen you're done with the `Dialer`.\n\n``` go\nimport (\n    \"database/sql\"\n\n    \"cloud.google.com/go/cloudsqlconn\"\n    \"cloud.google.com/go/cloudsqlconn/sqlserver/mssql\"\n)\n\nfunc connect() {\n    cleanup, err := mssql.RegisterDriver(\"cloudsql-sqlserver\", cloudsqlconn.WithCredentialsFile(\"key.json\"))\n    if err != nil {\n        // ... handle error\n    }\n    // call cleanup when you're done with the database connection\n    defer cleanup()\n\n    db, err := sql.Open(\n        \"cloudsql-sqlserver\",\n        \"sqlserver://user:password@localhost?database=mydb\u0026cloudsql=project:region:instance\",\n    )\n    // ... etc\n}\n```\n\n### Using DNS domain names to identify instances\n\nThe connector can be configured to use DNS to look up an instance. This would\nallow you to configure your application to connect to a database instance, and\ncentrally configure which instance in your DNS zone.\n\n#### Configure your DNS Records\n\nAdd a DNS TXT record for the Cloud SQL instance to a **private** DNS server \nor a private Google Cloud DNS Zone used by your application. \n\n**Note:** You are strongly discouraged from adding DNS records for your \nCloud SQL instances to a public DNS server. This would allow anyone on the\ninternet to discover the Cloud SQL instance name. \n\nFor example: suppose you wanted to use the domain name \n`prod-db.mycompany.example.com` to connect to your database instance \n`my-project:region:my-instance`. You would create the following DNS record: \n\n- Record type: `TXT` \n- Name: `prod-db.mycompany.example.com` – This is the domain name used by the application\n- Value: `my-project:region:my-instance` – This is the instance name\n\n#### Configure the connector\n\nConfigure the connector as described above, replacing the connector ID with\nthe DNS name. \n\nAdapting the MySQL + database/sql example above:\n\n```go\npackage main\n\nimport (\n\t\"database/sql\"\n\n\t\"cloud.google.com/go/cloudsqlconn\"\n\t\"cloud.google.com/go/cloudsqlconn/mysql/mysql\"\n)\n\nfunc connect() {\n\tcleanup, err := mysql.RegisterDriver(\"cloudsql-mysql\",\n\t\tcloudsqlconn.WithDNSResolver())\n\tif err != nil {\n\t\t// ... handle error\n\t}\n\t// call cleanup when you're done with the database connection\n\tdefer cleanup()\n\n\tdb, err := sql.Open(\n\t\t\"cloudsql-mysql\",\n\t\t\"myuser:mypass@cloudsql-mysql(prod-db.mycompany.example.com)/mydb\",\n\t)\n\t// ... etc\n}\n```\n\n### Automatic fail-over using DNS domain names\n\nWhen the connector is configured using a domain name, the connector will \nperiodically check if the DNS record for an instance changes. When the connector \ndetects that the domain name refers to a different instance, the connector will\nclose all open connections to the old instance. Subsequent connection attempts\nwill be directed to the new instance. \n\nFor example: suppose application is configured to connect using the\ndomain name `prod-db.mycompany.example.com`. Initially the corporate DNS \nzone has a TXT record with the value `my-project:region:my-instance`. The\napplication establishes connections to the `my-project:region:my-instance` \nCloud SQL instance. \n\nThen, to reconfigure the application to use a different database\ninstance, change the value of the `prod-db.mycompany.example.com` DNS record\nfrom `my-project:region:my-instance` to `my-project:other-region:my-instance-2`\n\nThe connector inside the application detects the change to this\nDNS record. Now, when the application connects to its database using the \ndomain name `prod-db.mycompany.example.com`, it will connect to the\n`my-project:other-region:my-instance-2` Cloud SQL instance. \n\nThe connector will automatically close all existing connections to\n`my-project:region:my-instance`. This will force the connection pools to \nestablish new connections. Also, it may cause database queries in progress \nto fail. \n\nThe connector will poll for changes to the DNS name every 30 seconds by default.\nYou may configure the frequency of the connections using the option \n`WithFailoverPeriod(d time.Duration)`. When this is set to 0, the connector will\ndisable polling and only check if the DNS record changed when it is\ncreating a new connection. \n\n\n### Using Options\n\nIf you need to customize something about the `Dialer`, you can initialize\ndirectly with `NewDialer`:\n\n```go\nd, err := cloudsqlconn.NewDialer(\n    ctx,\n    cloudsqlconn.WithCredentialsFile(\"key.json\"),\n)\nif err != nil {\n    log.Fatalf(\"unable to initialize dialer: %s\", err)\n}\n\nconn, err := d.Dial(ctx, \"project:region:instance\")\n```\n\nFor a full list of customizable behavior, see Option.\n\n### Using DialOptions\n\nIf you want to customize things about how the connection is created, use\n`Option`:\n\n```go\nconn, err := d.Dial(\n    ctx,\n    \"project:region:instance\",\n    cloudsqlconn.WithPrivateIP(),\n)\n```\n\nYou can also use the `WithDefaultDialOptions` Option to specify\nDialOptions to be used by default:\n\n```go\nd, err := cloudsqlconn.NewDialer(\n    ctx,\n    cloudsqlconn.WithDefaultDialOptions(\n        cloudsqlconn.WithPrivateIP(),\n    ),\n)\n```\n\n### Automatic IAM Database Authentication\n\nConnections using [Automatic IAM database authentication][] are supported when\nusing Postgres or MySQL drivers.\n\nMake sure to [configure your Cloud SQL Instance to allow IAM authentication][configure-iam-authn]\nand [add an IAM database user][add-iam-user].\n\nA `Dialer` can be configured to connect to a Cloud SQL instance using\nautomatic IAM database authentication with the `WithIAMAuthN` Option\n(recommended) or the `WithDialIAMAuthN` DialOption.\n\n```go\nd, err := cloudsqlconn.NewDialer(ctx, cloudsqlconn.WithIAMAuthN())\n```\n\nWhen configuring the DSN for IAM authentication, the `password` field can be\nomitted and the `user` field should be formatted as follows:\n\u003e Postgres: For an IAM user account, this is the user's email address.\n\u003e For a service account, it is the service account's email without the\n\u003e `.gserviceaccount.com` domain suffix.\n\u003e\n\u003e MySQL: For an IAM user account, this is the user's email address, without\n\u003e the `@` or domain name. For example, for `test-user@gmail.com`, set the\n\u003e `user` field to `test-user`. For a service account, this is the service\n\u003e account's email address without the `@project-id.iam.gserviceaccount.com`\n\u003e suffix.\n\nExample DSNs using the `test-sa@test-project.iam.gserviceaccount.com`\nservice account to connect can be found below.\n\n**Postgres**:\n\n```go\ndsn := \"user=test-sa@test-project.iam dbname=mydb sslmode=disable\"\n```\n\n**MySQL**:\n\n```go\ndsn := \"user=test-sa dbname=mydb sslmode=disable\"\n```\n\n[Automatic IAM database authentication]: https://cloud.google.com/sql/docs/postgres/authentication#automatic\n[configure-iam-authn]: https://cloud.google.com/sql/docs/postgres/create-edit-iam-instances#configure-iam-db-instance\n[add-iam-user]: https://cloud.google.com/sql/docs/postgres/create-manage-iam-users#creating-a-database-user\n\n### Enabling Metrics and Tracing\n\nThis library includes support for metrics and tracing using [OpenCensus][].\nTo enable metrics or tracing, you need to configure an [exporter][].\nOpenCensus supports many backends for exporters.\n\nSupported metrics include:\n\n- `cloudsqlconn/dial_latency`: The distribution of dialer latencies (ms)\n- `cloudsqlconn/open_connections`: The current number of open Cloud SQL\n  connections\n- `cloudsqlconn/dial_failure_count`: The number of failed dial attempts\n- `cloudsqlconn/refresh_success_count`: The number of successful certificate\n  refresh operations\n- `cloudsqlconn/refresh_failure_count`: The number of failed refresh\n  operations\n- `cloudsqlconn/bytes_sent`: The number of bytes sent to Cloud SQL\n- `cloudsqlconn/bytes_received`: The number of bytes received from Cloud SQL\n\nSupported traces include:\n\n- `cloud.google.com/go/cloudsqlconn.Dial`: The dial operation including\n  refreshing an ephemeral certificate and connecting the instance\n- `cloud.google.com/go/cloudsqlconn/internal.InstanceInfo`: The call to retrieve\n  instance metadata (e.g., database engine type, IP address, etc)\n- `cloud.google.com/go/cloudsqlconn/internal.Connect`: The connection attempt\n  using the ephemeral certificate\n- SQL Admin API client operations\n\nFor example, to use [Cloud Monitoring][] and [Cloud Trace][], you would\nconfigure an exporter like so:\n\n```golang\nimport (\n    \"contrib.go.opencensus.io/exporter/stackdriver\"\n    \"go.opencensus.io/trace\"\n)\n\nfunc main() {\n    sd, err := stackdriver.NewExporter(stackdriver.Options{\n        ProjectID: \"mycoolproject\",\n    })\n    if err != nil {\n        // handle error\n    }\n    defer sd.Flush()\n    trace.RegisterExporter(sd)\n\n    sd.StartMetricsExporter()\n    defer sd.StopMetricsExporter()\n\n    // Use cloudsqlconn as usual.\n    // ...\n}\n```\n\nAs OpenTelemetry has now reached feature parity with OpenCensus, the migration\nfrom OpenCensus to OpenTelemetry is strongly encouraged.\n[OpenTelemetry bridge](https://github.com/open-telemetry/opentelemetry-go/tree/main/bridge/opencensus)\ncan be leveraged to migrate to OpenTelemetry without the need of replacing the\nOpenCensus APIs in this library. Example code is shown below for migrating an\napplication using the OpenTelemetry bridge for traces.\n\n```golang\nimport (\n\ttexporter \"github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace\"\n\t\"go.opencensus.io/trace\"\n\t\"go.opentelemetry.io/otel\"\n\t\"go.opentelemetry.io/otel/bridge/opencensus\"\n\tsdktrace \"go.opentelemetry.io/otel/sdk/trace\"\n\t\"google.golang.org/api/option\"\n)\n\nfunc main() {\n\t// trace.AlwaysSample() is expensive. Replacing it with your own\n\t// sampler for production environments is recommended.\n\ttrace.ApplyConfig(trace.Config{DefaultSampler: trace.AlwaysSample()})\n\n\texporter, err := texporter.New(\n\t\ttexporter.WithTraceClientOptions([]option.ClientOption{option.WithTelemetryDisabled()}),\n\t\ttexporter.WithProjectID(\"mycoolproject\"),\n\t)\n\tif err != nil {\n\t\t// Handle error\n\t}\n\n\ttp := sdktrace.NewTracerProvider(sdktrace.WithSyncer(exporter))\n\totel.SetTracerProvider(tp)\n\ttracer := tp.Tracer(\"Cloud SQL Go Connector Trace\")\n\ttrace.DefaultTracer = opencensus.NewTracer(tracer)\n\n\t// Use cloudsqlconn as usual.\n\t// ...\n}\n```\n\nA known OpenTelemetry issue has been reported [here](https://github.com/googleapis/google-cloud-go/issues/7100).\nIt shouldn't impact database operations.\n\n[OpenCensus]: https://opencensus.io/\n[exporter]: https://opencensus.io/exporters/\n[Cloud Monitoring]: https://cloud.google.com/monitoring\n[Cloud Trace]: https://cloud.google.com/trace\n\n### Debug Logging\n\nThe Go Connector supports optional debug logging to help diagnose problems with\nthe background certificate refresh. To enable it, provide a logger that\nimplements the `debug.ContextLogger` interface when initializing the Dialer.\n\nFor example:\n\n``` go\nimport (\n    \"context\"\n    \"net\"\n\n    \"cloud.google.com/go/cloudsqlconn\"\n)\n\ntype myLogger struct{}\n\nfunc (l *myLogger) Debugf(ctx context.Context, format string, args ...interface{}) {\n    // Log as you like here\n}\n\nfunc connect() {\n    l := \u0026myLogger{}\n\n    d, err := NewDialer(\n        context.Background(),\n        cloudsqlconn.WithContextDebugLogger(l),\n    )\n    // use dialer as usual...\n}\n```\n\n## Support policy\n\n### Major version lifecycle\n\nThis project uses [semantic versioning](https://semver.org/), and uses the\nfollowing lifecycle regarding support for a major version:\n\n**Active** - Active versions get all new features and security fixes (that\nwouldn’t otherwise introduce a breaking change). New major versions are\nguaranteed to be \"active\" for a minimum of 1 year.\n\n**Deprecated** - Deprecated versions continue to receive security and critical\nbug fixes, but do not receive new features. Deprecated versions will be\nsupported for 1 year.\n\n**Unsupported** - Any major version that has been deprecated for \u003e=1 year is\nconsidered unsupported.\n\n### Supported Go Versions\n\nWe follow the [Go Version Support Policy][go-policy] used by Google Cloud\nLibraries for Go.\n\n[go-policy]: https://github.com/googleapis/google-cloud-go#go-versions-supported\n\n### Release cadence\n\nThis project aims for a release on at least a monthly basis. If no new features\nor fixes have been added, a new PATCH version with the latest dependencies is\nreleased.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglecloudplatform%2Fcloud-sql-go-connector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgooglecloudplatform%2Fcloud-sql-go-connector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglecloudplatform%2Fcloud-sql-go-connector/lists"}