mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-17 20:41:51 +00:00
``` $ gvt delete github.com/weaveworks/common $ gvt fetch --revision 4d96fd8dcf2c7b417912c6219b310112cb4a4626 github.com/weaveworks/common 2018/07/23 15:31:11 Fetching: github.com/weaveworks/common 2018/07/23 15:31:14 · Skipping (existing): github.com/golang/protobuf/ptypes/any 2018/07/23 15:31:14 · Fetching recursive dependency: github.com/pkg/errors 2018/07/23 15:31:16 · Skipping (existing): github.com/aws/aws-sdk-go/aws 2018/07/23 15:31:16 · Fetching recursive dependency: github.com/sirupsen/logrus 2018/07/23 15:31:18 ·· Skipping (existing): golang.org/x/sys/unix 2018/07/23 15:31:18 ·· Skipping (existing): golang.org/x/crypto/ssh/terminal 2018/07/23 15:31:18 · Skipping (existing): google.golang.org/grpc/status 2018/07/23 15:31:18 · Skipping (existing): github.com/gorilla/mux 2018/07/23 15:31:18 · Fetching recursive dependency: github.com/opentracing-contrib/go-stdlib/nethttp 2018/07/23 15:31:20 ·· Skipping (existing): github.com/opentracing/opentracing-go/ext 2018/07/23 15:31:20 ·· Skipping (existing): github.com/opentracing/opentracing-go/log 2018/07/23 15:31:20 ·· Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:31:20 · Skipping (existing): github.com/prometheus/client_golang/prometheus 2018/07/23 15:31:20 · Skipping (existing): google.golang.org/grpc 2018/07/23 15:31:20 · Skipping (existing): github.com/pmezard/go-difflib/difflib 2018/07/23 15:31:20 · Fetching recursive dependency: github.com/go-kit/kit/log 2018/07/23 15:31:23 ·· Fetching recursive dependency: github.com/go-logfmt/logfmt 2018/07/23 15:31:25 ··· Fetching recursive dependency: github.com/kr/logfmt 2018/07/23 15:31:27 ·· Fetching recursive dependency: github.com/go-stack/stack 2018/07/23 15:31:29 · Fetching recursive dependency: google.golang.org/genproto/googleapis/rpc/status 2018/07/23 15:31:37 ·· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:31:37 ·· Skipping (existing): github.com/golang/protobuf/ptypes/any 2018/07/23 15:31:37 · Skipping (existing): github.com/opentracing/opentracing-go/log 2018/07/23 15:31:37 · Fetching recursive dependency: github.com/sercand/kuberesolver 2018/07/23 15:31:39 ·· Skipping (existing): google.golang.org/grpc/grpclog 2018/07/23 15:31:39 ·· Skipping (existing): google.golang.org/grpc/resolver 2018/07/23 15:31:39 ·· Skipping (existing): golang.org/x/net/context 2018/07/23 15:31:39 · Skipping (existing): google.golang.org/grpc/metadata 2018/07/23 15:31:39 · Skipping (existing): github.com/opentracing/opentracing-go/ext 2018/07/23 15:31:39 · Skipping (existing): github.com/armon/go-socks5 2018/07/23 15:31:39 · Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:31:39 · Skipping (existing): github.com/davecgh/go-spew/spew 2018/07/23 15:31:39 · Skipping (existing): github.com/golang/protobuf/ptypes 2018/07/23 15:31:39 · Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:31:39 · Fetching recursive dependency: github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc 2018/07/23 15:31:41 ·· Skipping (existing): github.com/opentracing/opentracing-go/log 2018/07/23 15:31:41 ·· Skipping (existing): golang.org/x/net/context 2018/07/23 15:31:41 ·· Skipping (existing): google.golang.org/grpc/codes 2018/07/23 15:31:41 ·· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:31:41 ·· Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:31:41 ·· Skipping (existing): github.com/opentracing/opentracing-go/ext 2018/07/23 15:31:41 ·· Skipping (existing): google.golang.org/grpc 2018/07/23 15:31:41 ·· Skipping (existing): google.golang.org/grpc/metadata 2018/07/23 15:31:41 ·· Skipping (existing): google.golang.org/grpc/status 2018/07/23 15:31:41 · Fetching recursive dependency: github.com/uber/jaeger-client-go/config 2018/07/23 15:31:44 ·· Fetching recursive dependency: github.com/uber/jaeger-client-go/internal/throttler/remote 2018/07/23 15:31:44 ··· Fetching recursive dependency: github.com/uber/jaeger-client-go/utils 2018/07/23 15:31:44 ···· Fetching recursive dependency: github.com/uber/jaeger-client-go/thrift 2018/07/23 15:31:44 ···· Fetching recursive dependency: github.com/uber/jaeger-client-go/thrift-gen/agent 2018/07/23 15:31:44 ····· Fetching recursive dependency: github.com/uber/jaeger-client-go/thrift-gen/jaeger 2018/07/23 15:31:44 ····· Fetching recursive dependency: github.com/uber/jaeger-client-go/thrift-gen/zipkincore 2018/07/23 15:31:44 ··· Fetching recursive dependency: github.com/uber/jaeger-client-go 2018/07/23 15:31:44 ···· Fetching recursive dependency: github.com/crossdock/crossdock-go 2018/07/23 15:31:46 ····· Skipping (existing): github.com/davecgh/go-spew/spew 2018/07/23 15:31:46 ····· Skipping (existing): golang.org/x/net/context/ctxhttp 2018/07/23 15:31:46 ····· Skipping (existing): golang.org/x/net/context 2018/07/23 15:31:46 ····· Skipping (existing): github.com/pmezard/go-difflib/difflib 2018/07/23 15:31:46 ···· Skipping (existing): github.com/opentracing/opentracing-go/log 2018/07/23 15:31:46 ···· Fetching recursive dependency: go.uber.org/zap/zapcore 2018/07/23 15:31:49 ····· Fetching recursive dependency: go.uber.org/atomic 2018/07/23 15:31:51 ····· Fetching recursive dependency: go.uber.org/zap/internal/bufferpool 2018/07/23 15:31:51 ······ Fetching recursive dependency: go.uber.org/zap/buffer 2018/07/23 15:31:51 ····· Fetching recursive dependency: go.uber.org/multierr 2018/07/23 15:31:54 ····· Fetching recursive dependency: go.uber.org/zap/internal/exit 2018/07/23 15:31:54 ····· Fetching recursive dependency: go.uber.org/zap/internal/color 2018/07/23 15:31:54 ···· Fetching recursive dependency: go.uber.org/zap 2018/07/23 15:31:54 ···· Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:31:54 ···· Skipping (existing): github.com/opentracing/opentracing-go/ext 2018/07/23 15:31:54 ···· Fetching recursive dependency: github.com/uber/jaeger-lib/metrics 2018/07/23 15:31:56 ····· Fetching recursive dependency: github.com/uber-go/tally 2018/07/23 15:31:58 ······ Fetching recursive dependency: github.com/m3db/prometheus_client_golang/prometheus/promhttp 2018/07/23 15:32:00 ······· Skipping (existing): github.com/prometheus/client_golang/prometheus 2018/07/23 15:32:00 ······· Skipping (existing): github.com/prometheus/common/expfmt 2018/07/23 15:32:00 ······· Skipping (existing): github.com/prometheus/client_model/go 2018/07/23 15:32:00 ······ Fetching recursive dependency: gopkg.in/validator.v2 2018/07/23 15:32:06 ······ Fetching recursive dependency: github.com/cactus/go-statsd-client/statsd 2018/07/23 15:32:08 ······ Skipping (existing): gopkg.in/yaml.v2 2018/07/23 15:32:08 ······ Fetching recursive dependency: github.com/m3db/prometheus_client_golang/prometheus 2018/07/23 15:32:08 ······· Skipping (existing): github.com/prometheus/procfs 2018/07/23 15:32:08 ······· Skipping (existing): github.com/prometheus/client_model/go 2018/07/23 15:32:08 ······· Skipping (existing): github.com/prometheus/common/expfmt 2018/07/23 15:32:08 ······· Skipping (existing): golang.org/x/net/context 2018/07/23 15:32:08 ······· Skipping (existing): github.com/beorn7/perks/quantile 2018/07/23 15:32:08 ······· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:32:08 ······· Skipping (existing): github.com/prometheus/common/model 2018/07/23 15:32:08 ······· Skipping (existing): github.com/prometheus/client_golang/prometheus 2018/07/23 15:32:08 ······ Fetching recursive dependency: github.com/apache/thrift/lib/go/thrift 2018/07/23 15:32:13 ····· Skipping (existing): github.com/stretchr/testify/assert 2018/07/23 15:32:13 ····· Fetching recursive dependency: github.com/go-kit/kit/metrics/influx 2018/07/23 15:32:13 ······ Fetching recursive dependency: github.com/influxdata/influxdb/client/v2 2018/07/23 15:32:17 ······· Fetching recursive dependency: github.com/influxdata/influxdb/models 2018/07/23 15:32:17 ········ Fetching recursive dependency: github.com/influxdata/influxdb/pkg/escape 2018/07/23 15:32:17 ······ Fetching recursive dependency: github.com/go-kit/kit/metrics 2018/07/23 15:32:17 ······· Fetching recursive dependency: github.com/performancecopilot/speed 2018/07/23 15:32:19 ······· Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/aws 2018/07/23 15:32:28 ········ Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/internal/sdk 2018/07/23 15:32:28 ········ Skipping (existing): github.com/go-ini/ini 2018/07/23 15:32:28 ········ Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/service/sts 2018/07/23 15:32:28 ········· Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/private/protocol/query 2018/07/23 15:32:28 ·········· Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/private/protocol 2018/07/23 15:32:28 ········· Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/internal/awsutil 2018/07/23 15:32:28 ·········· Skipping (existing): github.com/jmespath/go-jmespath 2018/07/23 15:32:28 ······· Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/service/cloudwatch 2018/07/23 15:32:29 ······· Skipping (existing): github.com/aws/aws-sdk-go/aws 2018/07/23 15:32:29 ······· Skipping (existing): github.com/prometheus/client_golang/prometheus 2018/07/23 15:32:29 ······· Skipping (existing): github.com/aws/aws-sdk-go/service/cloudwatch 2018/07/23 15:32:29 ······· Skipping (existing): github.com/aws/aws-sdk-go/service/cloudwatch/cloudwatchiface 2018/07/23 15:32:29 ······· Fetching recursive dependency: golang.org/x/sync/errgroup 2018/07/23 15:32:31 ········ Skipping (existing): golang.org/x/net/context 2018/07/23 15:32:31 ······· Fetching recursive dependency: github.com/go-kit/kit/util/conn 2018/07/23 15:32:31 ······· Fetching recursive dependency: github.com/VividCortex/gohistogram 2018/07/23 15:32:33 ····· Skipping (existing): github.com/prometheus/client_golang/prometheus 2018/07/23 15:32:33 ····· Fetching recursive dependency: github.com/codahale/hdrhistogram 2018/07/23 15:32:35 ·· Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:32:35 · Fetching recursive dependency: github.com/mwitkow/go-grpc-middleware 2018/07/23 15:32:37 ·· Fetching recursive dependency: github.com/grpc-ecosystem/go-grpc-middleware/logging 2018/07/23 15:32:39 ··· Fetching recursive dependency: github.com/grpc-ecosystem/go-grpc-middleware 2018/07/23 15:32:39 ···· Fetching recursive dependency: github.com/golang/protobuf/jsonpb 2018/07/23 15:32:42 ····· Skipping (existing): github.com/golang/protobuf/ptypes/timestamp 2018/07/23 15:32:42 ····· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:32:42 ····· Skipping (existing): github.com/golang/protobuf/ptypes/duration 2018/07/23 15:32:42 ····· Skipping (existing): github.com/golang/protobuf/ptypes/any 2018/07/23 15:32:42 ····· Skipping (existing): github.com/golang/protobuf/ptypes/struct 2018/07/23 15:32:42 ····· Skipping (existing): github.com/golang/protobuf/ptypes/wrappers 2018/07/23 15:32:42 ···· Skipping (existing): google.golang.org/grpc/metadata 2018/07/23 15:32:42 ···· Fetching recursive dependency: github.com/stretchr/testify/suite 2018/07/23 15:32:45 ····· Skipping (existing): github.com/stretchr/testify/assert 2018/07/23 15:32:45 ····· Fetching recursive dependency: github.com/stretchr/testify/require 2018/07/23 15:32:45 ······ Skipping (existing): github.com/stretchr/testify/assert 2018/07/23 15:32:45 ···· Skipping (existing): google.golang.org/grpc/peer 2018/07/23 15:32:45 ···· Skipping (existing): golang.org/x/net/context 2018/07/23 15:32:45 ···· Skipping (existing): golang.org/x/net/trace 2018/07/23 15:32:45 ···· Fetching recursive dependency: github.com/gogo/protobuf/gogoproto 2018/07/23 15:32:48 ····· Fetching recursive dependency: github.com/gogo/protobuf/protoc-gen-gogo/descriptor 2018/07/23 15:32:48 ······ Skipping (existing): github.com/gogo/protobuf/proto 2018/07/23 15:32:48 ····· Skipping (existing): github.com/gogo/protobuf/proto 2018/07/23 15:32:48 ···· Skipping (existing): google.golang.org/grpc/credentials 2018/07/23 15:32:48 ···· Skipping (existing): google.golang.org/grpc 2018/07/23 15:32:48 ···· Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:32:48 ···· Skipping (existing): google.golang.org/grpc/codes 2018/07/23 15:32:48 ···· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:32:48 ···· Skipping (existing): google.golang.org/grpc/grpclog 2018/07/23 15:32:48 ···· Skipping (existing): github.com/opentracing/opentracing-go/ext 2018/07/23 15:32:48 ···· Skipping (existing): github.com/opentracing/opentracing-go/log 2018/07/23 15:32:48 ··· Skipping (existing): golang.org/x/net/context 2018/07/23 15:32:48 ··· Skipping (existing): google.golang.org/grpc 2018/07/23 15:32:48 ··· Skipping (existing): google.golang.org/grpc/grpclog 2018/07/23 15:32:48 ··· Skipping (existing): google.golang.org/grpc/codes 2018/07/23 15:32:48 ··· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:32:48 ·· Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:32:48 ·· Skipping (existing): google.golang.org/grpc 2018/07/23 15:32:48 ·· Skipping (existing): golang.org/x/net/context 2018/07/23 15:32:48 ·· Skipping (existing): google.golang.org/grpc/codes 2018/07/23 15:32:48 ·· Skipping (existing): google.golang.org/grpc/grpclog 2018/07/23 15:32:48 ·· Skipping (existing): github.com/opentracing/opentracing-go/log 2018/07/23 15:32:48 ·· Skipping (existing): google.golang.org/grpc/metadata 2018/07/23 15:32:48 ·· Skipping (existing): google.golang.org/grpc/peer 2018/07/23 15:32:48 ·· Skipping (existing): google.golang.org/grpc/credentials 2018/07/23 15:32:48 ·· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:32:48 ·· Skipping (existing): golang.org/x/net/trace 2018/07/23 15:32:48 ·· Skipping (existing): github.com/opentracing/opentracing-go/ext 2018/07/23 15:32:48 · Fetching recursive dependency: github.com/weaveworks/promrus 2018/07/23 15:32:53 ·· Skipping (existing): gopkg.in/yaml.v2 2018/07/23 15:32:53 ·· Skipping (existing): golang.org/x/net/context/ctxhttp 2018/07/23 15:32:53 ·· Fetching recursive dependency: github.com/stretchr/objx 2018/07/23 15:32:55 ·· Fetching recursive dependency: gopkg.in/alecthomas/kingpin.v2 2018/07/23 15:32:58 ··· Fetching recursive dependency: github.com/alecthomas/units 2018/07/23 15:33:00 ··· Fetching recursive dependency: github.com/alecthomas/template 2018/07/23 15:33:02 ·· Fetching recursive dependency: github.com/julienschmidt/httprouter 2018/07/23 15:33:05 ·· Skipping (existing): golang.org/x/net/context 2018/07/23 15:33:05 · Skipping (existing): github.com/aws/aws-sdk-go/aws/credentials 2018/07/23 15:33:05 · Skipping (existing): github.com/golang/protobuf/ptypes/empty 2018/07/23 15:33:05 · Skipping (existing): golang.org/x/net/context 2018/07/23 15:33:05 · Skipping (existing): golang.org/x/tools/cover 2018/07/23 15:33:05 · Skipping (existing): github.com/mgutz/ansi ```
192 lines
8.8 KiB
Go
192 lines
8.8 KiB
Go
// Copyright 2014 The Prometheus Authors
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
// Package prometheus is the core instrumentation package. It provides metrics
|
|
// primitives to instrument code for monitoring. It also offers a registry for
|
|
// metrics. Sub-packages allow to expose the registered metrics via HTTP
|
|
// (package promhttp) or push them to a Pushgateway (package push). There is
|
|
// also a sub-package promauto, which provides metrics constructors with
|
|
// automatic registration.
|
|
//
|
|
// All exported functions and methods are safe to be used concurrently unless
|
|
// specified otherwise.
|
|
//
|
|
// A Basic Example
|
|
//
|
|
// As a starting point, a very basic usage example:
|
|
//
|
|
// package main
|
|
//
|
|
// import (
|
|
// "log"
|
|
// "net/http"
|
|
//
|
|
// "github.com/prometheus/client_golang/prometheus"
|
|
// "github.com/prometheus/client_golang/prometheus/promhttp"
|
|
// )
|
|
//
|
|
// var (
|
|
// cpuTemp = prometheus.NewGauge(prometheus.GaugeOpts{
|
|
// Name: "cpu_temperature_celsius",
|
|
// Help: "Current temperature of the CPU.",
|
|
// })
|
|
// hdFailures = prometheus.NewCounterVec(
|
|
// prometheus.CounterOpts{
|
|
// Name: "hd_errors_total",
|
|
// Help: "Number of hard-disk errors.",
|
|
// },
|
|
// []string{"device"},
|
|
// )
|
|
// )
|
|
//
|
|
// func init() {
|
|
// // Metrics have to be registered to be exposed:
|
|
// prometheus.MustRegister(cpuTemp)
|
|
// prometheus.MustRegister(hdFailures)
|
|
// }
|
|
//
|
|
// func main() {
|
|
// cpuTemp.Set(65.3)
|
|
// hdFailures.With(prometheus.Labels{"device":"/dev/sda"}).Inc()
|
|
//
|
|
// // The Handler function provides a default handler to expose metrics
|
|
// // via an HTTP server. "/metrics" is the usual endpoint for that.
|
|
// http.Handle("/metrics", promhttp.Handler())
|
|
// log.Fatal(http.ListenAndServe(":8080", nil))
|
|
// }
|
|
//
|
|
//
|
|
// This is a complete program that exports two metrics, a Gauge and a Counter,
|
|
// the latter with a label attached to turn it into a (one-dimensional) vector.
|
|
//
|
|
// Metrics
|
|
//
|
|
// The number of exported identifiers in this package might appear a bit
|
|
// overwhelming. However, in addition to the basic plumbing shown in the example
|
|
// above, you only need to understand the different metric types and their
|
|
// vector versions for basic usage. Furthermore, if you are not concerned with
|
|
// fine-grained control of when and how to register metrics with the registry,
|
|
// have a look at the promauto package, which will effectively allow you to
|
|
// ignore registration altogether in simple cases.
|
|
//
|
|
// Above, you have already touched the Counter and the Gauge. There are two more
|
|
// advanced metric types: the Summary and Histogram. A more thorough description
|
|
// of those four metric types can be found in the Prometheus docs:
|
|
// https://prometheus.io/docs/concepts/metric_types/
|
|
//
|
|
// A fifth "type" of metric is Untyped. It behaves like a Gauge, but signals the
|
|
// Prometheus server not to assume anything about its type.
|
|
//
|
|
// In addition to the fundamental metric types Gauge, Counter, Summary,
|
|
// Histogram, and Untyped, a very important part of the Prometheus data model is
|
|
// the partitioning of samples along dimensions called labels, which results in
|
|
// metric vectors. The fundamental types are GaugeVec, CounterVec, SummaryVec,
|
|
// HistogramVec, and UntypedVec.
|
|
//
|
|
// While only the fundamental metric types implement the Metric interface, both
|
|
// the metrics and their vector versions implement the Collector interface. A
|
|
// Collector manages the collection of a number of Metrics, but for convenience,
|
|
// a Metric can also “collect itself”. Note that Gauge, Counter, Summary,
|
|
// Histogram, and Untyped are interfaces themselves while GaugeVec, CounterVec,
|
|
// SummaryVec, HistogramVec, and UntypedVec are not.
|
|
//
|
|
// To create instances of Metrics and their vector versions, you need a suitable
|
|
// …Opts struct, i.e. GaugeOpts, CounterOpts, SummaryOpts, HistogramOpts, or
|
|
// UntypedOpts.
|
|
//
|
|
// Custom Collectors and constant Metrics
|
|
//
|
|
// While you could create your own implementations of Metric, most likely you
|
|
// will only ever implement the Collector interface on your own. At a first
|
|
// glance, a custom Collector seems handy to bundle Metrics for common
|
|
// registration (with the prime example of the different metric vectors above,
|
|
// which bundle all the metrics of the same name but with different labels).
|
|
//
|
|
// There is a more involved use case, too: If you already have metrics
|
|
// available, created outside of the Prometheus context, you don't need the
|
|
// interface of the various Metric types. You essentially want to mirror the
|
|
// existing numbers into Prometheus Metrics during collection. An own
|
|
// implementation of the Collector interface is perfect for that. You can create
|
|
// Metric instances “on the fly” using NewConstMetric, NewConstHistogram, and
|
|
// NewConstSummary (and their respective Must… versions). That will happen in
|
|
// the Collect method. The Describe method has to return separate Desc
|
|
// instances, representative of the “throw-away” metrics to be created later.
|
|
// NewDesc comes in handy to create those Desc instances.
|
|
//
|
|
// The Collector example illustrates the use case. You can also look at the
|
|
// source code of the processCollector (mirroring process metrics), the
|
|
// goCollector (mirroring Go metrics), or the expvarCollector (mirroring expvar
|
|
// metrics) as examples that are used in this package itself.
|
|
//
|
|
// If you just need to call a function to get a single float value to collect as
|
|
// a metric, GaugeFunc, CounterFunc, or UntypedFunc might be interesting
|
|
// shortcuts.
|
|
//
|
|
// Advanced Uses of the Registry
|
|
//
|
|
// While MustRegister is the by far most common way of registering a Collector,
|
|
// sometimes you might want to handle the errors the registration might cause.
|
|
// As suggested by the name, MustRegister panics if an error occurs. With the
|
|
// Register function, the error is returned and can be handled.
|
|
//
|
|
// An error is returned if the registered Collector is incompatible or
|
|
// inconsistent with already registered metrics. The registry aims for
|
|
// consistency of the collected metrics according to the Prometheus data model.
|
|
// Inconsistencies are ideally detected at registration time, not at collect
|
|
// time. The former will usually be detected at start-up time of a program,
|
|
// while the latter will only happen at scrape time, possibly not even on the
|
|
// first scrape if the inconsistency only becomes relevant later. That is the
|
|
// main reason why a Collector and a Metric have to describe themselves to the
|
|
// registry.
|
|
//
|
|
// So far, everything we did operated on the so-called default registry, as it
|
|
// can be found in the global DefaultRegisterer variable. With NewRegistry, you
|
|
// can create a custom registry, or you can even implement the Registerer or
|
|
// Gatherer interfaces yourself. The methods Register and Unregister work in the
|
|
// same way on a custom registry as the global functions Register and Unregister
|
|
// on the default registry.
|
|
//
|
|
// There are a number of uses for custom registries: You can use registries with
|
|
// special properties, see NewPedanticRegistry. You can avoid global state, as
|
|
// it is imposed by the DefaultRegisterer. You can use multiple registries at
|
|
// the same time to expose different metrics in different ways. You can use
|
|
// separate registries for testing purposes.
|
|
//
|
|
// Also note that the DefaultRegisterer comes registered with a Collector for Go
|
|
// runtime metrics (via NewGoCollector) and a Collector for process metrics (via
|
|
// NewProcessCollector). With a custom registry, you are in control and decide
|
|
// yourself about the Collectors to register.
|
|
//
|
|
// HTTP Exposition
|
|
//
|
|
// The Registry implements the Gatherer interface. The caller of the Gather
|
|
// method can then expose the gathered metrics in some way. Usually, the metrics
|
|
// are served via HTTP on the /metrics endpoint. That's happening in the example
|
|
// above. The tools to expose metrics via HTTP are in the promhttp sub-package.
|
|
// (The top-level functions in the prometheus package are deprecated.)
|
|
//
|
|
// Pushing to the Pushgateway
|
|
//
|
|
// Function for pushing to the Pushgateway can be found in the push sub-package.
|
|
//
|
|
// Graphite Bridge
|
|
//
|
|
// Functions and examples to push metrics from a Gatherer to Graphite can be
|
|
// found in the graphite sub-package.
|
|
//
|
|
// Other Means of Exposition
|
|
//
|
|
// More ways of exposing metrics can easily be added by following the approaches
|
|
// of the existing implementations.
|
|
package prometheus
|