Documentation
¶
Overview ¶
Package jaegertracing provides middleware to Opentracing using Jaeger.
Example: ``` package main import (
"github.com/labstack/echo-contrib/jaegertracing" "github.com/labstack/echo/v4"
)
func main() { e := echo.New() // Enable tracing middleware c := jaegertracing.New(e, nil) defer c.Close() e.Logger.Fatal(e.Start(":1323")) }
```
Index ¶
- Variables
- func CreateChildSpan(ctx echo.Context, name string) opentracing.Span
- func New(e *echo.Echo, skipper middleware.Skipper) io.Closer
- func NewTracedRequest(method string, url string, body io.Reader, span opentracing.Span) (*http.Request, error)
- func Trace(tracer opentracing.Tracer) echo.MiddlewareFunc
- func TraceFunction(ctx echo.Context, fn interface{}, params ...interface{}) (result []reflect.Value)
- func TraceWithConfig(config TraceConfig) echo.MiddlewareFunc
- type TraceConfig
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultTraceConfig is the default Trace middleware config. DefaultTraceConfig = TraceConfig{ Skipper: middleware.DefaultSkipper, ComponentName: defaultComponentName, IsBodyDump: false, LimitHTTPBody: true, LimitSize: 60_000, OperationNameFunc: defaultOperationName, } )
Functions ¶
func CreateChildSpan ¶
func CreateChildSpan(ctx echo.Context, name string) opentracing.Span
CreateChildSpan creates a new opentracing span adding tags for the span name and caller details. User must call defer `sp.Finish()`
func New ¶
func New(e *echo.Echo, skipper middleware.Skipper) io.Closer
New creates an Opentracing tracer and attaches it to Echo middleware. Returns Closer do be added to caller function as `defer closer.Close()`
func NewTracedRequest ¶
func NewTracedRequest(method string, url string, body io.Reader, span opentracing.Span) (*http.Request, error)
NewTracedRequest generates a new traced HTTP request with opentracing headers injected into it
func Trace ¶
func Trace(tracer opentracing.Tracer) echo.MiddlewareFunc
Trace returns a Trace middleware. Trace middleware traces http requests and reporting errors.
func TraceFunction ¶
func TraceFunction(ctx echo.Context, fn interface{}, params ...interface{}) (result []reflect.Value)
TraceFunction wraps funtion with opentracing span adding tags for the function name and caller details
func TraceWithConfig ¶
func TraceWithConfig(config TraceConfig) echo.MiddlewareFunc
TraceWithConfig returns a Trace middleware with config. See: `Trace()`.
Types ¶
type TraceConfig ¶
type TraceConfig struct { // Skipper defines a function to skip middleware. Skipper middleware.Skipper // OpenTracing Tracer instance which should be got before Tracer opentracing.Tracer // ComponentName used for describing the tracing component name ComponentName string // add req body & resp body to tracing tags IsBodyDump bool // prevent logging long http request bodies LimitHTTPBody bool // http body limit size (in bytes) // NOTE: don't specify values larger than 60000 as jaeger can't handle values in span.LogKV larger than 60000 bytes LimitSize int // OperationNameFunc composes operation name based on context. Can be used to override default naming OperationNameFunc func(c echo.Context) string }
TraceConfig defines the config for Trace middleware.