Skip to content

Commit

Permalink
incorporate changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul2393 committed Nov 12, 2024
1 parent 2415d71 commit 8aa36ea
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion spanner/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func setupMockedTestServerWithConfigAndGCPMultiendpointPool(t *testing.T, config
if len(token) != 1 {
return status.Errorf(codes.Internal, "unexpected number of api client token headers: %v", len(token))
}
if !strings.HasPrefix(token[0], "gl-go/") {
if !strings.Contains(token[0], "gl-go/") {
return status.Errorf(codes.Internal, "unexpected api client token: %v", token[0])
}
if !strings.Contains(token[0], "gccl/") {
Expand Down
2 changes: 1 addition & 1 deletion spanner/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ var (
return "global"
}

// GCM exporter should use the same options as Bigtable client
// GCM exporter should use the same options as Spanner client
// createExporterOptions takes Spanner client options and returns exporter options
// Overwritten in tests
createExporterOptions = func(spannerOpts ...option.ClientOption) []option.ClientOption {
Expand Down
4 changes: 2 additions & 2 deletions spanner/metrics_monitoring_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
monitoring "cloud.google.com/go/monitoring/apiv3/v2"
"cloud.google.com/go/monitoring/apiv3/v2/monitoringpb"
"cloud.google.com/go/spanner/internal"
"github.com/googleapis/gax-go/v2/callctx"
"go.opentelemetry.io/otel/attribute"
otelmetric "go.opentelemetry.io/otel/sdk/metric"
otelmetricdata "go.opentelemetry.io/otel/sdk/metric/metricdata"
Expand All @@ -38,7 +39,6 @@ import (
googlemetricpb "google.golang.org/genproto/googleapis/api/metric"
monitoredrespb "google.golang.org/genproto/googleapis/api/monitoredres"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"
)
Expand Down Expand Up @@ -149,7 +149,7 @@ func (me *monitoringExporter) exportTimeSeries(ctx context.Context, rm *otelmetr
Name: name,
TimeSeries: tss[i:j],
}
err = me.client.CreateServiceTimeSeries(metadata.NewOutgoingContext(ctx, metadata.Pairs("x-goog-api-client", "gccl/"+internal.Version)), req)
err = me.client.CreateServiceTimeSeries(callctx.SetHeaders(ctx, "x-goog-api-client", "gccl/"+internal.Version), req)
if err != nil {
if status.Code(err) == codes.PermissionDenied {
err = fmt.Errorf("%w Need monitoring metric writer permission on project=%s. Follow https://cloud.google.com/spanner/docs/view-manage-client-side-metrics#access-client-side-metrics to set up permissions",
Expand Down
5 changes: 1 addition & 4 deletions spanner/spannertest/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ func makeClient(t *testing.T) (*spanner.Client, *dbadmin.DatabaseAdminClient, *v
client, _, err = spanner.NewMultiEndpointClient(ctx, dbName(), gmeCfg, opts...)
os.Setenv("SPANNER_EMULATOR_HOST", old)
} else {
opts = append(opts,
option.WithGRPCDialOption(grpc.WithTransportCredentials(insecure.NewCredentials())),
option.WithoutAuthentication(),
option.WithEndpoint(srv.Addr))
opts = append(opts, option.WithGRPCConn(conn))
client, err = spanner.NewClient(ctx, dbName(), opts...)
}
if err != nil {
Expand Down

0 comments on commit 8aa36ea

Please sign in to comment.