diff options
author | Paul Okstad <pokstad@gitlab.com> | 2019-11-26 19:45:55 +0300 |
---|---|---|
committer | Paul Okstad <pokstad@gitlab.com> | 2019-11-26 19:45:55 +0300 |
commit | 39bfe1dfaa4fcd493d53b21b7a172d0cad2ef8ac (patch) | |
tree | 013092720996ebbbbd6271bb27154967d4caab45 | |
parent | 2a58fb46a881a16ba792e3e7c361fcd3d5256499 (diff) | |
parent | 6df4c85ae7201b62ea960443642e708b06ae66ec (diff) |
Merge branch 'jv-list-commits-oid-histogram' into 'master'
ListCommitsByOid: add histogram for request size
See merge request gitlab-org/gitaly!1650
-rw-r--r-- | internal/service/commit/list_commits_by_oid.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/service/commit/list_commits_by_oid.go b/internal/service/commit/list_commits_by_oid.go index c64e88792..614626055 100644 --- a/internal/service/commit/list_commits_by_oid.go +++ b/internal/service/commit/list_commits_by_oid.go @@ -5,8 +5,27 @@ import ( gitlog "gitlab.com/gitlab-org/gitaly/internal/git/log" "gitlab.com/gitlab-org/gitaly/internal/helper/chunk" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" + + "github.com/prometheus/client_golang/prometheus" +) + +var ( + listCommitsbyOidHistogram = prometheus.NewHistogram( + prometheus.HistogramOpts{ + Name: "gitaly_list_commits_by_oid_request_size", + Help: "Number of commits requested in a ListCommitsByOid request", + + // We want to count the pathological case where the request is empty. I + // am not sure if with floats, Observe(0) would go into bucket 0. Use + // bucket 0.001 because 0 <= 0.001 for sure. + Buckets: []float64{0.001, 1, 5, 10, 20}, + }) ) +func init() { + prometheus.MustRegister(listCommitsbyOidHistogram) +} + func (s *server) ListCommitsByOid(in *gitalypb.ListCommitsByOidRequest, stream gitalypb.CommitService_ListCommitsByOidServer) error { ctx := stream.Context() @@ -16,6 +35,7 @@ func (s *server) ListCommitsByOid(in *gitalypb.ListCommitsByOidRequest, stream g } sender := chunk.New(&commitsByOidSender{stream: stream}) + listCommitsbyOidHistogram.Observe(float64(len(in.Oid))) for _, oid := range in.Oid { commit, err := gitlog.GetCommitCatfile(c, oid) |