Back to

Package echo

Latest Go to latest

The highest tagged major version is v1.

Published: Oct 15, 2020 | Licenses: Apache-2.0 , BSD-3-Clause , Apache-2.0 | Module:


Package echo provides functions to trace the labstack/echo package (


To start tracing requests, add the trace middleware to your echo router.


r := echo.New()

// Use the tracer middleware with your desired service name.

// Set up an endpoint.
r.GET("/hello", func(c echo.Context) error {
	return c.String(200, "hello world!")

// ...and listen for incoming requests
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.

// 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

	return c.String(200, "ok!")



func Middleware

func Middleware(opts ...Option) echo.MiddlewareFunc

Middleware returns echo middleware which will trace incoming requests.

type Option

type Option func(*config)

Option represents an option that can be passed to Middleware.

func WithAnalytics

func WithAnalytics(on bool) Option

WithAnalytics enables Trace Analytics for all started spans.

func WithAnalyticsRate

func WithAnalyticsRate(rate float64) Option

WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.

func WithServiceName

func WithServiceName(name string) Option

WithServiceName sets the given service name for the system.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier