Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Wiedler <iwiedler@gitlab.com>2021-09-03 13:49:16 +0300
committerIgor Wiedler <iwiedler@gitlab.com>2021-09-03 13:49:16 +0300
commitb5f53b02f897bbe60fd61c59200fa86b85ff8117 (patch)
tree2c7c2a33c87d600c0c62888a93c6559316e2738f
parent5e157393f28fd8d5a791840fd2daa67f9ebfd0b8 (diff)
Fix duplicate spans when tracing catfile.Batchtrace-spawn-token
Changelog: changed
-rw-r--r--internal/git/catfile/batch.go13
-rw-r--r--internal/git/catfile/batch_cache.go6
2 files changed, 10 insertions, 9 deletions
diff --git a/internal/git/catfile/batch.go b/internal/git/catfile/batch.go
index a83ca21b7..591505cb8 100644
--- a/internal/git/catfile/batch.go
+++ b/internal/git/catfile/batch.go
@@ -32,8 +32,9 @@ type batch struct {
sync.Mutex
*batchCheckProcess
*batchProcess
- cancel func()
- closed bool
+ cancel func()
+ closed bool
+ batchCtx context.Context
}
// Info returns an ObjectInfo if spec exists. If the revision does not exist
@@ -112,9 +113,9 @@ func (bc *BatchCache) newBatch(ctx context.Context, repo git.RepositoryExecutor)
// batch processes are long-lived and reused across RPCs,
// so we de-correlate the process from the RPC
- ctx = correlation.ContextWithCorrelation(ctx, "")
- ctx = opentracing.ContextWithSpan(ctx, nil)
- span2, ctx := opentracing.StartSpanFromContext(ctx, "catfile.Batch")
+ batchCtx := correlation.ContextWithCorrelation(ctx, "")
+ batchCtx = opentracing.ContextWithSpan(batchCtx, nil)
+ span2, batchCtx := opentracing.StartSpanFromContext(batchCtx, "catfile.Batch")
ctx, cancel := context.WithCancel(ctx)
defer func() {
@@ -138,7 +139,7 @@ func (bc *BatchCache) newBatch(ctx context.Context, repo git.RepositoryExecutor)
return nil, ctx, err
}
- return &batch{batchProcess: batchProcess, batchCheckProcess: batchCheckProcess}, ctx, nil
+ return &batch{batchProcess: batchProcess, batchCheckProcess: batchCheckProcess, batchCtx: batchCtx}, ctx, nil
}
func newInstrumentedBatch(ctx context.Context, c Batch, catfileLookupCounter *prometheus.CounterVec) Batch {
diff --git a/internal/git/catfile/batch_cache.go b/internal/git/catfile/batch_cache.go
index 336d9db3d..15cb98713 100644
--- a/internal/git/catfile/batch_cache.go
+++ b/internal/git/catfile/batch_cache.go
@@ -178,11 +178,11 @@ func (bc *BatchCache) BatchProcess(ctx context.Context, repo git.RepositoryExecu
sessionID := metadata.GetValue(ctx, SessionIDField)
if sessionID == "" {
- c, ctx, err := bc.newBatch(ctx, repo)
+ c, _, err := bc.newBatch(ctx, repo)
if err != nil {
return nil, err
}
- return newInstrumentedBatch(ctx, c, bc.catfileLookupCounter), err
+ return newInstrumentedBatch(c.batchCtx, c, bc.catfileLookupCounter), err
}
cacheKey := newCacheKey(sessionID, repo)
@@ -190,7 +190,7 @@ func (bc *BatchCache) BatchProcess(ctx context.Context, repo git.RepositoryExecu
if c, ok := bc.checkout(cacheKey); ok {
go bc.returnWhenDone(requestDone, cacheKey, c)
- return newInstrumentedBatch(ctx, c, bc.catfileLookupCounter), nil
+ return newInstrumentedBatch(c.batchCtx, c, bc.catfileLookupCounter), nil
}
// if we are using caching, create a fresh context for the new batch