What is opentracing ? Vendor neutral APIs and instrumentation for distributed tracing.
Why you need muxtrace ? For example you are using Datadog Tracer to monitor your application performance on http request. We rely on both Datadog and Mux router. Unfortunately, the datadog package for tracing http request on mux was not compatible with opentracing.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Things you need to use the package
- Gorilla Mux - Router and dispatcher
- Opentracing - Vendor-neutral APIs and instrumentation for distributed tracing
With go:
$ go get -u github.com/anthonyhartanto/muxtrace
package main
import (
"fmt"
"github.com/anthonyhartanto/dd-trace-go/ddtrace/opentracer"
"github.com/anthonyhartanto/dd-trace-go/ddtrace/tracer"
"github.com/opentracing/opentracing-go"
"github.com/anthonyhartanto/muxtrace"
"net/http"
)
// ExampleHandler handle example
func ExampleHandler(rw http.ResponseWriter, r *http.Request) {
fmt.Fprintf(rw, "OK")
}
func main() {
// Set tracer
t := opentracer.New(tracer.WithServiceName("example-service"))
defer tracer.Stop()
opentracing.SetGlobalTracer(t)
// Set router
router := muxtrace.NewRouter()
router.HandleFunc("/example", ExampleHandler).Methods(http.MethodGet)
// Run server
server := &http.Server{
Addr: ":8080",
Handler: router,
}
server.ListenAndServe()
}
Result on Datadog:
- Go - The language used
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Anthony Hartanto - Software Engineer