Skip to content

Commit 47c06c3

Browse files
authored
Merge pull request #59 from Sovietaced/accessToken
Add OTEL to http clients by default
2 parents cdad72f + f792955 commit 47c06c3

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

keyfunc/okta/okta.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/benbjohnson/clock"
88
"github.com/golang-jwt/jwt/v5"
99
"github.com/sovietaced/okta-jwt-verifier/metadata"
10+
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
1011
"io"
1112
"log/slog"
1213
"net/http"
@@ -72,7 +73,12 @@ func WithBackgroundCtx(ctx context.Context) Option {
7273

7374
func defaultOptions() *Options {
7475
opts := &Options{}
75-
WithHttpClient(http.DefaultClient)(opts)
76+
77+
httpClient := http.Client{
78+
Transport: otelhttp.NewTransport(http.DefaultTransport),
79+
}
80+
81+
WithHttpClient(&httpClient)(opts)
7682
withClock(clock.New())(opts)
7783
WithCacheTtl(DefaultCacheTtl)(opts)
7884
WithFetchStrategy(Lazy)(opts)

metadata/okta/okta.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"github.com/benbjohnson/clock"
88
"github.com/sovietaced/okta-jwt-verifier/metadata"
9+
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
910
"log/slog"
1011
"net/http"
1112
"sync"
@@ -70,7 +71,11 @@ func WithBackgroundCtx(ctx context.Context) Option {
7071

7172
func defaultOptions() *Options {
7273
opts := &Options{}
73-
WithHttpClient(http.DefaultClient)(opts)
74+
75+
httpClient := http.Client{
76+
Transport: otelhttp.NewTransport(http.DefaultTransport),
77+
}
78+
WithHttpClient(&httpClient)(opts)
7479
withClock(clock.New())(opts)
7580
WithCacheTtl(DefaultCacheTtl)(opts)
7681
WithFetchStrategy(Lazy)(opts)

0 commit comments

Comments
 (0)