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

Commit

Permalink
all: make prometheus metrics greppable (#386)
Browse files Browse the repository at this point in the history
Co-authored-by: Sourcegraph Bot <campaigns@sourcegraph.com>
  • Loading branch information
sourcegraph-bot and Sourcegraph Bot committed May 2, 2020
1 parent c4262e9 commit 4b49d01
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 60 deletions.
12 changes: 4 additions & 8 deletions buildserver/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,16 +529,12 @@ var NewDepRepoVFS = func(ctx context.Context, cloneURL *url.URL, rev string, zip
}

var depZipFetch = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "golangserver",
Subsystem: "vfs",
Name: "dep_zip_fetch_total",
Help: "Total number of zip URL fetches by NewDepRepoVFS.",
Name: "golangserver_vfs_dep_zip_fetch_total",
Help: "Total number of zip URL fetches by NewDepRepoVFS.",
})
var depZipFetchFailed = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "golangserver",
Subsystem: "vfs",
Name: "dep_zip_fetch_failed_total",
Help: "Total number of zip URL fetches by NewDepRepoVFS that failed.",
Name: "golangserver_vfs_dep_zip_fetch_failed_total",
Help: "Total number of zip URL fetches by NewDepRepoVFS that failed.",
})

func init() {
Expand Down
12 changes: 4 additions & 8 deletions buildserver/vfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,12 @@ var RemoteFS = func(ctx context.Context, initializeParams lspext.InitializeParam
}

var zipFetch = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "golangserver",
Subsystem: "vfs",
Name: "zip_fetch_total",
Help: "Total number of times a zip archive was fetched for the currently-viewed repo.",
Name: "golangserver_vfs_zip_fetch_total",
Help: "Total number of times a zip archive was fetched for the currently-viewed repo.",
})
var zipFetchFailed = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "golangserver",
Subsystem: "vfs",
Name: "zip_fetch_failed_total",
Help: "Total number of times fetching a zip archive for the currently-viewed repo failed.",
Name: "golangserver_vfs_zip_fetch_failed_total",
Help: "Total number of times fetching a zip archive for the currently-viewed repo failed.",
})

func init() {
Expand Down
24 changes: 8 additions & 16 deletions langserver/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,20 @@ var (
cacheID int64

typecheckCacheSize = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: "golangserver",
Subsystem: "typecheck",
Name: "cache_size",
Help: "Number of items in the typecheck cache",
Name: "golangserver_typecheck_cache_size",
Help: "Number of items in the typecheck cache",
})
typecheckCacheTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "golangserver",
Subsystem: "typecheck",
Name: "cache_request_total",
Help: "Count of requests to cache.",
Name: "golangserver_typecheck_cache_request_total",
Help: "Count of requests to cache.",
}, []string{"type"})
symbolCacheSize = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: "golangserver",
Subsystem: "symbol",
Name: "cache_size",
Help: "Number of items in the symbol cache",
Name: "golangserver_symbol_cache_size",
Help: "Number of items in the symbol cache",
})
symbolCacheTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "golangserver",
Subsystem: "symbol",
Name: "cache_request_total",
Help: "Count of requests to cache.",
Name: "golangserver_symbol_cache_request_total",
Help: "Count of requests to cache.",
}, []string{"type"})
)

Expand Down
12 changes: 6 additions & 6 deletions langserver/internal/gocode/suggest/candidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ func classifyObject(obj types.Object) string {
}

type candidateCollector struct {
exact []types.Object
badcase []types.Object
localpkg *types.Package
partial string
filter objectFilter
builtin bool
exact []types.Object
badcase []types.Object
localpkg *types.Package
partial string
filter objectFilter
builtin bool
}

func (b *candidateCollector) getCandidates() []Candidate {
Expand Down
12 changes: 6 additions & 6 deletions langserver/internal/refs/refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,12 @@ type dereferencable interface {
func dereferenceType(otyp types.Type) types.Type {
for {
switch typ := otyp.(type) {
case *types.Map:
return otyp
case dereferencable:
otyp = typ.Elem()
default:
return otyp
case *types.Map:
return otyp
case dereferencable:
otyp = typ.Elem()
default:
return otyp
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@ var (
lintTool = flag.String("lint-tool", "none", "which tool is used to linting. Supported: none and golint. Can be overridden by InitializationOptions.")

openGauge = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: "golangserver",
Subsystem: "build",
Name: "open_connections",
Help: "Number of open connections to the language server.",
Name: "golangserver_build_open_connections",
Help: "Number of open connections to the language server.",
})
)

Expand Down
6 changes: 2 additions & 4 deletions vfsutil/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ func zipNewFileReader(f *os.File) (*zip.Reader, error) {
}

var cachedFileEvict = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "golangserver",
Subsystem: "vfs",
Name: "cached_file_evict",
Help: "Total number of evictions to cachedFetch archives.",
Name: "golangserver_vfs_cached_file_evict",
Help: "Total number of evictions to cachedFetch archives.",
})

func init() {
Expand Down
12 changes: 4 additions & 8 deletions vfsutil/github_archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,12 @@ func NewGitHubRepoVFS(ctx context.Context, repo, rev string) (*ArchiveFS, error)
var githubRepoRx = regexp.MustCompile(`^github\.com/[\w.-]{1,100}/[\w.-]{1,100}$`)

var ghFetch = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "golangserver",
Subsystem: "vfs",
Name: "github_fetch_total",
Help: "Total number of fetches by GitHubRepoVFS.",
Name: "golangserver_vfs_github_fetch_total",
Help: "Total number of fetches by GitHubRepoVFS.",
})
var ghFetchFailed = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "golangserver",
Subsystem: "vfs",
Name: "github_fetch_failed_total",
Help: "Total number of fetches by GitHubRepoVFS that failed.",
Name: "golangserver_vfs_github_fetch_failed_total",
Help: "Total number of fetches by GitHubRepoVFS that failed.",
})

func init() {
Expand Down

0 comments on commit 4b49d01

Please sign in to comment.