Skip to content

Latest commit

 

History

History
54 lines (36 loc) · 1.74 KB

File metadata and controls

54 lines (36 loc) · 1.74 KB

Sourcegraph GoDoc Go Report Card License

Echo OpenTelemetry (OTel) middleware

OpenTelemetry middleware for Echo framework.

Versioning

  • version v0.x.y tracks the latest Echo version (v5).
  • main branch is compatible with the latest Echo version (v5).

Usage

Add OpenTelemetry middleware dependency with go modules

go get github.com/labstack/echo-opentelemetry

Use as an import statement

import echootel "github.com/labstack/echo-opentelemetry"

Add middleware in simplified form, by providing only the server name

e.Use(echootel.NewMiddleware("app.example.com"))

Add middleware with configuration options

e.Use(echootel.NewMiddlewareWithConfig(echootel.Config{
  TracerProvider: tp,
}))

Retrieving the tracer from the Echo context

tp, err := echo.ContextGet[trace.Tracer](c, echootel.TracerKey)

Full example

See example