Commit Graph

73 Commits

Author SHA1 Message Date
beorn7 b1e7299877 Turned "le" and "quantile" label names into constants. 2015-02-19 15:54:26 +01:00
beorn7 3e50eddd64 Do not count the +Inf bucket for bucket creation.
Add explanation for DefBuckets.
2015-02-19 15:54:26 +01:00
beorn7 4c4f51d546 Catch illegal label names for summaries in histograms. 2015-02-19 15:54:26 +01:00
beorn7 6958242277 Add support for histograms to the Go client library. 2015-02-19 15:54:26 +01:00
beorn7 a7c56882af Mark slow test as such and exclude them from travis. 2015-02-19 15:51:11 +01:00
Julius Volz 765fdaf37e Update protobuf library package name.
The Golang protocol buffer library has now moved to GitHub:

https://github.com/golang/protobuf

Although "go get"-ing the old package name still works, moving
everything to the new one will make vendoring cleaner.

See also https://github.com/matttproud/golang_protobuf_extensions/pull/7
2015-02-14 00:00:34 +01:00
Deyuan Deng 550b950411 Fix document 2015-02-11 17:35:04 -05:00
Tobias Schmidt 98061eecab Add todo comment to bring back error reporting 2015-02-11 14:58:35 -05:00
Tobias Schmidt 7faf9e76ef Handle process collector errors gracefully
As it is expected that the process collector can fail under certain
conditions (proc information for a process only readable by root or
other user for example) and as there is currently no option to configure
the error behavior of the client, this change reverts the error
reporting introduced in 159e96f. This effectively means that errors are
simply ignored and there won't be any samples for the process_* metrics
in case of an error.

Once a user can control how to behave in case of errors returned by
collectors, this change should probably be reverted.
2015-02-10 16:19:27 -05:00
Johannes 'fish' Ziemke 93d11c8e35 Remove procfs dependency unless cgo is enabled 2015-02-09 16:38:04 +01:00
Tobias Schmidt d1d9dee31b Remove dependency on procfs/cgo in non-procfs systems
The procfs package has a cgo dependency (necessary to calculate system
times). As procfs is not available under windows, darwin and supposely
all newer BSD systems, this change remove the procfs dependency on these
systems.
2015-02-02 15:40:04 -05:00
Tobias Schmidt 3cb16a9503 Use clear error interface for process pidFn
If a given pidFn for a process collector can't determine the pid, this
had to be signaled with an invalid pid so far (pid <= 0). In order to
make the error interface clearer for users, this change introduces an
explicit error parameter.
2015-02-02 14:59:24 -05:00
beorn7 4f73a8b017 Improve Gauge and Counter performance.
This is accomplished by using the functions from the atomic packages
instead of a mutex.

benchmark                                      old ns/op     new ns/op     delta
BenchmarkGaugeNoLabels-2                       118           9.40          -92.03%
BenchmarkGaugeNoLabels                         117           9.38          -91.98%
BenchmarkGaugeNoLabels-4                       117           9.40          -91.97%
BenchmarkCounterNoLabels-2                     137           16.8          -87.74%
BenchmarkCounterNoLabels                       136           16.8          -87.65%
BenchmarkCounterNoLabels-4                     136           16.8          -87.65%
BenchmarkGaugeWithLabelValues-4                400           279           -30.25%
BenchmarkGaugeWithLabelValues-2                398           279           -29.90%
BenchmarkGaugeWithLabelValues                  400           283           -29.25%
BenchmarkCounterWithLabelValues-4              397           286           -27.96%
BenchmarkCounterWithLabelValues-2              396           286           -27.78%
BenchmarkCounterWithLabelValues                394           285           -27.66%
BenchmarkCounterWithPreparedMappedLabels       587           454           -22.66%
BenchmarkCounterWithPreparedMappedLabels-2     581           456           -21.51%
BenchmarkCounterWithPreparedMappedLabels-4     654           539           -17.58%
BenchmarkCounterWithMappedLabels-2             1441          1218          -15.48%
BenchmarkCounterWithMappedLabels               1099          963           -12.37%
BenchmarkCounterWithMappedLabels-4             1636          1501          -8.25%
2015-02-02 18:11:11 +01:00
Bjoern Rabenstein d7f8eb1083 Change "Prometheus Team" to "The Prometheus Authors". 2015-02-02 15:14:36 +01:00
Julius Volz f3e101bd1c Fix race condition in writePB().
The RLock already needs to be acquired when reading r.dimHashesByName.

This fixes https://github.com/prometheus/client_golang/issues/61
2015-01-31 22:10:27 +01:00
Bjoern Rabenstein 3798bbca12 Add const labels to counter. 2015-01-28 15:47:48 +01:00
juliusv 3713bd7d97 Merge pull request #48 from prometheus/beorn7/fix-summary-dimensions
Beorn7/fix summary dimensions
2015-01-22 17:03:39 +01:00
Bjoern Rabenstein 31b6c1fe12 Make number notation consistent. 2015-01-21 15:24:34 +01:00
Bjoern Rabenstein 15c9ded5a3 Fix the summary decay by avoiding the Merge method.
This makes the Observe method of summaries more expensive. :-(
2015-01-21 13:44:43 +01:00
Bjoern Rabenstein 6b9530d72e Update vendoring of perks to newest (fixed) version.
Adjust the API and usage accordingly.
Make tests stricter.

Since the merging is still faulty, test are broken now.
The next commit will fix it by avoiding merging.
2015-01-20 18:27:10 +01:00
Bjoern Rabenstein 26e2417d3e Quick-fix the doc comment. 2015-01-13 17:26:38 +01:00
Bjoern Rabenstein 5c6a472617 Merge branch 'beorn7/allow-collect-errors' into beorn7/fix-summary-dimensions 2015-01-13 16:54:12 +01:00
Bjoern Rabenstein dd4e57186a Improve doc comment for Describe. 2015-01-13 16:52:42 +01:00
Bjoern Rabenstein 05059724f8 Remove the partition of summaries by HTTP status code and method.
Summaries as implemented cannot be aggregated in a meaningful
way. Partitoning them by status code and method only made sense if we
were interested in the individual latency and size of e.g. GET request
that result in status 503. In general, that's not the case. Most of
the time, the user will be interested in the latency and size of _all_
HTTP requests.

(With future changes to client_golang, we will consider making the
HTTP instrumentation configurable, e.g. to handle the case where the
user is only interested in the latency of successful requests.)
2015-01-13 14:57:37 +01:00
Bjoern Rabenstein 159e96f6c7 Allow error reporting during metrics collection and simplify Register().
Both are interface changes I want to get in before public
announcement. They only break rare usage cases, and are always easy to
fix, but still we want to avoid breaking changes after a wider
announcement of the project.

The change of Register() simply removes the return of the Collector,
which nobody was using in practice. It was just bloating the call
syntax. Note that this is different from RegisterOrGet(), which is
used at various occasions where you want to register something that
might or might not be registered already, but if it is, you want the
previously registered Collector back (because that's the relevant
one).

WRT error reporting: I first tried the obvious way of letting the
Collector methods Describe() and Collect() return error. However, I
had to conclude that that bloated _many_ calls and their handling in
very obnoxious ways. On the other hand, the case where you actually
want to report errors during registration or collection is very
rare. Hence, this approach has the wrong trade-off. The approach taken
here might at first appear clunky but is in practice quite handy,
mostly because there is almost no change for the "normal" case of "no
special error handling", but also because it plays well with the way
descriptors and metrics are handled (via channels).

Explaining the approach in more detail:

- During registration / describe: Error handling was actually already
  in place (for invalid descriptors, which carry an error anyway). I
  only added a convenience function to create an invalid descriptor
  with a given error on purpose.

- Metrics are now treated in a similar way. The Write method returns
  an error now (the only change in interface). An "invalid metric" is
  provided that can be sent via the channel to signal that that metric
  could not be collected. It alse transports an error.

NON-GOALS OF THIS COMMIT:

This is NOT yet the major improvement of the whole registry part,
where we want a public Registry interface and plenty of modular
configurations (for error handling, various auto-metrics, http
instrumentation, testing, ...). However, we can do that whole thing
without breaking existing interfaces. For now (which is a significant
issue) any error during collection will either cause a 500 HTTP
response or a panic (depending on registry config). Later, we
definitely want to have a possibility to skip (and only report
somehow) non-collectible metrics instead of aborting the whole scrape.
2015-01-12 19:16:09 +01:00
Jeff Younker 014d4bd173 Remove a Go 1.4ism to allow compilation under Go 1.3. 2015-01-09 14:52:23 +01:00
Tobias Schmidt d66557ae59 Register process and go collectors by default 2014-12-22 13:55:44 -05:00
Tobias Schmidt dbd48d666b Add ProcessCollector and GoCollector
This change adds two new collectors to the prometheus package which
export metrics about a given or the current process.

* ProcessCollector exports metrics about cpu time, vss, rss, fd usage as
  well as the start time of a given process.
* GoCollector exports currently only the number of active goroutines.
2014-12-22 13:49:45 -05:00
Julius Volz 7fcb2c594a Drain collector channel when returning prematurely. 2014-12-19 14:18:55 +01:00
Bjoern Rabenstein 4c69ef579b Disable the timing-sensitive test TestSummaryDecay for now.
Obviously, the proper solution is to implement the test in a way that
does not depend on timing.
2014-12-18 18:05:06 +01:00
Bjoern Rabenstein f4be228ba0 Fix a race condition in the http instrumentation.
computeApproximateRequestSize is run in a goroutine, but the
handlerFunc that runs in parallel may modify the URL, which is also
needed by computeApproximateRequestSize. So get the URL length
beforehand.

Change-Id: Idb84735845afe7be4ef79b3d642d5764f6d26a7c
2014-10-08 19:01:24 +02:00
Bjoern Rabenstein 6fbc8ef5c2 Fix typo in doc comment.
Change-Id: Ifa40feb83e89b60b8e3efea298264d91f3758ecb
2014-09-19 13:20:59 +02:00
Bjoern Rabenstein b09d588309 Add missing error check.
Change-Id: I6fcf6d5d50333ff0c205fd87cdb9430f1bc02c43
2014-07-30 19:02:39 +02:00
Bjoern Rabenstein 96297bcbae Add a configurable version of InstrumentHandler and InstrumentHandlerFunc.
Also, remove quotes from the Content-type header. It's not illegal to
have quotes there, but they are not needed, and at other places, we
are not using them. So fewer characters and more consistency.

Change-Id: If7a78bde85154163e4426daec493d973213e83e9
2014-07-22 17:40:20 +02:00
Bjoern Rabenstein 23e5e5fefd Add gzip support.
Change-Id: I6ea6e0dcbe7234ad143403d262da6cb40e7d3b50
2014-07-04 17:08:57 +02:00
Bjoern Rabenstein 5ac9f00fa9 Add Content-Length header.
Since we prepare the whole content in a buf before sending, we can as
well set the Content-Length explicitly.

Change-Id: Ifd91764c90af53be49f93f0b33032138130b6f96
2014-07-03 13:12:39 +02:00
Bjoern Rabenstein 0afe1a813e Add pushgateway support.
Change-Id: I4730b150ac84ae38939b16effaf4b2ad4afa5bc0
2014-07-03 13:12:39 +02:00
Bjoern Rabenstein 998774096c Make the collectorID independent of the desc order.
This is actually the intended behavior, and (as a nice side effect)
makes things cheaper to calculate.

Also, introduce a separator character to avoid hash collisions
(like label values {"ab","c"} vs {"a", "bc"}).

Apply the same principles to signature.go.

Change-Id: I607db544f278ed89684fe5fa11abdbc3e03d3061
2014-06-26 15:50:11 +02:00
Bjoern Rabenstein 010dc1af88 Vendorize perks/quantile.
Change-Id: I2b24bddf5a975a46ceb598db328c317982154466
2014-06-23 19:48:50 +02:00
Bjoern Rabenstein f9401ffab9 Added "callback" metrics, e.g. GaugeFunc.
Change-Id: I449b558207963ce60572bd04c8102f1db684dd4c
2014-06-23 14:35:01 +02:00
Bjoern Rabenstein 5122dc6cc0 Fix doc comment typo.
Change-Id: I19b4b553b01823da0c1015d779f1f05b2c2cfb5b
2014-06-23 11:45:49 +02:00
Bjoern Rabenstein 8234d12ed0 Add InstrumentHandlerFunc.
Also, fix seconds to microseconds fot the http instrumentation to
match the metric name.

Fix Desc.String().

Simplify http error display.

Change-Id: Ib7397f4eac1eeed92b291e1c9cc88c080aee99ca
2014-06-20 20:57:27 +02:00
Bjoern Rabenstein 5d40912fd2 Complete rewrite of the exposition library.
This rewrite had may backs and forths. In my git repository, it
consists of 35 commits which I cannot group or merge into reasonable
review buckets. Gerrit breaks fundamental git semantics, so I have to
squash the 35 commits into one for the review.

I'll push this not with refs/for/master, but with refs/for/next so
that we can transition after submission in a controlled fashion.

For the review, I recommend to start with looking at godoc and in
particular the many examples. After that, continue with a line-by-line
detailed review. (The big picture is hopefully as expected after
wrapping up the discussion earlier.)

Change-Id: Ib38cc46493a5139ca29d84020650929d94cac850
2014-06-17 14:08:22 +02:00
Bjoern Rabenstein 3dfae09d30 Fix things commented on in past code review.
Change-Id: I4dafd098eefa99bc37fdbfebeb4c61a7251ad0be
2014-04-29 13:37:49 +02:00
Bjoern Rabenstein 84dc53148d Enable the Golang client library to create the new text formats.
Most important here is the simple & flat text format, but while I'm on
it, I have also added the text representations for protobufs (which is
purely meant for debugging purposes). I hope my basic idea about
handling those various protocols (and the text package) becomes
clearer now.

Change-Id: I7299853eadc82a426101e907f2b3d4e37f9e4c71
2014-04-25 21:45:04 +02:00
Bjoern Rabenstein 9da2fbcce3 Eliminate a number of style-guide violations.
Change-Id: Iedcd611e5c7ad24c84c004d8d6c551d1734e443c
2014-04-25 21:18:04 +02:00
Bjoern Rabenstein 00816363e4 Remove the one duplication of the Tester interface.
Change-Id: Ie17ec3393a7e12e0f27e51b4060aa478a172f612
2014-04-25 20:51:08 +02:00
Bjoern Rabenstein e5dc0421cd Move signature.go and related tests to the model package.
The LabelsToSignature function is now used outside of the prometheus
package, too. Leaving it in the prometheuos package is misleading
design and will lead to circulat import chains soon.

Change-Id: If1ca442d4023b33b138cf79fee68e82ff2a355be
2014-04-25 20:48:16 +02:00
Bjoern Rabenstein 46fc7a3748 Support the new protobuf fields.
- Full support for UNTYPED type.

- Receptive support for timestamp_ms (i.e. the processor can process
  it, but the client library cannot yet create it - which is kind of
  intended as timestamps are meant for other things like federation,
  which will need separate support anyway).

Change-Id: I5913164a80089943d49ad58bf86e465a843ab82b
2014-04-22 15:11:34 +02:00
Bjoern Rabenstein ecac33bed0 Conversion back and forth between MetricFamily protobuf and text format.
The idea here is to always go via the protobufs if dealing with the
text format. That won't always be the most efficient way, but it
avoids the multiplicity of conversion routines required for direct
conversion (e.g. text format -> internal representation in the
Prometheus server). The loss of efficiency is acceptable because the
text format should not be used in high performance (high throughput,
low latency) situations anyway.

In that way, the text format stays perfectly isolated from other parts
of the code. To receive text format, just plug the conversion in
before the code path that normally reads protobufs. Correspondingly,
for sending text format, simply replace the WriteDelimited call by a
text.Create call.

Nevertheless, the conversion code itself is optimized for efficiency
and minimized memory churn (which was one of the reason for handcoding
the parser and not using a lexer/parser code generation tool).

Change-Id: Iee45ffe8aa421a844225d13a1f859becd8a3b066
2014-04-17 16:28:13 +02:00