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:
authorQuang-Minh Nguyen <qmnguyen@gitlab.com>2023-02-20 13:15:13 +0300
committerQuang-Minh Nguyen <qmnguyen@gitlab.com>2023-02-22 18:45:32 +0300
commit0aa76e990f06374d7a882f9b525e7edceb0199ae (patch)
tree8492213dfa9efb82168ad0a8b26cc8a7ebd86b24 /internal
parent027a6c871b58e04e8c41edad8285b1e2dd5a9dd4 (diff)
tracing: Detach git catfile cache's span
Git Catfile cache is an optimization. It re-uses git-cat-file process if it's already open by other goroutines. As a result, the process's life span may be stretched outside the request starting the process. At present, that span is attributed to the first request. That makes the timing visualization of the whole trace looks weird. This commit detaches that span from the starting request.
Diffstat (limited to 'internal')
-rw-r--r--internal/git/catfile/cache.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/internal/git/catfile/cache.go b/internal/git/catfile/cache.go
index be759aa42..8c75de3dc 100644
--- a/internal/git/catfile/cache.go
+++ b/internal/git/catfile/cache.go
@@ -234,6 +234,11 @@ func (c *ProcessCache) getOrCreateProcess(
c.catfileCacheCounter.WithLabelValues("miss").Inc()
span.SetTag("hit", false)
+ // When cache misses, a new process is created. This process may be re-used later.
+ // In that case, the lifecycle of the process is stretched across multiple
+ // gorountines. We should not attribute the span of this shared process to the
+ // current trace.
+ ctx = tracing.DiscardSpanInContext(ctx)
// We have not found any cached process, so we need to create a new one. In this
// case, we need to detach the process from the current context such that it does
// not get killed when the parent context is cancelled.