From 308d1137ff620da5423d26526c44a54bb05f4af2 Mon Sep 17 00:00:00 2001 From: radekg Date: Tue, 1 Oct 2019 18:31:27 +0200 Subject: [PATCH] upgradeContextWithBearerToken does not need a receiver Signed-off-by: radekg --- plugin/storage/grpc/shared/grpc_client.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugin/storage/grpc/shared/grpc_client.go b/plugin/storage/grpc/shared/grpc_client.go index 26cfa493364..63fa498f535 100644 --- a/plugin/storage/grpc/shared/grpc_client.go +++ b/plugin/storage/grpc/shared/grpc_client.go @@ -38,7 +38,7 @@ type grpcClient struct { // upgradeContextWithBearerToken turns the context into a gRPC outgoing context with bearer token // in the request metadata, if the original context has bearer token attached. // Otherwise returns original context. -func (c *grpcClient) upgradeContextWithBearerToken(ctx context.Context) context.Context { +func upgradeContextWithBearerToken(ctx context.Context) context.Context { bearerToken, hasToken := spanstore.GetBearerToken(ctx) if hasToken { requestMetadata := metadata.New(map[string]string{ @@ -66,7 +66,7 @@ func (c *grpcClient) SpanWriter() spanstore.Writer { // GetTrace takes a traceID and returns a Trace associated with that traceID func (c *grpcClient) GetTrace(ctx context.Context, traceID model.TraceID) (*model.Trace, error) { - stream, err := c.readerClient.GetTrace(c.upgradeContextWithBearerToken(ctx), &storage_v1.GetTraceRequest{ + stream, err := c.readerClient.GetTrace(upgradeContextWithBearerToken(ctx), &storage_v1.GetTraceRequest{ TraceID: traceID, }) if err != nil { @@ -89,7 +89,7 @@ func (c *grpcClient) GetTrace(ctx context.Context, traceID model.TraceID) (*mode // GetServices returns a list of all known services func (c *grpcClient) GetServices(ctx context.Context) ([]string, error) { - resp, err := c.readerClient.GetServices(c.upgradeContextWithBearerToken(ctx), &storage_v1.GetServicesRequest{}) + resp, err := c.readerClient.GetServices(upgradeContextWithBearerToken(ctx), &storage_v1.GetServicesRequest{}) if err != nil { return nil, errors.Wrap(err, "plugin error") } @@ -99,7 +99,7 @@ func (c *grpcClient) GetServices(ctx context.Context) ([]string, error) { // GetOperations returns the operations of a given service func (c *grpcClient) GetOperations(ctx context.Context, service string) ([]string, error) { - resp, err := c.readerClient.GetOperations(c.upgradeContextWithBearerToken(ctx), &storage_v1.GetOperationsRequest{ + resp, err := c.readerClient.GetOperations(upgradeContextWithBearerToken(ctx), &storage_v1.GetOperationsRequest{ Service: service, }) if err != nil { @@ -111,7 +111,7 @@ func (c *grpcClient) GetOperations(ctx context.Context, service string) ([]strin // FindTraces retrieves traces that match the traceQuery func (c *grpcClient) FindTraces(ctx context.Context, query *spanstore.TraceQueryParameters) ([]*model.Trace, error) { - stream, err := c.readerClient.FindTraces(c.upgradeContextWithBearerToken(ctx), &storage_v1.FindTracesRequest{ + stream, err := c.readerClient.FindTraces(upgradeContextWithBearerToken(ctx), &storage_v1.FindTracesRequest{ Query: &storage_v1.TraceQueryParameters{ ServiceName: query.ServiceName, OperationName: query.OperationName, @@ -149,7 +149,7 @@ func (c *grpcClient) FindTraces(ctx context.Context, query *spanstore.TraceQuery // FindTraceIDs retrieves traceIDs that match the traceQuery func (c *grpcClient) FindTraceIDs(ctx context.Context, query *spanstore.TraceQueryParameters) ([]model.TraceID, error) { - resp, err := c.readerClient.FindTraceIDs(c.upgradeContextWithBearerToken(ctx), &storage_v1.FindTraceIDsRequest{ + resp, err := c.readerClient.FindTraceIDs(upgradeContextWithBearerToken(ctx), &storage_v1.FindTraceIDsRequest{ Query: &storage_v1.TraceQueryParameters{ ServiceName: query.ServiceName, OperationName: query.OperationName,