Skip to content

Commit

Permalink
otelgrpc: Modify example to use grpc.StatsHandler (#4325)
Browse files Browse the repository at this point in the history
  • Loading branch information
fatsheep9146 authored Sep 22, 2023
1 parent bf86b26 commit 76d9c69
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Set the description for the `rpc.server.duration` metric in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc`. (#4302)
- Add `NewServerHandler` and `NewClientHandler` that return a `grpc.StatsHandler` used for gRPC instrumentation in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc`. (#3002)

### Changed

- Use `grpc.StatsHandler` for gRPC instrumentation in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/example`. (#4325)

## [1.19.0/0.44.0/0.13.0] - 2023-09-12

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ func main() {

var conn *grpc.ClientConn
conn, err = grpc.Dial(":7777", grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor()),
grpc.WithStreamInterceptor(otelgrpc.StreamClientInterceptor()),
grpc.WithStatsHandler(otelgrpc.NewClientHandler()),
)

if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ func main() {
}

s := grpc.NewServer(
grpc.UnaryInterceptor(otelgrpc.UnaryServerInterceptor()),
grpc.StreamInterceptor(otelgrpc.StreamServerInterceptor()),
grpc.StatsHandler(otelgrpc.NewServerHandler()),
)

api.RegisterHelloServiceServer(s, &server{})
Expand Down

0 comments on commit 76d9c69

Please sign in to comment.