Documentation
¶
Overview ¶
Example ¶
This example shows how to instrument an HTTP server that uses github.com/gorilla/mux with Instana
package main
import (
"log"
"net/http"
"github.com/gorilla/mux"
instana "github.com/instana/go-sensor"
"github.com/instana/go-sensor/instrumentation/instamux"
)
func main() {
// Initialize Instana collector
c := instana.InitCollector(&instana.Options{
Service: "my-web-server",
})
r := mux.NewRouter()
// Add an instrumentation middleware to the router. This middleware will be applied to all handlers
// registered with this instance.
instamux.AddMiddleware(c, r)
// Use mux.Router to register request handlers as usual
r.HandleFunc("/foo", func(w http.ResponseWriter, req *http.Request) {
// ...
})
if err := http.ListenAndServe(":0", nil); err != nil {
log.Fatalf("failed to start server: %s", err)
}
}
Index ¶
Examples ¶
Constants ¶
View Source
const Version = "1.39.0"
Version is the instrumentation module semantic version
Variables ¶
This section is empty.
Functions ¶
func AddMiddleware ¶
func AddMiddleware(sensor instana.TracerLogger, router *mux.Router)
AddMiddleware instruments the mux.Router instance with Instana
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.