Traffic tracing instrumentation for your proxies. Designed to be extended to trace custom data or modify the request/response.
Relies on log package to write structured traces and optionally send them via hooks to different storage services.
go get -u gopkg.in/vinxi/trace.v0
See godoc reference.
package main
import (
"fmt"
"net/http"
"gopkg.in/vinxi/trace.v0"
"gopkg.in/vinxi/vinxi.v0"
)
const port = 3100
func main() {
// Create a new vinxi proxy
vs := vinxi.NewServer(vinxi.ServerOptions{Port: port})
// Instrument the proxy with trace middleware
// Now all the incoming traffic will be registered.
vs.Use(trace.Default)
// Target server to forward
vs.Forward("http://httpbin.org")
fmt.Printf("Server listening on port: %d\n", port)
err := vs.Listen()
if err != nil {
fmt.Errorf("Error: %s\n", err)
}
}
MIT