connectrpc / otelconnect-go

OpenTelemetry tracing and metrics for Connect.
https://connectrpc.com
Apache License 2.0
127 stars 29 forks source link

Typo in docs #149

Closed LiamMaguireANZ closed 11 months ago

LiamMaguireANZ commented 11 months ago

for docs linked. https://connectrpc.com/docs/go/observability/#enabling-opentelemetry-for-connect

missing an s on WithInterceptor func should be WithInterceptors

having the pkgs to import also makes it a little easier to integrate with.

import (
"connectrpc.com/connect"
"connectrpc.com/otelconnect"
)

func main() {
    mux := http.NewServeMux()
    mux.Handle(pingv1connect.NewPingServiceHandler(
        &pingv1connect.UnimplementedPingServiceHandler{},
        connect.WithInterceptors(
            otelconnect.NewInterceptor(),
        ),
    ))

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

func makeRequest() {
    client := pingv1connect.NewPingServiceClient(
        http.DefaultClient,
        "http://localhost:8080",
        connect.WithInterceptors(
            otelconnect.NewInterceptor(),
        ),
    )
    resp, err := client.Ping(
        context.Background(),
        connect.NewRequest(&pingv1.PingRequest{}),
    )
    if err != nil {
        log.Fatal(err)
    }
    log.Print(resp)
}
emcfarlane commented 11 months ago

Thanks for reporting! I've made a change in the example code to highlight the changes needed. Is that helpful? Or would a full example be more useful?

LiamMaguireANZ commented 11 months ago

i think both are fine. full code snippet could be too verbose for some people. But it is fine for now.