Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 4b49d01

Browse files
sourcegraph-botSourcegraph Bot
and
Sourcegraph Bot
authored
all: make prometheus metrics greppable (#386)
Co-authored-by: Sourcegraph Bot <[email protected]>
1 parent c4262e9 commit 4b49d01

File tree

8 files changed

+36
-60
lines changed

8 files changed

+36
-60
lines changed

buildserver/deps.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -529,16 +529,12 @@ var NewDepRepoVFS = func(ctx context.Context, cloneURL *url.URL, rev string, zip
529529
}
530530

531531
var depZipFetch = prometheus.NewCounter(prometheus.CounterOpts{
532-
Namespace: "golangserver",
533-
Subsystem: "vfs",
534-
Name: "dep_zip_fetch_total",
535-
Help: "Total number of zip URL fetches by NewDepRepoVFS.",
532+
Name: "golangserver_vfs_dep_zip_fetch_total",
533+
Help: "Total number of zip URL fetches by NewDepRepoVFS.",
536534
})
537535
var depZipFetchFailed = prometheus.NewCounter(prometheus.CounterOpts{
538-
Namespace: "golangserver",
539-
Subsystem: "vfs",
540-
Name: "dep_zip_fetch_failed_total",
541-
Help: "Total number of zip URL fetches by NewDepRepoVFS that failed.",
536+
Name: "golangserver_vfs_dep_zip_fetch_failed_total",
537+
Help: "Total number of zip URL fetches by NewDepRepoVFS that failed.",
542538
})
543539

544540
func init() {

buildserver/vfs.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,12 @@ var RemoteFS = func(ctx context.Context, initializeParams lspext.InitializeParam
5151
}
5252

5353
var zipFetch = prometheus.NewCounter(prometheus.CounterOpts{
54-
Namespace: "golangserver",
55-
Subsystem: "vfs",
56-
Name: "zip_fetch_total",
57-
Help: "Total number of times a zip archive was fetched for the currently-viewed repo.",
54+
Name: "golangserver_vfs_zip_fetch_total",
55+
Help: "Total number of times a zip archive was fetched for the currently-viewed repo.",
5856
})
5957
var zipFetchFailed = prometheus.NewCounter(prometheus.CounterOpts{
60-
Namespace: "golangserver",
61-
Subsystem: "vfs",
62-
Name: "zip_fetch_failed_total",
63-
Help: "Total number of times fetching a zip archive for the currently-viewed repo failed.",
58+
Name: "golangserver_vfs_zip_fetch_failed_total",
59+
Help: "Total number of times fetching a zip archive for the currently-viewed repo failed.",
6460
})
6561

6662
func init() {

langserver/cache.go

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,20 @@ var (
2424
cacheID int64
2525

2626
typecheckCacheSize = prometheus.NewGauge(prometheus.GaugeOpts{
27-
Namespace: "golangserver",
28-
Subsystem: "typecheck",
29-
Name: "cache_size",
30-
Help: "Number of items in the typecheck cache",
27+
Name: "golangserver_typecheck_cache_size",
28+
Help: "Number of items in the typecheck cache",
3129
})
3230
typecheckCacheTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
33-
Namespace: "golangserver",
34-
Subsystem: "typecheck",
35-
Name: "cache_request_total",
36-
Help: "Count of requests to cache.",
31+
Name: "golangserver_typecheck_cache_request_total",
32+
Help: "Count of requests to cache.",
3733
}, []string{"type"})
3834
symbolCacheSize = prometheus.NewGauge(prometheus.GaugeOpts{
39-
Namespace: "golangserver",
40-
Subsystem: "symbol",
41-
Name: "cache_size",
42-
Help: "Number of items in the symbol cache",
35+
Name: "golangserver_symbol_cache_size",
36+
Help: "Number of items in the symbol cache",
4337
})
4438
symbolCacheTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
45-
Namespace: "golangserver",
46-
Subsystem: "symbol",
47-
Name: "cache_request_total",
48-
Help: "Count of requests to cache.",
39+
Name: "golangserver_symbol_cache_request_total",
40+
Help: "Count of requests to cache.",
4941
}, []string{"type"})
5042
)
5143

langserver/internal/gocode/suggest/candidate.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ func classifyObject(obj types.Object) string {
7575
}
7676

7777
type candidateCollector struct {
78-
exact []types.Object
79-
badcase []types.Object
80-
localpkg *types.Package
81-
partial string
82-
filter objectFilter
83-
builtin bool
78+
exact []types.Object
79+
badcase []types.Object
80+
localpkg *types.Package
81+
partial string
82+
filter objectFilter
83+
builtin bool
8484
}
8585

8686
func (b *candidateCollector) getCandidates() []Candidate {

langserver/internal/refs/refs.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,12 @@ type dereferencable interface {
316316
func dereferenceType(otyp types.Type) types.Type {
317317
for {
318318
switch typ := otyp.(type) {
319-
case *types.Map:
320-
return otyp
321-
case dereferencable:
322-
otyp = typ.Elem()
323-
default:
324-
return otyp
319+
case *types.Map:
320+
return otyp
321+
case dereferencable:
322+
otyp = typ.Elem()
323+
default:
324+
return otyp
325325
}
326326
}
327327
}

main.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ var (
5656
lintTool = flag.String("lint-tool", "none", "which tool is used to linting. Supported: none and golint. Can be overridden by InitializationOptions.")
5757

5858
openGauge = prometheus.NewGauge(prometheus.GaugeOpts{
59-
Namespace: "golangserver",
60-
Subsystem: "build",
61-
Name: "open_connections",
62-
Help: "Number of open connections to the language server.",
59+
Name: "golangserver_build_open_connections",
60+
Help: "Number of open connections to the language server.",
6361
})
6462
)
6563

vfsutil/cache.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,8 @@ func zipNewFileReader(f *os.File) (*zip.Reader, error) {
6464
}
6565

6666
var cachedFileEvict = prometheus.NewCounter(prometheus.CounterOpts{
67-
Namespace: "golangserver",
68-
Subsystem: "vfs",
69-
Name: "cached_file_evict",
70-
Help: "Total number of evictions to cachedFetch archives.",
67+
Name: "golangserver_vfs_cached_file_evict",
68+
Help: "Total number of evictions to cachedFetch archives.",
7169
})
7270

7371
func init() {

vfsutil/github_archive.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,12 @@ func NewGitHubRepoVFS(ctx context.Context, repo, rev string) (*ArchiveFS, error)
2222
var githubRepoRx = regexp.MustCompile(`^github\.com/[\w.-]{1,100}/[\w.-]{1,100}$`)
2323

2424
var ghFetch = prometheus.NewCounter(prometheus.CounterOpts{
25-
Namespace: "golangserver",
26-
Subsystem: "vfs",
27-
Name: "github_fetch_total",
28-
Help: "Total number of fetches by GitHubRepoVFS.",
25+
Name: "golangserver_vfs_github_fetch_total",
26+
Help: "Total number of fetches by GitHubRepoVFS.",
2927
})
3028
var ghFetchFailed = prometheus.NewCounter(prometheus.CounterOpts{
31-
Namespace: "golangserver",
32-
Subsystem: "vfs",
33-
Name: "github_fetch_failed_total",
34-
Help: "Total number of fetches by GitHubRepoVFS that failed.",
29+
Name: "golangserver_vfs_github_fetch_failed_total",
30+
Help: "Total number of fetches by GitHubRepoVFS that failed.",
3531
})
3632

3733
func init() {

0 commit comments

Comments
 (0)