Documentation
¶
Overview ¶
Package tests provides a ready made oida-instrumented server for use in tests and examples: a chi router with the tracing middleware, the debug front end mounted, memory storage, and a handful of routes that record spans.
Example (MountServeMux) ¶
Example_mountServeMux mounts the tracer's dashboard on the standard library mux: the tracer is an http.Handler, so Handle is the whole integration.
package main
import (
"fmt"
"net/http"
"net/http/httptest"
"github.com/titpetric/oida"
)
func main() {
opts := oida.NewOptions("billing-api")
opts.Enabled = true
tracer, err := oida.New(opts)
if err != nil {
fmt.Println(err)
return
}
mux := http.NewServeMux()
mux.Handle("/debug/oida/", tracer)
response := httptest.NewRecorder()
mux.ServeHTTP(response, httptest.NewRequest(http.MethodGet, "/debug/oida/", nil))
fmt.Println(response.Code)
}
Output: 200
Index ¶
Examples ¶
Constants ¶
View Source
const Path = "/debug/oida"
Path is the mount path of the debug front end on the test server.
Variables ¶
This section is empty.
Functions ¶
func NewHTTPServer ¶
NewHTTPServer starts NewServer on a local listener and closes it when the test ends.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.