Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 52c8bc1

Browse files
authored
gitserver: Move search observability (#61859)
Now co-located with the code it is observing. Test plan: N/a, moved code only.
1 parent 057b280 commit 52c8bc1

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

cmd/gitserver/internal/search.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"sync/atomic"
99
"time"
1010

11+
"github.com/prometheus/client_golang/prometheus"
12+
"github.com/prometheus/client_golang/prometheus/promauto"
1113
"github.com/sourcegraph/log"
1214
"go.opentelemetry.io/otel/attribute"
1315

@@ -21,6 +23,23 @@ import (
2123
"github.com/sourcegraph/sourcegraph/internal/trace"
2224
)
2325

26+
var (
27+
searchRunning = promauto.NewGauge(prometheus.GaugeOpts{
28+
Name: "src_gitserver_search_running",
29+
Help: "number of gitserver.Search running concurrently.",
30+
})
31+
searchDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
32+
Name: "src_gitserver_search_duration_seconds",
33+
Help: "gitserver.Search duration in seconds.",
34+
Buckets: []float64{0.01, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 30},
35+
}, []string{"error"})
36+
searchLatency = promauto.NewHistogram(prometheus.HistogramOpts{
37+
Name: "src_gitserver_search_latency_seconds",
38+
Help: "gitserver.Search latency (time until first result is sent) in seconds.",
39+
Buckets: []float64{0.01, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 30},
40+
})
41+
)
42+
2443
func searchWithObservability(ctx context.Context, logger log.Logger, repoDir common.GitDir, tr trace.Trace, args *protocol.SearchRequest, onMatch func(*protocol.CommitMatch) error) (limitHit bool, err error) {
2544
searchStart := time.Now()
2645

cmd/gitserver/internal/server.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -721,21 +721,6 @@ func scanCRLF(data []byte, atEOF bool) (advance int, token []byte, err error) {
721721
}
722722

723723
var (
724-
searchRunning = promauto.NewGauge(prometheus.GaugeOpts{
725-
Name: "src_gitserver_search_running",
726-
Help: "number of gitserver.Search running concurrently.",
727-
})
728-
searchDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
729-
Name: "src_gitserver_search_duration_seconds",
730-
Help: "gitserver.Search duration in seconds.",
731-
Buckets: []float64{0.01, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 30},
732-
}, []string{"error"})
733-
searchLatency = promauto.NewHistogram(prometheus.HistogramOpts{
734-
Name: "src_gitserver_search_latency_seconds",
735-
Help: "gitserver.Search latency (time until first result is sent) in seconds.",
736-
Buckets: []float64{0.01, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 30},
737-
})
738-
739724
pendingClones = promauto.NewGauge(prometheus.GaugeOpts{
740725
Name: "src_gitserver_clone_queue",
741726
Help: "number of repos waiting to be cloned.",

0 commit comments

Comments
 (0)