Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* [Official website](https://echo.labstack.com)
* [All middleware docs](https://echo.labstack.com/docs/category/middleware)

## Deprecations / alternatives

1. Prometheus middleware has a new separate repository - https://github.com/labstack/echo-prometheus
2. Jaeger middleware is deprecated, use [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + [OTLP exporters](https://opentelemetry.io/docs/languages/go/exporters/).
3. Zipkin middleware is deprecated, use [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + [OTLP exporters](https://opentelemetry.io/docs/languages/go/exporters/).

## Usage

For Echo `v5` support:
Expand Down
2 changes: 2 additions & 0 deletions echoprometheus/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Usage

Deprecated: use new repository [echo-prometheus middleware](https://github.com/labstack/echo-prometheus) or [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters

```go
package main

Expand Down
12 changes: 12 additions & 0 deletions echoprometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

/*
Package echoprometheus provides middleware to add Prometheus metrics.

Deprecated: use new repository [echo-prometheus middleware](https://github.com/labstack/echo-prometheus) or [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters
*/
package echoprometheus

Expand Down Expand Up @@ -115,6 +117,8 @@ type PushGatewayConfig struct {
}

// NewHandler creates new instance of Handler using Prometheus default registry.
//
// Deprecated: use new repository [echo-prometheus middleware](https://github.com/labstack/echo-prometheus) or [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters
func NewHandler() echo.HandlerFunc {
return NewHandlerWithConfig(HandlerConfig{})
}
Expand All @@ -137,11 +141,15 @@ func NewHandlerWithConfig(config HandlerConfig) echo.HandlerFunc {
}

// NewMiddleware creates new instance of middleware using Prometheus default registry.
//
// Deprecated: use new repository [echo-prometheus middleware](https://github.com/labstack/echo-prometheus) or [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters
func NewMiddleware(subsystem string) echo.MiddlewareFunc {
return NewMiddlewareWithConfig(MiddlewareConfig{Subsystem: subsystem})
}

// NewMiddlewareWithConfig creates new instance of middleware using given configuration.
//
// Deprecated: use [echo-prometheus middleware](https://github.com/labstack/echo-prometheus) or [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters
func NewMiddlewareWithConfig(config MiddlewareConfig) echo.MiddlewareFunc {
mw, err := config.ToMiddleware()
if err != nil {
Expand All @@ -151,6 +159,8 @@ func NewMiddlewareWithConfig(config MiddlewareConfig) echo.MiddlewareFunc {
}

// ToMiddleware converts configuration to middleware or returns an error.
//
// Deprecated: use new repository [echo-prometheus middleware](https://github.com/labstack/echo-prometheus) or [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters
func (conf MiddlewareConfig) ToMiddleware() (echo.MiddlewareFunc, error) {
if conf.timeNow == nil {
conf.timeNow = time.Now
Expand Down Expand Up @@ -386,6 +396,8 @@ func computeApproximateRequestSize(r *http.Request) int {
// }()
//
// ```
//
// Deprecated: use new repository [echo-prometheus middleware](https://github.com/labstack/echo-prometheus) or [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters
func RunPushGatewayGatherer(ctx context.Context, config PushGatewayConfig) error {
if config.PushGatewayURL == "" {
return errors.New("push gateway URL is missing")
Expand Down
14 changes: 14 additions & 0 deletions jaegertracing/jaegertracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
}

```

Deprecated: use [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters. Read this: https://github.com/jaegertracing/jaeger-client-go
*/
package jaegertracing

Expand Down Expand Up @@ -90,6 +92,8 @@ var (

// New creates an Opentracing tracer and attaches it to Echo middleware.
// Returns Closer do be added to caller function as `defer closer.Close()`
//
// Deprecated: use [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters. Read this: https://github.com/jaegertracing/jaeger-client-go
func New(e *echo.Echo, skipper middleware.Skipper) io.Closer {
// Add Opentracing instrumentation
defcfg := config.Configuration{
Expand Down Expand Up @@ -122,6 +126,8 @@ func New(e *echo.Echo, skipper middleware.Skipper) io.Closer {

// Trace returns a Trace middleware.
// Trace middleware traces http requests and reporting errors.
//
// Deprecated: use [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters. Read this: https://github.com/jaegertracing/jaeger-client-go
func Trace(tracer opentracing.Tracer) echo.MiddlewareFunc {
c := DefaultTraceConfig
c.Tracer = tracer
Expand All @@ -131,6 +137,8 @@ func Trace(tracer opentracing.Tracer) echo.MiddlewareFunc {

// TraceWithConfig returns a Trace middleware with config.
// See: `Trace()`.
//
// Deprecated: use [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters. Read this: https://github.com/jaegertracing/jaeger-client-go
func TraceWithConfig(config TraceConfig) echo.MiddlewareFunc {
if config.Tracer == nil {
panic("echo: trace middleware requires opentracing tracer")
Expand Down Expand Up @@ -279,6 +287,8 @@ func defaultOperationName(c *echo.Context) string {
}

// TraceFunction wraps funtion with opentracing span adding tags for the function name and caller details
//
// Deprecated: use [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters. Read this: https://github.com/jaegertracing/jaeger-client-go
func TraceFunction(ctx *echo.Context, fn interface{}, params ...interface{}) (result []reflect.Value) {
// Get function name
name := runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name()
Expand Down Expand Up @@ -314,6 +324,8 @@ func TraceFunction(ctx *echo.Context, fn interface{}, params ...interface{}) (re

// CreateChildSpan creates a new opentracing span adding tags for the span name and caller details.
// User must call defer `sp.Finish()`
//
// Deprecated: use [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters. Read this: https://github.com/jaegertracing/jaeger-client-go
func CreateChildSpan(ctx *echo.Context, name string) opentracing.Span {
parentSpan := opentracing.SpanFromContext(ctx.Request().Context())
sp := opentracing.StartSpan(
Expand All @@ -333,6 +345,8 @@ func CreateChildSpan(ctx *echo.Context, name string) opentracing.Span {
}

// NewTracedRequest generates a new traced HTTP request with opentracing headers injected into it
//
// Deprecated: use [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters. Read this: https://github.com/jaegertracing/jaeger-client-go
func NewTracedRequest(method string, url string, body io.Reader, span opentracing.Span) (*http.Request, error) {
req, err := http.NewRequest(method, url, body)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions zipkintracing/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Tracing Library for Go

> Deprecated: use [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters. Read this: https://github.com/openzipkin-contrib/zipkin-otel and https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/zipkinexporter
> `Go app -> OTLP -> OpenTelemetry Collector -> Zipkin`

This library provides tracing for go using [Zipkin](https://zipkin.io/)

## Usage
Expand Down
12 changes: 12 additions & 0 deletions zipkintracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,16 @@ var (
)

// DoHTTP is a http zipkin tracer implementation of HTTPDoer
//
// Deprecated: use [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters. Read this: https://github.com/openzipkin-contrib/zipkin-otel and https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/zipkinexporter
func DoHTTP(c *echo.Context, r *http.Request, client *zipkinhttp.Client) (*http.Response, error) {
req := r.WithContext(c.Request().Context())
return client.DoWithAppSpan(req, req.Method)
}

// TraceFunc wraps function call with span so that we can trace time taken by func, eventContext only provided if we want to store trace headers
//
// Deprecated: use [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters. Read this: https://github.com/openzipkin-contrib/zipkin-otel and https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/zipkinexporter
func TraceFunc(c *echo.Context, spanName string, spanTags Tags, tracer *zipkin.Tracer) func() {
span, _ := tracer.StartSpanFromContext(c.Request().Context(), spanName)
for key, value := range spanTags(c) {
Expand All @@ -71,13 +75,17 @@ func TraceFunc(c *echo.Context, spanName string, spanTags Tags, tracer *zipkin.T
}

// TraceProxy middleware that traces reverse proxy
//
// Deprecated: use [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters. Read this: https://github.com/openzipkin-contrib/zipkin-otel and https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/zipkinexporter
func TraceProxy(tracer *zipkin.Tracer) echo.MiddlewareFunc {
config := DefaultTraceProxyConfig
config.Tracer = tracer
return TraceProxyWithConfig(config)
}

// TraceProxyWithConfig middleware that traces reverse proxy
//
// Deprecated: use [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters. Read this: https://github.com/openzipkin-contrib/zipkin-otel and https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/zipkinexporter
func TraceProxyWithConfig(config TraceProxyConfig) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c *echo.Context) error {
Expand Down Expand Up @@ -116,13 +124,17 @@ func TraceProxyWithConfig(config TraceProxyConfig) echo.MiddlewareFunc {
}

// TraceServer middleware that traces server calls
//
// Deprecated: use [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters. Read this: https://github.com/openzipkin-contrib/zipkin-otel and https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/zipkinexporter
func TraceServer(tracer *zipkin.Tracer) echo.MiddlewareFunc {
config := DefaultTraceServerConfig
config.Tracer = tracer
return TraceServerWithConfig(config)
}

// TraceServerWithConfig middleware that traces server calls
//
// Deprecated: use [OpenTelemetry middleware](https://github.com/labstack/echo-opentelemetry) instead + OTLP exporters. Read this: https://github.com/openzipkin-contrib/zipkin-otel and https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/zipkinexporter
func TraceServerWithConfig(config TraceServerConfig) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c *echo.Context) error {
Expand Down
Loading