Commit Graph

640 Commits

Author SHA1 Message Date
beorn7 c32ffd121f Add tests for examplars
Signed-off-by: beorn7 <beorn@grafana.com>
2020-01-24 17:12:36 +01:00
beorn7 57d41259e1 Add exemplars to counter and histogram
Signed-off-by: beorn7 <beorn@grafana.com>
2020-01-24 17:12:08 +01:00
Bartlomiej Plotka 9e9cc003f8 Added testutil.CollectAndCount
Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
2020-01-09 11:20:19 +00:00
beorn7 2be4bb406e Improve doc string for `go_gc_duration_seconds`
Fixes #618.

Signed-off-by: beorn7 <beorn@grafana.com>
2020-01-06 13:38:35 +01:00
beorn7 de74638693 Improve doc comment for NewGaugeFunc
- Simplify confusing wording about concurrency safety.
- Add link to example for info metric.

Signed-off-by: beorn7 <beorn@grafana.com>
2019-12-09 18:20:27 +01:00
Dean Coakley 508fc33903
Fix link to writing exporters guide
Signed-off-by: Dean Coakley <dean.s.coakley@gmail.com>
2019-11-28 15:01:46 +00:00
kamaev 06342cf74f
fix tests
Signed-off-by: kamaev <timurkamaev@protonmail.com>
2019-10-23 00:15:54 +05:00
kamaev c333d152b1
add graphite tags
Signed-off-by: kamaev <timurkamaev@protonmail.com>
2019-10-23 00:15:41 +05:00
Jeff Widman 0dc0c2165f Remove old reference to basicMetricVec
Contrary to the code comment, I see no `basicMetricVec` implementation.
Grep'ing this project shows this is the only reference. So I suspect
it's an outdated comment and can be removed to minimize confusion.

I'm unclear whether other parts of that comment are also incorrect and
need updating.

Signed-off-by: Jeff Widman <jeff@jeffwidman.com>
2019-10-18 10:05:25 -07:00
Leo Antunes 4be0ab45ec ensure same collectorID calculated on reg and unreg
Signed-off-by: Leo Antunes <leo@costela.net>
2019-10-17 14:16:32 +02:00
beorn7 679da921f7 Simplify code
`gofmt -s` taught me that this is possible.

Signed-off-by: beorn7 <beorn@grafana.com>
2019-10-16 12:18:16 +02:00
beorn7 19af62dcc8 Use a cleaner initialization of `separatorByteSlice`
The `const separatorByte` wasn't used anymore actually. In `vec.go`,
we were using `model.SeparatorByte`, which is better anyway. So remove
the unused constant and initialize `separatorByteSlice` with
`model.SeparatorByte`, too.

Signed-off-by: beorn7 <beorn@grafana.com>
2019-10-15 19:52:31 +02:00
Björn Rabenstein c13325c862
Merge pull request #655 from prometheus/beorn7/test
Unflake TestGoCollectorGoroutines
2019-10-15 13:19:50 +02:00
Björn Rabenstein 8b3e008442
Merge pull request #657 from prometheus/beorn7/registry
Make hash collisions in the registry much less likely
2019-10-15 11:43:02 +02:00
beorn7 ee1078a03c Move registry hashing to xxhash
This is a much stronger hash function than fnv64a and comparably fast
(with super-fast assembly implementation for amd64).

Performance is not critical here anyway.

The old fnv64a is kept for vectors, where collision detection is in
place and the weakness of the hashing doesn't matter that much. I
implemented a vector version with xxhash and found that xxhash is
slower in all cases except very very high cardinality (where it is
only slightly faster). Also, ``xxhash.New`` comes with an allocation
of 80 bytes. Thus, to keep vectors alloc-free, we needed to add a
`sync.Pool`, which would have an additional performance overhead.

Signed-off-by: beorn7 <beorn@grafana.com>
2019-10-14 21:18:38 +02:00
beorn7 c2e3855f3b Minimal “fix” for hash collisions
This makes the collisions a bit less likely by XOR'ing descIDs rather
than adding them up for the collectorID.

Signed-off-by: beorn7 <beorn@grafana.com>
2019-10-14 20:14:43 +02:00
beorn7 bf9ff715fe Expose bug #633
Signed-off-by: beorn7 <beorn@grafana.com>
2019-10-14 20:02:58 +02:00
beorn7 6fa429cf42 Unflake TestGoCollectorGoroutines
This is not a great solution, but it's also hard to test for this
moving target.

Signed-off-by: beorn7 <beorn@grafana.com>
2019-10-14 19:44:28 +02:00
beorn7 bd362a9ced Use HTTP status code constants rather than numerical literals
Signed-off-by: beorn7 <beorn@grafana.com>
2019-10-14 19:27:09 +02:00
beorn7 f24de70161 Update push test to use status code 200
Signed-off-by: beorn7 <beorn@grafana.com>
2019-10-14 19:24:20 +02:00
Xin Zhang 7c6a9d7568 Fix check status code
Signed-off-by: Xin Zhang <ahjdzx1990@gmail.com>
2019-10-12 16:08:00 +08:00
beorn7 ad58180fde Add WriteHeader call to Flush
Flush is another of the methods that will call WriteHeader if it
hasn't happened yet. Since we want to call observeWriteHeader (if
set), we need to do the WriteHeader call already here, similar to what
we have done in Write and ReadFrom.

This commit also adds comments explaining the above to not tempt
developers to remove the WriteHeader call.

Signed-off-by: beorn7 <beorn@grafana.com>
2019-08-19 18:19:23 +02:00
Andrey Yurchenkov b0bcec8f2e
Fix typo in documentation
Signed-off-by: Andrey Yurchenkov <painhardcore@gmail.com>
2019-08-13 13:43:39 +03:00
beorn7 4b95c4ab42 Support new base64 encoding for pushing to the Pushgateway
This should only be released after PGW 0.9 is released.

Signed-off-by: beorn7 <beorn@grafana.com>
2019-07-22 20:31:37 +02:00
beorn7 48cd700822 Use method constants from the http package
Signed-off-by: beorn7 <beorn@grafana.com>
2019-06-28 15:23:00 +02:00
beorn7 9a1440d469 Add Delete method
Fixes #611.

Signed-off-by: beorn7 <beorn@grafana.com>
2019-06-28 15:12:09 +02:00
beorn7 2f3a0f8f2e Make the AlreadyRegisteredError useful for wrapped registries
Signed-off-by: beorn7 <beorn@grafana.com>
2019-06-14 17:55:35 +02:00
beorn7 f61dbeaded Update doc comment of NewProcessCollector
- Now also works on MS Windows.
- The hints for updating from older versions is obsolete by now.

Signed-off-by: beorn7 <beorn@grafana.com>
2019-06-14 12:33:52 +02:00
Calle Pettersson c5f4190338 Implement process collector for Windows (#596)
* Implement process collector for Windows

Signed-off-by: Calle Pettersson <calle@cape.nu>
2019-06-14 12:26:55 +02:00
beorn7 e7f6132a76 Remove work duplication in doc comment
Signed-off-by: beorn7 <beorn@grafana.com>
2019-06-12 01:46:17 +02:00
beorn7 761a2ff07c Remove all deprecated features
This is in preparation of the upcoming v1 release.

Signed-off-by: beorn7 <beorn@grafana.com>
2019-06-11 16:28:47 +02:00
beorn7 8576729b6f Add a simple buildInfoCollector
Signed-off-by: beorn7 <beorn@grafana.com>
2019-06-06 22:24:23 +02:00
beorn7 4d8144c11a Add test for the new promhttp_metric_handler_errors_total metric
Signed-off-by: beorn7 <beorn@grafana.com>
2019-06-06 16:56:58 +02:00
beorn7 3fa9fca2cb Add an error counter for internal errors in the HTTP handler
The doc comments explain the rationale in a quite detailed way.

Fixes #543 and #542

Signed-off-by: beorn7 <beorn@grafana.com>
2019-06-05 20:07:49 +02:00
beorn7 3d1d93eb51 Remove use of deprecated procfs functions
Signed-off-by: beorn7 <beorn@grafana.com>
2019-06-04 19:26:20 +02:00
Björn Rabenstein 388f9869ac
Merge pull request #588 from prometheus/beorn7/test
Attempt to fix flakiness of TestGoCollectorMemStats
2019-05-26 23:20:33 +02:00
beorn7 c818d96e15 Unflake TestGoCollectorGC
It is perfectly possible that a normal GC happens just before the
forced one. Thus seeing 2 GCs is fine.

Whenever this test failed, it was because two GCs were seen.

Signed-off-by: beorn7 <bjoern@rabenste.in>
2019-05-26 14:11:51 +02:00
beorn7 fe90eea9bb Attempt to fix flakiness of TestGoCollectorMemStats
This is really lame as it essentially just uses longer times to
wait. The test is still timing-dependent and thus could still
theoretically fail with unlucky scheduling. However, we are testing
something that _is_ about timing. Turning this all into something not
timing-dependent would be first quite involved and second might defeat
the purpose of testing code that is inherently about timing.

Let's see how this works out in practice.

Signed-off-by: beorn7 <bjoern@rabenste.in>
2019-05-26 13:25:59 +02:00
beorn7 b5f69192ee Purge remaining references to v0.10 from doc comments
Signed-off-by: beorn7 <bjoern@rabenste.in>
2019-05-16 23:35:36 +02:00
beorn7 bc54582c5e Make use of pre-existing context in InstrumentRoundTripperTrace
Fixes #580

Signed-off-by: beorn7 <bjoern@rabenste.in>
2019-05-16 17:52:19 +02:00
beorn7 6c520f6aca Add test to expose #580
Tests are heavily inspired by @shturec, see #584.

Signed-off-by: beorn7 <bjoern@rabenste.in>
2019-05-16 17:52:19 +02:00
Björn Rabenstein 775f94f6fc
Merge pull request #581 from prometheus/beorn7/test
Fix race in TestGoCollectorMemStats
2019-05-16 15:31:37 +02:00
beorn7 e91cd81632 Remove outdated use-case description from doc comment
We stopped advertising binary-wide setting of a label quite a while
ago. This doc comment was missed in the cleanup.

Signed-off-by: beorn7 <bjoern@rabenste.in>
2019-05-16 11:23:48 +02:00
beorn7 709dc4b1de Fix race in TestGoCollectorMemStats
Related to #573 (but only partially fixes it).

Signed-off-by: beorn7 <bjoern@rabenste.in>
2019-05-16 10:37:37 +02:00
Camilo Viecco facfcc21f8 fix regression issue 574
Signed-off-by: Camilo Viecco <camilo_viecco1@symantec.com>
2019-05-14 11:44:55 -07:00
beorn7 886e2ee0c0 Clarify deprecation of `DefObjectives`
Previously, the whole `Objectives` field was marked as deprecated by
linters.

Signed-off-by: beorn7 <bjoern@rabenste.in>
2019-05-08 13:38:43 +02:00
Björn Rabenstein 2d3b0fe0e0
Merge pull request #568 from prometheus/beorn7/go-collector
Return previous memstats if Go collector needs longer than 1s
2019-05-07 00:10:32 +02:00
Bjoern Rabenstein 7cf0955421 Handle long ReadMemStats duration in Go collector
tl;dr: Return previous memstats if reading new ones takes longer than
1s.

See the doc comment of NewGoCollector for details.

Signed-off-by: beorn7 <bjoern@rabenste.in>
2019-05-06 23:28:31 +02:00
beorn7 547c945a62 Replace fmt.Sprintf by simple concatenation
In this simple case, it's the fastest and easiest.

Signed-off-by: beorn7 <bjoern@rabenste.in>
2019-05-06 23:28:31 +02:00
beorn7 016273b1f9 Fix and tweak Go collector tests
Signed-off-by: beorn7 <bjoern@rabenste.in>
2019-05-06 23:28:31 +02:00
Björn Rabenstein f1d50bcc55
Merge pull request #559 from nghialt/master
Add HTTPClient interface to Pusher struct
2019-05-06 01:31:30 +02:00
NghiaLT 6ea6f07918 Replace HTTPClient with HTTPDoer; Update document accordingly
Signed-off-by: NghiaLT <nghialt.11@gmail.com>
2019-05-06 04:28:14 +07:00
Björn Rabenstein 906d2976cb
Merge pull request #567 from prometheus/beorn7/counter
Make TestCounterAddLarge more robust
2019-05-04 18:08:04 +02:00
Bjoern Rabenstein bf1f4e4a24 Make TestCounterAddLarge more robust
The previous `float64(math.MaxUint64 + 1)` is too close to
`float64(math.MaxUint64)` to actually overflow as indended.

The counter code is actually converting forward and backward and
compare the original and twice-converted value. On most platform, this
will create a deviation and thus trigger the expected behavior. By
sheer "luck", one might end up with the same value and thus still use
the uint64 representation. Which is OK within the precision we can
expect. But it breaks the test. With this change, the next
representable floating point value greater than the floating point
value used to represent math.MaxUint64 is used.

Signed-off-by: Bjoern Rabenstein <bjoern@rabenste.in>
2019-05-03 22:25:32 +02:00
Bjoern Rabenstein 57f7bd35fd Remove remaining traces of pre-go-1.8 handling
Signed-off-by: Bjoern Rabenstein <bjoern@rabenste.in>
2019-05-03 21:30:30 +02:00
KevinBetterQ a325fb7566 fix: fix a typo
Signed-off-by: KevinBetterQ <1093850932@qq.com>
2019-05-01 17:50:23 +08:00
Bjoern Rabenstein 1173d73405 Increase minimum required Go version to 1.9
This allows us to simplify a bunch of code while still supporting the
last four Go minor versions.

We have also run into minor annoyances a couple of times by now to
keep supporting 1.7 and 1.8.

It's time to pull the plug!

Signed-off-by: Bjoern Rabenstein <bjoern@rabenste.in>
2019-04-28 23:28:57 +02:00
NghiaLT c9d77912ac Add HTTPClient interface to Pusher struct
Signed-off-by: NghiaLT <nghialt.11@gmail.com>
2019-04-26 16:53:21 +07:00
Simon Pasquier 6894bb3c7c Add .golangci.yml
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-04-25 10:38:07 +02:00
Simon Pasquier 15da21f1e4 *: replace golang.org/x/net/context by context
The context package is available since Go 1.7 which is the minimal version
supported by client_golang.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-04-09 15:10:51 +02:00
Sergiusz Urbaniak 60728f445d prometheus/promhttp: actually observe values in trace in example
This is similar to
https://github.com/prometheus/client_golang/pull/535 fixing ExampleInstrumentRoundTripperDuration.

Signed-off-by: Sergiusz Urbaniak <sergiusz.urbaniak@gmail.com>
2019-03-06 13:59:53 +01:00
Frank Spitulski 10e34c668f fix(push): incorporate changes from review
Signed-off-by: Frank Spitulski <fspituls@ucsd.edu>
2019-02-24 15:15:35 -08:00
Frank Spitulski 7b127b3fe5 feat(push): add format builder option
Allow users to specify which format the pusher should push in.

Signed-off-by: Frank Spitulski <fspituls@ucsd.edu>
2019-02-24 12:51:45 -08:00
beorn7 4c99dd6630 Port histogram improvements into noObjectivesSummary
Signed-off-by: beorn7 <beorn@soundcloud.com>
2019-02-11 19:10:17 +01:00
beorn7 295f7e4861 Fix some comment and naming nits as leftover from #536
Signed-off-by: beorn7 <beorn@soundcloud.com>
2019-02-11 18:52:52 +01:00
Pascal S. de Kloe 19ff277483 Save memory on histograms: slightly faster with less code (#536)
Use the highest bit for buffer switch tracking in histograms

Signed-off-by: Pascal S. de Kloe <pascal@quies.net>
2019-02-11 18:29:02 +01:00
kklipsch a11607d7ae fix client trace examples to actually capture metrics
Signed-off-by: kklipsch <kklipsch@example.com>
2019-02-04 20:30:19 +00:00
beorn7 8785922956 Revert "Fix tests to adhere to the recent change in prometheus/common"
This reverts commit 2c9811f88e.

This is necessary because the changes in prometheus/common got reverted.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2019-01-27 23:18:44 +01:00
Matt Layher da7d5640a2 prometheus: reword comment to avoid cursing
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2019-01-16 17:03:06 -05:00
beorn7 b3d6096432 Improve testutil error messages
This also satisfy newer staticcheck versions.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2019-01-06 00:22:03 +01:00
beorn7 91b385db44 Fix staticcheck errors in push_test.go
Signed-off-by: beorn7 <beorn@soundcloud.com>
2019-01-05 22:11:07 +01:00
Björn Rabenstein 2945395678
Merge pull request #525 from RomanKrasavtsev/patch-1
fix typo
2019-01-05 21:35:34 +01:00
Björn Rabenstein cf7da0f496
Merge pull request #521 from prometheus/beorn7/summary
Lock-free summaries without objectives
2019-01-05 21:23:43 +01:00
Roman Krasavtsev c51ed6941c fix typo
Signed-off-by: Roman Krasavtsev <mr.krasavtsev@gmail.com>
2019-01-04 21:14:10 +01:00
JoeWrightss fb3d5cb2ad Fix some spelling errors (#523)
* Fix some spelling errors

Signed-off-by: JoeWrightss <zhoulin.xie@daocloud.io>
2018-12-30 21:31:21 +01:00
gkze ee4e5e071e Fix typo again
Signed-off-by: gkze <george.kontridze@gmail.com>
2018-12-26 17:39:47 -08:00
beorn7 226b83ac2e Provide lock-free implementation for Summary without objectives
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-12-24 11:23:13 +01:00
beorn7 a006a7550a Remove unused constants and fields
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-12-24 11:22:57 +01:00
gkze 67bb2a7be3 Fix typo
Signed-off-by: gkze <george.kontridze@gmail.com>
2018-12-21 15:40:57 -08:00
beorn7 2c9811f88e Fix tests to adhere to the recent change in prometheus/common
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-12-18 17:20:25 +01:00
beorn7 000ceb266b Fix doc comment typo
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-12-18 16:30:34 +01:00
beorn7 619eb595ba Simplify an `append` to `copy`
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-12-06 11:37:34 +01:00
beorn7 fae889635c Fix #512
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-12-06 11:35:30 +01:00
beorn7 9542e4005c Expose #512
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-12-06 11:22:30 +01:00
beorn7 48d3ae798b Return observed duration from Timer.ObserveDuration
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-12-03 21:10:34 +01:00
beorn7 8d9c21f0cf Nitpicking a doc comment
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-11-20 13:41:38 +01:00
Björn Rabenstein f6443e74d4
Merge pull request #495 from SvenDowideit/add-extra-hints-to-clustermanager-example
Add the last few lines needed to show a new user how the Collector/Gatherer fits together
2018-11-20 13:35:42 +01:00
Dowideit, Sven (O&A, St. Lucia) 8324e65597 Add the last few lines needed to show a new user how the Collector/Gatherer fits together
Signed-off-by: Dowideit, Sven (O&A, St. Lucia) <Sven.Dowideit@csiro.au>
2018-11-20 15:46:27 +10:00
Peter Jausovec a199184c14 Update the label is not valid error message to include the fqName
Fixes #504.

Signed-off-by: Peter Jausovec <peter.jausovec@oracle.com>
2018-11-19 16:51:57 -08:00
beorn7 8c67c139e2 Remove accidental gogo/protobuf import
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-11-16 13:23:08 +01:00
beorn7 c4c1f3461e Fix tiny punctuation issue in doc comment
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-11-15 18:40:33 +01:00
PhilipGough f9739b3d97
Compare text strings directly in testutil
Signed-off-by: PhilipGough <philip.p.gough@gmail.com>
2018-11-15 16:03:57 +00:00
PhilipGough 30503fe98e
Exposes bug #498 - unexpected results for Histograms in testutil
Signed-off-by: PhilipGough <philip.p.gough@gmail.com>
2018-11-14 11:58:43 +00:00
beorn7 86702ea6b4 Fix metric comparison for empty labels
reflect.DeepEqual is not suitable for zero occurrences of repeated
proto messages. This changes the comparison to act on the string
representation of proto messages.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-11-13 16:25:02 +01:00
beorn7 1db43792db Expose bug #494
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-11-13 15:48:48 +01:00
Björn Rabenstein da11cf2c83
Merge pull request #488 from peterj/master
Add more info to the inconsistent cardinality errors
2018-11-02 19:52:54 +01:00
Sevag Hanssian 88f4223778
Fix permissions of tempfile
Signed-off-by: Sevag Hanssian <sevag.hanssian@gmail.com>
2018-11-02 09:59:03 -07:00
Peter Jausovec f1bec54758 Update the ExampleRegister test
Signed-off-by: Peter Jausovec <peter.jausovec@oracle.com>
2018-11-02 09:46:03 -07:00
Sevag Hanssian 924d5919f3
Improve WriteToTextfile doc
Signed-off-by: Sevag Hanssian <sevag.hanssian@gmail.com>
2018-11-02 09:31:41 -07:00
Peter Jausovec b686a9e02e Remove fmt from import
Signed-off-by: Peter Jausovec <peter.jausovec@oracle.com>
2018-11-02 09:21:12 -07:00
Peter Jausovec ea348d7c20 Update code based on the PR feedback
Signed-off-by: Peter Jausovec <peter.jausovec@oracle.com>
2018-11-02 09:01:14 -07:00
Sevag Hanssian 42e6616334
Use code that already existed
Signed-off-by: Sevag Hanssian <sevag.hanssian@gmail.com>
2018-11-02 08:37:26 -07:00
Sevag Hanssian 1d54dabd43
Add WriteToTextfile test
Signed-off-by: Sevag Hanssian <sevag.hanssian@gmail.com>
2018-10-31 23:34:50 -07:00
Sevag Hanssian c5bdd15ac3
Remove typo
Signed-off-by: Sevag Hanssian <sevag.hanssian@gmail.com>
2018-10-31 15:31:42 -07:00
Sevag Hanssian e6fe89ce22
Add support for histograms and summaries
Signed-off-by: Sevag Hanssian <sevag.hanssian@gmail.com>
2018-10-31 15:27:11 -07:00
Sevag Hanssian 9416ff209b
First commit - WriteToTextfile
Signed-off-by: Sevag Hanssian <sevag.hanssian@gmail.com>
2018-10-31 14:22:11 -07:00
Peter Jausovec ceb819208d copy/pasta error
Signed-off-by: Peter Jausovec <peter.jausovec@oracle.com>
2018-10-31 11:16:16 -07:00
Peter Jausovec 4fe949f2fd Add missing fmt import
Signed-off-by: Peter Jausovec <peter.jausovec@oracle.com>
2018-10-31 11:09:12 -07:00
Peter Jausovec 902733d080 Add more info to the inconsistent cardinality errors
Signed-off-by: Peter Jausovec <peter.jausovec@oracle.com>
2018-10-31 11:01:42 -07:00
beorn7 fb0f7fe8c2 Pull up HTTP changes into deprecated functions
So that also users of those can benefit. Obviously, we will end
updating deprecated functions one day (at latest once v0.10 is out).

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-10-22 12:36:33 +02:00
beorn7 62361fc0fb Use streaming encoding of metrics
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-10-22 01:04:52 +02:00
beorn7 752f50d366 Merge branch 'use-gzip-pool' of github.com:glefloch/client_golang into beorn7/http 2018-10-20 00:51:31 +02:00
glefloch c2c6fd2ab4 Fix PR comments
Signed-off-by: glefloch <glfloch@gmail.com>
2018-10-19 13:51:45 +02:00
glefloch fdf4cbc87b Use sync.Pool for gzipWriter
Signed-off-by: glefloch <glfloch@gmail.com>
2018-10-17 13:17:33 +02:00
beorn7 5e8ac3cd58 Add a concurrent end-to-end test for observe-register-gather
This is an attempt to expose
https://github.com/istio/istio/issues/8906 .  The failure to do so
makes me believe the error is either already fixed in current
client_golang, or something weird I haven't spotted yet is happening
in the istio code.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-10-10 16:59:24 +02:00
beorn7 e1fb14a776 Adjust TestRegisterWithOrGet to the present
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-10-10 15:41:21 +02:00
beorn7 edb489a1ef Add check for duplicated label names
Fixes #471

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-30 16:25:48 +02:00
beorn7 dd9e125455 Expose failure to detect duplicate label names
This is #471.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-30 16:25:48 +02:00
beorn7 ff0177896a Be more precise about concurrency requirements
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-29 10:47:28 +02:00
beorn7 7eb5e8a08a Drain the desc channel after registering
This avoids leaking goroutines.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-29 10:44:19 +02:00
David E Worth c2c648fdcb
fix exponential buckets failure message
it appears there is a copy/paste error in the exponential buckets test failure message which is fixed here.

Signed-off-by: David Worth <dworth@strava.com>
2018-09-25 17:42:06 -06:00
beorn7 7973e4709d Ensure 64bit alignment on 32bit platforms for histograms
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-24 13:28:13 +02:00
beorn7 3a6edf5ff8 Handle items newly deprecated in Go 1.11
Remove where possible and ignore staticcheck warnings where we have
to.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-19 13:30:14 +02:00
beorn7 663a9ad019 Make Help strings optional
This is in line with
https://prometheus.io/docs/instrumenting/writing_clientlibs/#metric-description-and-help

Since the zero value of a string in Go is `""`, we cannot distinguish
between a Help string not set and an empty Help string. Thus, we just
make it formally optional here with an encouragement to set it in the
doc comment.

In v0.10, the Help string will probably become a "normal" argument of
the constructor rather than a field in an Opts struct.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-17 12:07:31 +02:00
beorn7 713e6eb604 Let NewConst... functions detect invalid Desc
The error of the invalid Desc is returned in that case.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-17 11:50:42 +02:00
beorn7 b7b390014b Reformat doc comment of InstrumentHandler
To help linters detect the Deprecated message.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-14 13:24:05 +02:00
beorn7 cec67c9ec8 Improve deprecated doc comment
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-14 12:48:16 +02:00
Björn Rabenstein 1362cad3aa
Merge pull request #458 from prometheus/beorn7/registry
Wrappable registerers
2018-09-14 12:15:22 +02:00
beorn7 fe28f32433 Discourage prefixing every metris with WrapRegistererWithPrefix
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-14 11:59:13 +02:00
beorn7 cf9b2a8c78 Rename WrapWith... to WrapRegistererWith...
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-13 17:43:05 +02:00
beorn7 837c7cb1f4 Update Collector example
It now uses the new WrapWith function instead of ConstLabels. Describe
is now implemented via DescribeByCollect.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-12 15:34:13 +02:00
beorn7 84d7aa0cd9 Add wrapping of Registerers with labels and prefix
Essentially middleware for Registerers!

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-12 15:34:07 +02:00
beorn7 1b2bd1d665 Make Histogram observations atomic while keeping them lock-free
Fixes #275

This is rather tricky and required some studying of the Go memory
model. I have added copious code comments to explain what's going on.

Benchmarks haven't changed significantly, despite the additional
atomic operations now required during Observe. Write performance is
noticable, but it is also much more involved now and has a mutex. (But
note that Write is supposed to be a relatively rare operation and thus
not in the hot path compared to Observe.) Allocs haven't changed at
all.

OLD:

BenchmarkHistogramWithLabelValues-4     10000000               151 ns/op               0 B/op          0 allocs/op
BenchmarkHistogramNoLabels-4            50000000                36.0 ns/op             0 B/op          0 allocs/op
BenchmarkHistogramObserve1-4            50000000                28.1 ns/op             0 B/op          0 allocs/op
BenchmarkHistogramObserve2-4            10000000               160 ns/op               0 B/op          0 allocs/op
BenchmarkHistogramObserve4-4             5000000               378 ns/op               0 B/op          0 allocs/op
BenchmarkHistogramObserve8-4             2000000               768 ns/op               0 B/op          0 allocs/op
BenchmarkHistogramWrite1-4               1000000              1589 ns/op             896 B/op         37 allocs/op
BenchmarkHistogramWrite2-4                500000              2973 ns/op            1792 B/op         74 allocs/op
BenchmarkHistogramWrite4-4                300000              6979 ns/op            3584 B/op        148 allocs/op
BenchmarkHistogramWrite8-4                100000             10701 ns/op            7168 B/op        296 allocs/op

NEW:

BenchmarkHistogramWithLabelValues-4     10000000               191 ns/op               0 B/op          0 allocs/op
BenchmarkHistogramNoLabels-4            30000000                50.1 ns/op             0 B/op          0 allocs/op
BenchmarkHistogramObserve1-4            30000000                40.0 ns/op             0 B/op          0 allocs/op
BenchmarkHistogramObserve2-4            20000000                91.5 ns/op             0 B/op          0 allocs/op
BenchmarkHistogramObserve4-4             5000000               317 ns/op               0 B/op          0 allocs/op
BenchmarkHistogramObserve8-4             2000000               636 ns/op               0 B/op          0 allocs/op
BenchmarkHistogramWrite1-4               1000000              2072 ns/op             896 B/op         37 allocs/op
BenchmarkHistogramWrite2-4                300000              3729 ns/op            1792 B/op         74 allocs/op
BenchmarkHistogramWrite4-4                200000              7847 ns/op            3584 B/op        148 allocs/op
BenchmarkHistogramWrite8-4                100000             16975 ns/op            7168 B/op        296 allocs/op

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-12 15:03:44 +02:00
beorn7 1e08f788cf Add test to expose #275
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-07 19:04:00 +02:00
beorn7 773f502723 Rework process collector
This unifies both constructors in one with an options argument.

The options argument allows to switch on error reporting, as discussed
in #219.

The change of the contructor signature is breaking, but only mildly
so. Plus, the process collector is rarely used explicitly. I used
Sourcegraph to search for public usages, with the following results:

- 2 occurrences of NewProcessCollectorPIDFn, once in @discordianfish's
  glimpse, once in @fabxc's etcd_exporter (deprecated anyway). Both
  are Prom veterans and will simply do the one line change if needed.
- 8 occurrences of NewProcessCollector, of which 7 are of the form
    NewProcessCollector(os.Getpid(), "")
  Thus, it's a very easy change, which I even hinted at in the doc
  comment.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-07 12:09:26 +02:00
beorn7 6803bb4021 Add a DescribeByCollect helper
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-05 14:10:51 +02:00
beorn7 74a2f46d2c Add package documentation
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-04 14:02:20 +02:00
beorn7 1301cf8fcd Add helper function to extract a simple float value from a metric
Signed-off-by: beorn7 <beorn@soundcloud.com>

foo
2018-09-04 14:02:19 +02:00
beorn7 da330f4281 Un-export prometheus.LabelPairSorter
The only known external usage of it was in prometheus/pushgateway,
where it was removed by
https://github.com/prometheus/pushgateway/pull/200 .

Originally, the expectation was that users would implement the Metric
interface now and then. As we know now, neither it is happening, nor
would it make a lot of sense. (Users implement the Collector interface
instead.) By now, LabelPairSorter is essentially noise in the already
quite cluttered namespace in the prometheus package.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-03 16:20:55 +02:00
Björn Rabenstein a10423e9da
Merge pull request #445 from prometheus/beorn7/testing
Add testutil package
2018-09-03 00:31:34 +02:00
beorn7 7be86f93c1 Create an internal package
This is for types we don't want to export but which are used in
different packages within client_golang.

Currently, that's only NormalizeMetricFamilies (used in the prometheus
package and in the testutil package). More to be added as needed.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-03 00:18:11 +02:00
beorn7 5ba0993f6f Improved interface
- Expected text format is now read from an io.Reader.
- Metrics are gathered from a Gatherer.
- Added a convenience wrapper to collect from a Collector.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-02 21:07:38 +02:00
Yutian Li 94f32c433e typo
Signed-off-by: Yutian Li <hotpxless@gmail.com>
2018-08-27 12:01:30 -04:00
beorn7 154f28a316 Fix import grouping
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-08-23 00:05:02 +02:00
beorn7 e60f998e9b Make license headers consistent
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-08-22 23:59:40 +02:00
beorn7 df0210c26c Rename testutils to testutil and move below prometheus dir
`testutil` is more in line with stdlib naming conventions.

The package should be below `prometheus` as it only provides utils to
test exposition code, not to test HTTP client code.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-08-22 23:57:08 +02:00
glefloch 949c45bad2 Add missing header and fix review comments
Signed-off-by: glefloch <glfloch@gmail.com>
2018-08-22 15:32:42 +02:00
glefloch cb71127117 Add missing license headers
Signed-off-by: glefloch <glfloch@gmail.com>
2018-08-22 13:53:56 +02:00
beorn7 abaece07d1 Fix import grouping
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-08-18 16:02:33 +02:00
beorn7 5240f7e8f5 Add a wrapper to add a timestamp to a metric
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-08-18 15:56:08 +02:00
Simon Pasquier d6dbfbfc28 Update the name of the maximum VM metric
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-08-08 08:09:48 +02:00
Björn Rabenstein 420e2efa8f
Merge pull request #438 from simonpasquier/add-max-vsize-process-metric
Add process_maximum_virtual_memory_bytes metric
2018-08-07 21:38:51 +02:00
Dalei Li 927ca8e4f4 go routine to goroutine
Signed-off-by: Dalei Li <dalei.li@icloud.com>
2018-08-07 21:23:58 +02:00
Simon Pasquier 4ab15af0dc Add process_maximum_virtual_memory_bytes metric
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2018-08-07 17:10:30 +02:00
Björn Rabenstein bcbbc08eb2
Merge pull request #429 from prometheus/beorn7/summary
Add more checks around summaries and histograms
2018-07-13 22:10:52 +02:00
beorn7 4572e24546 Add suffix collision checks during gathering
So far, if a gauge was named `xxx_count`, and a summary or histogram
`xxx`, this would have led to a legal protobuf exposition but would
have created a name collision on `xxx_count` in the text format and
within the Prometheus server.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-07-13 16:29:17 +02:00
Eric Daniels 2d0312e3dd
forgot some &s
Signed-off-by: Eric Daniels <eric@erdaniels.com>
2018-07-13 09:28:19 -04:00
beorn7 767a0218df Add more label checksn during gathering
Including check for an invalid "quantile" label in summaries.

Also, improve error messages.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-07-13 14:14:39 +02:00
beorn7 e064aa97f1 Check quantile label during SummaryVec construction
Also, document the existing behavior more clearly.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-07-13 13:43:21 +02:00
Eric Daniels c02aadb406
remove references to delegators
Signed-off-by: Eric Daniels <eric@erdaniels.com>
2018-07-12 17:56:44 -04:00
Eric Daniels b3076e068e
Make delegators wrapping responseWriterDelegator have value receivers
Signed-off-by: Eric Daniels <eric@erdaniels.com>
2018-07-12 11:37:51 -04:00
beorn7 ad1b9f7754 Introduce unchecked Collectors
Fixes #47 . See there for more detailed discussion.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-07-09 14:33:18 +02:00
neeral fe6c0fa342 Do not sanitize prefix in Graphite bridge
Refer to #418.

Signed-off-by: neeral <neeral@users.noreply.github.com>
2018-06-22 13:00:54 -07:00
beorn7 f6b1978ed4 Use stricter wording for Gather returning a non-nil error
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-06-07 14:35:06 +02:00
beorn7 c06fb788be Relax consistency checks during gathering
Also, clarify in the doc comment.

Previously, the assumption was that inconsistent label dimensions are
violating the exposition format spec. However, especially with the
knowledge that OpenMetrics will explicitly allow inconsistent label
dimensions in expositions, we should allow it in client_golang, too.

Note that registration with proper Descs provided will still check for
consistont label dimensions. However, you can "cheat" with custom
Collectors as you can collect metrics that don't follew the provided
Desc (this will be made more explicit and less cheaty once #47 is
fixed). You can also create expositions with inconsistent label
dimensions by merging Gatherers with the Gatherers slice type. (The
latter is used in the Pushgateway.)

Effectively, normal direct instrumentation will always have consistent
label dimensions in this way, but you can cover special use cases with
custom collectors or merging of different Gatherers.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-06-06 19:30:53 +02:00
beorn7 1b56b5c497 Be more robust about nil pointers in protobuf
While not strictly correct, it can easily happen that proto messages
are created that use nil pointers instead of pointers in empty strings
to denote an empty string.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-05-29 17:57:33 +02:00
beorn7 d66ac8f863 Document the stop-the-world implications of the Go collector
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-05-19 21:14:04 +02:00
Karsten Weiss d7590aab3c Fix three shadow variable warnings (govet -shadow)
Fixes:
http.go:118: declaration of "part" shadows declaration at http.go:117
http_test.go:50: declaration of "respBody" shadows declaration at http_test.go:25
promhttp/http.go:305: declaration of "part" shadows declaration at promhttp/http.go:304

Signed-off-by: Karsten Weiss <knweiss@gmail.com>
2018-04-13 23:25:14 +02:00
Karsten Weiss f3a13af35c http.go: Move helper function nowSeries() to test case
Fixes:
http.go:142:1⚠️ nowSeries is unused (deadcode)

Signed-off-by: Karsten Weiss <knweiss@gmail.com>
2018-04-13 23:25:14 +02:00
Karsten Weiss 0a453dce84 Build process_collector_test.go only on Linux
The test case requires the /proc filesystem. The change prevents this skip
message during "go test -v" on platforms other than Linux:

=== RUN   TestProcessCollector
--- SKIP: TestProcessCollector (0.00s)
	process_collector_test.go:15: skipping TestProcessCollector, procfs not available: could not read /proc: stat /proc: no such file or directory

Signed-off-by: Karsten Weiss <knweiss@gmail.com>
2018-04-13 23:25:14 +02:00
Karsten Weiss 7a495a15b3 Type processCollector: Remove unused field 'pid'
Fixes:
process_collector.go:19:2: field pid is unused (U1000)

Signed-off-by: Karsten Weiss <knweiss@gmail.com>
2018-04-13 23:25:14 +02:00
Karsten Weiss ea0d27e8cf Type responseWriterDelegator: Remove unused fields
Fixes:
http.go:355:2: field handler is unused (U1000)
http.go:355:11: field method is unused (U1000)

Signed-off-by: Karsten Weiss <knweiss@gmail.com>
2018-04-13 23:25:14 +02:00
Karsten Weiss 958ea82988 Fix typos
Signed-off-by: Karsten Weiss <knweiss@gmail.com>
2018-04-13 23:23:52 +02:00
Karsten Weiss 245fde70cb Simplify if expr in ExampleNewExpvarCollector()
Signed-off-by: Karsten Weiss <knweiss@gmail.com>
2018-04-13 23:23:52 +02:00
Karsten Weiss 587d5265f8 metric.go: Remove unused type hashSorter
Fixes:
metric.go:130:6: type hashSorter is unused (U1000)

Signed-off-by: Karsten Weiss <knweiss@gmail.com>
2018-04-13 23:23:52 +02:00
Karsten Weiss e01f7ec4fb Remove unnecessary conversion
Fixes:
go_collector.go:268:66⚠️ unnecessary conversion (unconvert)

Signed-off-by: Karsten Weiss <knweiss@gmail.com>
2018-04-13 23:18:25 +02:00
Karsten Weiss 66b5a26cec Remove unnecessary for loop in makeLabelPairs()
Fixes:
value.go:155:2: should replace loop with labelPairs = append(labelPairs, desc.constLabelPairs...) (S1011)

Signed-off-by: Karsten Weiss <knweiss@gmail.com>
2018-04-13 23:18:20 +02:00
Karsten Weiss daa9993ded Use direct API calls
Fixes:
prometheus/http_test.go:117:5⚠️ should use resp.Body.String() instead of string(resp.Body.Bytes()) (S1030) (megacheck)
prometheus/http_test.go:118:56⚠️ should use resp.Body.String() instead of string(resp.Body.Bytes()) (S1030) (megacheck)

Signed-off-by: Karsten Weiss <knweiss@gmail.com>
2018-04-13 23:17:58 +02:00
Eric Boren ddd94f24c5 Fix unprotected write in metricMap 2018-04-09 10:10:15 -04:00
Luke Hanley f504d69aff promhttp: fix DNSDone should call Done, not Start (#395)
When tracing, it appears DNSDone is instead calling the supplied DNSStart function
2018-03-28 15:04:30 +02:00
beorn7 d7f8852e05 Fix TestHandler
prometheus/common has changed and now adds the charset to the
Content-Type header.
2018-03-19 14:04:12 +01:00
Adam Thomason 660e6909cc promauto: add NewCounterFunc and NewGaugeFunc 2018-03-17 14:01:36 -07:00
beorn7 b82bcfe55f Add a package promauto that provides auto-registering metrics
Finally, I found an easy solution to provide the "evil"
auto-registration without getting death threats from the wardens of Go
purity. The reasoning can be found in the package's doc comment.
2018-02-16 12:55:57 +01:00
Brian Brazil a331f1ea4a Add Godoc link at the top of the README
For those following that link, make it more obvious
which subpackage they probably want.
2018-02-15 11:45:41 +00:00
Björn Rabenstein 7e8a70d021
Merge pull request #381 from prometheus/beorn7/push
Add completely new push syntax
2018-02-14 19:20:02 +01:00
beorn7 361cb3a7d0 Delete another use of HostnameGrouping from a doc comment 2018-02-14 18:59:17 +01:00
beorn7 38de287a56 Remove obsolete copyright notices 2018-02-14 18:49:18 +01:00
beorn7 779cbe15b2 Remove HostnameGrouping method 2018-02-14 17:19:52 +01:00
beorn7 3c2baee2d1 Add completely new push syntax
This allows adding more options in elegant ways, showcased here by
HTTP basic auth and by injecting a custom http.Client.

Fixes #341 and #372.
2018-02-14 13:40:57 +01:00
Brian Brazil 02aee00fdb
Fix a typo 2018-02-14 11:10:46 +00:00
beorn7 c551c3c661 promhttp: Introduce limit for connections in flight and timeout 2018-02-09 17:05:10 +01:00
Björn Rabenstein a85074fc85
Merge pull request #377 from prometheus/beorn7/http
Provide an InstrumentedHandler
2018-02-08 17:52:34 +01:00
beorn7 8fd47d2e8f Provide an InstrumentedHandler
See https://github.com/prometheus/client_golang/issues/316 for details.
2018-02-08 16:27:51 +01:00
beorn7 154bb450e4 Document that the process collector only works on Linux 2018-02-08 14:17:54 +01:00
beorn7 e87046a87e Fix more interface upgrade bugs 2018-02-02 15:53:28 +01:00
beorn7 d892fd2b51 Add test to expose interface upgrade bug
In principle, we needed to iterate through all permutations, mirroring
the same that is happening in the code. For lack of time, I only
picked one of the cases currently buggy.

As said, this really needs code generation, should we ever find
ourselves touching this again.
2018-02-02 15:50:46 +01:00
Torin Sandall 44a8a1218c Fix delegator return value for single hijacker
Previously, the pickDelegator function was not returning a
*hijackerDelegator so the return value did not implement the Hijacker
interface. As a result, code that attempts to hijack the connection
would fail when using a type assertion.

All the other cases returned the hijackerDelegator correctly.
2018-02-01 10:57:42 -08:00
beorn7 4957f7bba4 Add a safety goroutine budget
This makes sure we don't spin up a possibly infinite number of
goroutines in `Gather`, which could theoretically happen with unlucky
scheduling.
2018-01-31 14:49:15 +01:00
beorn7 e04451f4be Create goroutines adaptively during metrics gathering 2018-01-26 19:58:07 +01:00
Stephen McQuay (smcquay) b77ed204f6
Add a benchmark for concurrent counter increments 2018-01-19 15:15:10 -08:00
beorn7 a2facc3074 Iterate on a proposed performance improvement for counters
Original discussion see
https://github.com/prometheus/client_golang/pull/362 .

Assuming that the most frequently used method of a `Gauge` is `Set`
and the most frequently used method of a `Conuter` is `Inc`, this
separates the implementation of both metric types. `Inc` and integral
`Add` of a counter is now handled in a separate `uint64`. This would
create a race in `Set`, but luckily, there is no `Set` anymore in a
counter.

All attempts to solve above race (to use the same idea for a `Gauge`)
slow down `Set`, So we just stick with the old implementation
(formerly `value`) for `Gauge`.
2018-01-19 19:06:43 +01:00
beorn7 c7029dc87d Merge branch 'counter/fixed-prec' of git://github.com/smcquay/client_golang into beorn7/counter 2018-01-19 13:12:07 +01:00
beorn7 f02bfc3484 Minor doc comment fix
This was forgotten to be included in the previous commit.
2018-01-11 16:59:30 +01:00
beorn7 9ac0bad606 Take into account curried labels in promhttp 2017-12-24 14:39:06 +01:00
beorn7 1ba60c7d58 Pull currying methods up into ObserverVec interface 2017-12-22 16:11:58 +01:00
beorn7 dd20712622 Allow currying of metric vec's
The idea behind it is described in detail in
https://github.com/prometheus/client_golang/issues/320 .

This commit also updates the example given in
promhttp/instrument_server_test.go , which nicely illustrates the
benefit of this change.

So far, currying could be emulated by creating different metric vec's
with different values in their ConstLabels. This was quite difficult
to grasp - which is essentially what was done in the example mentioned
above. Now that this use case can be solved without ConstLabels, we
can safely declare ConstLabels as rarely used. (Perhaps we can
deprecate them entirely one day, but I'll take a raincheck on that
when the changes of v0.10 have materialized.) This commit thus also
updates the ConstLabel doc comments in the various Opts. (It contained
fairly outdated stuff anyway.)
2017-12-22 15:56:11 +01:00
beorn7 10c55533cb Rename the receiver of `...Vec` methods from `m` to `v` 2017-12-21 14:06:39 +01:00
beorn7 9e1588b2a2 Pull `With` and `WithLabelValues` up into exported types
The "panic in case of error" code was so far in metricVec. This pulls
it up into the exported types like CounterVec. This is code
replication, but it avoids an explicit type conversion. Mostly,
however, this is preparation to make the wrapped metricVec an
interface (required for curried vec's).
2017-12-21 14:06:39 +01:00
Stephen McQuay (smcquay) 35559538c7
Implements review commentary
Specifically @beorn7 pointed out that the previous implementation had
some shortcomings around large numbers. I've changed the code to match
the suggestion in review, as well as added a few test cases.
2017-12-15 11:03:30 -08:00
Stephen McQuay (smcquay) ae6939214c
Adds a faster counter 2017-12-15 11:03:24 -08:00
Brian Brazil 9f5d03c01f Fix typo in comment 2017-10-04 17:44:49 +01:00
beorn7 50b3332fd6 Polishing some doc comments 2017-09-13 12:48:29 +02:00
Povilas Versockas 77a1417b06 Change summary docs 2017-09-12 20:27:18 +03:00
Matt Bostock b092a4bc11 Correct DefaultRegistry to DefaultRegisterer
`DefaultRegistry` no longer exists as of a6321dd0b.
2017-09-05 01:08:40 +01:00
beorn7 2cb8df16e3 Fix error reporting bug
That's the same bug fixed in #342 (which is the deprecated code only
replicated in the `prometheus` package until v0.10 is out).
2017-08-31 15:10:58 +02:00
Will Rouesnel a166207919 http.go: incorrect error message displayed when no metrics encoded error
The "No metrics encoded" error was erroneously displayed the value of err, not
lastErr.
2017-08-31 12:05:46 +10:00
beorn7 6164fff8ce Remove the deprecated uses of Untyped metrics
I couldn't find any use of the removed identifiers on sourcegraph.com
(outside of this repo itself).
2017-08-29 17:31:45 +02:00
Lynn Lin be904beebc fix spelling typo 2017-08-28 08:57:51 +08:00
Marco Jantke a956c5fdd6 improve validation function naming 2017-08-25 17:58:59 +02:00
Marco Jantke 0b8aef084e implement review feedback 2017-08-25 14:51:19 +02:00
Marco Jantke 6df742e132 improve formatting of invalid label value error messages 2017-08-20 00:54:11 +02:00
Marco Jantke 555018f3c9 make code compatible with go 1.6 2017-08-20 00:53:55 +02:00
Marco Jantke 685a3c90d4 fail Gather'ing when label value is not utf8 2017-08-20 00:10:32 +02:00
Marco Jantke 7ee20d77cb validate ConstLabels values in NewDesc 2017-08-20 00:09:51 +02:00
Marco Jantke 703c4a9c6f add label value validation to NewConstMetric and friends 2017-08-20 00:09:51 +02:00
Marco Jantke 459e88167e extract and refactor label validation functions
so that we can reuse them in other parts of the code, not only as part
of a metricVec.
2017-08-20 00:09:50 +02:00
Marco Jantke 957bba6f68 add label value validation to GetMetricWith and friends 2017-08-19 22:55:41 +02:00
hazey.dazey f36d4a3e73 Add new default metric go_info 2017-07-23 23:36:09 +02:00
beorn7 ed379b7d99 Remove remaining references to MetricVec from doc comments
MetricVec is un-experted by now. godoc handles that correctly by
showing the methods of the embedded un-exported metricVec with the
exported type (CounterVec, SummaryVec, ...) that embeds metricVec.
2017-07-12 15:13:09 +02:00
Maxime Song 90494ea7b1 fix typo in comments
Signed-off-by: Maxime Song <me@cppdo.com>
2017-07-07 23:28:24 +08:00
Björn Rabenstein 310ce84375 Merge pull request #319 from prometheus/beorn7/vec
Unexport MetricVec
2017-06-30 16:48:34 +02:00
beorn7 e04de4bfe3 Document the use of Go1.9+ for monotonic time where applicable 2017-06-29 16:07:12 +02:00
beorn7 f66cdf0736 Un-export MetricVec
This is in preparation for "curried" metric vecs, as discussed.

And it's a good thing anyway. The exported MetricVec was from a time
when I thought people would define own Metric types and then create
Vecs of it. That has never happened.
2017-06-28 17:55:59 +02:00
beorn7 721f93fda8 Deprecate UntypedVec 2017-06-28 17:00:33 +02:00
Alexey Palazhchenko f0c4c478a2 Minor documentation fix 2017-06-28 15:40:03 +03:00
beorn7 14730c70c0 promhttp: Bite the bullet and implement all 32 possible interface combos
As it turned out, it's not that esay to guess "common" combination of
interface upgrades. So I decided to just implement all 32 possible
combination of interface upgrades. (Only 16 with Go 1.7 and earlier.)

Clearly, this calls for code generation. But right now, we still need
to find out what's the best form of the code. For later additions,
implementing code generation might be useful.

Note that newDelegator is called for each HTTP request. Thus, this
commit aims to make the upgrade selection quick. (After the type
checks, it's just directly accessing an element in a slice.)
2017-06-02 19:03:08 +02:00
Norbert Tretkowski e7e903064f Import "log", it is required for log.Fatal(... (#305)
Import "log" in the example doc comment

Package log is required for log.Fatal.
2017-05-31 15:00:54 +02:00
stuart nelson 2b3ab50dcd Add time to write header handler middleware (#304) 2017-05-29 11:42:43 +02:00
beorn7 023c31fd59 Fix handling of ConstLabels in checkLabels 2017-05-10 20:39:36 +02:00
beorn7 753a259e20 Improve promhttp tests
- Use local registry to avoid conflicts between tests.
- Expose https://github.com/prometheus/client_golang/issues/299 by
  using ConstLabels in a test.
- Improve example: Buckets and help string must be consistent, even
  if the former is not enforced as of now, but see
  https://github.com/prometheus/client_golang/issues/222
2017-05-10 19:49:36 +02:00
beorn7 4ea620c5bf Point to promhttp in deprecation notices 2017-05-09 18:54:33 +02:00
stuart nelson d300d5cf21 Instrument RoundTripper via middleware (#295)
Instrument RoundTripper via middleware
2017-05-09 18:46:09 +02:00
stuart nelson d01fd62222 new handler instrumentation (#285)
Add new HTTP handler instrumentation
2017-04-24 15:13:19 -04:00
Björn Rabenstein 08fd2e1237 Merge pull request #281 from adjust/add_gc_cpu_fraction
Adding GCCPUFraction metric to goCollector
2017-04-01 12:34:46 +02:00
Tong 6d619ff5a8 Fix typo 2017-03-22 21:29:18 +08:00
Ivan Borshukov bea9149ebb Fix typo 2017-03-07 16:11:13 +02:00
Tobias Schmidt ae77d82d88 Fix invalid Timer (gauge) example
The example method is assumed to be used as main() function. As a main()
function doesn't have any return values, the example doesn't compile and
is invalid.
2017-02-28 11:13:17 -04:00
Julius Volz 69bb387064 Fix typo 2017-02-23 10:28:41 +01:00
Francis Stephens 56cf0be13f Adding GCCPUFraction metric to goCollector 2017-02-22 17:26:08 +01:00
Tobias Schmidt 70693bc297 Document graphite bridge 2017-02-15 12:19:46 -04:00