Documentation ¶
Overview ¶
Package echo provides functions to trace the labstack/echo package (https://github.com/labstack/echo).
Example ¶
To start tracing requests, add the trace middleware to your echo router.
r := echo.New() // Use the tracer middleware with your desired service name. r.Use(Middleware(WithServiceName("my-web-app"))) // Set up an endpoint. r.GET("/hello", func(c echo.Context) error { return c.String(200, "hello world!") }) // ...and listen for incoming requests r.Start(":8080")
Output:
Example (SpanFromContext) ¶
An example illustrating tracing a child operation within the main context.
// Create a new instance of echo r := echo.New() // Use the tracer middleware with your desired service name. r.Use(Middleware(WithServiceName("image-encoder"))) // Set up some endpoints. r.GET("/image/encode", func(c echo.Context) error { // create a child span to track an operation span, _ := tracer.StartSpanFromContext(c.Request().Context(), "image.encode") // encode an image ... // finish the child span span.Finish() return c.String(200, "ok!") })
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
func Middleware(opts ...Option) echo.MiddlewareFunc
Middleware returns echo middleware which will trace incoming requests.
Types ¶
type IgnoreRequestFunc ¶ added in v1.40.0
type IgnoreRequestFunc func(c echo.Context) bool
IgnoreRequestFunc determines if tracing will be skipped for a request.
type Option ¶
type Option func(*config)
Option represents an option that can be passed to Middleware.
func NoDebugStack ¶ added in v1.36.0
func NoDebugStack() Option
NoDebugStack prevents stack traces from being attached to spans finishing with an error. This is useful in situations where errors are frequent and performance is critical.
func WithAnalytics ¶
WithAnalytics enables Trace Analytics for all started spans.
func WithAnalyticsRate ¶
WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.
func WithIgnoreRequest ¶ added in v1.40.0
func WithIgnoreRequest(ignoreRequestFunc IgnoreRequestFunc) Option
WithIgnoreRequest sets a function which determines if tracing will be skipped for a given request.
func WithServiceName ¶
WithServiceName sets the given service name for the system.