Skip to content

Commit

Permalink
Update README.md (#176)
Browse files Browse the repository at this point in the history
`otelconnect.NewInterceptor()` requires error handling
  • Loading branch information
ytnsym authored Jul 2, 2024
1 parent b4b0af3 commit da350af
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ import (

func main() {
mux := http.NewServeMux()
otelInterceptor, err := otelconnect.NewInterceptor()
if err != nil {
log.Fatal(err)
}

// otelconnect.NewInterceptor provides an interceptor that adds tracing and
// metrics to both clients and handlers. By default, it uses OpenTelemetry's
Expand All @@ -42,17 +46,22 @@ func main() {
// otelconnect.WithMeterProvider.
mux.Handle(pingv1connect.NewPingServiceHandler(
&pingv1connect.UnimplementedPingServiceHandler{},
connect.WithInterceptors(otelconnect.NewInterceptor()),
connect.WithInterceptors(otelInterceptor),
))

http.ListenAndServe("localhost:8080", mux)
}

func makeRequest() {
otelInterceptor, err := otelconnect.NewInterceptor()
if err != nil {
log.Fatal(err)
}

client := pingv1connect.NewPingServiceClient(
http.DefaultClient,
"http://localhost:8080",
connect.WithInterceptors(otelconnect.NewInterceptor()),
connect.WithInterceptors(otelInterceptor),
)
resp, err := client.Ping(
context.Background(),
Expand Down

0 comments on commit da350af

Please sign in to comment.