Skip to content

Commit 5627c64

Browse files
committed
Add otel middleware for OpenTelemetry instrumentation
remove Jaeger middleware reference
1 parent 19d4c9b commit 5627c64

3 files changed

Lines changed: 74 additions & 202 deletions

File tree

website/docs/middleware/jaeger.md

Lines changed: 0 additions & 189 deletions
This file was deleted.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
description: Open-telemetry middleware
3+
---
4+
5+
# Open-telemetry
6+
7+
Echo-opentelemetry is a middleware for Echo framework that provides OpenTelemetry instrumentation for HTTP requests.
8+
https://github.com/labstack/echo-opentelemetry
9+
10+
Open-telemetry is a set of open-source tools that provide instrumentation for cloud native applications.
11+
* [OpenTelemetry HTTP spec](https://opentelemetry.io/docs/specs/semconv/http/)
12+
* [HTTP metrics spec](https://opentelemetry.io/docs/specs/semconv/http/http-metrics/)
13+
14+
15+
16+
## Usage
17+
18+
Add OpenTelemetry middleware dependency with go modules
19+
20+
```bash
21+
go get github.com/labstack/echo-opentelemetry
22+
```
23+
24+
Use as an import statement
25+
26+
```go
27+
e.Use(echootel.NewMiddlewareWithConfig(echootel.Config{
28+
ServerName: "my-server",
29+
TracerProvider: tp,
30+
31+
//Skipper: nil,
32+
//OnNextError: nil,
33+
//OnExtractionError: nil,
34+
//MeterProvider: nil,
35+
//Propagators: nil,
36+
//SpanStartOptions: nil,
37+
//SpanStartAttributes: nil,
38+
//SpanEndAttributes: nil,
39+
//MetricAttributes: nil,
40+
//Metrics: nil,
41+
}))
42+
```
43+
For configuration options documentation see [Config](https://github.com/labstack/echo-opentelemetry/blob/main/otel.go#L28) struct.
44+
45+
Add middleware in simplified form, by providing only the server name
46+
47+
```go
48+
e.Use(echootel.NewMiddleware("app.example.com"))
49+
```
50+
51+
Add middleware with configuration options
52+
53+
```go
54+
e.Use(echootel.NewMiddlewareWithConfig(echootel.Config{
55+
TracerProvider: tp,
56+
}))
57+
```
58+
59+
Retrieving the tracer from the Echo context
60+
```go
61+
tp, err := echo.ContextGet[trace.Tracer](c, echootel.TracerKey)
62+
```
63+
64+
## Example
65+
66+
https://github.com/labstack/echo-opentelemetry/blob/main/example/main.go
67+

website/docs/middleware/prometheus.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,13 @@ description: Prometheus metrics middleware
44

55
# Prometheus
66

7-
:::note
8-
9-
Echo community contribution
10-
11-
:::
12-
137
Prometheus middleware generates metrics for HTTP requests.
148

15-
https://github.com/labstack/echo-contrib/blob/master/echoprometheus/prometheus.go
9+
https://github.com/labstack/echo-prometheus
1610

1711
## Usage
1812

19-
- Add needed module `go get -u github.com/labstack/echo-contrib/v5`
13+
- Add needed module `go get -u github.com/labstack/echo-prometheus`
2014
- Add Prometheus middleware and metrics serving route
2115
```go
2216
e := echo.New()
@@ -34,7 +28,7 @@ package main
3428
import (
3529
"net/http"
3630
37-
"github.com/labstack/echo-contrib/v5/echoprometheus"
31+
echoprometheus "github.com/labstack/echo-prometheus"
3832
"github.com/labstack/echo/v5"
3933
)
4034
@@ -116,7 +110,7 @@ package main
116110
import (
117111
"log"
118112
119-
"github.com/labstack/echo-contrib/v5/echoprometheus"
113+
echoprometheus "github.com/labstack/echo-prometheus"
120114
"github.com/labstack/echo/v5"
121115
"github.com/prometheus/client_golang/prometheus"
122116
)
@@ -156,7 +150,7 @@ package main
156150
import (
157151
"log"
158152
159-
"github.com/labstack/echo-contrib/v5/echoprometheus"
153+
echoprometheus "github.com/labstack/echo-prometheus"
160154
"github.com/labstack/echo/v5"
161155
"github.com/prometheus/client_golang/prometheus"
162156
)
@@ -203,7 +197,7 @@ import (
203197
"net/http"
204198
"strings"
205199
206-
"github.com/labstack/echo-contrib/v5/echoprometheus"
200+
echoprometheus "github.com/labstack/echo-prometheus"
207201
"github.com/labstack/echo/v5"
208202
)
209203
@@ -240,7 +234,7 @@ package main
240234
import (
241235
"net/http"
242236
243-
"github.com/labstack/echo-contrib/v5/echoprometheus"
237+
echoprometheus "github.com/labstack/echo-prometheus"
244238
"github.com/labstack/echo/v5"
245239
"github.com/prometheus/client_golang/prometheus"
246240
)

0 commit comments

Comments
 (0)