Commit Graph

1427 Commits

Author SHA1 Message Date
Jéssica Lins 07b1397ded
examples: Add exemplars and middleware examples (#1173)
* Add exemplars simple example, add go runtime and process collectors to simple example

Signed-off-by: Jéssica Lins <jessicaalins@gmail.com>

* Add middleware example

Signed-off-by: Jéssica Lins <jessicaalins@gmail.com>

* Lint

Signed-off-by: Jéssica Lins <jessicaalins@gmail.com>

Signed-off-by: Jéssica Lins <jessicaalins@gmail.com>
2022-11-22 22:42:31 +01:00
Bartlomiej Plotka 8b6e68085b
Merge pull request #1171 from prometheus/beorn7/histogram
Fix issue with atomic variables on ppc64le
2022-11-22 13:00:35 +00:00
beorn7 043372ee04 Initialize atomic variables in histogramCounts with atomic.Store...
Signed-off-by: beorn7 <beorn@grafana.com>
2022-11-14 15:03:17 +01:00
beorn7 efef9034c5 Rename histogram tests (from sparse to native)
Signed-off-by: beorn7 <beorn@grafana.com>
2022-11-14 14:53:16 +01:00
Björn Rabenstein 449b464350
Merge pull request #1166 from prometheus/beorn7/doc
Fix typo in doc comment
2022-11-10 09:40:14 +01:00
beorn7 b804be1e63 Fix typo in doc comment
Signed-off-by: beorn7 <beorn@grafana.com>
2022-11-09 17:56:59 +01:00
Kemal Akkoyun db41dad599
Merge pull request #1164 from prometheus/release-1.14
Merge release 1.14 to main
2022-11-08 09:47:31 +01:00
Bartlomiej Plotka 254e546841
Merge pull request #1162 from kakkoyun/cut-1.14.0
Cut v1.14.0
2022-11-08 09:06:03 +01:00
Kemal Akkoyun c8a3d321a0 Cut v1.14.0
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
2022-11-08 05:00:31 +01:00
Bartlomiej Plotka 07d3a81494
Merge pull request #1161 from prometheus/release-1.13
Merge release branch 1.13 to main
2022-11-08 00:15:39 +01:00
Kemal Akkoyun 870469ecf9
Test and support 1.19 (#1160)
* Add new Go 1.19 metrics

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

* Format files with the latest formatter

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

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
2022-11-08 00:14:19 +01:00
copy rogers b785d0c828
Fix go_collector_latest_test Fail on go1.19 (#1136)
Signed-off-by: rogerogers <rogers@rogerogers.com>

Signed-off-by: rogerogers <rogers@rogerogers.com>
2022-11-07 20:17:41 +01:00
Seth Bunce 4d54769c6b
Fix float64 comparison test failure on archs using FMA (#1133)
* Fix float64 comparison test failure on archs using FMA

Architectures using FMA optimization yield slightly different results so
we cannot assume floating point values will be precisely the same across
different architectures.

The solution in this change is to check "abs(a-b) < tolerance" instead
of comparing the exact values. This will give us confidence that the
histogram buckets are near identical.

Signed-off-by: Seth Bunce <seth.bunce@getcruise.com>

* Apply suggestions from code review

Co-authored-by: Daniel Swarbrick <daniel.swarbrick@gmail.com>
Signed-off-by: Seth Bunce <seth.bunce@getcruise.com>

* copy float compare dependency

Per discussion in the pull request, we'd like to avoid having an extra
dependency on a float comparison package. Instead, we copy the float compare
functions from the float comparison package.

The float comparison package we're choosing is this. The author of this
package has commented in the pull request and it looks like we have consensus
that this is the best option.
github.com/beorn7/floats

Signed-off-by: Seth Bunce <seth.bunce@gmail.com>

* remove float32 variant, relocate into separate file

This change removes the float32 variant of the AlmostEqual funcs, that we will
likely never use. This change also relocates the function into a separate file
to avoid modifying a file that's a fork of another vendored package.

Signed-off-by: Seth Bunce <seth.bunce@gmail.com>

Signed-off-by: Seth Bunce <seth.bunce@getcruise.com>
Signed-off-by: Seth Bunce <seth.bunce@gmail.com>
Co-authored-by: Daniel Swarbrick <daniel.swarbrick@gmail.com>
2022-11-07 19:20:43 +01:00
Kemal Akkoyun 53e51c4f53
Merge pull request #1157 from prometheus/cut-1.13.1
Bugfixes + Cut 1.13.1 + documenting release process.
2022-11-02 09:12:58 +01:00
bwplotka 79ca0eb2ba Added tip from Björn + Grammarly.
Signed-off-by: bwplotka <bwplotka@gmail.com>
2022-11-01 16:54:19 +00:00
bwplotka 078f11f85b Cut 1.13.1 release (+ documenting release process).
Signed-off-by: bwplotka <bwplotka@gmail.com>
2022-11-01 16:37:13 +00:00
Fabian Stäber ddd7f0edcd Fix race condition with Exemplar in Counter (#1146)
* Fix race condition with Exemplar in Counter

Potential fix for #1145.

Signed-off-by: Fabian Stäber <fabian@fstab.de>

* Fix race condition with Exemplar in Counter

Signed-off-by: Fabian Stäber <fabian@fstab.de>

Signed-off-by: Fabian Stäber <fabian@fstab.de>
2022-11-01 16:22:27 +00:00
Balint Zsilavecz 1f93f64580 Fix `CumulativeCount` value of `+Inf` bucket created from exemplar (#1148)
* Fix `CumulativeCount` value of `+Inf` bucket created from exemplar

Signed-off-by: Balint Zsilavecz <balint.zsilavecz@skyscanner.net>

* Update prometheus/metric_test.go

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
Signed-off-by: Balint Zsilavecz <balint.zsilavecz@skyscanner.net>

* Clarify description of implicit `+Inf` bucket count

Signed-off-by: Balint Zsilavecz <balint.zsilavecz@skyscanner.net>

* Fix test variables

Signed-off-by: Balint Zsilavecz <balint.zsilavecz@skyscanner.net>

Signed-off-by: Balint Zsilavecz <balint.zsilavecz@skyscanner.net>
Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
2022-11-01 16:22:22 +00:00
Dave Henderson 8cc2b6c472 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-11-01 16:20:44 +00:00
Björn Rabenstein 5f202eefdb
Merge pull request #1150 from prometheus/sparsehistogram
Merge sparsehistogram branch into main
2022-10-31 16:55:36 +01:00
beorn7 fffb76cafe Merge branch 'main' into sparsehistogram 2022-10-31 16:30:59 +01:00
beorn7 e92a8c7f48 Avoid the term 'sparse' where possible
This intends to avoid confusing users by the subtle difference between
a native histogram and a sparse bucket.

Signed-off-by: beorn7 <beorn@grafana.com>
2022-10-31 16:23:08 +01:00
Kemal Akkoyun 0859bb8f37
Merge pull request #1152 from jessicalins/update-to-custom-reg
Update examples to use custom registry
2022-10-26 10:15:58 -04:00
Jéssica Lins a340ca4ba6
Run make format
Signed-off-by: Jéssica Lins <jessicaalins@gmail.com>
2022-10-21 17:23:15 +02:00
Jéssica Lins 6056615b26
Update random example to use custom registry
Signed-off-by: Jéssica Lins <jessicaalins@gmail.com>
2022-10-21 16:47:21 +02:00
Jéssica Lins 0b7f4888b0
Update simple example to use custom registry
Signed-off-by: Jéssica Lins <jessicaalins@gmail.com>
2022-10-21 16:22:25 +02:00
Jéssica Lins 9b5c5b8a47
Update basic example to use custom registry
Signed-off-by: Jéssica Lins <jessicaalins@gmail.com>
2022-10-21 16:06:49 +02:00
beorn7 d31f13b599 Add SparseBucketsZeroThresholdZero and groom doc comments
Signed-off-by: beorn7 <beorn@grafana.com>
2022-10-19 19:22:46 +02:00
beorn7 58a8ca4588 examples: Adjust doc comment for native histograms
Signed-off-by: beorn7 <beorn@grafana.com>
2022-10-19 18:38:57 +02:00
beorn7 4e71e6ff20 Update prometheus/client_model dependency
Native histograms are now in a tagged version (v0.3.0).

Signed-off-by: beorn7 <beorn@grafana.com>
2022-10-19 18:27:50 +02:00
beorn7 111fae11e1 Merge branch 'main' into sparsehistogram 2022-10-19 18:09:21 +02:00
Fabian Stäber 10b0550932
Fix race condition with Exemplar in Counter (#1146)
* Fix race condition with Exemplar in Counter

Potential fix for #1145.

Signed-off-by: Fabian Stäber <fabian@fstab.de>

* Fix race condition with Exemplar in Counter

Signed-off-by: Fabian Stäber <fabian@fstab.de>

Signed-off-by: Fabian Stäber <fabian@fstab.de>
2022-10-17 20:50:50 +02:00
Balint Zsilavecz dcea97eee2
Fix `CumulativeCount` value of `+Inf` bucket created from exemplar (#1148)
* Fix `CumulativeCount` value of `+Inf` bucket created from exemplar

Signed-off-by: Balint Zsilavecz <balint.zsilavecz@skyscanner.net>

* Update prometheus/metric_test.go

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
Signed-off-by: Balint Zsilavecz <balint.zsilavecz@skyscanner.net>

* Clarify description of implicit `+Inf` bucket count

Signed-off-by: Balint Zsilavecz <balint.zsilavecz@skyscanner.net>

* Fix test variables

Signed-off-by: Balint Zsilavecz <balint.zsilavecz@skyscanner.net>

Signed-off-by: Balint Zsilavecz <balint.zsilavecz@skyscanner.net>
Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
2022-10-13 13:52:19 +02:00
Björn Rabenstein 25bc1886c0
Merge pull request #1144 from prometheus/beorn7/histogram2
sparse buckets: Fix handling of +Inf/-Inf/NaN observations
2022-10-11 12:57:40 +02:00
beorn7 6942f9e454 sparse buckets: Fix handling of +Inf/-Inf/NaN observations
NaN observations now go to no bucket, but increment count (and
effectively set sum to NaN, too).

±Inf observations now go to the bucket following the bucket that would
have received math.MaxFloat64. The former is now the last bucket that
can be created.

The getLe is modified to return math.MaxFloat64 for the penultimate
possible bucket.

Also add a test for getLe.

Signed-off-by: beorn7 <beorn@grafana.com>
2022-10-06 17:40:15 +02:00
rogerogers 9801a4e3ce
Examples: Replace deprecated WithGoCollections with WithGoCollectorRuntimeMetrics (#1130)
Signed-off-by: rogerogers <rogers@rogerogers.com>

Signed-off-by: rogerogers <rogers@rogerogers.com>
2022-09-12 11:24:20 +02:00
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
beorn7 95cf173f19 Merge branch 'main' into sparsehistogram 2022-08-23 14:28:33 +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
Kemal Akkoyun c7aa2a5b84
Merge pull request #1113 from prometheus/release-1.13
Merging release-1.13.0 to main (non-squash)
2022-08-06 10:02:27 +02:00
PrometheusBot 1e61b8ea3c
Update common Prometheus files (#1111)
Signed-off-by: prombot <prometheus-team@googlegroups.com>
2022-08-05 22:38:30 +02:00
Bartlomiej Plotka 64435fc00a
Cut 1.13.0 (#1110)
Signed-off-by: bwplotka <bwplotka@gmail.com>
2022-08-05 20:31:42 +02: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