census-instrumentation / opencensus-service

OpenCensus service allows OpenCensus libraries to export to an exporter service rather than having to link vendor-specific exports.
Apache License 2.0
153 stars 63 forks source link

Enable zpages for Agent #83

Closed bogdandrutu closed 6 years ago

bogdandrutu commented 6 years ago

This is not about building zpages for the intercepted spans, it is about enabling zpages for the ocagent process.

Should be enabled on the same port as the one we use in oc interceptor.

odeke-em commented 6 years ago

@bogdandrutu thank you for filing this issue!

Should be enabled on the same port as the one we use in oc interceptor.

If I may ask, why are we enabling zPages on the same port as the OC interceptor running a gRPC server? It is definitely trivial to do but I am just wonder why the same port. Thanks.

bogdandrutu commented 6 years ago

@odeke-em because it is easier for users to remember only one port. If not possible we can have a different port. As far as I know gRPC supports multiplexing on the same port and I thought this is how we want people to use the zpages in general.

odeke-em commented 6 years ago

Gotcha. In deed, gRPC supports multiplexing on the same port. The only problem is that if running locally without a TLS enabled connection the detection for multiplexing that they recommend is quite buggy and doesn't work and they also spell that out in their docs. https://godoc.org/google.golang.org/grpc#Server.ServeHTTP

if r.ProtoMajor == 2 && strings.HasPrefix(
    r.Header.Get("Content-Type"), "application/grpc") {
    grpcServer.ServeHTTP(w, r)
} else {
    yourMux.ServeHTTP(w, r)
}