sourcegraph / go-langserver

Go language server to add Go support to editors and other tools that use the Language Server Protocol (LSP)
https://sourcegraph.com
MIT License
1.17k stars 89 forks source link

all: make prometheus metrics greppable #386

Closed sourcegraph-bot closed 4 years ago

sourcegraph-bot commented 4 years ago

Right now most prometheus metrics are declared like this:

var requestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
    Namespace: "src",
    Subsystem: "zoekt",
    Name:      "request_duration_seconds",
    Help:      "Time (in seconds) spent on request.",
    Buckets:   prometheus.DefBuckets,
}, []string{"category", "code"})

However, this makes it very hard to find the metric unless you know where it is declared.

I propose we instead stop using the Namespace and Subsystem fields, and just use the Name field. I have seen other projects do this, and it makes it very easy to grep. So the above would become.

var requestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
    Name:      "src_zoekt_request_duration_seconds",
    Help:      "Time (in seconds) spent on request.",
    Buckets:   prometheus.DefBuckets,
}, []string{"category", "code"})

See https://github.com/sourcegraph/sourcegraph/issues/9941