go-sql-spanner
go-sql-spanner copied to clipboard
Unable to specify spanner.ClientConfig.SessionLabels
SessionLabels are used to distinguish different systems connecting to spanner and to help diagnosing problems. Currently there's no way to set session labels for connections created by go-sql-spanner. It would be helpful to specify these values.
https://pkg.go.dev/cloud.google.com/go/spanner#ClientConfig.SessionLabels
I can see two approaches here:
A. Add a new options to DSN in https://github.com/googleapis/go-sql-spanner/blob/94bc4174c8386e46eab510acdc65c39c42d4024b/driver.go#L187, which would allow to set the config.SessionLabels.
B. Create something like func NewConnector(..., config spanner.ClientConfig) (Connector, error), which could be used in combination with https://pkg.go.dev/database/sql#OpenDB. (This also avoids some of the issues with regards to using global registry for registering connectors).
The A. approach has the benefit of not needing a new API function and can nicely hook into the existing system. However, since it's a "map[string]string" encoding the arguments in a DSN can be unwieldy.
The B. approach has the benefit of exposing everything on spanner.ClientConfig, making it possible to set everything and also doesn't need changing when new features are added to spanner.ClientConfig. Although, it will require designing new API, with multiple additional options for the client ([]option.ClientOption).