Skip to content

Commit d61b3c2

Browse files
Jan Waślosipiuk
authored andcommitted
Document instrumenting the http client using OpenTelemetry
1 parent 8d73fac commit d61b3c2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,19 @@ trino.RegisterCustomClient("foobar", foobarClient)
209209
db, err := sql.Open("trino", "https://user@localhost:8080?custom_client=foobar")
210210
```
211211

212+
A custom client can also be used to add OpenTelemetry instrumentation. The
213+
[otelhttp](https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp)
214+
package provides a transport wrapper that creates spans for HTTP requests and
215+
propagates the trace ID in HTTP headers:
216+
217+
```go
218+
otelClient := &http.Client{
219+
Transport: otelhttp.NewTransport(http.DefaultTransport),
220+
}
221+
trino.RegisterCustomClient("otel", otelClient)
222+
db, err := sql.Open("trino", "https://user@localhost:8080?custom_client=otel")
223+
```
224+
212225
#### Examples
213226

214227
```

0 commit comments

Comments
 (0)