From 1affbec82d5ef9fbc36418e10292f102307f05b0 Mon Sep 17 00:00:00 2001 From: rahul yadav Date: Tue, 6 Aug 2024 19:00:55 +0530 Subject: [PATCH] chore(spanner): add support of client side native metrics collection and export --- spanner/apiv1/spanner_client_options.go | 8 + spanner/client.go | 67 ++++ spanner/go.mod | 13 +- spanner/go.sum | 45 ++- spanner/grpc_client.go | 498 ++++++++++++++++++++++++ spanner/integration_test.go | 3 - spanner/metrics.go | 469 ++++++++++++++++++++++ spanner/metrics_monitoring_exporter.go | 344 ++++++++++++++++ spanner/read_test.go | 3 +- spanner/session.go | 13 +- spanner/sessionclient.go | 45 +-- spanner/sessionclient_test.go | 2 +- spanner/test/opentelemetry/test/go.mod | 4 + spanner/test/opentelemetry/test/go.sum | 36 ++ spanner/transaction.go | 3 +- 15 files changed, 1500 insertions(+), 53 deletions(-) create mode 100644 spanner/grpc_client.go create mode 100644 spanner/metrics.go create mode 100644 spanner/metrics_monitoring_exporter.go diff --git a/spanner/apiv1/spanner_client_options.go b/spanner/apiv1/spanner_client_options.go index 5b924b5d1d74..1e370cfdf1c0 100644 --- a/spanner/apiv1/spanner_client_options.go +++ b/spanner/apiv1/spanner_client_options.go @@ -23,3 +23,11 @@ import "google.golang.org/api/option" func DefaultClientOptions() []option.ClientOption { return defaultGRPCClientOptions() } + +// Returns the default call options used by the generated Spanner client. +// +// This function is only intended for use by the client library, and may be +// removed at any time without any warning. +func DefaultCallOptions() *CallOptions { + return defaultCallOptions() +} diff --git a/spanner/client.go b/spanner/client.go index 5d3d078a5b0d..3d7550c28437 100644 --- a/spanner/client.go +++ b/spanner/client.go @@ -31,8 +31,10 @@ import ( "github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp" grpcgcppb "github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp/grpc_gcp" "github.com/googleapis/gax-go/v2" + go_grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/metric/noop" "google.golang.org/api/iterator" "google.golang.org/api/option" "google.golang.org/api/option/internaloption" @@ -42,6 +44,7 @@ import ( "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/encoding/gzip" "google.golang.org/grpc/metadata" + "google.golang.org/grpc/peer" vkit "cloud.google.com/go/spanner/apiv1" "cloud.google.com/go/spanner/internal" @@ -96,6 +99,9 @@ func parseDatabaseName(db string) (project, instance, database string, err error return matches[1], matches[2], matches[3], nil } +// PeerKey is a key used to store peer information in a context. +type PeerKey struct{} + // Client is a client for reading and writing data to a Cloud Spanner database. // A client is safe to use concurrently, except for its Close method. type Client struct { @@ -111,6 +117,7 @@ type Client struct { disableRouteToLeader bool dro *sppb.DirectedReadOptions otConfig *openTelemetryConfig + metricsTracerFactory *builtinMetricsTracerFactory } // DatabaseName returns the full name of a database, e.g., @@ -461,6 +468,21 @@ func newClientWithConfig(ctx context.Context, database string, config ClientConf sc.otConfig = otConfig sc.mu.Unlock() + metricsProvider := otConfig.meterProvider + if emulatorAddr := os.Getenv("SPANNER_EMULATOR_HOST"); emulatorAddr != "" { + // Do not emit metrics when emulator is being used + metricsProvider = noop.NewMeterProvider() + } + + // Create a OpenTelemetry metrics configuration + metricsTracerFactory, err := newBuiltinMetricsTracerFactory(ctx, database, metricsProvider) + if err != nil { + metricsProvider = noop.NewMeterProvider() + } + sc.mu.Lock() + sc.metricsTracerFactory = metricsTracerFactory + sc.mu.Unlock() + // Create a session pool. config.SessionPoolConfig.sessionLabels = sessionLabels sp, err := newSessionPool(sc, config.SessionPoolConfig) @@ -482,6 +504,7 @@ func newClientWithConfig(ctx context.Context, database string, config ClientConf disableRouteToLeader: config.DisableRouteToLeader, dro: config.DirectedReadOptions, otConfig: otConfig, + metricsTracerFactory: metricsTracerFactory, } return c, nil } @@ -540,6 +563,8 @@ func allClientOpts(numChannels int, compression string, userOpts ...option.Clien } if enableDirectPathXds, _ := strconv.ParseBool(os.Getenv("GOOGLE_SPANNER_ENABLE_DIRECT_ACCESS")); enableDirectPathXds { clientDefaultOpts = append(clientDefaultOpts, internaloption.EnableDirectPath(true), internaloption.EnableDirectPathXds()) + clientDefaultOpts = append(clientDefaultOpts, option.WithGRPCDialOption(grpc.WithUnaryInterceptor(AddUnaryPeerInterceptor())), + option.WithGRPCDialOption(grpc.WithStreamInterceptor(AddStreamPeerInterceptor()))) } if compression == "gzip" { userOpts = append(userOpts, option.WithGRPCDialOption(grpc.WithDefaultCallOptions( @@ -549,6 +574,45 @@ func allClientOpts(numChannels int, compression string, userOpts ...option.Clien return append(allDefaultOpts, userOpts...) } +func unaryPeerSetter() grpc.UnaryClientInterceptor { + return func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, + invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { + p, ok := ctx.Value(PeerKey{}).(*peer.Peer) + if ok { + opts = append(opts, grpc.Peer(p)) + } + + return invoker(ctx, method, req, reply, cc, opts...) + } +} + +// streamPeerSetter makes the grpc connection include peer information in a context variable keyed by PeerKey{} if it exists. +func streamPeerSetter() grpc.StreamClientInterceptor { + return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, + streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { + p, ok := ctx.Value(PeerKey{}).(*peer.Peer) + if ok { + opts = append(opts, grpc.Peer(p)) + } + + return streamer(ctx, desc, cc, method, opts...) + } +} + +// AddUnaryPeerInterceptor intercepts unary requests and add PeerKey. +func AddUnaryPeerInterceptor() grpc.UnaryClientInterceptor { + unaryInterceptors := []grpc.UnaryClientInterceptor{} + unaryInterceptors = append(unaryInterceptors, unaryPeerSetter()) + return go_grpc_middleware.ChainUnaryClient(unaryInterceptors...) +} + +// AddStreamPeerInterceptor intercepts stream requests and add PeerKey. +func AddStreamPeerInterceptor() grpc.StreamClientInterceptor { + streamInterceptors := []grpc.StreamClientInterceptor{} + streamInterceptors = append(streamInterceptors, streamPeerSetter()) + return go_grpc_middleware.ChainStreamClient(streamInterceptors...) +} + // getQueryOptions returns the query options overwritten by the environment // variables if exist. The input parameter is the query options set by users // via application-level configuration. If the environment variables are set, @@ -570,6 +634,9 @@ func getQueryOptions(opts QueryOptions) QueryOptions { // Close closes the client. func (c *Client) Close() { + if c.metricsTracerFactory != nil { + c.metricsTracerFactory.shutdown() + } if c.idleSessions != nil { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() diff --git a/spanner/go.mod b/spanner/go.mod index 1af591b4cdda..e41024af87db 100644 --- a/spanner/go.mod +++ b/spanner/go.mod @@ -6,12 +6,17 @@ require ( cloud.google.com/go v0.115.1 cloud.google.com/go/iam v1.1.13 cloud.google.com/go/longrunning v0.5.12 + cloud.google.com/go/monitoring v1.20.3 github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.0 github.com/google/go-cmp v0.6.0 + github.com/google/uuid v1.6.0 github.com/googleapis/gax-go/v2 v2.13.0 + github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 go.opencensus.io v0.24.0 + go.opentelemetry.io/contrib/detectors/gcp v1.28.0 go.opentelemetry.io/otel v1.28.0 go.opentelemetry.io/otel/metric v1.28.0 + go.opentelemetry.io/otel/sdk/metric v1.28.0 golang.org/x/oauth2 v0.22.0 golang.org/x/sync v0.8.0 google.golang.org/api v0.193.0 @@ -27,6 +32,7 @@ require ( cloud.google.com/go/auth v0.9.0 // indirect cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect cloud.google.com/go/compute/metadata v0.5.0 // indirect + github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.24.0 // indirect github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b // indirect @@ -38,15 +44,14 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/s2a-go v0.1.8 // indirect - github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect - go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.52.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect go.opentelemetry.io/otel/sdk v1.28.0 // indirect go.opentelemetry.io/otel/trace v1.28.0 // indirect golang.org/x/crypto v0.26.0 // indirect golang.org/x/net v0.28.0 // indirect - golang.org/x/sys v0.24.0 // indirect + golang.org/x/sys v0.23.0 // indirect golang.org/x/text v0.17.0 // indirect golang.org/x/time v0.6.0 // indirect ) diff --git a/spanner/go.sum b/spanner/go.sum index f3e595f9856f..ec2035bf84cb 100644 --- a/spanner/go.sum +++ b/spanner/go.sum @@ -378,6 +378,8 @@ cloud.google.com/go/monitoring v1.7.0/go.mod h1:HpYse6kkGo//7p6sT0wsIC6IBDET0RhI cloud.google.com/go/monitoring v1.8.0/go.mod h1:E7PtoMJ1kQXWxPjB6mv2fhC5/15jInuulFdYYtlcvT4= cloud.google.com/go/monitoring v1.12.0/go.mod h1:yx8Jj2fZNEkL/GYZyTLS4ZtZEZN8WtDEiEqG4kLK50w= cloud.google.com/go/monitoring v1.13.0/go.mod h1:k2yMBAB1H9JT/QETjNkgdCGD9bPF712XiLTVr+cBrpw= +cloud.google.com/go/monitoring v1.20.3 h1:v/7MXFxYrhXLEZ9sSfwXdlTLLB/xrU7xTyYjY5acynQ= +cloud.google.com/go/monitoring v1.20.3/go.mod h1:GPIVIdNznIdGqEjtRKQWTLcUeRnPjZW85szouimiczU= cloud.google.com/go/networkconnectivity v1.4.0/go.mod h1:nOl7YL8odKyAOtzNX73/M5/mGZgqqMeryi6UPZTk/rA= cloud.google.com/go/networkconnectivity v1.5.0/go.mod h1:3GzqJx7uhtlM3kln0+x5wyFvuVH1pIBJjhCpjzSt75o= cloud.google.com/go/networkconnectivity v1.6.0/go.mod h1:OJOoEXW+0LAxHh89nXd64uGG+FbQoeH8DtxCHVOMlaM= @@ -613,6 +615,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.0 h1:oVLqHXhnYtUwM89y9T1fXGaK9wTkXHgNp8/ZNMQzUxE= github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.0/go.mod h1:dppbR7CwXD4pgtV9t3wD1812RaLDcBjtblcDF5f1vI0= +github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.24.0 h1:N4xzkSD2BkRwEZSPf3C2eUZxjS5trpo4gOwRh8mu+BA= +github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.24.0/go.mod h1:p2puVVSKjQ84Qb1gzw2XHLs34WQyHTYFZLaVxypAFYs= github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY= @@ -624,6 +628,7 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd github.com/apache/arrow/go/v10 v10.0.1/go.mod h1:YvhnlEePVnBS4+0z3fhPfUy7W1Ikj0Ih0vcRo/gZ1M0= github.com/apache/arrow/go/v11 v11.0.0/go.mod h1:Eg5OsL5H+e299f7u5ssuXsuHQVEGC4xei5aX110hRiI= github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -692,8 +697,10 @@ github.com/go-fonts/stix v0.1.0/go.mod h1:w/c1f0ldAUlJmLBvlbkvVXLAD+tAMqobIIQpmn github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-latex/latex v0.0.0-20210118124228-b3d85cf34e07/go.mod h1:CO1AlKB2CSIqUrmQPqA0gdRIlnLEY0gK5JGjh37zN5U= github.com/go-latex/latex v0.0.0-20210823091927-c0d11ff05a81/go.mod h1:SX0U8uGpxhq9o2S/CELCSUxEWWAuoCUcVCQWv7G2OCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -701,7 +708,9 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-pdf/fpdf v0.5.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= github.com/go-pdf/fpdf v0.6.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= @@ -812,6 +821,8 @@ github.com/googleapis/gax-go/v2 v2.13.0 h1:yitjD5f7jQHhyDsnhKEBU52NdvvdSeGzlAnDP github.com/googleapis/gax-go/v2 v2.13.0/go.mod h1:Z/fvTZXF8/uw7Xu5GuslPw+bplx6SS338j1Is2S+B7A= github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= @@ -825,10 +836,12 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -844,6 +857,7 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY= github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= @@ -865,14 +879,17 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -901,21 +918,29 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.52.0 h1:vS1Ao/R55RNV4O7TA2Qopok8yN+X0LIP6RVWLFkprck= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.52.0/go.mod h1:BMsdeOxN04K0L5FNUBfjFdvwWGNe/rkmSwH4Aelu/X0= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 h1:4K4tsIXefpVJtvA/8srF4V4y0akAoPHkIslgAkjixJA= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0/go.mod h1:jjdQuTGVsXV4vSs+CJ2qYDeDPf9yIJV23qlIzBm73Vg= +go.opentelemetry.io/contrib/detectors/gcp v1.28.0 h1:eAaOyCwPqwAG7INWn0JTDD3KFR4qbSlhh0YCuFOmmDE= +go.opentelemetry.io/contrib/detectors/gcp v1.28.0/go.mod h1:9BIqH22qyHWAiZxQh0whuJygro59z+nbMVuc7ciiGug= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= +go.opentelemetry.io/otel/sdk/metric v1.28.0 h1:OkuaKgKrgAbYrrY0t92c+cC+2F6hsFNnCQArXCKlg08= +go.opentelemetry.io/otel/sdk/metric v1.28.0/go.mod h1:cWPjykihLAPvXKi4iZc1dpER3Jdq2Z0YLse3moQUCpg= go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -1096,6 +1121,7 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1145,6 +1171,7 @@ golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1169,8 +1196,8 @@ golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= +golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= @@ -1223,6 +1250,7 @@ golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -1245,6 +1273,7 @@ golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= @@ -1254,6 +1283,7 @@ golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= @@ -1369,6 +1399,7 @@ google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= @@ -1555,7 +1586,9 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/spanner/grpc_client.go b/spanner/grpc_client.go new file mode 100644 index 000000000000..b44443f161f6 --- /dev/null +++ b/spanner/grpc_client.go @@ -0,0 +1,498 @@ +/* +Copyright 2024 Google LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package spanner + +import ( + "context" + "fmt" + "net/url" + "strings" + "time" + + "github.com/googleapis/gax-go/v2" + "google.golang.org/api/option" + gtransport "google.golang.org/api/transport/grpc" + "google.golang.org/grpc" + "google.golang.org/grpc/peer" + + vkit "cloud.google.com/go/spanner/apiv1" + "cloud.google.com/go/spanner/apiv1/spannerpb" + "cloud.google.com/go/spanner/internal" +) + +const ( + directPathIPV6Prefix = "[2001:4860:8040" + directPathIPV4Prefix = "34.126" +) + +// spannerClient is an interface that defines the methods available from Cloud Spanner API. +type spannerClient interface { + Close() error + setGoogleClientInfo(...string) + Connection() *grpc.ClientConn + CreateSession(context.Context, *spannerpb.CreateSessionRequest, ...gax.CallOption) (*spannerpb.Session, error) + BatchCreateSessions(context.Context, *spannerpb.BatchCreateSessionsRequest, ...gax.CallOption) (*spannerpb.BatchCreateSessionsResponse, error) + GetSession(context.Context, *spannerpb.GetSessionRequest, ...gax.CallOption) (*spannerpb.Session, error) + ListSessions(context.Context, *spannerpb.ListSessionsRequest, ...gax.CallOption) *vkit.SessionIterator + DeleteSession(context.Context, *spannerpb.DeleteSessionRequest, ...gax.CallOption) error + ExecuteSql(context.Context, *spannerpb.ExecuteSqlRequest, ...gax.CallOption) (*spannerpb.ResultSet, error) + ExecuteStreamingSql(context.Context, *spannerpb.ExecuteSqlRequest, ...gax.CallOption) (spannerpb.Spanner_ExecuteStreamingSqlClient, error) + ExecuteBatchDml(context.Context, *spannerpb.ExecuteBatchDmlRequest, ...gax.CallOption) (*spannerpb.ExecuteBatchDmlResponse, error) + Read(context.Context, *spannerpb.ReadRequest, ...gax.CallOption) (*spannerpb.ResultSet, error) + StreamingRead(context.Context, *spannerpb.ReadRequest, ...gax.CallOption) (spannerpb.Spanner_StreamingReadClient, error) + BeginTransaction(context.Context, *spannerpb.BeginTransactionRequest, ...gax.CallOption) (*spannerpb.Transaction, error) + Commit(context.Context, *spannerpb.CommitRequest, ...gax.CallOption) (*spannerpb.CommitResponse, error) + Rollback(context.Context, *spannerpb.RollbackRequest, ...gax.CallOption) error + PartitionQuery(context.Context, *spannerpb.PartitionQueryRequest, ...gax.CallOption) (*spannerpb.PartitionResponse, error) + PartitionRead(context.Context, *spannerpb.PartitionReadRequest, ...gax.CallOption) (*spannerpb.PartitionResponse, error) + BatchWrite(context.Context, *spannerpb.BatchWriteRequest, ...gax.CallOption) (spannerpb.Spanner_BatchWriteClient, error) +} + +// grpcSpannerClient is the gRPC API implementation of the transport-agnostic +// spannerClient interface. +type grpcSpannerClient struct { + raw *vkit.Client + connPool gtransport.ConnPool + client spannerpb.SpannerClient + CallOptions **vkit.CallOptions + xGoogHeaders []string + metricsTracerFactory *builtinMetricsTracerFactory +} + +var ( + // Ensure that grpcSpannerClient implements spannerClient. + _ spannerClient = (*grpcSpannerClient)(nil) +) + +// newGRPCSpannerClient initializes a new spannerClient that uses the gRPC +// Spanner API. +func newGRPCSpannerClient(ctx context.Context, sc *sessionClient, opts ...option.ClientOption) (spannerClient, error) { + raw, err := vkit.NewClient(ctx, opts...) + if err != nil { + return nil, err + } + clientOpts := vkit.DefaultClientOptions() + connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) + if err != nil { + return nil, err + } + clientInfo := []string{"gccl", internal.Version} + if sc.userAgent != "" { + agentWithVersion := strings.SplitN(sc.userAgent, "/", 2) + if len(agentWithVersion) == 2 { + clientInfo = append(clientInfo, agentWithVersion[0], agentWithVersion[1]) + } + } + raw.SetGoogleClientInfo(clientInfo...) + if sc.callOptions != nil { + raw.CallOptions = mergeCallOptions(raw.CallOptions, sc.callOptions) + } + + return &grpcSpannerClient{raw: raw, metricsTracerFactory: sc.metricsTracerFactory, connPool: connPool, client: spannerpb.NewSpannerClient(connPool)}, nil +} + +func (g *grpcSpannerClient) newBuiltinMetricsTracer(ctx context.Context, isStreaming bool) *builtinMetricsTracer { + mt := g.metricsTracerFactory.createBuiltinMetricsTracer(ctx, isStreaming) + return &mt +} + +func (g *grpcSpannerClient) setGoogleClientInfo(keyval ...string) { + g.raw.SetGoogleClientInfo(keyval...) + kv := append([]string{"gl-go", gax.GoVersion}, keyval...) + kv = append(kv, "gapic", internal.Version, "gax", gax.Version, "grpc", grpc.Version) + g.xGoogHeaders = []string{ + "x-goog-api-client", gax.XGoogHeader(kv...), + } +} + +func (g *grpcSpannerClient) Close() error { + return g.raw.Close() +} + +func (g *grpcSpannerClient) Connection() *grpc.ClientConn { + return g.raw.Connection() +} + +func (g *grpcSpannerClient) CreateSession(ctx context.Context, req *spannerpb.CreateSessionRequest, opts ...gax.CallOption) (*spannerpb.Session, error) { + mt := g.newBuiltinMetricsTracer(ctx, false) + defer recordOperationCompletion(mt) + hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "database", url.QueryEscape(req.GetDatabase()))} + + hds = append(g.xGoogHeaders, hds...) + ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) + opts = append((*g.raw.CallOptions).CreateSession[0:len((*g.raw.CallOptions).CreateSession):len((*g.raw.CallOptions).CreateSession)], opts...) + var resp *spannerpb.Session + err := gaxInvokeWithRecorder(ctx, mt, "CreateSession", func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = g.client.CreateSession(ctx, req, settings.GRPC...) + return err + }, opts...) + statusCode, _ := convertToGrpcStatusErr(err) + mt.currOp.setStatus(statusCode.String()) + if err != nil { + return nil, err + } + return resp, nil +} + +func (g *grpcSpannerClient) BatchCreateSessions(ctx context.Context, req *spannerpb.BatchCreateSessionsRequest, opts ...gax.CallOption) (*spannerpb.BatchCreateSessionsResponse, error) { + mt := g.newBuiltinMetricsTracer(ctx, false) + defer recordOperationCompletion(mt) + hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "database", url.QueryEscape(req.GetDatabase()))} + + hds = append(g.xGoogHeaders, hds...) + ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) + opts = append((*g.raw.CallOptions).BatchCreateSessions[0:len((*g.raw.CallOptions).BatchCreateSessions):len((*g.raw.CallOptions).BatchCreateSessions)], opts...) + var resp *spannerpb.BatchCreateSessionsResponse + err := gaxInvokeWithRecorder(ctx, mt, "BatchCreateSessions", func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = g.client.BatchCreateSessions(ctx, req, settings.GRPC...) + return err + }, opts...) + statusCode, _ := convertToGrpcStatusErr(err) + mt.currOp.setStatus(statusCode.String()) + if err != nil { + return nil, err + } + return resp, nil +} + +func (g *grpcSpannerClient) GetSession(ctx context.Context, req *spannerpb.GetSessionRequest, opts ...gax.CallOption) (*spannerpb.Session, error) { + mt := g.newBuiltinMetricsTracer(ctx, false) + defer recordOperationCompletion(mt) + hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} + + hds = append(g.xGoogHeaders, hds...) + ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) + opts = append((*g.raw.CallOptions).GetSession[0:len((*g.raw.CallOptions).GetSession):len((*g.raw.CallOptions).GetSession)], opts...) + var resp *spannerpb.Session + err := gaxInvokeWithRecorder(ctx, mt, "GetSession", func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = g.client.GetSession(ctx, req, settings.GRPC...) + return err + }, opts...) + statusCode, _ := convertToGrpcStatusErr(err) + mt.currOp.setStatus(statusCode.String()) + if err != nil { + return nil, err + } + return resp, nil +} + +func (g *grpcSpannerClient) ListSessions(ctx context.Context, req *spannerpb.ListSessionsRequest, opts ...gax.CallOption) *vkit.SessionIterator { + return g.raw.ListSessions(ctx, req, opts...) +} + +func (g *grpcSpannerClient) DeleteSession(ctx context.Context, req *spannerpb.DeleteSessionRequest, opts ...gax.CallOption) error { + mt := g.newBuiltinMetricsTracer(ctx, false) + defer recordOperationCompletion(mt) + hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} + + hds = append(g.xGoogHeaders, hds...) + ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) + opts = append((*g.raw.CallOptions).DeleteSession[0:len((*g.raw.CallOptions).DeleteSession):len((*g.raw.CallOptions).DeleteSession)], opts...) + err := gaxInvokeWithRecorder(ctx, mt, "DeleteSession", func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = g.client.DeleteSession(ctx, req, settings.GRPC...) + return err + }, opts...) + statusCode, _ := convertToGrpcStatusErr(err) + mt.currOp.setStatus(statusCode.String()) + return err +} + +func (g *grpcSpannerClient) ExecuteSql(ctx context.Context, req *spannerpb.ExecuteSqlRequest, opts ...gax.CallOption) (*spannerpb.ResultSet, error) { + mt := g.newBuiltinMetricsTracer(ctx, false) + defer recordOperationCompletion(mt) + hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "session", url.QueryEscape(req.GetSession()))} + + hds = append(g.xGoogHeaders, hds...) + ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) + opts = append((*g.raw.CallOptions).ExecuteSql[0:len((*g.raw.CallOptions).ExecuteSql):len((*g.raw.CallOptions).ExecuteSql)], opts...) + var resp *spannerpb.ResultSet + err := gaxInvokeWithRecorder(ctx, mt, "ExecuteSql", func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = g.client.ExecuteSql(ctx, req, settings.GRPC...) + return err + }, opts...) + statusCode, _ := convertToGrpcStatusErr(err) + mt.currOp.setStatus(statusCode.String()) + if err != nil { + return nil, err + } + return resp, nil +} + +func (g *grpcSpannerClient) ExecuteStreamingSql(ctx context.Context, req *spannerpb.ExecuteSqlRequest, opts ...gax.CallOption) (spannerpb.Spanner_ExecuteStreamingSqlClient, error) { + mt := g.newBuiltinMetricsTracer(ctx, true) + defer recordOperationCompletion(mt) + hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "session", url.QueryEscape(req.GetSession()))} + + hds = append(g.xGoogHeaders, hds...) + ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) + opts = append((*g.raw.CallOptions).ExecuteStreamingSql[0:len((*g.raw.CallOptions).ExecuteStreamingSql):len((*g.raw.CallOptions).ExecuteStreamingSql)], opts...) + var resp spannerpb.Spanner_ExecuteStreamingSqlClient + err := gaxInvokeWithRecorder(ctx, mt, "ExecuteStreamingSql", func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = g.client.ExecuteStreamingSql(ctx, req, settings.GRPC...) + return err + }, opts...) + statusCode, _ := convertToGrpcStatusErr(err) + mt.currOp.setStatus(statusCode.String()) + if err != nil { + return nil, err + } + return resp, nil +} + +func (g *grpcSpannerClient) ExecuteBatchDml(ctx context.Context, req *spannerpb.ExecuteBatchDmlRequest, opts ...gax.CallOption) (*spannerpb.ExecuteBatchDmlResponse, error) { + mt := g.newBuiltinMetricsTracer(ctx, false) + defer recordOperationCompletion(mt) + hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "session", url.QueryEscape(req.GetSession()))} + + hds = append(g.xGoogHeaders, hds...) + ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) + opts = append((*g.raw.CallOptions).ExecuteBatchDml[0:len((*g.raw.CallOptions).ExecuteBatchDml):len((*g.raw.CallOptions).ExecuteBatchDml)], opts...) + var resp *spannerpb.ExecuteBatchDmlResponse + err := gaxInvokeWithRecorder(ctx, mt, "ExecuteBatchDml", func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = g.client.ExecuteBatchDml(ctx, req, settings.GRPC...) + return err + }, opts...) + statusCode, _ := convertToGrpcStatusErr(err) + mt.currOp.setStatus(statusCode.String()) + if err != nil { + return nil, err + } + return resp, nil +} + +func (g *grpcSpannerClient) Read(ctx context.Context, req *spannerpb.ReadRequest, opts ...gax.CallOption) (*spannerpb.ResultSet, error) { + mt := g.newBuiltinMetricsTracer(ctx, false) + defer recordOperationCompletion(mt) + hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "session", url.QueryEscape(req.GetSession()))} + + hds = append(g.xGoogHeaders, hds...) + ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) + opts = append((*g.raw.CallOptions).Read[0:len((*g.raw.CallOptions).Read):len((*g.raw.CallOptions).Read)], opts...) + var resp *spannerpb.ResultSet + err := gaxInvokeWithRecorder(ctx, mt, "Read", func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = g.client.Read(ctx, req, settings.GRPC...) + return err + }, opts...) + statusCode, _ := convertToGrpcStatusErr(err) + mt.currOp.setStatus(statusCode.String()) + if err != nil { + return nil, err + } + return resp, nil +} + +func (g *grpcSpannerClient) StreamingRead(ctx context.Context, req *spannerpb.ReadRequest, opts ...gax.CallOption) (spannerpb.Spanner_StreamingReadClient, error) { + mt := g.newBuiltinMetricsTracer(ctx, true) + defer recordOperationCompletion(mt) + hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "session", url.QueryEscape(req.GetSession()))} + + hds = append(g.xGoogHeaders, hds...) + ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) + opts = append((*g.raw.CallOptions).StreamingRead[0:len((*g.raw.CallOptions).StreamingRead):len((*g.raw.CallOptions).StreamingRead)], opts...) + var resp spannerpb.Spanner_StreamingReadClient + err := gaxInvokeWithRecorder(ctx, mt, "StreamingRead", func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = g.client.StreamingRead(ctx, req, settings.GRPC...) + return err + }, opts...) + statusCode, _ := convertToGrpcStatusErr(err) + mt.currOp.setStatus(statusCode.String()) + if err != nil { + return nil, err + } + return resp, nil +} + +func (g *grpcSpannerClient) BeginTransaction(ctx context.Context, req *spannerpb.BeginTransactionRequest, opts ...gax.CallOption) (*spannerpb.Transaction, error) { + mt := g.newBuiltinMetricsTracer(ctx, true) + defer recordOperationCompletion(mt) + hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "session", url.QueryEscape(req.GetSession()))} + + hds = append(g.xGoogHeaders, hds...) + ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) + opts = append((*g.raw.CallOptions).BeginTransaction[0:len((*g.raw.CallOptions).BeginTransaction):len((*g.raw.CallOptions).BeginTransaction)], opts...) + var resp *spannerpb.Transaction + err := gaxInvokeWithRecorder(ctx, mt, "BeginTransaction", func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = g.client.BeginTransaction(ctx, req, settings.GRPC...) + return err + }, opts...) + statusCode, _ := convertToGrpcStatusErr(err) + mt.currOp.setStatus(statusCode.String()) + if err != nil { + return nil, err + } + return resp, nil +} + +func (g *grpcSpannerClient) Commit(ctx context.Context, req *spannerpb.CommitRequest, opts ...gax.CallOption) (*spannerpb.CommitResponse, error) { + mt := g.newBuiltinMetricsTracer(ctx, false) + defer recordOperationCompletion(mt) + hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "session", url.QueryEscape(req.GetSession()))} + + hds = append(g.xGoogHeaders, hds...) + ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) + opts = append((*g.raw.CallOptions).Commit[0:len((*g.raw.CallOptions).Commit):len((*g.raw.CallOptions).Commit)], opts...) + var resp *spannerpb.CommitResponse + err := gaxInvokeWithRecorder(ctx, mt, "Commit", func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = g.client.Commit(ctx, req, settings.GRPC...) + return err + }, opts...) + statusCode, _ := convertToGrpcStatusErr(err) + mt.currOp.setStatus(statusCode.String()) + if err != nil { + return nil, err + } + return resp, nil +} + +func (g *grpcSpannerClient) Rollback(ctx context.Context, req *spannerpb.RollbackRequest, opts ...gax.CallOption) error { + mt := g.newBuiltinMetricsTracer(ctx, false) + defer recordOperationCompletion(mt) + hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "session", url.QueryEscape(req.GetSession()))} + + hds = append(g.xGoogHeaders, hds...) + ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) + opts = append((*g.raw.CallOptions).Rollback[0:len((*g.raw.CallOptions).Rollback):len((*g.raw.CallOptions).Rollback)], opts...) + err := gaxInvokeWithRecorder(ctx, mt, "Rollback", func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = g.client.Rollback(ctx, req, settings.GRPC...) + return err + }, opts...) + statusCode, _ := convertToGrpcStatusErr(err) + mt.currOp.setStatus(statusCode.String()) + return err +} + +func (g *grpcSpannerClient) PartitionQuery(ctx context.Context, req *spannerpb.PartitionQueryRequest, opts ...gax.CallOption) (*spannerpb.PartitionResponse, error) { + mt := g.newBuiltinMetricsTracer(ctx, false) + defer recordOperationCompletion(mt) + hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "session", url.QueryEscape(req.GetSession()))} + + hds = append(g.xGoogHeaders, hds...) + ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) + opts = append((*g.raw.CallOptions).PartitionQuery[0:len((*g.raw.CallOptions).PartitionQuery):len((*g.raw.CallOptions).PartitionQuery)], opts...) + var resp *spannerpb.PartitionResponse + err := gaxInvokeWithRecorder(ctx, mt, "PartitionQuery", func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = g.client.PartitionQuery(ctx, req, settings.GRPC...) + return err + }, opts...) + statusCode, _ := convertToGrpcStatusErr(err) + mt.currOp.setStatus(statusCode.String()) + if err != nil { + return nil, err + } + return resp, nil +} + +func (g *grpcSpannerClient) PartitionRead(ctx context.Context, req *spannerpb.PartitionReadRequest, opts ...gax.CallOption) (*spannerpb.PartitionResponse, error) { + mt := g.newBuiltinMetricsTracer(ctx, false) + defer recordOperationCompletion(mt) + hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "session", url.QueryEscape(req.GetSession()))} + + hds = append(g.xGoogHeaders, hds...) + ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) + opts = append((*g.raw.CallOptions).PartitionRead[0:len((*g.raw.CallOptions).PartitionRead):len((*g.raw.CallOptions).PartitionRead)], opts...) + var resp *spannerpb.PartitionResponse + err := gaxInvokeWithRecorder(ctx, mt, "PartitionRead", func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = g.client.PartitionRead(ctx, req, settings.GRPC...) + return err + }, opts...) + statusCode, _ := convertToGrpcStatusErr(err) + mt.currOp.setStatus(statusCode.String()) + if err != nil { + return nil, err + } + return resp, nil +} + +func (g *grpcSpannerClient) BatchWrite(ctx context.Context, req *spannerpb.BatchWriteRequest, opts ...gax.CallOption) (spannerpb.Spanner_BatchWriteClient, error) { + mt := g.newBuiltinMetricsTracer(ctx, false) + defer recordOperationCompletion(mt) + hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "session", url.QueryEscape(req.GetSession()))} + + hds = append(g.xGoogHeaders, hds...) + ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) + opts = append((*g.raw.CallOptions).BatchWrite[0:len((*g.raw.CallOptions).BatchWrite):len((*g.raw.CallOptions).BatchWrite)], opts...) + var resp spannerpb.Spanner_BatchWriteClient + err := gaxInvokeWithRecorder(ctx, mt, "BatchWrite", func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = g.client.BatchWrite(ctx, req, settings.GRPC...) + return err + }, opts...) + statusCode, _ := convertToGrpcStatusErr(err) + mt.currOp.setStatus(statusCode.String()) + if err != nil { + return nil, err + } + return resp, nil +} + +// gaxInvokeWithRecorder: +// - wraps 'f' in a new function 'callWrapper' that: +// - updates tracer state and records built in attempt specific metrics +// - does not return errors seen while recording the metrics +// +// - then, calls gax.Invoke with 'callWrapper' as an argument +func gaxInvokeWithRecorder(ctx context.Context, mt *builtinMetricsTracer, method string, + f func(ctx context.Context, _ gax.CallSettings) error, opts ...gax.CallOption) error { + + mt.method = method + callWrapper := func(ctx context.Context, callSettings gax.CallSettings) error { + peerInfo := &peer.Peer{} + ctx = context.WithValue(ctx, PeerKey{}, peerInfo) + // Increment number of attempts + mt.currOp.incrementAttemptCount() + + mt.currOp.currAttempt = attemptTracer{} + + // record start time + mt.currOp.currAttempt.setStartTime(time.Now()) + + // f makes calls to Spanner service + err := f(ctx, callSettings) + + // Set attempt status + statusCode, _ := convertToGrpcStatusErr(err) + mt.currOp.currAttempt.setStatus(statusCode.String()) + + isDirectPathUsed := false + if peerInfo.Addr != nil { + remoteIP := peerInfo.Addr.String() + if strings.HasPrefix(remoteIP, directPathIPV4Prefix) || strings.HasPrefix(remoteIP, directPathIPV6Prefix) { + isDirectPathUsed = true + } + } + mt.currOp.currAttempt.setDirectPathUsed(isDirectPathUsed) + + // Record attempt specific metrics + recordAttemptCompletion(mt) + return err + } + return gax.Invoke(ctx, callWrapper, opts...) +} diff --git a/spanner/integration_test.go b/spanner/integration_test.go index ae2fd6f32bbe..d4929ccd92c1 100644 --- a/spanner/integration_test.go +++ b/spanner/integration_test.go @@ -63,9 +63,6 @@ import ( ) const ( - directPathIPV6Prefix = "[2001:4860:8040" - directPathIPV4Prefix = "34.126" - singerDDLStatements = "SINGER_DDL_STATEMENTS" simpleDDLStatements = "SIMPLE_DDL_STATEMENTS" readDDLStatements = "READ_DDL_STATEMENTS" diff --git a/spanner/metrics.go b/spanner/metrics.go new file mode 100644 index 000000000000..422c7c4f7257 --- /dev/null +++ b/spanner/metrics.go @@ -0,0 +1,469 @@ +/* +Copyright 2024 Google LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package spanner + +import ( + "context" + "errors" + "fmt" + + "log" + "os" + "strconv" + "time" + + "github.com/google/uuid" + "go.opentelemetry.io/contrib/detectors/gcp" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/metric/noop" + sdkmetric "go.opentelemetry.io/otel/sdk/metric" + semconv "go.opentelemetry.io/otel/semconv/v1.24.0" + "google.golang.org/api/option" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "cloud.google.com/go/spanner/internal" +) + +const ( + builtInMetricsMeterName = "gax-go" + + nativeMetricsPrefix = "spanner.googleapis.com/internal/client/" + + // Monitored resource labels + monitoredResLabelKeyProject = "project_id" + monitoredResLabelKeyInstance = "instance_id" + monitoredResLabelKeyInstanceConfig = "instance_config" + monitoredResLabelKeyLocation = "location" + + // Metric labels + metricLabelKeyClientUID = "client_uid" + metricLabelKeyClientName = "client_name" + metricLabelKeyDatabase = "database" + metricLabelKeyMethod = "method" + metricLabelKeyStatus = "status" + metricLabelKeyDirectPathEnabled = "directpath_enabled" + metricLabelKeyDirectPathUsed = "directpath_used" + + // Metric names + metricNameOperationLatencies = "operation_latencies" + metricNameAttemptLatencies = "attempt_latencies" + metricNameOperationCount = "operation_count" + metricNameAttemptCount = "attempt_count" + + // Metric units + metricUnitMS = "ms" + metricUnitCount = "1" +) + +// These are effectively const, but for testing purposes they are mutable +var ( + // duration between two metric exports + defaultSamplePeriod = 5 * time.Second + + clientName = fmt.Sprintf("go-spanner v%v", internal.Version) + + bucketBounds = []float64{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 8.0, 10.0, 13.0, 16.0, 20.0, 25.0, 30.0, 40.0, + 50.0, 65.0, 80.0, 100.0, 130.0, 160.0, 200.0, 250.0, 300.0, 400.0, 500.0, 650.0, + 800.0, 1000.0, 2000.0, 5000.0, 10000.0, 20000.0, 50000.0, 100000.0, 200000.0, + 400000.0, 800000.0, 1600000.0, 3200000.0} + + // All the built-in metrics have same attributes except 'status' and 'streaming' + // These attributes need to be added to only few of the metrics + metricsDetails = map[string]metricInfo{ + metricNameOperationLatencies: { + additionalAttrs: []string{ + metricLabelKeyStatus, + }, + recordedPerAttempt: false, + }, + metricNameAttemptLatencies: { + additionalAttrs: []string{ + metricLabelKeyStatus, + }, + recordedPerAttempt: true, + }, + metricNameAttemptCount: { + additionalAttrs: []string{ + metricLabelKeyStatus, + }, + recordedPerAttempt: true, + }, + } + + // Generates unique client ID in the format go-@ + generateClientUID = func() (string, error) { + hostname := "localhost" + hostname, err := os.Hostname() + if err != nil { + return "", err + } + return "go-" + uuid.NewString() + "@" + hostname, nil + } + + exporterOpts = []option.ClientOption{} +) + +type metricInfo struct { + additionalAttrs []string + recordedPerAttempt bool +} + +type builtinMetricsTracerFactory struct { + enabled bool + isDirectPathEnabled bool + + // To be called on client close + shutdown func() + + // attributes that are specific to a client instance and + // do not change across different function calls on client + clientAttributes []attribute.KeyValue + + operationLatencies metric.Float64Histogram + attemptLatencies metric.Float64Histogram + operationCount metric.Int64Counter + attemptCount metric.Int64Counter +} + +func detectClientLocation(ctx context.Context) string { + resource, err := gcp.NewDetector().Detect(ctx) + if err != nil { + return "global" + } + for _, attr := range resource.Attributes() { + if attr.Key == semconv.CloudRegionKey { + return attr.Value.AsString() + } + } + // If region is not found, return global + return "global" +} + +func newBuiltinMetricsTracerFactory(ctx context.Context, dbpath string, metricsProvider metric.MeterProvider) (*builtinMetricsTracerFactory, error) { + clientUID, err := generateClientUID() + if err != nil { + log.Printf("built-in metrics: generateClientUID failed: %v. Using empty string in the %v metric atteribute", err, metricLabelKeyClientUID) + } + project, instance, database, err := parseDatabaseName(dbpath) + if err != nil { + return nil, err + } + + tracerFactory := &builtinMetricsTracerFactory{ + enabled: false, + clientAttributes: []attribute.KeyValue{ + attribute.String(monitoredResLabelKeyProject, project), + attribute.String(monitoredResLabelKeyInstance, instance), + attribute.String(metricLabelKeyDatabase, database), + attribute.String(metricLabelKeyClientUID, clientUID), + attribute.String(metricLabelKeyClientName, clientName), + // Skipping instance config until we have a way to get it + attribute.String(monitoredResLabelKeyInstanceConfig, "unknown"), + attribute.String(monitoredResLabelKeyLocation, detectClientLocation(ctx)), + }, + shutdown: func() {}, + } + + tracerFactory.isDirectPathEnabled = false + tracerFactory.isDirectPathEnabled, _ = strconv.ParseBool(os.Getenv("GOOGLE_SPANNER_ENABLE_DIRECT_ACCESS")) + + var meterProvider *sdkmetric.MeterProvider + if metricsProvider == nil { + // Create default meter provider + mpOptions, err := builtInMeterProviderOptions(project) + if err != nil { + return tracerFactory, err + } + meterProvider = sdkmetric.NewMeterProvider(mpOptions...) + + tracerFactory.enabled = true + tracerFactory.shutdown = func() { meterProvider.Shutdown(ctx) } + } else { + switch metricsProvider.(type) { + case noop.MeterProvider: + tracerFactory.enabled = false + return tracerFactory, nil + default: + tracerFactory.enabled = false + return tracerFactory, errors.New("unknown MetricsProvider type") + } + } + + // Create meter and instruments + meter := meterProvider.Meter(builtInMetricsMeterName, metric.WithInstrumentationVersion(internal.Version)) + err = tracerFactory.createInstruments(meter) + return tracerFactory, err +} + +func builtInMeterProviderOptions(project string) ([]sdkmetric.Option, error) { + defaultExporter, err := newMonitoringExporter(context.Background(), project, exporterOpts...) + if err != nil { + return nil, err + } + + return []sdkmetric.Option{sdkmetric.WithReader( + sdkmetric.NewPeriodicReader( + defaultExporter, + sdkmetric.WithInterval(defaultSamplePeriod), + ), + )}, nil +} + +func (tf *builtinMetricsTracerFactory) createInstruments(meter metric.Meter) error { + var err error + + // Create operation_latencies + tf.operationLatencies, err = meter.Float64Histogram( + nativeMetricsPrefix+metricNameOperationLatencies, + metric.WithDescription("Total time until final operation success or failure, including retries and backoff."), + metric.WithUnit(metricUnitMS), + metric.WithExplicitBucketBoundaries(bucketBounds...), + ) + if err != nil { + return err + } + + // Create attempt_latencies + tf.attemptLatencies, err = meter.Float64Histogram( + nativeMetricsPrefix+metricNameAttemptLatencies, + metric.WithDescription("Client observed latency per RPC attempt."), + metric.WithUnit(metricUnitMS), + metric.WithExplicitBucketBoundaries(bucketBounds...), + ) + if err != nil { + return err + } + + // Create operation_count + tf.operationCount, err = meter.Int64Counter( + nativeMetricsPrefix+metricNameOperationCount, + metric.WithDescription("The count of database operations."), + metric.WithUnit(metricUnitCount), + ) + + // Create attempt_count + tf.attemptCount, err = meter.Int64Counter( + nativeMetricsPrefix+metricNameAttemptCount, + metric.WithDescription("The number of additional RPCs sent after the initial attempt."), + metric.WithUnit(metricUnitCount), + ) + return err +} + +// builtinMetricsTracer is created one per operation +// It is used to store metric instruments, attribute values +// and other data required to obtain and record them +type builtinMetricsTracer struct { + ctx context.Context + builtInEnabled bool + + // attributes that are specific to a client instance and + // do not change across different operations on client + clientAttributes []attribute.KeyValue + + instrumentOperationLatencies metric.Float64Histogram + instrumentAttemptLatencies metric.Float64Histogram + instrumentOperationCount metric.Int64Counter + instrumentAttemptCount metric.Int64Counter + + method string + isStreaming bool + + currOp opTracer +} + +// opTracer is used to record metrics for the entire operation, including retries. +// Operation is a logical unit that represents a single method invocation on client. +// The method might require multiple attempts/rpcs and backoff logic to complete +type opTracer struct { + attemptCount int64 + + startTime time.Time + + // gRPC status code of last completed attempt + status string + + directPathEnabled bool + + currAttempt attemptTracer +} + +func (o *opTracer) setStartTime(t time.Time) { + o.startTime = t +} + +func (o *opTracer) setStatus(status string) { + o.status = status +} + +func (o *opTracer) setDirectPathEnabled(directPathEnabled bool) { + o.directPathEnabled = directPathEnabled +} + +func (o *opTracer) incrementAttemptCount() { + o.attemptCount++ +} + +// attemptTracer is used to record metrics for each individual attempt of the operation. +// Attempt corresponds to an attempt of an RPC. +type attemptTracer struct { + startTime time.Time + // gRPC status code + status string + + directPathUsed bool +} + +func (a *attemptTracer) setStartTime(t time.Time) { + a.startTime = t +} + +func (a *attemptTracer) setStatus(status string) { + a.status = status +} + +func (o *attemptTracer) setDirectPathUsed(directPathUsage bool) { + o.directPathUsed = directPathUsage +} + +func (tf *builtinMetricsTracerFactory) createBuiltinMetricsTracer(ctx context.Context, isStreaming bool) builtinMetricsTracer { + // Operation has started but not the attempt. + // So, create only operation tracer and not attempt tracer + currOpTracer := opTracer{} + currOpTracer.setStartTime(time.Now()) + currOpTracer.setDirectPathEnabled(tf.isDirectPathEnabled) + + return builtinMetricsTracer{ + ctx: ctx, + builtInEnabled: tf.enabled, + + currOp: currOpTracer, + clientAttributes: tf.clientAttributes, + + instrumentOperationLatencies: tf.operationLatencies, + instrumentAttemptLatencies: tf.attemptLatencies, + instrumentOperationCount: tf.operationCount, + instrumentAttemptCount: tf.attemptCount, + + isStreaming: isStreaming, + } +} + +// toOtelMetricAttrs: +// - converts metric attributes values captured throughout the operation / attempt +// to OpenTelemetry attributes format, +// - combines these with common client attributes and returns +func (mt *builtinMetricsTracer) toOtelMetricAttrs(metricName string) ([]attribute.KeyValue, error) { + // Create attribute key value pairs for attributes common to all metricss + attrKeyValues := []attribute.KeyValue{ + attribute.String(metricLabelKeyMethod, mt.method), + } + attrKeyValues = append(attrKeyValues, mt.clientAttributes...) + + // Get metric details + mDetails, found := metricsDetails[metricName] + if !found { + return attrKeyValues, fmt.Errorf("unable to create attributes list for unknown metric: %v", metricName) + } + + attrKeyValues = append(attrKeyValues, attribute.Bool(metricLabelKeyDirectPathEnabled, mt.currOp.directPathEnabled)) + attrKeyValues = append(attrKeyValues, attribute.Bool(metricLabelKeyDirectPathUsed, mt.currOp.currAttempt.directPathUsed)) + + rpcStatus := mt.currOp.status + if mDetails.recordedPerAttempt { + rpcStatus = mt.currOp.currAttempt.status + } + + // Add additional attributes to metrics + for _, attrKey := range mDetails.additionalAttrs { + switch attrKey { + case metricLabelKeyStatus: + attrKeyValues = append(attrKeyValues, attribute.String(metricLabelKeyStatus, rpcStatus)) + default: + return attrKeyValues, fmt.Errorf("unknown additional attribute: %v", attrKey) + } + } + + return attrKeyValues, nil +} + +// Convert error to grpc status error +func convertToGrpcStatusErr(err error) (codes.Code, error) { + if err == nil { + return codes.OK, nil + } + + if errStatus, ok := status.FromError(err); ok { + return errStatus.Code(), status.Error(errStatus.Code(), errStatus.Message()) + } + + ctxStatus := status.FromContextError(err) + if ctxStatus.Code() != codes.Unknown { + return ctxStatus.Code(), status.Error(ctxStatus.Code(), ctxStatus.Message()) + } + + return codes.Unknown, err +} + +// recordAttemptCompletion records as many attempt specific metrics as it can +// Ignore errors seen while creating metric attributes since metric can still +// be recorded with rest of the attributes +func recordAttemptCompletion(mt *builtinMetricsTracer) { + if !mt.builtInEnabled { + return + } + + // Calculate elapsed time + elapsedTime := convertToMs(time.Since(mt.currOp.currAttempt.startTime)) + + // Record attempt_latencies + attemptLatAttrs, _ := mt.toOtelMetricAttrs(metricNameAttemptLatencies) + mt.instrumentAttemptLatencies.Record(mt.ctx, elapsedTime, metric.WithAttributes(attemptLatAttrs...)) +} + +// recordOperationCompletion records as many operation specific metrics as it can +// Ignores error seen while creating metric attributes since metric can still +// be recorded with rest of the attributes +func recordOperationCompletion(mt *builtinMetricsTracer) { + if !mt.builtInEnabled { + return + } + + // Calculate elapsed time + elapsedTimeMs := convertToMs(time.Since(mt.currOp.startTime)) + + // Record operation_count + opCntAttrs, _ := mt.toOtelMetricAttrs(metricNameOperationCount) + mt.instrumentOperationCount.Add(mt.ctx, 1, metric.WithAttributes(opCntAttrs...)) + + // Record operation_latencies + opLatAttrs, _ := mt.toOtelMetricAttrs(metricNameOperationLatencies) + mt.instrumentOperationLatencies.Record(mt.ctx, elapsedTimeMs, metric.WithAttributes(opLatAttrs...)) + + // Record attempt_count + attemptCntAttrs, _ := mt.toOtelMetricAttrs(metricNameAttemptCount) + if mt.currOp.attemptCount > 1 { + // Only record when retry count is greater than 0 so the retry + // graph will be less confusing + mt.instrumentAttemptCount.Add(mt.ctx, mt.currOp.attemptCount-1, metric.WithAttributes(attemptCntAttrs...)) + } +} +func convertToMs(d time.Duration) float64 { + return float64(d.Nanoseconds()) / 1000000 +} diff --git a/spanner/metrics_monitoring_exporter.go b/spanner/metrics_monitoring_exporter.go new file mode 100644 index 000000000000..cc5d58e4ef95 --- /dev/null +++ b/spanner/metrics_monitoring_exporter.go @@ -0,0 +1,344 @@ +/* +Copyright 2024 Google LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// This is a modified version of https://github.com/GoogleCloudPlatform/opentelemetry-operations-go/blob/exporter/metric/v0.46.0/exporter/metric/metric.go + +package spanner + +import ( + "context" + "errors" + "fmt" + "math" + "reflect" + "sync" + "time" + + monitoring "cloud.google.com/go/monitoring/apiv3/v2" + "cloud.google.com/go/monitoring/apiv3/v2/monitoringpb" + "go.opentelemetry.io/otel/attribute" + otelmetric "go.opentelemetry.io/otel/sdk/metric" + otelmetricdata "go.opentelemetry.io/otel/sdk/metric/metricdata" + "google.golang.org/api/option" + "google.golang.org/genproto/googleapis/api/distribution" + googlemetricpb "google.golang.org/genproto/googleapis/api/metric" + monitoredrespb "google.golang.org/genproto/googleapis/api/monitoredres" + "google.golang.org/protobuf/types/known/timestamppb" +) + +const ( + spannerResourceType = "spanner_instance_client" + + // The number of timeserieses to send to GCM in a single request. This + // is a hard limit in the GCM API, so we never want to exceed 200. + sendBatchSize = 200 +) + +var ( + monitoredResLabelsSet = map[string]bool{ + monitoredResLabelKeyProject: true, + monitoredResLabelKeyInstance: true, + monitoredResLabelKeyInstanceConfig: true, + monitoredResLabelKeyLocation: true, + } + + errShutdown = fmt.Errorf("exporter is shutdown") +) + +type errUnexpectedAggregationKind struct { + kind string +} + +func (e errUnexpectedAggregationKind) Error() string { + return fmt.Sprintf("the metric kind is unexpected: %v", e.kind) +} + +// monitoringExporter is the implementation of OpenTelemetry metric exporter for +// Google Cloud Monitoring. +// Default exporter for built-in metrics +type monitoringExporter struct { + shutdown chan struct{} + client *monitoring.MetricClient + shutdownOnce sync.Once + projectID string +} + +func newMonitoringExporter(ctx context.Context, project string, opts ...option.ClientOption) (*monitoringExporter, error) { + client, err := monitoring.NewMetricClient(ctx, opts...) + if err != nil { + return nil, err + } + return &monitoringExporter{ + client: client, + shutdown: make(chan struct{}), + projectID: project, + }, nil +} + +// ForceFlush does nothing, the exporter holds no state. +func (e *monitoringExporter) ForceFlush(ctx context.Context) error { return ctx.Err() } + +// Shutdown shuts down the client connections. +func (e *monitoringExporter) Shutdown(ctx context.Context) error { + err := errShutdown + e.shutdownOnce.Do(func() { + close(e.shutdown) + err = errors.Join(ctx.Err(), e.client.Close()) + }) + return err +} + +// Export exports OpenTelemetry Metrics to Google Cloud Monitoring. +func (me *monitoringExporter) Export(ctx context.Context, rm *otelmetricdata.ResourceMetrics) error { + select { + case <-me.shutdown: + return errShutdown + default: + } + + return me.exportTimeSeries(ctx, rm) +} + +// Temporality returns the Temporality to use for an instrument kind. +func (me *monitoringExporter) Temporality(ik otelmetric.InstrumentKind) otelmetricdata.Temporality { + return otelmetricdata.CumulativeTemporality +} + +// Aggregation returns the Aggregation to use for an instrument kind. +func (me *monitoringExporter) Aggregation(ik otelmetric.InstrumentKind) otelmetric.Aggregation { + return otelmetric.DefaultAggregationSelector(ik) +} + +// exportTimeSeries create TimeSeries from the records in cps. +// res should be the common resource among all TimeSeries, such as instance id, application name and so on. +func (me *monitoringExporter) exportTimeSeries(ctx context.Context, rm *otelmetricdata.ResourceMetrics) error { + tss, err := me.recordsToTimeSeriesPbs(rm) + if len(tss) == 0 { + return err + } + + name := fmt.Sprintf("projects/%s", me.projectID) + + errs := []error{err} + for i := 0; i < len(tss); i += sendBatchSize { + j := i + sendBatchSize + if j >= len(tss) { + j = len(tss) + } + + req := &monitoringpb.CreateTimeSeriesRequest{ + Name: name, + TimeSeries: tss[i:j], + } + errs = append(errs, me.client.CreateServiceTimeSeries(ctx, req)) + } + + return errors.Join(errs...) +} + +// recordToMetricAndMonitoredResourcePbs converts data from records to Metric and Monitored resource proto type for Cloud Monitoring. +func (me *monitoringExporter) recordToMetricAndMonitoredResourcePbs(metrics otelmetricdata.Metrics, attributes attribute.Set) (*googlemetricpb.Metric, *monitoredrespb.MonitoredResource) { + mr := &monitoredrespb.MonitoredResource{ + Type: spannerResourceType, + Labels: map[string]string{}, + } + labels := make(map[string]string) + addAttributes := func(attr *attribute.Set) { + iter := attr.Iter() + for iter.Next() { + kv := iter.Attribute() + labelKey := string(kv.Key) + + if _, isResLabel := monitoredResLabelsSet[labelKey]; isResLabel { + // Add labels to monitored resource + mr.Labels[labelKey] = kv.Value.Emit() + } else { + // Add labels to metric + labels[labelKey] = kv.Value.Emit() + + } + } + } + addAttributes(&attributes) + return &googlemetricpb.Metric{ + Type: metrics.Name, + Labels: labels, + }, mr +} + +func (me *monitoringExporter) recordsToTimeSeriesPbs(rm *otelmetricdata.ResourceMetrics) ([]*monitoringpb.TimeSeries, error) { + var ( + tss []*monitoringpb.TimeSeries + errs []error + ) + for _, scope := range rm.ScopeMetrics { + if scope.Scope.Name != builtInMetricsMeterName { + // Filter out metric data for instruments that are not part of the spanner builtin metrics + continue + } + for _, metrics := range scope.Metrics { + ts, err := me.recordToTimeSeriesPb(metrics) + errs = append(errs, err) + tss = append(tss, ts...) + } + } + + return tss, errors.Join(errs...) +} + +// recordToTimeSeriesPb converts record to TimeSeries proto type with common resource. +// ref. https://cloud.google.com/monitoring/api/ref_v3/rest/v3/TimeSeries +func (me *monitoringExporter) recordToTimeSeriesPb(m otelmetricdata.Metrics) ([]*monitoringpb.TimeSeries, error) { + var tss []*monitoringpb.TimeSeries + var errs []error + if m.Data == nil { + return nil, nil + } + switch a := m.Data.(type) { + case otelmetricdata.Histogram[float64]: + for _, point := range a.DataPoints { + metric, mr := me.recordToMetricAndMonitoredResourcePbs(m, point.Attributes) + ts, err := histogramToTimeSeries(point, m, mr) + if err != nil { + errs = append(errs, err) + continue + } + ts.Metric = metric + tss = append(tss, ts) + } + case otelmetricdata.Sum[int64]: + for _, point := range a.DataPoints { + metric, mr := me.recordToMetricAndMonitoredResourcePbs(m, point.Attributes) + var ts *monitoringpb.TimeSeries + var err error + ts, err = sumToTimeSeries[int64](point, m, mr) + if err != nil { + errs = append(errs, err) + continue + } + ts.Metric = metric + tss = append(tss, ts) + } + default: + errs = append(errs, errUnexpectedAggregationKind{kind: reflect.TypeOf(m.Data).String()}) + } + return tss, errors.Join(errs...) +} + +func sumToTimeSeries[N int64 | float64](point otelmetricdata.DataPoint[N], metrics otelmetricdata.Metrics, mr *monitoredrespb.MonitoredResource) (*monitoringpb.TimeSeries, error) { + interval, err := toNonemptyTimeIntervalpb(point.StartTime, point.Time) + if err != nil { + return nil, err + } + value, valueType := numberDataPointToValue[N](point) + return &monitoringpb.TimeSeries{ + Resource: mr, + Unit: string(metrics.Unit), + MetricKind: googlemetricpb.MetricDescriptor_CUMULATIVE, + ValueType: valueType, + Points: []*monitoringpb.Point{{ + Interval: interval, + Value: value, + }}, + }, nil +} + +func histogramToTimeSeries[N int64 | float64](point otelmetricdata.HistogramDataPoint[N], metrics otelmetricdata.Metrics, mr *monitoredrespb.MonitoredResource) (*monitoringpb.TimeSeries, error) { + interval, err := toNonemptyTimeIntervalpb(point.StartTime, point.Time) + if err != nil { + return nil, err + } + distributionValue := histToDistribution(point) + return &monitoringpb.TimeSeries{ + Resource: mr, + Unit: string(metrics.Unit), + MetricKind: googlemetricpb.MetricDescriptor_CUMULATIVE, + ValueType: googlemetricpb.MetricDescriptor_DISTRIBUTION, + Points: []*monitoringpb.Point{{ + Interval: interval, + Value: &monitoringpb.TypedValue{ + Value: &monitoringpb.TypedValue_DistributionValue{ + DistributionValue: distributionValue, + }, + }, + }}, + }, nil +} + +func toNonemptyTimeIntervalpb(start, end time.Time) (*monitoringpb.TimeInterval, error) { + // The end time of a new interval must be at least a millisecond after the end time of the + // previous interval, for all non-gauge types. + // https://cloud.google.com/monitoring/api/ref_v3/rpc/google.monitoring.v3#timeinterval + if end.Sub(start).Milliseconds() <= 1 { + end = start.Add(time.Millisecond) + } + startpb := timestamppb.New(start) + endpb := timestamppb.New(end) + err := errors.Join( + startpb.CheckValid(), + endpb.CheckValid(), + ) + if err != nil { + return nil, err + } + + return &monitoringpb.TimeInterval{ + StartTime: startpb, + EndTime: endpb, + }, nil +} + +func histToDistribution[N int64 | float64](hist otelmetricdata.HistogramDataPoint[N]) *distribution.Distribution { + counts := make([]int64, len(hist.BucketCounts)) + for i, v := range hist.BucketCounts { + counts[i] = int64(v) + } + var mean float64 + if !math.IsNaN(float64(hist.Sum)) && hist.Count > 0 { // Avoid divide-by-zero + mean = float64(hist.Sum) / float64(hist.Count) + } + return &distribution.Distribution{ + Count: int64(hist.Count), + Mean: mean, + BucketCounts: counts, + BucketOptions: &distribution.Distribution_BucketOptions{ + Options: &distribution.Distribution_BucketOptions_ExplicitBuckets{ + ExplicitBuckets: &distribution.Distribution_BucketOptions_Explicit{ + Bounds: hist.Bounds, + }, + }, + }, + } +} + +func numberDataPointToValue[N int64 | float64]( + point otelmetricdata.DataPoint[N], +) (*monitoringpb.TypedValue, googlemetricpb.MetricDescriptor_ValueType) { + switch v := any(point.Value).(type) { + case int64: + return &monitoringpb.TypedValue{Value: &monitoringpb.TypedValue_Int64Value{ + Int64Value: v, + }}, + googlemetricpb.MetricDescriptor_INT64 + case float64: + return &monitoringpb.TypedValue{Value: &monitoringpb.TypedValue_DoubleValue{ + DoubleValue: v, + }}, + googlemetricpb.MetricDescriptor_DOUBLE + } + // It is impossible to reach this statement + return nil, googlemetricpb.MetricDescriptor_INT64 +} diff --git a/spanner/read_test.go b/spanner/read_test.go index 7ef3f550ffe1..966461ee22da 100644 --- a/spanner/read_test.go +++ b/spanner/read_test.go @@ -25,7 +25,6 @@ import ( "testing" "time" - vkit "cloud.google.com/go/spanner/apiv1" sppb "cloud.google.com/go/spanner/apiv1/spannerpb" . "cloud.google.com/go/spanner/internal/testutil" "github.com/googleapis/gax-go/v2" @@ -1774,7 +1773,7 @@ func TestIteratorWithError(t *testing.T) { } } -func createSession(client *vkit.Client) (*sppb.Session, error) { +func createSession(client spannerClient) (*sppb.Session, error) { var formattedDatabase string = fmt.Sprintf("projects/%s/instances/%s/databases/%s", "[PROJECT]", "[INSTANCE]", "[DATABASE]") var request = &sppb.CreateSessionRequest{ Database: formattedDatabase, diff --git a/spanner/session.go b/spanner/session.go index 3e587095a007..1ae6efcb45b0 100644 --- a/spanner/session.go +++ b/spanner/session.go @@ -31,7 +31,6 @@ import ( "time" "cloud.google.com/go/internal/trace" - vkit "cloud.google.com/go/spanner/apiv1" sppb "cloud.google.com/go/spanner/apiv1/spannerpb" "cloud.google.com/go/spanner/internal" "go.opencensus.io/stats" @@ -91,7 +90,7 @@ type sessionHandle struct { // access it directly. session *session // client is the RPC channel to Cloud Spanner. It is set only once during session acquisition. - client *vkit.Client + client spannerClient // checkoutTime is the time the session was checked out of the pool. checkoutTime time.Time // lastUseTime is the time the session was last used after checked out of the pool. @@ -151,7 +150,7 @@ func (sh *sessionHandle) getID() string { // getClient gets the Cloud Spanner RPC client associated with the session ID // in sessionHandle. -func (sh *sessionHandle) getClient() *vkit.Client { +func (sh *sessionHandle) getClient() spannerClient { sh.mu.Lock() defer sh.mu.Unlock() if sh.session == nil { @@ -227,7 +226,7 @@ func (sh *sessionHandle) updateLastUseTime() { type session struct { // client is the RPC channel to Cloud Spanner. It is set only once during // session's creation. - client *vkit.Client + client spannerClient // id is the unique id of the session in Cloud Spanner. It is set only once // during session's creation. id string @@ -603,7 +602,7 @@ type sessionPool struct { // multiplexSessionClientCounter is the counter for the multiplexed session client. multiplexSessionClientCounter int // clientPool is a pool of Cloud Spanner grpc clients. - clientPool []*vkit.Client + clientPool []spannerClient // multiplexedSession contains the multiplexed session multiplexedSession *session // mayGetSession is for broadcasting that session retrival/creation may @@ -1084,14 +1083,14 @@ func (p *sessionPool) newSessionHandle(s *session) (sh *sessionHandle) { return sh } -func (p *sessionPool) getRoundRobinClient() *vkit.Client { +func (p *sessionPool) getRoundRobinClient() spannerClient { p.sc.mu.Lock() defer func() { p.multiplexSessionClientCounter++ p.sc.mu.Unlock() }() if len(p.clientPool) == 0 { - p.clientPool = make([]*vkit.Client, p.sc.connPool.Num()) + p.clientPool = make([]spannerClient, p.sc.connPool.Num()) for i := 0; i < p.sc.connPool.Num(); i++ { c, err := p.sc.nextClient() if err != nil { diff --git a/spanner/sessionclient.go b/spanner/sessionclient.go index e9352bd42c5a..7468f21bc722 100644 --- a/spanner/sessionclient.go +++ b/spanner/sessionclient.go @@ -21,7 +21,6 @@ import ( "fmt" "log" "reflect" - "strings" "sync" "time" @@ -90,17 +89,18 @@ type sessionClient struct { closed bool disableRouteToLeader bool - connPool gtransport.ConnPool - database string - id string - userAgent string - sessionLabels map[string]string - databaseRole string - md metadata.MD - batchTimeout time.Duration - logger *log.Logger - callOptions *vkit.CallOptions - otConfig *openTelemetryConfig + connPool gtransport.ConnPool + database string + id string + userAgent string + sessionLabels map[string]string + databaseRole string + md metadata.MD + batchTimeout time.Duration + logger *log.Logger + callOptions *vkit.CallOptions + otConfig *openTelemetryConfig + metricsTracerFactory *builtinMetricsTracerFactory } // newSessionClient creates a session client to use for a database. @@ -249,9 +249,8 @@ func (sc *sessionClient) batchCreateSessions(createSessionCount int32, distribut // executeBatchCreateSessions executes the gRPC call for creating a batch of // sessions. -func (sc *sessionClient) executeBatchCreateSessions(client *vkit.Client, createCount int32, labels map[string]string, md metadata.MD, consumer sessionConsumer) { +func (sc *sessionClient) executeBatchCreateSessions(client spannerClient, createCount int32, labels map[string]string, md metadata.MD, consumer sessionConsumer) { defer sc.waitWorkers.Done() - ctx, cancel := context.WithTimeout(context.Background(), sc.batchTimeout) defer cancel() ctx = trace.StartSpan(ctx, "cloud.google.com/go/spanner.BatchCreateSessions") @@ -325,7 +324,7 @@ func (sc *sessionClient) executeBatchCreateSessions(client *vkit.Client, createC } } -func (sc *sessionClient) executeCreateMultiplexedSession(ctx context.Context, client *vkit.Client, md metadata.MD, consumer sessionConsumer) { +func (sc *sessionClient) executeCreateMultiplexedSession(ctx context.Context, client spannerClient, md metadata.MD, consumer sessionConsumer) { ctx = trace.StartSpan(ctx, "cloud.google.com/go/spanner.CreateSession") defer func() { trace.EndSpan(ctx, nil) }() trace.TracePrintf(ctx, nil, "Creating a multiplexed session") @@ -395,7 +394,7 @@ func (sc *sessionClient) sessionWithID(id string) (*session, error) { // client is set on the session, and used by all subsequent gRPC calls on the // session. Using the same channel for all gRPC calls for a session ensures the // optimal usage of server side caches. -func (sc *sessionClient) nextClient() (*vkit.Client, error) { +func (sc *sessionClient) nextClient() (spannerClient, error) { var clientOpt option.ClientOption if _, ok := sc.connPool.(*gmeWrapper); ok { // Pass GCPMultiEndpoint as a pool. @@ -404,21 +403,11 @@ func (sc *sessionClient) nextClient() (*vkit.Client, error) { // Pick a grpc.ClientConn from a regular pool. clientOpt = option.WithGRPCConn(sc.connPool.Conn()) } - client, err := vkit.NewClient(context.Background(), clientOpt) + client, err := newGRPCSpannerClient(context.Background(), sc, clientOpt) if err != nil { return nil, err } - clientInfo := []string{"gccl", internal.Version} - if sc.userAgent != "" { - agentWithVersion := strings.SplitN(sc.userAgent, "/", 2) - if len(agentWithVersion) == 2 { - clientInfo = append(clientInfo, agentWithVersion[0], agentWithVersion[1]) - } - } - client.SetGoogleClientInfo(clientInfo...) - if sc.callOptions != nil { - client.CallOptions = mergeCallOptions(client.CallOptions, sc.callOptions) - } + return client, nil } diff --git a/spanner/sessionclient_test.go b/spanner/sessionclient_test.go index d1813754267b..9c3180f991a6 100644 --- a/spanner/sessionclient_test.go +++ b/spanner/sessionclient_test.go @@ -281,7 +281,7 @@ func TestBatchCreateAndCloseSession(t *testing.T) { t.Fatalf("number of sessions created mismatch\ngot: %v\nwant: %v", created, expectedNumSessions) } // Check that all channels are used evenly. - channelCounts := make(map[*vkit.Client]int32) + channelCounts := make(map[spannerClient]int32) for _, s := range consumer.sessions { channelCounts[s.client]++ } diff --git a/spanner/test/opentelemetry/test/go.mod b/spanner/test/opentelemetry/test/go.mod index 2d73f4544f8a..f5473e3e730b 100644 --- a/spanner/test/opentelemetry/test/go.mod +++ b/spanner/test/opentelemetry/test/go.mod @@ -24,7 +24,9 @@ require ( cloud.google.com/go/compute/metadata v0.5.0 // indirect cloud.google.com/go/iam v1.1.13 // indirect cloud.google.com/go/longrunning v0.5.12 // indirect + cloud.google.com/go/monitoring v1.20.3 // indirect github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.0 // indirect + github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.24.0 // indirect github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b // indirect @@ -39,7 +41,9 @@ require ( github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect github.com/googleapis/gax-go/v2 v2.13.0 // indirect + github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect go.opencensus.io v0.24.0 // indirect + go.opentelemetry.io/contrib/detectors/gcp v1.28.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.52.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect go.opentelemetry.io/otel/metric v1.28.0 // indirect diff --git a/spanner/test/opentelemetry/test/go.sum b/spanner/test/opentelemetry/test/go.sum index b3472900d8aa..47c0027c4ef9 100644 --- a/spanner/test/opentelemetry/test/go.sum +++ b/spanner/test/opentelemetry/test/go.sum @@ -1154,6 +1154,7 @@ cloud.google.com/go/monitoring v1.18.1/go.mod h1:52hTzJ5XOUMRm7jYi7928aEdVxBEmGw cloud.google.com/go/monitoring v1.19.0/go.mod h1:25IeMR5cQ5BoZ8j1eogHE5VPJLlReQ7zFp5OiLgiGZw= cloud.google.com/go/monitoring v1.20.1/go.mod h1:FYSe/brgfuaXiEzOQFhTjsEsJv+WePyK71X7Y8qo6uQ= cloud.google.com/go/monitoring v1.20.2/go.mod h1:36rpg/7fdQ7NX5pG5x1FA7cXTVXusOp6Zg9r9e1+oek= +cloud.google.com/go/monitoring v1.20.3 h1:v/7MXFxYrhXLEZ9sSfwXdlTLLB/xrU7xTyYjY5acynQ= cloud.google.com/go/monitoring v1.20.3/go.mod h1:GPIVIdNznIdGqEjtRKQWTLcUeRnPjZW85szouimiczU= cloud.google.com/go/networkconnectivity v1.4.0/go.mod h1:nOl7YL8odKyAOtzNX73/M5/mGZgqqMeryi6UPZTk/rA= cloud.google.com/go/networkconnectivity v1.5.0/go.mod h1:3GzqJx7uhtlM3kln0+x5wyFvuVH1pIBJjhCpjzSt75o= @@ -1851,6 +1852,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.0 h1:oVLqHXhnYtUwM89y9T1fXGaK9wTkXHgNp8/ZNMQzUxE= github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.0/go.mod h1:dppbR7CwXD4pgtV9t3wD1812RaLDcBjtblcDF5f1vI0= +github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.24.0 h1:N4xzkSD2BkRwEZSPf3C2eUZxjS5trpo4gOwRh8mu+BA= +github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.24.0/go.mod h1:p2puVVSKjQ84Qb1gzw2XHLs34WQyHTYFZLaVxypAFYs= github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY= @@ -1873,6 +1876,7 @@ github.com/apache/arrow/go/v14 v14.0.2/go.mod h1:u3fgh3EdgN/YQ8cVQRguVW3R+seMybF github.com/apache/arrow/go/v15 v15.0.2/go.mod h1:DGXsR3ajT524njufqf95822i+KTh+yea1jass9YXgjA= github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU= github.com/apache/thrift v0.17.0/go.mod h1:OLxhMRJxomX+1I/KUw03qoV3mMz16BwaKI+d4fPBx7Q= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -1954,8 +1958,10 @@ github.com/go-fonts/liberation v0.1.1/go.mod h1:K6qoJYypsmfVjWg8KOVDQhLc8UDgIK2H github.com/go-fonts/liberation v0.2.0/go.mod h1:K6qoJYypsmfVjWg8KOVDQhLc8UDgIK2HYqyqAO9z7GY= github.com/go-fonts/stix v0.1.0/go.mod h1:w/c1f0ldAUlJmLBvlbkvVXLAD+tAMqobIIQpmnUIzUY= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-latex/latex v0.0.0-20210118124228-b3d85cf34e07/go.mod h1:CO1AlKB2CSIqUrmQPqA0gdRIlnLEY0gK5JGjh37zN5U= github.com/go-latex/latex v0.0.0-20210823091927-c0d11ff05a81/go.mod h1:SX0U8uGpxhq9o2S/CELCSUxEWWAuoCUcVCQWv7G2OCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -1970,10 +1976,12 @@ github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvSc github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-yaml v1.9.8/go.mod h1:JubOolP3gh0HpiBc4BLRD4YmjEjHAmIIB2aaXKkTfoE= github.com/goccy/go-yaml v1.11.0/go.mod h1:H+mJrWtjPTJAHvRbV09MCK9xYwODM+wRTVFFTWckfng= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= @@ -2083,6 +2091,8 @@ github.com/googleapis/gax-go/v2 v2.13.0 h1:yitjD5f7jQHhyDsnhKEBU52NdvvdSeGzlAnDP github.com/googleapis/gax-go/v2 v2.13.0/go.mod h1:Z/fvTZXF8/uw7Xu5GuslPw+bplx6SS338j1Is2S+B7A= github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= @@ -2098,6 +2108,7 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= @@ -2105,6 +2116,7 @@ github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQs github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.3/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -2135,6 +2147,7 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= @@ -2157,8 +2170,10 @@ github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qq github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= @@ -2166,6 +2181,7 @@ github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcD github.com/spf13/afero v1.10.0/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= @@ -2188,6 +2204,7 @@ github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vl github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= @@ -2201,6 +2218,8 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.opentelemetry.io/contrib/detectors/gcp v1.28.0 h1:eAaOyCwPqwAG7INWn0JTDD3KFR4qbSlhh0YCuFOmmDE= +go.opentelemetry.io/contrib/detectors/gcp v1.28.0/go.mod h1:9BIqH22qyHWAiZxQh0whuJygro59z+nbMVuc7ciiGug= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1/go.mod h1:4UoMYEZOC0yN/sPGH76KPkkU7zgiEWYWL9vwmbnTJPE= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0/go.mod h1:r9vWsPS/3AQItv3OSlEJ/E4mbrhUbbw18meOjArPtKQ= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.48.0/go.mod h1:tIKj3DbO8N9Y2xo52og3irLsPI4GW02DSMtrVgNMgxg= @@ -2250,6 +2269,10 @@ go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqe go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -2307,11 +2330,13 @@ golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTk golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -2339,6 +2364,7 @@ golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= @@ -2427,6 +2453,7 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -2447,6 +2474,7 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -2473,6 +2501,7 @@ golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -2584,10 +2613,13 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= @@ -2702,6 +2734,7 @@ google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRn google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= @@ -2959,6 +2992,7 @@ google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ij google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= @@ -3035,7 +3069,9 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= diff --git a/spanner/transaction.go b/spanner/transaction.go index f251adca1be2..11f53daaea66 100644 --- a/spanner/transaction.go +++ b/spanner/transaction.go @@ -32,7 +32,6 @@ import ( "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" - vkit "cloud.google.com/go/spanner/apiv1" durationpb "google.golang.org/protobuf/types/known/durationpb" ) @@ -1477,7 +1476,7 @@ func (t *ReadWriteTransaction) setSessionEligibilityForLongRunning(sh *sessionHa } } -func beginTransaction(ctx context.Context, sid string, client *vkit.Client, opts TransactionOptions) (transactionID, error) { +func beginTransaction(ctx context.Context, sid string, client spannerClient, opts TransactionOptions) (transactionID, error) { res, err := client.BeginTransaction(ctx, &sppb.BeginTransactionRequest{ Session: sid, Options: &sppb.TransactionOptions{