Skip to content

Commit

Permalink
Merge pull request #1065 from jonjohnsonjr/more-span
Browse files Browse the repository at this point in the history
Add more spans around potentially slow ops
  • Loading branch information
jonjohnsonjr committed Mar 13, 2024
2 parents 266f1da + 013be86 commit 9636e29
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions pkg/build/apk.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ import (
"fmt"
"regexp"

"go.opentelemetry.io/otel"
"golang.org/x/sync/errgroup"
"k8s.io/apimachinery/pkg/util/sets"
)

func (bc *Context) initializeApk(ctx context.Context) error {
ctx, span := otel.Tracer("apko").Start(ctx, "iniializeApk")
defer span.End()

alpineVersions := parseOptionsFromRepositories(bc.ic.Contents.Repositories)
if err := bc.apk.InitDB(ctx, alpineVersions...); err != nil {
return fmt.Errorf("failed to initialize apk database: %w", err)
Expand Down
8 changes: 8 additions & 0 deletions pkg/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ func (bc *Context) GetBuildDateEpoch() (time.Time, error) {

func (bc *Context) BuildImage(ctx context.Context) error {
log := clog.FromContext(ctx)

ctx, span := otel.Tracer("apko").Start(ctx, "BuildImage")
defer span.End()

if err := bc.buildImage(ctx); err != nil {
log.Debugf("buildImage failed: %v", err)
b, err2 := yaml.Marshal(bc.ic)
Expand Down Expand Up @@ -192,6 +196,10 @@ func NewOptions(opts ...Option) (*options.Options, *types.ImageConfiguration, er
// overwrite the provided timestamp if present.
func New(ctx context.Context, fs apkfs.FullFS, opts ...Option) (*Context, error) {
log := clog.FromContext(ctx)

ctx, span := otel.Tracer("apko").Start(ctx, "New")
defer span.End()

bc := Context{
o: options.Default,
fs: fs,
Expand Down
3 changes: 0 additions & 3 deletions pkg/build/build_implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ func (bc *Context) BuildTarball(ctx context.Context) (string, hash.Hash, hash.Ha
func (bc *Context) buildImage(ctx context.Context) error {
log := clog.FromContext(ctx)

ctx, span := otel.Tracer("apko").Start(ctx, "buildImage")
defer span.End()

if bc.o.Lockfile != "" {
lock, err := lock.FromFile(bc.o.Lockfile)
if err != nil {
Expand Down

0 comments on commit 9636e29

Please sign in to comment.