Commit Graph

1740 Commits

Author SHA1 Message Date
Oleg Zaytsev 005d8de006
Improve performance of WithLabelValues(...)
The slice with variadic arguments passed to MetricVec.WithLabelValues()
was escaping to heap. This change fixes that by performing a copy of the
slice before passing it to fmt.Errorf(), which is where the slice was
escaping. This keeps the hot path without that allocation.

Meaningful benchmark results (skipping ~0 CPU and 0 alloc ones):

                                                               │    old.txt    │               new.txt                │
                                                               │    sec/op     │    sec/op     vs base                │
Counter/With_Label_Values-16                                     108.00n ±  6%   58.06n ±  1%  -46.24% (p=0.000 n=10)
Counter/With_Label_Values_and_Constraint-16                       174.5n ± 15%   136.8n ±  6%  -21.63% (p=0.000 n=10)
Counter/With_triple_Label_Values-16                               309.3n ± 12%   172.9n ±  1%  -44.08% (p=0.000 n=10)
Counter/With_triple_Label_Values_and_Constraint-16                591.5n ± 11%   418.9n ±  3%  -29.17% (p=0.000 n=10)
Counter/With_repeated_Label_Values-16                             212.9n ± 10%   116.8n ± 23%  -45.16% (p=0.000 n=10)
Counter/With_repeated_Label_Values_and_Constraint-16              406.2n ± 14%   275.1n ±  4%  -32.30% (p=0.000 n=10)
CounterWithLabelValuesConcurrent-16                               85.45n ±  2%   89.09n ±  2%   +4.26% (p=0.003 n=10)

                                                               │    old.txt     │                  new.txt                  │
                                                               │      B/op      │     B/op      vs base                     │
Counter/With_Label_Values-16                                       48.00 ± 0%        0.00 ± 0%  -100.00% (p=0.000 n=10)
Counter/With_Label_Values_and_Constraint-16                        96.00 ± 0%       48.00 ± 0%   -50.00% (p=0.000 n=10)
Counter/With_triple_Label_Values-16                                144.0 ± 0%         0.0 ± 0%  -100.00% (p=0.000 n=10)
Counter/With_triple_Label_Values_and_Constraint-16                 288.0 ± 0%       144.0 ± 0%   -50.00% (p=0.000 n=10)
Counter/With_repeated_Label_Values-16                              96.00 ± 0%        0.00 ± 0%  -100.00% (p=0.000 n=10)
Counter/With_repeated_Label_Values_and_Constraint-16              192.00 ± 0%       96.00 ± 0%   -50.00% (p=0.000 n=10)
CounterWithLabelValuesConcurrent-16                                48.00 ± 0%        0.00 ± 0%  -100.00% (p=0.000 n=10)

                                                               │   old.txt    │                 new.txt                 │
                                                               │  allocs/op   │ allocs/op   vs base                     │
Counter/With_Label_Values-16                                     1.000 ± 0%     0.000 ± 0%  -100.00% (p=0.000 n=10)
Counter/With_Label_Values_and_Constraint-16                      2.000 ± 0%     1.000 ± 0%   -50.00% (p=0.000 n=10)
Counter/With_triple_Label_Values-16                              3.000 ± 0%     0.000 ± 0%  -100.00% (p=0.000 n=10)
Counter/With_triple_Label_Values_and_Constraint-16               6.000 ± 0%     3.000 ± 0%   -50.00% (p=0.000 n=10)
Counter/With_repeated_Label_Values-16                            2.000 ± 0%     0.000 ± 0%  -100.00% (p=0.000 n=10)
Counter/With_repeated_Label_Values_and_Constraint-16             4.000 ± 0%     2.000 ± 0%   -50.00% (p=0.000 n=10)
CounterWithLabelValuesConcurrent-16                              1.000 ± 0%     0.000 ± 0%  -100.00% (p=0.000 n=10)

Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
2023-10-04 18:09:15 +02:00
github-actions[bot] dac14aae41
Merge pull request #1356 from prometheus/dependabot/go_modules/github.com/prometheus/procfs-0.12.0
Bump github.com/prometheus/procfs from 0.11.1 to 0.12.0
2023-10-04 14:54:05 +00:00
dependabot[bot] 87a016c909
Bump github.com/prometheus/procfs from 0.11.1 to 0.12.0
Bumps [github.com/prometheus/procfs](https://github.com/prometheus/procfs) from 0.11.1 to 0.12.0.
- [Release notes](https://github.com/prometheus/procfs/releases)
- [Commits](https://github.com/prometheus/procfs/compare/v0.11.1...v0.12.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/procfs
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-04 14:51:07 +00:00
github-actions[bot] 556bf30066
Merge pull request #1357 from prometheus/dependabot/go_modules/golang.org/x/sys-0.12.0
Bump golang.org/x/sys from 0.11.0 to 0.12.0
2023-10-04 14:50:12 +00:00
dependabot[bot] 7004b66eda
Bump golang.org/x/sys from 0.11.0 to 0.12.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.11.0 to 0.12.0.
- [Commits](https://github.com/golang/sys/compare/v0.11.0...v0.12.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-04 14:47:05 +00:00
Arthur Silva Sens 22540dc438
Configure CI to automerge dependabot PRs (#1359)
Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>
2023-10-04 15:41:39 +01:00
Arthur Silva Sens 4c10365899
Merge pull request #1358 from prometheus/dependabot/go_modules/tutorial/whatsup/github.com/prometheus/client_golang-1.17.0
Bump github.com/prometheus/client_golang from 1.16.0 to 1.17.0 in /tutorial/whatsup
2023-10-02 14:28:43 +02:00
Arthur Silva Sens 40c7d2fa8b
Merge pull request #1355 from prometheus/dependabot/go_modules/examples/middleware/github.com/prometheus/client_golang-1.17.0
Bump github.com/prometheus/client_golang from 1.16.0 to 1.17.0 in /examples/middleware
2023-10-02 14:28:30 +02:00
dependabot[bot] 1844c50e03
Bump github.com/prometheus/client_golang in /tutorial/whatsup
Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.16.0 to 1.17.0.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.16.0...v1.17.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/client_golang
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-01 09:55:17 +00:00
dependabot[bot] e43edfcedc
Bump github.com/prometheus/client_golang in /examples/middleware
Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.16.0 to 1.17.0.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.16.0...v1.17.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/client_golang
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-01 09:13:35 +00:00
Arthur Silva Sens 3278043c6d
Add changelog entry for 1.17 (#1353)
Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>
2023-09-30 10:23:27 +01:00
Oleksandr Redko 1bae6c1e63
Deprecated comment should begin with "Deprecated:" (#1347)
See https://go.dev/blog/godoc

Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2023-09-21 12:31:45 +01:00
Oleksandr Redko bbab8fe770
Fix typos in comments, tests, and errors (#1346)
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2023-09-21 12:31:08 +01:00
Arthur Silva Sens df7fa49417
Extend Counters, Summaries and Histograms with creation timestamp (#1313)
* Extend Counters, Summaries and Histograms with creation timestamp

Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>

* Backport created timestamp to existing tests

Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>

* Last touches (readability and consistency)

Changes:

* Comments for "now" are more explicit and not inlined.
* populateMetrics is simpler and bit more efficient without timestamp to time to timestamp conversionts for more common code.
* Test consistency and simplicity - the fewer variables the better.
* Fixed inconsistency for v2 and MetricVec - let's pass opt.now consistently.
* We don't need TestCounterXXXTimestamp - we test CT in many other places already.
* Added more involved test for counter vectors with created timestamp.
* Refactored normalization for simplicity.
* Make histogram, summaries now consistent.
* Simplified histograms CT flow and implemented proper CT on reset.

TODO for next PRs:
* NewConstSummary and NewConstHistogram - ability to specify CTs there.

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

* Update prometheus/counter_test.go

Co-authored-by: Arthur Silva Sens <arthursens2005@gmail.com>
Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

---------

Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>
Signed-off-by: bwplotka <bwplotka@gmail.com>
Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
Co-authored-by: bwplotka <bwplotka@gmail.com>
2023-09-21 10:46:54 +01:00
Oleksandr Redko 74cc26257c
Add go_godebug_non_default_behavior_tlsmaxrsasize_events_total (#1348)
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2023-09-21 10:46:14 +01:00
Ben Kochie d03abf3a31
Cleanup golangci-lint errcheck (#1339)
Move the errcheck excludes list from an external file to inline in the golangci-lint config file.

Signed-off-by: SuperQ <superq@gmail.com>
2023-09-03 18:34:37 +01:00
PrometheusBot ca6ba04f2f
Update common Prometheus files (#1338)
Signed-off-by: prombot <prometheus-team@googlegroups.com>
2023-09-03 18:34:10 +01:00
PrometheusBot 51d24f8680
Update common Prometheus files (#1332)
Signed-off-by: prombot <prometheus-team@googlegroups.com>
2023-08-15 09:39:13 +02:00
Ben Kochie c17edf09ed
Merge pull request #1304 from prometheus/dependabot/go_modules/google.golang.org/protobuf-1.31.0
Bump google.golang.org/protobuf from 1.30.0 to 1.31.0
2023-08-14 22:18:20 +02:00
dependabot[bot] 8483c5dab8
Bump google.golang.org/protobuf from 1.30.0 to 1.31.0
Bumps google.golang.org/protobuf from 1.30.0 to 1.31.0.

---
updated-dependencies:
- dependency-name: google.golang.org/protobuf
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-14 14:54:09 +00:00
Ben Kochie 760a55a415
Merge pull request #1330 from prometheus/dependabot/go_modules/tutorial/whatsup/github.com/prometheus/common-0.44.0
Bump github.com/prometheus/common from 0.42.0 to 0.44.0 in /tutorial/whatsup
2023-08-14 16:53:27 +02:00
Ben Kochie f58d0fd655
Merge pull request #1284 from prometheus/dependabot/go_modules/github.com/prometheus/common-0.44.0
Bump github.com/prometheus/common from 0.42.0 to 0.44.0
2023-08-14 16:53:10 +02:00
dependabot[bot] 85f4592a0c
Bump github.com/prometheus/common from 0.42.0 to 0.44.0
Bumps [github.com/prometheus/common](https://github.com/prometheus/common) from 0.42.0 to 0.44.0.
- [Release notes](https://github.com/prometheus/common/releases)
- [Commits](https://github.com/prometheus/common/compare/v0.42.0...v0.44.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/common
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-14 13:46:29 +00:00
dependabot[bot] 802a963a20
Bump github.com/prometheus/common in /tutorial/whatsup
Bumps [github.com/prometheus/common](https://github.com/prometheus/common) from 0.42.0 to 0.44.0.
- [Release notes](https://github.com/prometheus/common/releases)
- [Commits](https://github.com/prometheus/common/compare/v0.42.0...v0.44.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/common
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-14 13:43:04 +00:00
Ben Kochie fa04b7b613
Merge pull request #1328 from prometheus/dependabot/go_modules/examples/middleware/github.com/prometheus/client_golang-1.16.0
Bump github.com/prometheus/client_golang from 1.13.1 to 1.16.0 in /examples/middleware
2023-08-14 15:41:41 +02:00
Ben Kochie adb018069e
Merge pull request #1329 from prometheus/dependabot/go_modules/tutorial/whatsup/github.com/prometheus/client_golang-1.16.0
Bump github.com/prometheus/client_golang from 1.15.1-0.20230416215738-0963f595c689 to 1.16.0 in /tutorial/whatsup
2023-08-14 15:41:19 +02:00
Ben Kochie 301a7bdb7f
Merge pull request #1331 from prometheus/dependabot/go_modules/golang.org/x/sys-0.11.0
Bump golang.org/x/sys from 0.10.0 to 0.11.0
2023-08-14 15:40:40 +02:00
dependabot[bot] f215f759c6
Bump golang.org/x/sys from 0.10.0 to 0.11.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.10.0 to 0.11.0.
- [Commits](https://github.com/golang/sys/compare/v0.10.0...v0.11.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-14 13:30:38 +00:00
dependabot[bot] 390448ff3c
Bump github.com/prometheus/client_golang in /tutorial/whatsup
Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.15.1-0.20230416215738-0963f595c689 to 1.16.0.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/commits/v1.16.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/client_golang
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-14 13:30:30 +00:00
dependabot[bot] 0e33cf9a99
Bump github.com/prometheus/client_golang in /examples/middleware
Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.13.1 to 1.16.0.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.13.1...v1.16.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/client_golang
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-14 13:30:29 +00:00
Ben Kochie 4abd83d655
Update building (#1326)
* Remove unused / non-standard .go-version.
* Cleanup indenting in Makefile.
* Enable dependabot for subdirs.
* Update golanci-lint CI.
* Update go.mod version directives to match supported versions.
* Disable golanci-lint unused-parameter.

Signed-off-by: SuperQ <superq@gmail.com>
2023-08-14 15:29:51 +02:00
Bartlomiej Plotka 6f576e2c6f
histogram docs: Fixed minor nit. (#1324)
Signed-off-by: bwplotka <bwplotka@gmail.com>
2023-08-13 14:11:06 +01:00
Arthur Silva Sens 1a88780343
Bump prometheus/client_model (#1323)
By upgrading prometheus/client_model, several test functions had to be re-written due to 2 breaking changes made in protobuf when parsing messages to text:
1. '<' and '>' characters were replaced with '{' and '}' respectively.
2. The text format is non-deterministic. More information in https://github.com/golang/protobuf/issues/1121

Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>
2023-08-11 20:17:55 +01:00
Kemal Akkoyun 06d4592b1c
Add Go 1.21 support (#1325)
* Add Go 1.21 support

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

* Update README.md

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

---------

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
2023-08-11 12:27:52 +02:00
Björn Rabenstein cdd7f45dc5
Merge pull request #1322 from sengi/docs
docs: trivial grammar fixes to improve readability in promauto Godoc
2023-08-08 15:02:33 +02:00
Chris Banks f16b435f04
docs: trivial grammar fixes to improve readability
Fix a few typos / grammatical errors in the Godoc comments for promauto.
Only trivial stuff but slightly helps readability of the docs.

Signed-off-by: Chris Banks <chris.banks@digital.cabinet-office.gov.uk>
2023-08-05 11:41:47 +01:00
dependabot[bot] e6d9092baf
Bump github.com/prometheus/procfs from 0.11.0 to 0.11.1 (#1319)
Bumps [github.com/prometheus/procfs](https://github.com/prometheus/procfs) from 0.11.0 to 0.11.1.
- [Release notes](https://github.com/prometheus/procfs/releases)
- [Commits](https://github.com/prometheus/procfs/compare/v0.11.0...v0.11.1)

---
updated-dependencies:
- dependency-name: github.com/prometheus/procfs
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-01 18:56:09 +01:00
dependabot[bot] 99e905a3d5
Bump golang.org/x/sys from 0.9.0 to 0.10.0 (#1320)
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.9.0 to 0.10.0.
- [Commits](https://github.com/golang/sys/compare/v0.9.0...v0.10.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-01 17:12:04 +01:00
ZiViZiViZ 23387fe2f4
Add missing tick "`" in README (#1321)
Cosmetic change

Signed-off-by: ZiViZiViZ <95288998+ZiViZiViZ@users.noreply.github.com>
2023-08-01 17:11:49 +01:00
Tiago Silva 59c00e3e9c
Fix data-race in metric without code and method but with `WithLabelFromCtx` (#1318)
This commit fixes a data race that exists when the metric used in any
`promhttp` middleware doesn't collect the `code` and `method` but uses
`WithLabelFromCtx` to collect values from context.

The problem happens because when no `code` and `method` tags are
collected, the `labels` function returns a pre-initialized map
`emptyLabels` for every request.

When one or multipe `WithLabelFromCtx` options are configured, the
returned map from the `labels` function call is used to collect the
metrics from context which creates a multi-write data race.

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2023-08-01 17:11:17 +01:00
PrometheusBot 7f2db5f1ed
Update common Prometheus files (#1302)
Signed-off-by: prombot <prometheus-team@googlegroups.com>
2023-07-26 12:54:03 +01:00
dependabot[bot] 6e3b962584
Bump github.com/prometheus/procfs from 0.10.1 to 0.11.0 (#1305)
Bumps [github.com/prometheus/procfs](https://github.com/prometheus/procfs) from 0.10.1 to 0.11.0.
- [Release notes](https://github.com/prometheus/procfs/releases)
- [Commits](https://github.com/prometheus/procfs/compare/v0.10.1...v0.11.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/procfs
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-26 12:53:49 +01:00
Bartlomiej Plotka 90b169a60d
Merge pull request #1314 from prometheus/beorn7/histogram
histogram: Enable detection of a native histogram without observations
2023-07-26 13:53:11 +02:00
dependabot[bot] 98025d8797
Bump google.golang.org/grpc from 1.45.0 to 1.53.0 in /tutorial/whatsup (#1307)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.45.0 to 1.53.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.45.0...v1.53.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-26 12:46:42 +01:00
dependabot[bot] 3b6fb7aa3f
Bump golang.org/x/sys from 0.8.0 to 0.9.0 (#1306)
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.8.0 to 0.9.0.
- [Commits](https://github.com/golang/sys/compare/v0.8.0...v0.9.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-26 12:46:32 +01:00
beorn7 3d82c94432 histogram: Add a no-op span for an otherwise empty histogram
Fixes #1127.

If a native histogram has no observations and a zero threshold of
zero, then it is indistinguishable from a classic histogram. To give
scrapers a hint that it is indeed a native histogram, we add a no-op
span.

This needs follow-up PRs in prometheus/prometheus and
prometheus/client_model.

Signed-off-by: beorn7 <beorn@grafana.com>
2023-07-20 17:34:00 +02:00
beorn7 f9db3821a8 histograms: Small code comment and code formatting improvements
Signed-off-by: beorn7 <beorn@grafana.com>
2023-07-20 16:13:28 +02:00
Quentin D 644c80d136
Do not allocate memory when there's no constraints (#1296)
Signed-off-by: Quentin Devos <4972091+Okhoshi@users.noreply.github.com>
2023-06-27 12:21:36 +01:00
Diogo Teles Sant'Anna 553eb4c7a8
ci: define minimal permissions to github workflows (#1295)
Signed-off-by: Diogo Teles Sant'Anna <diogoteles@google.com>
2023-06-19 09:53:04 +01:00
PrometheusBot f6bb79e03d
Update common Prometheus files (#1297)
Signed-off-by: prombot <prometheus-team@googlegroups.com>
2023-06-19 09:12:39 +01:00