Commit Graph

531 Commits

Author SHA1 Message Date
Rafael Franco 7c46c150bd
Clarify documentation around what constructors do (#1125)
The wording of the documentation is slightly misleading. Before this
commit, it says that the returned collectors are "already registered".
This could be interpreted in two ways, one could think that promauto
keeps some sort of cache of already registered Collectors that are
returned by this package, and the other way is that the Collectors
constructed are registered before being returned. What is actually
happening is the latter, and the wording after this PR leaves no room to
think that the former could be the case.

Signed-off-by: Rafael Franco <me@rafaelfranco.es>

Signed-off-by: Rafael Franco <me@rafaelfranco.es>
2022-09-12 11:17:56 +02:00
Robert Fratto 83d56b1144
Extend prometheus.Registry to implement Collector (#1103)
* prometheus: implement Collector interface for Registry

This change allows Registries to be used as Collectors.

This enables new instances of Registry to be passed to ephemeral
subroutines for collecting metrics from subroutines which are still
running:

```go
package main

import (
  "fmt"

  "github.com/prometheus/client_golang/prometheus"
)

func main() {
  globalReg := prometheus.NewRegistry()

  for i := 0; i < 100; i++ {
    workerReg := prometheus.WrapRegistererWith(prometheus.Labels{
      // Add an ID label so registered metrics from workers don't
      // collide.
      "worker_id": fmt.Sprintf("%d", i),
    }, prometheus.NewRegistry()

    globalReg.MustRegister(workerReg)

    go func(i int) {
      runWorker(workerReg)

      // Unregister any metrics the worker may have created.
      globalReg.Unregister(workerReg)
    }(i)
  }
}

// runWorker runs a worker, registering worker-specific metrics.
func runWorker(reg *prometheus.Registry) {
  // ... register metrics ...
  // ... do work ...
}
```

This change makes it easier to avoid leaking metrics from subroutines
which do not consistently properly unregister metrics.

Signed-off-by: Robert Fratto <robertfratto@gmail.com>

* fix grammar in doc comment

Signed-off-by: Robert Fratto <robertfratto@gmail.com>

* document why Registry implements Collector with example

Signed-off-by: Robert Fratto <robertfratto@gmail.com>

Signed-off-by: Robert Fratto <robertfratto@gmail.com>
2022-08-23 11:09:29 +02:00
Dave Henderson 4c41dfbcd5
Clarify exemplar(Add|Observe) by renaming to (add|observe)WithExemplar (#1122)
* Clarify exemplarAdd by renaming to addWithExemplar

Signed-off-by: Dave Henderson <dhenderson@gmail.com>

* Documenting addWithExemplar

Signed-off-by: Dave Henderson <dhenderson@gmail.com>

* Also rename exemplarObserve to follow the same pattern

Signed-off-by: Dave Henderson <dhenderson@gmail.com>

Signed-off-by: Dave Henderson <dhenderson@gmail.com>
2022-08-22 17:31:08 +02:00
Dave Henderson f73e3cc0e2
Fix double-counting bug in promhttp.InstrumentRoundTripperCounter (#1118)
Signed-off-by: Dave Henderson <dhenderson@gmail.com>

Signed-off-by: Dave Henderson <dhenderson@gmail.com>
2022-08-22 08:28:46 +03:00
Bartlomiej Plotka 5b7e8b2e67
collectors.GoCollector: Added rule support for granular metric configuration. (#1102)
* goCollector: Added rule support for granular metric configuration.

Fixes: https://github.com/prometheus/client_golang/issues/1089

Signed-off-by: bwplotka <bwplotka@gmail.com>

* Added compatibility mode with old options. (#1107)

* Added compatibility mode with old options.

Signed-off-by: bwplotka <bwplotka@gmail.com>

* Copyright header.

Signed-off-by: bwplotka <bwplotka@gmail.com>

* Remove bucket option for now. (#1108)

Signed-off-by: bwplotka <bwplotka@gmail.com>

* collectors/GoCollector: Add tests and examples (#1109)

* Add tests and examples

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Add docs for the presets

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

Co-authored-by: Kemal Akkoyun <kakkoyun@users.noreply.github.com>
2022-08-05 19:37:46 +02:00
Christian Stewart d44fbbefdd
Fix build against GopherJS (#897)
* Fix build against GopherJS

When building against GopherJS, ThreadCreateProfile and Getpid are not
available.

Return 1 to shim the functions.

Signed-off-by: Christian Stewart <christian@paral.in>

* Fix formatting

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Fix linter issue

Move build tags for licence header checks

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

Co-authored-by: Kemal Akkoyun <kakkoyun@gmail.com>
2022-08-05 16:28:54 +02:00
Soroosh Azary Marhabi 1638da9ae4
testutil: Add ScrapeAndCompare (#1043)
* testutil: Add ScrapeAndCompare

Signed-off-by: sazary <soroosh@azary.ir>

* testutil: Use %w verb wherever we're using an error in fmt.Errorf

Signed-off-by: sazary <soroosh@azary.ir>

* Format

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

Co-authored-by: Kemal Akkoyun <kakkoyun@users.noreply.github.com>
Co-authored-by: Kemal Akkoyun <kakkoyun@gmail.com>
2022-08-05 16:27:47 +02:00
Kemal Akkoyun c576b951ad
Generate new Go runtime metrics for go 1.19 (#1105)
* Generate new Go runtime metrics

Fix generation script

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Address review issues

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
2022-08-05 15:48:33 +02:00
Christoph Mewes 618194de6a
fix assorted oddities found by golangci-lint (#1040)
* fix assorted oddities found by golangci-lint

Signed-off-by: Christoph Mewes <christoph@kubermatic.com>

* permanently enable the linters

Signed-off-by: Christoph Mewes <christoph@kubermatic.com>

* post-rebase blues

Signed-off-by: Christoph Mewes <christoph@kubermatic.com>
2022-08-03 06:30:51 +02:00
Bartlomiej Plotka c7488be2e4
Added exemplar support to http middleware. (#1055)
* Added exemplar support to http middlewares.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Small fix.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Fixed test.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Added tests and options for RT.

Signed-off-by: bwplotka <bwplotka@gmail.com>

* goimports.

Signed-off-by: bwplotka <bwplotka@gmail.com>
2022-08-02 19:33:08 +02:00
Bartlomiej Plotka 3faf3bae70
Fixed support for unordered input of exemplars. (#1100)
Signed-off-by: bwplotka <bwplotka@gmail.com>
2022-08-02 11:32:30 +02:00
Arun Mahendra 807b1ee73c
explicitly add +inf bucket in withExemplarsMetric (#1094)
* explicitly adding +inf bucket to withExemplarsMetric

Signed-off-by: Arun Mahendra <arun.mahendra@shopify.com>

* Update prometheus/metric_test.go

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Update prometheus/metric.go

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>

* updated comment and removed unnecessary test

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
2022-08-02 10:48:18 +02:00
inosato 44c2c4de85
Remove ioutil (#1096)
Signed-off-by: inosato <si17_21@yahoo.co.jp>
2022-08-02 10:27:49 +02:00
Fredrik Enestad a528affed9
Update documentation for exemplar label limit (#1095)
Signed-off-by: Fredrik Enestad <fredrik@enestad.com>
2022-07-27 17:45:49 +02:00
Bryan Boreham ba4a543ab4
Raise exemplar labels limit from 64 to 128 (#1091)
In line with the OpenMetrics spec:
"The combined length of the label names and values of an Exemplar's
LabelSet MUST NOT exceed 128 UTF-8 character code points"

https://github.com/OpenObservability/OpenMetrics/blob/98ae26c87b/specification/OpenMetrics.md#exemplars

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2022-07-19 16:50:45 +02:00
Curith 810fcb46ab
Add Error API for pusher (#1075)
Signed-off-by: kun <oiooj@qq.com>
2022-06-30 17:00:36 +02:00
Soroosh Azary Marhabi 2cfd1eb960
Enable same linters as the Prometheus repo itself (#1056)
* Add gofumpt to github workflow & fix all files for it

Signed-off-by: sazary <soroosh@azary.ir>

* Add goimports to golangci & fix it's issues

Signed-off-by: sazary <soroosh@azary.ir>

* Add revive to golangci & fix it's issues

Signed-off-by: sazary <soroosh@azary.ir>

* Add errcheck & misspell to golangci and fix their issues

Signed-off-by: sazary <soroosh@azary.ir>

* Add govet & gosimple to golangci and fix their issues

Signed-off-by: sazary <soroosh@azary.ir>

* Enable all default linters of golangci

Signed-off-by: sazary <soroosh@azary.ir>
2022-06-17 09:04:06 +02:00
Kemal Akkoyun 35c82f2c7e
Remove -Inf buckets from go collector histograms (#1049)
* Remove -Inf buckets from go collector histograms

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Update prometheus/collectors/go_collector_latest_test.go

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Simplify

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
2022-05-13 10:04:45 +02:00
Kemal Akkoyun f25114699a
prometheus: Fix convention violating names for generated collector metrics (#1048)
* Fix convention violating names for generated collector metrics

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Add new Go collector example

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
2022-05-09 10:33:45 +02:00
Zach Stone 4dcf02ec7b
Implement deletion based on partially matching labels (#1013)
* WIP partial match

Signed-off-by: Zach Stone <zach@giantswarm.io>

* Cleanup

Signed-off-by: Zach Stone <zach@giantswarm.io>

* Comments

Signed-off-by: Zach Stone <zach@giantswarm.io>

* Tests and comments

Signed-off-by: Zach Stone <zach@giantswarm.io>

* Handle properly deleting multiple metrics, update tests

Signed-off-by: Zach Stone <zach@giantswarm.io>

* Comments

Signed-off-by: Zach Stone <zach@giantswarm.io>

* Try using curry values

Signed-off-by: Zach Stone <zach@giantswarm.io>

* Skip curry value to demo

Signed-off-by: Zach Stone <zach@giantswarm.io>

* Fix curry deletion, remove outdated comment.

Signed-off-by: Zach Stone <zach@giantswarm.io>

* Fix logic for deletion of metrics from prior to currying

Signed-off-by: Zach Stone <zach@giantswarm.io>

* Don't match curried values. Update tests.

Signed-off-by: Zach Stone <zach@giantswarm.io>

* Remove unneccesasry helper and todo comments

Signed-off-by: Zach Stone <zach@giantswarm.io>

* Comment about partial matching curried labels

Signed-off-by: Zach Stone <zach@giantswarm.io>

* Simplify curried value check

Signed-off-by: Zach Stone <zach@giantswarm.io>
2022-04-21 08:29:05 +02:00
Bartlomiej Plotka 11ee9add27
gocollector: Reverted client_golang v1.12 addition of runtime/metrics metrics by default. (#1033)
Fixes https://github.com/prometheus/client_golang/issues/967

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
2022-04-13 20:43:29 +02:00
Sourik Ghosh cd90f33be8
smart diff to testutil.GatherAndCompare (#998)
* added smart diff to testutil.GatherAndCompare

Signed-off-by: Sourik Ghosh <sourikghosh31@gmail.com>

* v2 testuitls added for better diff

Signed-off-by: Sourik Ghosh <sourikghosh31@gmail.com>

* replaced CollectAndCompare to CollectAndCompareV2 in testutil_test

Signed-off-by: Sourik Ghosh <sourikghosh31@gmail.com>

* renamed methods from v2 to withT

Signed-off-by: Sourik Ghosh <sourikghosh31@gmail.com>

* replaced testify with custom diff func

Signed-off-by: Sourik Ghosh <sourikghosh31@gmail.com>

* difflib GetUnifiedDiffString added with test

Signed-off-by: Sourik Ghosh <sourikghosh31@gmail.com>

* license meta data added to file

Signed-off-by: Sourik Ghosh <sourikghosh31@gmail.com>

* moved difflib to internal

Signed-off-by: Sourik Ghosh <sourikghosh31@gmail.com>
2022-04-13 18:38:05 +01:00
Manuel Rüger 46d3dd4e6c
Bump minimum required Go version to 1.16 (#1032)
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2022-04-13 16:21:42 +01:00
Bartlomiej Plotka 24172847e3
gocollector: Added options to Go Collector for changing the (#1031)
* Renamed files.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* gocollector: Added options to Go Collector for diffetent collections.

Fixes https://github.com/prometheus/client_golang/issues/983

Also:

* fixed TestMemStatsEquivalence, it was noop before (:
* Removed gc_cpu_fraction metric completely, since it's not working completely for Go1.17+

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
2022-04-13 09:55:22 +01:00
Tatsuhiro Tsujikawa 0bab4fda94
push: Add PushContext and AddContext to Pusher (#1028)
Add PushContext and AddContext to Pusher, which are context-aware
version of Push and Add respectively.  They give a caller the ability
to cancel an HTTP request.

Signed-off-by: Tatsuhiro Tsujikawa <ttsujika@zlab.co.jp>
2022-04-12 16:25:43 +02:00
Mitsuo Heijo 8dfa334295
Remove workaround for pre go1.15 (#1010)
Signed-off-by: Mitsuo Heijo <mitsuo.heijo@gmail.com>
2022-03-27 19:11:56 +01:00
zhijian 36b47eb0ab
When prefix is empty, no more dots should be written (#1005)
Signed-off-by: zhijian <djx@juicedata.io>
2022-03-17 15:43:50 +00:00
Kemal Akkoyun 5d78aaad41
.circleci: Add config to test against go1.18 (#1006)
* Add config to test against go1.18

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Try to fix circleci

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
2022-03-17 15:34:12 +00:00
Bartlomiej Plotka 9894406186 Fixed lint warning.
Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
2022-03-17 11:31:49 +00:00
William Perron 66837e3298
Add exemplar support for const histogram and const metric (#986)
* Add support for exemplars on constHistogram

Co-authored-by: William Perron <william.perron@shopify.com>
Signed-off-by: William Perron <william.perron@shopify.com>

* remove GetExemplars function

Signed-off-by: William Perron <william.perron@shopify.com>

* fixed linting warnings

reduce repetition in constHistogram w/ exemplar

Signed-off-by: William Perron <william.perron@shopify.com>

* Add values to correct bucket

Signed-off-by: William Perron <william.perron@shopify.com>

* Misc fixes

Co-authored-by: Francis Bogsanyi <francis.bogsanyi@shopify.com>

Signed-off-by: William Perron <william.perron@shopify.com>

* avoid panic when there are fewer buckets than exemplars

Co-authored-by: Arun Mahendra <arun.mahendra@shopify.com>

Signed-off-by: William Perron <william.perron@shopify.com>

* Added MustNewMetricWithExemplars that wraps metrics with exemplar (#3)

Changes:
* Make sure to not "leak" dto.Metric
* Reused upper bounds we already have for histogram
* Common code for all types.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

Co-authored-by: Arun Mahendra <arun.mahendra@shopify.com>
Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
2022-03-17 11:30:41 +00:00
Bartlomiej Plotka 1f81b3e913
Added Transactional Gatherer allowed cached solutions (#989)
* Added cached collector.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

update.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

Attempt 2

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

Added blocking registry, with raw collector and transactional handler.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

Added fast path to normal (empty) registry to save 8 allocs and 3K5B per Gather.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

Simplified API, added tests.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

Fix.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

Simplified implementation.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

Added benchmark.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

Optimized.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Optimization attempt.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Revert "Optimization attempt."

This reverts commit 2fcaf51be9.

Optimization was not worth it:

 benchstat v1.txt v2.txt
name                                                           old time/op    new time/op    delta
CachedTGatherer_Update/Update_of_one_element_without_reset-12    2.64µs ± 0%    4.05µs ± 0%   ~     (p=1.000 n=1+1)
CachedTGatherer_Update/Update_of_all_elements_with_reset-12       701ms ± 0%     358ms ± 0%   ~     (p=1.000 n=1+1)
CachedTGatherer_Update/Gather-12                                  535µs ± 0%  703934µs ± 0%   ~     (p=1.000 n=1+1)

name                                                           old alloc/op   new alloc/op   delta
CachedTGatherer_Update/Update_of_one_element_without_reset-12      208B ± 0%      208B ± 0%   ~     (all equal)
CachedTGatherer_Update/Update_of_all_elements_with_reset-12      40.2MB ± 0%    41.1MB ± 0%   ~     (p=1.000 n=1+1)
CachedTGatherer_Update/Gather-12                                 48.6kB ± 0%    84.3kB ± 0%   ~     (p=1.000 n=1+1)

name                                                           old allocs/op  new allocs/op  delta
CachedTGatherer_Update/Update_of_one_element_without_reset-12      3.00 ± 0%      3.00 ± 0%   ~     (all equal)
CachedTGatherer_Update/Update_of_all_elements_with_reset-12        6.00 ± 0%   4003.00 ± 0%   ~     (p=1.000 n=1+1)
CachedTGatherer_Update/Gather-12                                  1.00k ± 0%     2.01k ± 0%   ~     (p=1.000 n=1+1)

* nit.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Another optimization attempt.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* rename and further optimization.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Hopefully final optimization.

benchstat -delta-test=none v6.txt v9.txt
name                                                           old time/op    new time/op    delta
CachedTGatherer_Update/Update_of_one_element_without_reset-12    13.1ms ± 0%     0.0ms ± 0%  -99.81%
CachedTGatherer_Update/Update_of_all_elements_with_reset-12       309ms ± 0%     282ms ± 0%   -8.77%
CachedTGatherer_Update/Gather-12                                  422ms ± 0%       0ms ± 0%  -99.95%

name                                                           old alloc/op   new alloc/op   delta
CachedTGatherer_Update/Update_of_one_element_without_reset-12      208B ± 0%      208B ± 0%    0.00%
CachedTGatherer_Update/Update_of_all_elements_with_reset-12      2.47kB ± 0%    1.67kB ± 0%  -32.56%
CachedTGatherer_Update/Gather-12                                 52.8kB ± 0%    24.6kB ± 0%  -53.34%

name                                                           old allocs/op  new allocs/op  delta
CachedTGatherer_Update/Update_of_one_element_without_reset-12      3.00 ± 0%      3.00 ± 0%    0.00%
CachedTGatherer_Update/Update_of_all_elements_with_reset-12        0.00           0.00         0.00%
CachedTGatherer_Update/Gather-12                                  1.00k ± 0%     0.00k ± 0%  -99.60%

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Removed obsolete comment

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Fixed tests.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Removed cache.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Fixed tests.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Re-add cache.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Removed cache.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
2022-02-23 11:22:52 +00:00
Michael Knyszek 77626d64fa
Reduce granularity of histogram buckets for Go 1.17 collector (#974)
The Go runtime/metrics package currently exports extremely granular
histograms. Exponentially bucket any histogram with unit "seconds"
or "bytes" instead to dramatically reduce the number of buckets, and
thus the number of metrics.

This change also adds a test to check for expected cardinality to
prevent cardinality surprises in the future.

Signed-off-by: Michael Anthony Knyszek <mknyszek@google.com>
2022-01-28 05:46:45 +01:00
Michael Knyszek 85206714ae
Use simpler locking in the Go 1.17 collector (#975)
A previous PR made it so that the Go 1.17 collector locked only around
uses of rmSampleBuf, but really that means that Metric values may be
sent over the channel containing some values from future metrics.Read
calls. While generally-speaking this isn't a problem, we lose any
consistency guarantees provided by the runtime/metrics package.

Also, that optimization to not just lock around all of Collect was
premature. Truthfully, Collect is called relatively infrequently, and
its critical path is fairly fast (10s of µs). To prove it, this change
also adds a benchmark.

name            old time/op  new time/op  delta
GoCollector-16  43.7µs ± 2%  43.2µs ± 2%   ~     (p=0.190 n=9+9)

Note that because the benchmark is single-threaded it actually looks
like it might be getting *slightly* faster, because all those Collect
calls for the Metrics are direct calls instead of interface calls.

Signed-off-by: Michael Anthony Knyszek <mknyszek@google.com>
2022-01-25 08:43:45 +01:00
Michael Knyszek f63e219e6b
Make the Go 1.17 collector thread-safe (#969) 2022-01-21 08:34:45 +01:00
Kemal Akkoyun 5bd9ee52dc
go.*: Update dependencies (#965)
* Update dependencies

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Update deprecated APIs

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Add missing dependency explicitly

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
2022-01-18 20:32:44 +01:00
Kemal Akkoyun 9075cdf616
promhttp: Check validity of method and code label values (#962)
* Check validity of method and code label values

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Use more flexibly functional option pattern for configuration

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Update documentation

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Simplify

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Fix inconsistent method naming

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
2022-01-18 10:19:28 +01:00
Michael Knyszek 22da9497b8
Use the runtime/metrics package for the Go collector for 1.17+ (#955)
This change introduces use of the runtime/metrics package in place of
runtime.MemStats for Go 1.17 or later. The runtime/metrics package was
introduced in Go 1.16, but not all the old metrics were accounted for
until 1.17.

The runtime/metrics package offers several advantages over using
runtime.MemStats:
* The list of metrics and their descriptions are machine-readable,
  allowing new metrics to get added without any additional work.
* Detailed histogram-based metrics are now available, offering much
  deeper insights into the Go runtime.
* The runtime/metrics API is significantly more efficient than
  runtime.MemStats, even with the additional metrics added, because
  it does not require any stop-the-world events.

That being said, integrating the package comes with some caveats, some
of which were discussed in #842. Namely:
* The old MemStats-based metrics need to continue working, so they're
  exported under their old names backed by equivalent runtime/metrics
  metrics.
* Earlier versions of Go need to continue working, so the old code
  remains, but behind a build tag.

Finally, a few notes about the implementation:
* This change includes a whole bunch of refactoring to avoid significant
  code duplication.
* This change adds a new histogram metric type specifically optimized
  for runtime/metrics histograms. This type's methods also include
  additional logic to deal with differences in bounds conventions.
* This change makes a whole bunch of decisions about how runtime/metrics
  names are translated.
* This change adds a `go generate` script to generate a list of expected
  runtime/metrics names for a given Go version for auditing. Users of
  new versions of Go will transparently be allowed to use new metrics,
  however.

Signed-off-by: Michael Anthony Knyszek <mknyszek@google.com>
2022-01-16 16:41:56 +00:00
Manuel Rüger 8535b62021 Add new go:build lines for go 1.17
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
2021-12-17 23:38:35 +01:00
Gökhan Özeloğlu 55320aa8b0 Fix typo
Signed-off-by: Gökhan Özeloğlu <gozeloglu@gmail.com>
2021-11-25 11:21:10 +03:00
Seth Bunce 2261d5cda1
add ExponentialBucketsRange function (#899)
This function calculates exponential buckets with different arguments
than the existing ExponentialBuckets function. Instead of specifying the
start and factor, the user can specify the min and max bucket value. We
have been doing it this way internally at my company for some time.

Signed-off-by: Seth Bunce <seth.bunce@getcruise.com>
2021-08-12 16:56:44 +01:00
SuperQ 6d946b5526
Update status badgets
Update to new locations
* Switch to CircleCI build badge.
* Use new pkg.go.dev for docs.

Signed-off-by: SuperQ <superq@gmail.com>
2021-06-23 10:12:43 +02:00
beorn7 f34145a85e Document implications of negative observations
Signed-off-by: beorn7 <beorn@grafana.com>
2021-05-26 23:41:30 +02:00
beorn7 81a9556c8b Make dbStatsCollector more DRY
Signed-off-by: beorn7 <beorn@grafana.com>
2021-05-20 22:31:53 +02:00
Mitsuo Heijo a66da1df4a
Add collector for database/sql#DBStats (#866)
* Add collector for database/sql#DBStats

Signed-off-by: Mitsuo Heijo <mitsuo.heijo@gmail.com>
2021-05-20 22:22:17 +02:00
Mitsuo Heijo e07445a773
Add new collectors package
Signed-off-by: Mitsuo Heijo <mitsuo.heijo@gmail.com>
2021-05-08 10:43:31 +09:00
Dean Coakley 3998a677f9
Improve description of MaxAge in summary docs (#864)
* Improve description of MaxAge in summary docs

Signed-off-by: Dean Coakley <dean.s.coakley@gmail.com>
2021-05-04 15:58:41 +02:00
beorn7 e92283d644 Fix linter ignores
Signed-off-by: beorn7 <beorn@grafana.com>
2021-03-16 17:19:03 +01:00
beorn7 6635a8f35b Bump minumim required Go version to 1.13
Since 1.16 is out, we still support the last four minor releases.

The bump was required by the prometheus/procfs package using the new
`%w` printf directives. However, it also allows us to remove some
special casing about build info.

Signed-off-by: beorn7 <beorn@grafana.com>
2021-03-11 20:45:00 +01:00
debiandebiandebian 9443f4449b Fix typo in comments
Signed-off-by: debiandebiandebian <debiandebiandebiandebian@gmail.com>
2021-02-08 08:58:51 +09:00
beorn7 98eb6cbf7c promhttp: Correctly detect invalid metric and label names
Without this fix, the `InstrumentHandler...` middlewares get locked in
an endless loop in case of an invalid Collector, eating all the memory.

Signed-off-by: beorn7 <beorn@grafana.com>
2020-12-09 17:58:53 +01:00