client_golang/prometheus
beorn7 4f73a8b017 Improve Gauge and Counter performance.
This is accomplished by using the functions from the atomic packages
instead of a mutex.

benchmark                                      old ns/op     new ns/op     delta
BenchmarkGaugeNoLabels-2                       118           9.40          -92.03%
BenchmarkGaugeNoLabels                         117           9.38          -91.98%
BenchmarkGaugeNoLabels-4                       117           9.40          -91.97%
BenchmarkCounterNoLabels-2                     137           16.8          -87.74%
BenchmarkCounterNoLabels                       136           16.8          -87.65%
BenchmarkCounterNoLabels-4                     136           16.8          -87.65%
BenchmarkGaugeWithLabelValues-4                400           279           -30.25%
BenchmarkGaugeWithLabelValues-2                398           279           -29.90%
BenchmarkGaugeWithLabelValues                  400           283           -29.25%
BenchmarkCounterWithLabelValues-4              397           286           -27.96%
BenchmarkCounterWithLabelValues-2              396           286           -27.78%
BenchmarkCounterWithLabelValues                394           285           -27.66%
BenchmarkCounterWithPreparedMappedLabels       587           454           -22.66%
BenchmarkCounterWithPreparedMappedLabels-2     581           456           -21.51%
BenchmarkCounterWithPreparedMappedLabels-4     654           539           -17.58%
BenchmarkCounterWithMappedLabels-2             1441          1218          -15.48%
BenchmarkCounterWithMappedLabels               1099          963           -12.37%
BenchmarkCounterWithMappedLabels-4             1636          1501          -8.25%
2015-02-02 18:11:11 +01:00
..
.gitignore Rearrange file and package per convention. 2013-04-04 15:27:09 +02:00
README.md Complete rewrite of the exposition library. 2014-06-17 14:08:22 +02:00
benchmark_test.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
collector.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
counter.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
counter_test.go Improve Gauge and Counter performance. 2015-02-02 18:11:11 +01:00
desc.go Allow error reporting during metrics collection and simplify Register(). 2015-01-12 19:16:09 +01:00
doc.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
example_clustermanager_test.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
example_memstats_test.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
example_selfcollector_test.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
examples_test.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
expvar.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
expvar_test.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
gauge.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
gauge_test.go Improve Gauge and Counter performance. 2015-02-02 18:11:11 +01:00
go_collector.go Add ProcessCollector and GoCollector 2014-12-22 13:49:45 -05:00
go_collector_test.go Fix the summary decay by avoiding the Merge method. 2015-01-21 13:44:43 +01:00
http.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
http_test.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
metric.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
metric_test.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
process_collector.go Allow error reporting during metrics collection and simplify Register(). 2015-01-12 19:16:09 +01:00
process_collector_test.go Add ProcessCollector and GoCollector 2014-12-22 13:49:45 -05:00
registry.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
registry_test.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
summary.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
summary_test.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
untyped.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
value.go Improve Gauge and Counter performance. 2015-02-02 18:11:11 +01:00
vec.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
vec_test.go Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00

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)
}

Documentation

GoDoc