Commit Graph

252 Commits

Author SHA1 Message Date
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
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