diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2019-11-01 18:36:14 +0300 |
---|---|---|
committer | Paul Okstad <pokstad@gitlab.com> | 2019-11-01 18:36:14 +0300 |
commit | 7060c8827906d8248b05eee8f3f9562b0641c07f (patch) | |
tree | baa5d55bc3e0c19859e8589756a498d2603a3d2f /internal/helper/fieldextractors | |
parent | 2d465eb4419d862f34f2720381ec6ec50b93842a (diff) |
Count dangling refs before/after FetchIntoObjectPool
Diffstat (limited to 'internal/helper/fieldextractors')
-rw-r--r-- | internal/helper/fieldextractors/fieldextractor.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/internal/helper/fieldextractors/fieldextractor.go b/internal/helper/fieldextractors/fieldextractor.go index 82c889ebe..4318eef5c 100644 --- a/internal/helper/fieldextractors/fieldextractor.go +++ b/internal/helper/fieldextractors/fieldextractor.go @@ -94,7 +94,42 @@ func FieldExtractor(fullMethod string, req interface{}) map[string]interface{} { if result == nil { result = make(map[string]interface{}) } + + switch { + case strings.HasPrefix(fullMethod, "/gitaly.ObjectPoolService/"): + addObjectPool(req, result) + } + result["fullMethod"] = fullMethod return result } + +type objectPoolRequest interface { + GetObjectPool() *gitalypb.ObjectPool +} + +func addObjectPool(req interface{}, tags map[string]interface{}) { + oReq, ok := req.(objectPoolRequest) + if !ok { + return + } + + pool := oReq.GetObjectPool() + if pool == nil { + return + } + + repo := pool.GetRepository() + if repo == nil { + return + } + + for k, v := range map[string]string{ + "pool.storage": repo.StorageName, + "pool.relativePath": repo.RelativePath, + "pool.sourceProjectPath": repo.GlProjectPath, + } { + tags[k] = v + } +} |