Skip to content
Snippets Groups Projects
Commit 39e01d32 authored by ale's avatar ale
Browse files

Opportunistically call Init() from WrapHandler

parent 4f7bac42
No related branches found
No related tags found
No related merge requests found
...@@ -148,6 +148,8 @@ func Init() { ...@@ -148,6 +148,8 @@ func Init() {
// WrapTransport optionally wraps a http.RoundTripper with OpenCensus // WrapTransport optionally wraps a http.RoundTripper with OpenCensus
// tracing functionality, if it is globally enabled. // tracing functionality, if it is globally enabled.
//
// Must call Init() first.
func WrapTransport(t http.RoundTripper) http.RoundTripper { func WrapTransport(t http.RoundTripper) http.RoundTripper {
if Enabled { if Enabled {
t = othttp.NewTransport(t) t = othttp.NewTransport(t)
...@@ -158,10 +160,10 @@ func WrapTransport(t http.RoundTripper) http.RoundTripper { ...@@ -158,10 +160,10 @@ func WrapTransport(t http.RoundTripper) http.RoundTripper {
// WrapHandler wraps a http.Handler with OpenCensus tracing // WrapHandler wraps a http.Handler with OpenCensus tracing
// functionality, if globally enabled. Automatically calls Init(). // functionality, if globally enabled. Automatically calls Init().
func WrapHandler(h http.Handler, endpointAddr string) http.Handler { func WrapHandler(h http.Handler, endpointAddr string) http.Handler {
if Enabled {
serviceName := getServiceName() serviceName := getServiceName()
initTracing(serviceName) initTracing(serviceName)
h = othttp.NewHandler(h, serviceName) if !Enabled {
}
return h return h
} }
return othttp.NewHandler(h, serviceName)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment