示例#1
0
// Register registers pprof endpoints on the given registrar under _pprof.
// The _pprof endpoint uses as-http and is a tunnel to the default serve mux.
func Register(registrar tchannel.Registrar) {
	handler := func(ctx context.Context, call *tchannel.InboundCall) {
		req, err := thttp.ReadRequest(call)
		if err != nil {
			registrar.Logger().Warnf("Failed to read HTTP request: %v", err)
			return
		}

		serveHTTP(req, call.Response())
	}
	registrar.Register(tchannel.HandlerFunc(handler), "_pprof")
}
示例#2
0
// Register registers pprof endpoints on the given registrar under _pprof.
// The _pprof endpoint uses as-http and is a tunnel to the default serve mux.
func Register(registrar tchannel.Registrar) {
	handler := func(ctx context.Context, call *tchannel.InboundCall) {
		req, err := thttp.ReadRequest(call)
		if err != nil {
			registrar.Logger().WithFields(
				tchannel.LogField{Key: "err", Value: err.Error()},
			).Warn("Failed to read HTTP request.")
			return
		}

		serveHTTP(req, call.Response())
	}
	registrar.Register(tchannel.HandlerFunc(handler), "_pprof")
}