forked from mirror/client_golang
dd4dd69878
InstrumentHandler provides proxy object over given http.ResponseWriter - responseWriterDelegator that only implements the bare minimum required of an http.ResponseWriter and doesn’t implement any interface upgrades (http.Flusher, http.Hijacker, etc.). This commit fixes it by providing fancyResponseWriterDelegator with all the fancy bells and whistles if standard library http.ResponseWriter is detected. Heavily inspired by Goji's middleware. https://avtok.com/2014/11/05/interface-upgrades.html#the-proxy-problem |
||
---|---|---|
.. | ||
.gitignore | ||
README.md | ||
benchmark_test.go | ||
collector.go | ||
counter.go | ||
counter_test.go | ||
desc.go | ||
doc.go | ||
example_clustermanager_test.go | ||
example_memstats_test.go | ||
example_selfcollector_test.go | ||
examples_test.go | ||
expvar.go | ||
expvar_test.go | ||
gauge.go | ||
gauge_test.go | ||
go_collector.go | ||
go_collector_test.go | ||
histogram.go | ||
histogram_test.go | ||
http.go | ||
http_test.go | ||
metric.go | ||
metric_test.go | ||
process_collector.go | ||
process_collector_test.go | ||
push.go | ||
registry.go | ||
registry_test.go | ||
summary.go | ||
summary_test.go | ||
untyped.go | ||
value.go | ||
vec.go | ||
vec_test.go |
README.md
Overview
This is the Prometheus telemetric instrumentation client Go client library. It enable authors to define process-space metrics for their servers and expose them through a web service interface for extraction, aggregation, and a whole slew of other post processing techniques.
Installing
$ go get github.com/prometheus/client_golang/prometheus
Example
package main
import (
"net/http"
"github.com/prometheus/client_golang/prometheus"
)
var (
indexed = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "my_company",
Subsystem: "indexer",
Name: "documents_indexed",
Help: "The number of documents indexed.",
})
size = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: "my_company",
Subsystem: "storage",
Name: "documents_total_size_bytes",
Help: "The total size of all documents in the storage.",
})
)
func main() {
http.Handle("/metrics", prometheus.Handler())
indexed.Inc()
size.Set(5)
http.ListenAndServe(":8080", nil)
}
func init() {
prometheus.MustRegister(indexed)
prometheus.MustRegister(size)
}