Last active
July 14, 2016 18:17
-
-
Save bg451/ee74cbf0e2279eb46dd59e2f1f7bca63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func serviceHandler(w http.ResponseWriter, r *http.Request) { | |
var sp opentracing.Span | |
opName := r.URL.Path | |
// Attempt to join a trace by getting trace context from the headers. | |
wireContext, err := opentracing.GlobalTracer().Extract( | |
opentracing.TextMap, | |
opentracing.HTTPHeaderTextMapCarrier(r.Header)) | |
if err != nil { | |
// If for whatever reason we can't join, go ahead an start a new root span. | |
sp = opentracing.StartSpan(opName) | |
} else { | |
sp = opentracing.StartSpan(opName, opentracing.ChildOf(wireContext)) | |
} | |
defer sp.Finish() | |
// ... rest of the function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment