Skip to content

Commit

Permalink
feat(tracing): add tracing to intercp gRPC server and client (#9383)
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Beaumont <mjboamail@gmail.com>
  • Loading branch information
michaelbeaumont committed Feb 23, 2024
1 parent 16d9c36 commit b1b53ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/intercp/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/url"

"github.com/pkg/errors"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/credentials"
Expand Down Expand Up @@ -47,5 +48,6 @@ func New(serverURL string, tlsCfg *TLSConfig) (Conn, error) {
default:
return nil, errors.Errorf("unsupported scheme %q. Use one of %s", url.Scheme, []string{"grpc", "grpcs"})
}
dialOpts = append(dialOpts, grpc.WithStatsHandler(otelgrpc.NewClientHandler()))
return grpc.Dial(url.Host, dialOpts...)
}
2 changes: 2 additions & 0 deletions pkg/intercp/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"
"time"

"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/keepalive"
Expand Down Expand Up @@ -74,6 +75,7 @@ func New(

grpcOptions = append(grpcOptions, grpc.Creds(credentials.NewTLS(tlsCfg)))
grpcOptions = append(grpcOptions, metrics.GRPCServerInterceptors()...)
grpcOptions = append(grpcOptions, grpc.StatsHandler(otelgrpc.NewServerHandler()))
grpcServer := grpc.NewServer(grpcOptions...)

return &InterCpServer{
Expand Down

0 comments on commit b1b53ac

Please sign in to comment.