https://github.com/prometheus/client_golang

Last synced: about 23 hours ago

Repository metadata:

Prometheus instrumentation library for Go applications


Owner metadata:


Committers metadata

Last synced: 1 day ago

Total Commits: 1,212
Total Committers: 249
Avg Commits per committer: 4.867
Development Distribution Score (DDS): 0.839

Commits in past year: 172
Committers in past year: 44
Avg Commits per committer in past year: 3.909
Development Distribution Score (DDS) in past year: 0.703

Name Email Commits
beorn7 b****n@s****m 195
beorn7 b****n@g****m 119
dependabot[bot] 4****] 85
Matt T. Proud m****d@g****m 64
prombot p****m@g****m 64
Bartlomiej Plotka b****a@g****m 45
Bjoern Rabenstein b****n@s****m 41
Julius Volz j****s@s****m 24
beorn7 b****n@r****n 21
Kemal Akkoyun k****n 18
Ben Kochie s****q@g****m 17
Fabian Reinartz f****z@g****m 17
Thomas Jackson j****9@g****m 13
Arthur Silva Sens a****s@c****m 12
Julius Volz j****z@g****m 12
André Carvalho a****c@g****m 11
Karsten Weiss k****s@g****m 11
Simon Pasquier s****e@r****m 10
Kevin Pike k****e@d****e 10
Bernerd Schaefer b****r@g****m 10
Marco Jantke m****e@g****m 9
Arthur Silva Sens a****5@g****m 8
Robert Vollmert r****t@g****m 8
Manuel Rüger m****l@r****u 8
glefloch g****h@g****m 7
Tobias Schmidt ts@s****m 7
Peter Jausovec p****c@o****m 7
György Krajcsovits g****s@g****m 7
Daniel Bornkessel d****l@s****m 7
Sevag Hanssian s****n@g****m 7
and 219 more...

Issue and Pull Request metadata

Last synced: about 23 hours ago


Package metadata

go: github.com/prometheus/client_golang

go: github.com/prometheus/client_golang/prometheus/internal

Copyright (c) 2015 Björn Rabenstein Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. The code in this package is copy/paste to avoid a dependency. Hence this file carries the copyright of the original repo. https://github.com/beorn7/floats Copyright 2022 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. It provides tools to compare sequences of strings and generate textual diffs. Maintaining `GetUnifiedDiffString` here because original repository (https://github.com/pmezard/go-difflib) is no longer maintained.

go: github.com/Prometheus/client_golang

  • Homepage: https://github.com/Prometheus/client_golang
  • Documentation: https://pkg.go.dev/github.com/Prometheus/client_golang#section-documentation
  • Licenses: Apache-2.0
  • Latest release: v1.19.1 (published 6 months ago)
  • Last Synced: 2024-11-11T01:17:59.490Z (2 days ago)
  • Versions: 43
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Rankings:
    • Forks count: 0.583%
    • Stargazers count: 0.624%
    • Average: 4.388%
    • Dependent packages count: 6.999%
    • Dependent repos count: 9.346%
go: github.com/prometheus/client_goLang

  • Homepage: https://github.com/prometheus/client_goLang
  • Documentation: https://pkg.go.dev/github.com/prometheus/client_goLang#section-documentation
  • Licenses: Apache-2.0
  • Latest release: v1.19.1 (published 6 months ago)
  • Last Synced: 2024-11-11T01:18:00.607Z (2 days ago)
  • Versions: 43
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Rankings:
    • Forks count: 0.583%
    • Stargazers count: 0.624%
    • Average: 4.388%
    • Dependent packages count: 6.999%
    • Dependent repos count: 9.346%
go: github.com/prometheus/Client_golang

  • Homepage: https://github.com/prometheus/Client_golang
  • Documentation: https://pkg.go.dev/github.com/prometheus/Client_golang#section-documentation
  • Licenses: Apache-2.0
  • Latest release: v1.19.1 (published 6 months ago)
  • Last Synced: 2024-11-11T01:18:04.836Z (2 days ago)
  • Versions: 43
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Rankings:
    • Forks count: 0.583%
    • Stargazers count: 0.624%
    • Average: 4.388%
    • Dependent packages count: 6.999%
    • Dependent repos count: 9.346%
go: github.com/prometheus/client_Golang

  • Homepage: https://github.com/prometheus/client_Golang
  • Documentation: https://pkg.go.dev/github.com/prometheus/client_Golang#section-documentation
  • Licenses: Apache-2.0
  • Latest release: v1.19.1 (published 6 months ago)
  • Last Synced: 2024-11-11T01:18:17.460Z (2 days ago)
  • Versions: 43
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Rankings:
    • Forks count: 0.583%
    • Stargazers count: 0.624%
    • Average: 4.388%
    • Dependent packages count: 6.999%
    • Dependent repos count: 9.346%
go: github.com/prometheus/client_golang/prometheus

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. As a starting point, a very basic usage example: 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. It register the metrics using a custom registry and exposes them via an HTTP server on the /metrics endpoint. 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/ In addition to the fundamental metric types Gauge, Counter, Summary, and Histogram, 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, and HistogramVec. 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, and Histogram are interfaces themselves while GaugeVec, CounterVec, SummaryVec, and HistogramVec are not. To create instances of Metrics and their vector versions, you need a suitable …Opts struct, i.e. GaugeOpts, CounterOpts, SummaryOpts, or HistogramOpts. 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). NewConstMetric is used for all metric types with just a float64 as their value: Counter, Gauge, and a special “type” called Untyped. Use the latter if you are not sure if the mirrored metric is a Counter or a Gauge. Creation of the Metric instance happens 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. Alternatively, you could return no Desc at all, which will mark the Collector “unchecked”. No checks are performed at registration time, but metric consistency will still be ensured at scrape time, i.e. any inconsistencies will lead to scrape errors. Thus, with unchecked Collectors, the responsibility to not collect metrics that lead to inconsistencies in the total scrape result lies with the implementer of the Collector. While this is not a desirable state, it is sometimes necessary. The typical use case is a situation where the exact metrics to be returned by a Collector cannot be predicted at registration time, but the implementer has sufficient knowledge of the whole system to guarantee metric consistency. 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. 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. 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. Function for pushing to the Pushgateway can be found in the push sub-package. Functions and examples to push metrics from a Gatherer to Graphite can be found in the graphite sub-package. More ways of exposing metrics can easily be added by following the approaches of the existing implementations.

go: github.com/prometheus/client_golang/prometheus/promhttp

Package promhttp provides tooling around HTTP servers and clients. First, the package allows the creation of http.Handler instances to expose Prometheus metrics via HTTP. promhttp.Handler acts on the prometheus.DefaultGatherer. With HandlerFor, you can create a handler for a custom registry or anything that implements the Gatherer interface. It also allows the creation of handlers that act differently on errors or allow to log errors. Second, the package provides tooling to instrument instances of http.Handler via middleware. Middleware wrappers follow the naming scheme InstrumentHandlerX, where X describes the intended use of the middleware. See each function's doc comment for specific details. Finally, the package allows for an http.RoundTripper to be instrumented via middleware. Middleware wrappers follow the naming scheme InstrumentRoundTripperX, where X describes the intended use of the middleware. See each function's doc comment for specific details.

go: github.com/prometheus/client_golang/tutorials/whatsup

go: github.com/prometheus/client_golang/examples/middleware


Dependencies

go.mod go
  • github.com/beorn7/perks v1.0.1
  • github.com/cespare/xxhash/v2 v2.1.2
  • github.com/davecgh/go-spew v1.1.1
  • github.com/golang/protobuf v1.5.2
  • github.com/jpillora/backoff v1.0.0
  • github.com/json-iterator/go v1.1.12
  • github.com/matttproud/golang_protobuf_extensions v1.0.1
  • github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421
  • github.com/modern-go/reflect2 v1.0.2
  • github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f
  • github.com/prometheus/client_model v0.2.0
  • github.com/prometheus/common v0.35.0
  • github.com/prometheus/procfs v0.7.3
  • golang.org/x/net v0.0.0-20220225172249-27dd8689420f
  • golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b
  • golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
  • golang.org/x/text v0.3.7
  • google.golang.org/appengine v1.6.6
  • google.golang.org/protobuf v1.28.0
  • gopkg.in/yaml.v2 v2.4.0
go.sum go
  • 390 dependencies
.github/workflows/codeql-analysis.yml actions
  • actions/checkout v2 composite
  • github/codeql-action/analyze v1 composite
  • github/codeql-action/autobuild v1 composite
  • github/codeql-action/init v1 composite
.github/workflows/golangci-lint.yml actions
  • actions/checkout v3 composite
  • actions/setup-go v2 composite
  • golangci/golangci-lint-action v3.2.0 composite
Dockerfile docker
  • golang 1 build
  • quay.io/prometheus/busybox latest build
examples/middleware/go.mod go
  • github.com/beorn7/perks v1.0.1
  • github.com/cespare/xxhash/v2 v2.1.2
  • github.com/golang/protobuf v1.5.2
  • github.com/matttproud/golang_protobuf_extensions v1.0.1
  • github.com/prometheus/client_golang v1.13.1
  • github.com/prometheus/client_model v0.2.0
  • github.com/prometheus/common v0.37.0
  • github.com/prometheus/procfs v0.8.0
  • golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
  • google.golang.org/protobuf v1.28.1
examples/middleware/go.sum go
  • 466 dependencies
.github/workflows/go.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-go v4 composite
.bingo/go.mod go
tutorial/whatsup/go.mod go
  • github.com/beorn7/perks v1.0.1
  • github.com/bwplotka/tracing-go v0.0.0-20230421061608-abdf862ceccd
  • github.com/cenkalti/backoff/v4 v4.1.2
  • github.com/cespare/xxhash/v2 v2.2.0
  • github.com/davecgh/go-spew v1.1.1
  • github.com/efficientgo/core v1.0.0-rc.2
  • github.com/efficientgo/e2e v0.14.1-0.20230421070206-d72d43f3b937
  • github.com/efficientgo/tools/core v0.0.0-20220225185207-fe763185946b
  • github.com/felixge/httpsnoop v1.0.2
  • github.com/go-logr/logr v1.2.3
  • github.com/go-logr/stdr v1.2.2
  • github.com/golang/protobuf v1.5.3
  • github.com/google/go-cmp v0.5.9
  • github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0
  • github.com/jpillora/backoff v1.0.0
  • github.com/json-iterator/go v1.1.12
  • github.com/matttproud/golang_protobuf_extensions v1.0.4
  • github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
  • github.com/modern-go/reflect2 v1.0.2
  • github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f
  • github.com/oklog/run v1.1.0
  • github.com/pkg/errors v0.9.1
  • github.com/prometheus/client_golang v1.16.0
  • github.com/prometheus/client_model v0.4.0
  • github.com/prometheus/common v0.44.0
  • github.com/prometheus/procfs v0.10.1
  • go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.32.0
  • go.opentelemetry.io/otel v1.7.0
  • go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.6.3
  • go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.6.3
  • go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.6.3
  • go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.6.3
  • go.opentelemetry.io/otel/metric v0.30.0
  • go.opentelemetry.io/otel/sdk v1.6.3
  • go.opentelemetry.io/otel/trace v1.7.0
  • go.opentelemetry.io/proto/otlp v0.15.0
  • golang.org/x/net v0.10.0
  • golang.org/x/oauth2 v0.8.0
  • golang.org/x/sys v0.8.0
  • golang.org/x/text v0.9.0
  • google.golang.org/appengine v1.6.7
  • google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f
  • google.golang.org/grpc v1.53.0
  • google.golang.org/protobuf v1.30.0
  • gopkg.in/yaml.v2 v2.4.0
tutorial/whatsup/go.sum go
  • 478 dependencies
.github/workflows/automerge-dependabot.yml actions
  • dependabot/fetch-metadata c9c4182bf1b97f5224aee3906fd373f6b61b4526 composite