From d61b3c290395f62999a8ae6b575d90b7794a7e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wa=C5=9B?= Date: Mon, 23 Oct 2023 10:41:45 +0200 Subject: [PATCH] Document instrumenting the http client using OpenTelemetry --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 7db4a11..497b209 100644 --- a/README.md +++ b/README.md @@ -209,6 +209,19 @@ trino.RegisterCustomClient("foobar", foobarClient) db, err := sql.Open("trino", "https://user@localhost:8080?custom_client=foobar") ``` +A custom client can also be used to add OpenTelemetry instrumentation. The +[otelhttp](https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp) +package provides a transport wrapper that creates spans for HTTP requests and +propagates the trace ID in HTTP headers: + +```go +otelClient := &http.Client{ + Transport: otelhttp.NewTransport(http.DefaultTransport), +} +trino.RegisterCustomClient("otel", otelClient) +db, err := sql.Open("trino", "https://user@localhost:8080?custom_client=otel") +``` + #### Examples ```