Skip to content

Commit

Permalink
feat(grpc.go): import helpers package to use SpanContextFromBinary fu…
Browse files Browse the repository at this point in the history
…nction

feat(grpc.go): add logging of SpanContext from grpcTraceBin metadata field using helpers.SpanContextFromBinary function
  • Loading branch information
shumkovdenis committed May 13, 2023
1 parent 2aa13d6 commit ad7061b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions services/integration/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"net"

"github.com/shumkovdenis/services/integration/helpers"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
pb "google.golang.org/grpc/examples/helloworld/helloworld"
Expand Down Expand Up @@ -51,6 +52,9 @@ func (s *GRPCServer) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.Hel
log.Println("metadata grpc-trace-bin:", grpcTraceBin)

ctx = metadata.AppendToOutgoingContext(ctx, "dapr-app-id", "remote")

sc, ok := helpers.SpanContextFromBinary([]byte(grpcTraceBin))
log.Println("sc:", sc.TraceID(), sc.SpanID(), "ok:", ok)
// ctx = metadata.AppendToOutgoingContext(ctx, "grpc-trace-bin", string(md["grpc-trace-bin"][0]))

grpc.SetHeader(ctx, metadata.Pairs("grpc-trace-bin", grpcTraceBin))
Expand Down

0 comments on commit ad7061b

Please sign in to comment.