Skip to content

Commit e72e7ed

Browse files
committed
solver: fix parent span for preprocess traces
Signed-off-by: Tonis Tiigi <[email protected]>
1 parent 3da6d96 commit e72e7ed

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

solver/jobs.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ type state struct {
5151
parents map[digest.Digest]struct{}
5252
childVtx map[digest.Digest]struct{}
5353

54-
mpw *progress.MultiWriter
55-
allPw map[progress.Writer]struct{}
56-
mspan *tracing.MultiSpan
54+
mpw *progress.MultiWriter
55+
allPw map[progress.Writer]struct{}
56+
mspan *tracing.MultiSpan
57+
execSpan trace.Span
5758

5859
vtx Vertex
5960
clientVertex client.Vertex
@@ -902,6 +903,7 @@ func (s *sharedOp) LoadCache(ctx context.Context, rec *CacheRecord) (Result, err
902903
}
903904
// no cache hit. start evaluating the node
904905
span, ctx := tracing.StartSpan(ctx, "load cache: "+s.st.vtx.Name(), trace.WithAttributes(attribute.String("vertex", s.st.vtx.Digest().String())))
906+
s.st.execSpan = span
905907
notifyCompleted := notifyStarted(ctx, &s.st.clientVertex, true)
906908
res, err := s.Cache().Load(withAncestorCacheOpts(ctx, s.st), rec)
907909
tracing.FinishWithError(span, err)
@@ -938,7 +940,9 @@ func (s *sharedOp) CalcSlowCache(ctx context.Context, index Index, p PreprocessF
938940
return "", errors.Errorf("failed to get state for index %d on %v", index, s.st.vtx.Name())
939941
}
940942
ctx2 := progress.WithProgress(ctx, st.mpw)
941-
if st.mspan.Span != nil {
943+
if st.execSpan != nil {
944+
ctx2 = trace.ContextWithSpan(ctx2, st.execSpan)
945+
} else if st.mspan.Span != nil {
942946
ctx2 = trace.ContextWithSpan(ctx2, st.mspan)
943947
}
944948
err = p(ctx2, res, st)
@@ -1093,6 +1097,7 @@ func (s *sharedOp) Exec(ctx context.Context, inputs []Result) (outputs []Result,
10931097

10941098
// no cache hit. start evaluating the node
10951099
span, ctx := tracing.StartSpan(ctx, s.st.vtx.Name(), trace.WithAttributes(attribute.String("vertex", s.st.vtx.Digest().String())))
1100+
s.st.execSpan = span
10961101
notifyCompleted := notifyStarted(ctx, &s.st.clientVertex, false)
10971102
defer func() {
10981103
tracing.FinishWithError(span, retErr)

0 commit comments

Comments
 (0)