Skip to content

Commit

Permalink
Merge pull request moby#5185 from jedevc/add-resolving-spans
Browse files Browse the repository at this point in the history
otel: add wrapping "resolving" spans for ResolveImageConfig
  • Loading branch information
tonistiigi authored Jul 23, 2024
2 parents f7c4196 + 08bd639 commit ffadc9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion client/llb/imagemetaresolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/moby/buildkit/client/llb/sourceresolver"
"github.com/moby/buildkit/util/contentutil"
"github.com/moby/buildkit/util/imageutil"
"github.com/moby/buildkit/util/tracing"
"github.com/moby/buildkit/version"
"github.com/moby/locker"
digest "github.com/opencontainers/go-digest"
Expand Down Expand Up @@ -75,7 +76,12 @@ type resolveResult struct {
dgst digest.Digest
}

func (imr *imageMetaResolver) ResolveImageConfig(ctx context.Context, ref string, opt sourceresolver.Opt) (string, digest.Digest, []byte, error) {
func (imr *imageMetaResolver) ResolveImageConfig(ctx context.Context, ref string, opt sourceresolver.Opt) (resolvedRef string, digest digest.Digest, config []byte, retErr error) {
span, ctx := tracing.StartSpan(ctx, "resolving "+ref)
defer func() {
tracing.FinishWithError(span, retErr)
}()

imr.locker.Lock(ref)
defer imr.locker.Unlock(ref)

Expand Down
8 changes: 7 additions & 1 deletion source/containerimage/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/moby/buildkit/util/imageutil"
"github.com/moby/buildkit/util/pull"
"github.com/moby/buildkit/util/resolver"
"github.com/moby/buildkit/util/tracing"
digest "github.com/opencontainers/go-digest"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
Expand Down Expand Up @@ -148,7 +149,12 @@ func (is *Source) Resolve(ctx context.Context, id source.Identifier, sm *session
return p, nil
}

func (is *Source) ResolveImageConfig(ctx context.Context, ref string, opt sourceresolver.Opt, sm *session.Manager, g session.Group) (digest.Digest, []byte, error) {
func (is *Source) ResolveImageConfig(ctx context.Context, ref string, opt sourceresolver.Opt, sm *session.Manager, g session.Group) (digest digest.Digest, config []byte, retErr error) {
span, ctx := tracing.StartSpan(ctx, "resolving "+ref)
defer func() {
tracing.FinishWithError(span, retErr)
}()

key := ref
var (
rm resolver.ResolveMode
Expand Down

0 comments on commit ffadc9f

Please sign in to comment.