Documentation ¶
Index ¶
Constants ¶
View Source
const ( DefaultParentSpanKey = "#defaultTracingParentSpanKey" DefaultComponentName = "fiber/v2" )
Variables ¶
View Source
var ( // DefaultTraceConfig is the default Trace middleware config. DefaultConfig = Config{ Modify: func(ctx *fiber.Ctx, span opentracing.Span) { ext.HTTPMethod.Set(span, ctx.Method()) ext.HTTPUrl.Set(span, ctx.OriginalURL()) ext.Component.Set(span, DefaultComponentName) span.SetTag("http.remote_addr", ctx.IP()) span.SetTag("http.path", ctx.Path()) span.SetTag("http.host", ctx.Hostname()) }, OperationName: func(ctx *fiber.Ctx) string { return "HTTP " + ctx.Method() + " URL: " + ctx.Path() }, ComponentName: DefaultComponentName, ParentSpanKey: DefaultParentSpanKey, } )
Functions ¶
func New ¶
func New(tracer opentracing.Tracer) fiber.Handler
New returns a Trace middleware. Trace middleware traces http requests and reporting errors.
func NewWithConfig ¶
func NewWithConfig(config ...Config) fiber.Handler
NewWithConfig returns a Trace middleware with config.
func NewWithJaegerTracer ¶
NewWithJaegerTracer creates an Opentracing tracer and attaches it to Fiber middleware. Returns Closer do be added to caller function as `defer closer.Close()`
Types ¶
type Config ¶
type Config struct { // Tracer // Default: NoopTracer Tracer opentracing.Tracer // ParentSpanKey // Default: #defaultTracingParentSpanKey ParentSpanKey string // ComponentName used for describing the tracing component name ComponentName string // OperationName // Default: func(ctx *fiber.Ctx) string { // return "HTTP " + ctx.Method() + " URL: " + ctx.Path() // } OperationName func(*fiber.Ctx) string // Filter defines a function to skip middleware. // Optional. Default: nil Filter func(*fiber.Ctx) bool // Modify Modify func(*fiber.Ctx, opentracing.Span) }
Config ...
Click to show internal directories.
Click to hide internal directories.