Skip to content

Commit ab61734

Browse files
author
Maksym Pavlenko
authored
Merge pull request containerd#10231 from jedevc/add-get-token-span
auth: add span to FetchToken helpers
2 parents 8f4a282 + 9831a62 commit ab61734

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

core/remotes/docker/auth/fetch.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"time"
2828

2929
remoteserrors "github.com/containerd/containerd/v2/core/remotes/errors"
30+
"github.com/containerd/containerd/v2/pkg/tracing"
3031
"github.com/containerd/containerd/v2/version"
3132
"github.com/containerd/log"
3233
)
@@ -95,6 +96,10 @@ type OAuthTokenResponse struct {
9596

9697
// FetchTokenWithOAuth fetches a token using a POST request
9798
func FetchTokenWithOAuth(ctx context.Context, client *http.Client, headers http.Header, clientID string, to TokenOptions) (*OAuthTokenResponse, error) {
99+
c := *client
100+
client = &c
101+
tracing.UpdateHTTPClient(client, tracing.Name("remotes.docker.resolver", "FetchTokenWithOAuth"))
102+
98103
form := url.Values{}
99104
if len(to.Scopes) > 0 {
100105
form.Set("scope", strings.Join(to.Scopes, " "))
@@ -161,6 +166,10 @@ type FetchTokenResponse struct {
161166

162167
// FetchToken fetches a token using a GET request
163168
func FetchToken(ctx context.Context, client *http.Client, headers http.Header, to TokenOptions) (*FetchTokenResponse, error) {
169+
c := *client
170+
client = &c
171+
tracing.UpdateHTTPClient(client, tracing.Name("remotes.docker.resolver", "FetchToken"))
172+
164173
req, err := http.NewRequestWithContext(ctx, http.MethodGet, to.Realm, nil)
165174
if err != nil {
166175
return nil, err

0 commit comments

Comments
 (0)