Commit graph

102 commits

Author SHA1 Message Date
bakins
e60f77df30 Move escapeMetricName to mapper
Signed-off-by: bakins <brian@akins.org>
2020-01-16 11:20:37 -05:00
Matthias Rampke
53f732d480
Log error and exit instead of panicking
Following the lead of prometheus/prometheus, we prefer to log-and-exit
instead of an unstructured panic.

cf. https://github.com/prometheus/prometheus/pull/3061/files#diff-4a3ccbb3ebdcd530af96f0105fe833c2R182

Signed-off-by: Matthias Rampke <mr@soundcloud.com>
2020-01-10 14:02:59 +00:00
mhartenbower
5f4f780e16 Add noplogger to tests
Signed-off-by: mhartenbower <matt.hartenbower@gmail.com>
2019-10-13 16:44:16 -05:00
mhartenbower
c710b851c7 Switch to go-kit logging
Fixes #270

Signed-off-by: mhartenbower <matt.hartenbower@gmail.com>
2019-10-13 13:19:28 -05:00
Tony Wooster
df740e7778 Minor fixups
Signed-off-by: Tony Wooster <twooster@gmail.com>
2019-09-19 18:31:10 +02:00
Tony Wooster
a4b92689bc DRY up tag-parsing code
Signed-off-by: Tony Wooster <twooster@gmail.com>
2019-09-18 15:33:23 +02:00
Tony Wooster
0e000fe833 Drop metrics with mixed tagging styles
Signed-off-by: Tony Wooster <twooster@gmail.com>
2019-09-18 15:33:23 +02:00
Tony Wooster
e01507a57c Remove "Librato" from tag error messages
Signed-off-by: Tony Wooster <twooster@gmail.com>
2019-09-17 17:35:57 +02:00
Tony Wooster
5537c504cc Add support for InfluxDB style tagging
Signed-off-by: Tony Wooster <twooster@gmail.com>
2019-09-17 17:01:34 +02:00
Tony Wooster
2933dd8ad0 Add support for Librato-style tags
Signed-off-by: Tony Wooster <twooster@gmail.com>
2019-09-14 17:14:03 +02:00
Amit Saha
1bddef857d Add test
Signed-off-by: Amit Saha <amitsaha.in@gmail.com>
2019-09-13 14:27:48 +10:00
Amit Saha
028531e953 Fix for issue #250
Signed-off-by: Amit Saha <amitsaha.in@gmail.com>
2019-09-09 17:25:19 +10:00
Clayton O'Neill
c7e76967c8
Add internal event queuing and flushing
At high traffic levels, the locking around sending on channels can cause
a large amount of blocking and CPU usage.  These adds an event queue
mechanism so that events are queued for short period of time, and
flushed in batches to the main exporter goroutine periodically.

The default is is to flush every 1000 events, or every 200ms, whichever
happens first.

Signed-off-by: Clayton O'Neill <claytono@github.com>
2019-06-04 06:57:48 -04:00
Clayton O'Neill
f6c0dd965b
Remove dead code
This removes all the code that the new registry code replaces.

Signed-off-by: Clayton O'Neill <claytono@github.com>
2019-05-31 08:38:16 -04:00
Clayton O'Neill
7c30120dbc
Rework metric registration and tracking
This reworks/rewrites the way that metric registration and tracking is
handled across all of statsd_exporter.  The goal here is to reduce
memory and cpu usage, but also to reduce complexity by unifying metric
registration with the ttl tracking for expiration.

Some high level notes:

* Previously metric names and labels were being hashed three times for
every event accepted: in the container code, the save label set code and
again in the prometheus client libraries.  This unifies the first two
and caches the results of `GetMetricWith` to avoid the third.

* This optimizes the label hashing to reduce cpu overhead and memory
allocations.  The label hashing code previously showed up high on all
profiling done for both CPU and memory allocations

Using the BenchmarkExporterListener benchmark, the improvement looks
like this.

Before:
cpu: 11,341,797 ns/op
memory allocated: 1,731,119 B/op
memory allocations: 58,028 allocs/op

After:
cpu: 7,084,651 ns/op
memory allocated: 906,556 B/op
memory allocations: 42,026 allocs/op

Signed-off-by: Clayton O'Neill <claytono@github.com>
2019-05-31 08:38:15 -04:00
Tony Nyurkin
7d6244987a Fix inconsistent label cardinality error
Signed-off-by: Tony Nyurkin <ptqa@users.noreply.github.com>
2019-05-24 14:26:17 +03:00
Matthias Rampke
26e9d482db
Revert "Reduce memory allocations in handlePacket" 2019-05-20 08:20:19 +00:00
Matthias Rampke
c9004f8f3f
Merge pull request #219 from claytono/optimize-label-handling
Optimize label sorting
2019-05-17 13:47:03 +00:00
Matthias Rampke
4e64da2a41
Merge pull request #218 from claytono/handlepacket-optimization
Reduce memory allocations in handlePacket
2019-05-17 13:38:56 +00:00
Clayton O'Neill
d143398343
Optimize label sorting
Previously we were sorting labels in every container to build a map key,
but also when generating the hash key by calling the `LabelsToSignature`
method.  This moves the sorting to be done early in the event processing
then passes the sorted label array around.

Signed-off-by: Clayton O'Neill <claytono@github.com>
2019-05-16 17:17:09 -04:00
Clayton O'Neill
4cf6f74dc3
Reduce memory allocations in handlePacket
This converts the byte buffer to a string by casting and parses the
string by looping over it instead of calling Split.

This usage of unsafe is taken from the strings.Builder package here:
cb5c82bc3d/src/strings/builder.go (L47)

Signed-off-by: Clayton O'Neill <claytono@github.com>
2019-05-16 16:35:32 -04:00
Clayton O'Neill
98da6f7057
Convert escapeMetricName to use strings.Builder
This converts escapeMetricName to use strings.Builder instead of
allocating a byte array, filling it and then converting it to a string.
This also optimizes for the case where the metricName is already valid,
and in that case, it just returns the original string.

This reduces memory allocations from 2 per call to 1 per call in the
case when the string does need to be escaped, and reduces it to zero
memory allocations when the string is already valid.

Signed-off-by: Clayton O'Neill <claytono@github.com>
2019-05-16 09:28:35 -04:00
Clayton O'Neill
cce95f6980
Check for histogram conflict on main name
While it doesn't report it as a metric, when collecting, the registry
considers the base metric name to below to the histogram that's
registered.  This means that we need to prevent other metrics from
registering anything under this name, in addition to checking for the
bucket, sum and count suffixes.

Signed-off-by: Clayton O'Neill <claytono@github.com>
2019-05-15 09:04:19 -04:00
Clayton O'Neill
9f1c6b81a5
Add checking for conflicting metrics
This adds sanity checking before registering a metric to ensure that the
metric isn't already registered under an existing name.  This prevents
the exporter from getting into a state where it has accepted and
registered conflicting metrics, and then cannot report the metrics it
has collected.

Signed-off-by: Clayton O'Neill <claytono@github.com>
2019-05-14 18:33:49 -04:00
Matthias Rampke
bee73cbb9e
Merge pull request #211 from claytono/add-distributions
Add support for Datadog distribution type
2019-05-14 16:23:07 +00:00
Matthias Rampke
d7eb1edeed
Merge pull request #210 from claytono/tag-parsing-optimizations
Tag parsing optimizations
2019-05-14 16:18:37 +00:00
Vitaliy Sakhartchouk
cddeb87405 Add default quantiles for summaries if no mapping file exists
Signed-off-by: Vitaliy Sakhartchouk <vsakhart@github.com>
2019-05-13 17:14:42 -07:00
Clayton O'Neill
04bba78d61
Add support for Datadog distribution type
This adds the ability to accept Datadog's distribution type and treat it
like a histogram/summary.

Signed-off-by: Clayton O'Neill <claytono@github.com>
2019-05-13 14:59:21 -04:00
Clayton O'Neill
a4faae262b
Replace Split with special purpose implementation
This improves performance from 3169ns/op to 2836 ns/op and drops one
allocation per op.

Signed-off-by: Clayton O'Neill <claytono@github.com>
2019-05-13 13:32:25 -04:00
Clayton O'Neill
e3cdd85a09
Extract individual tag parsing into new function
Signed-off-by: Clayton O'Neill <claytono@github.com>
2019-05-13 12:46:50 -04:00
Clayton O'Neill
a441eac07a
Replace SplitN w/special purpose implementation
This improves performance per call in the a-z case from around 5533
ns/op to 3169ns/op.  It also drops allocations per call from 57 to 31
in the a-z case.

Signed-off-by: Clayton O'Neill <claytono@github.com>
2019-05-13 12:46:50 -04:00
Clayton O'Neill
052beaa3ac
Replace TrimPrefix w/special purpose implementation
On the a-z benchmark, this brings the ns/op down from 5658 to 5533.

Signed-off-by: Clayton O'Neill <claytono@github.com>
2019-05-13 12:46:50 -04:00
Matthias Rampke
e3d6050616
Merge pull request #199 from Kong/feat/unixgram-socket
Implement listener for Unixgram sockets
2019-04-23 08:44:11 +00:00
Wangchong Zhou
383ee9bd3b
Add a signal handler to allow clean up of unixgram socket file
Signed-off-by: Wangchong Zhou <fffonion@gmail.com>
2019-04-22 16:33:22 -07:00
Brian Akins
45402964a4 use label for metric type and decrement
Signed-off-by: Brian Akins <brian@akins.org>
2019-04-15 08:16:00 -04:00
Brian Akins
92957ce080 Add metric to track unique metric names the exporter is tracking
Signed-off-by: Brian Akins <brian@akins.org>
2019-04-10 12:23:07 -04:00
Matthias Rampke
ece9385f22
Merge pull request #197 from bakins/escapeMetricName-performance
Increase escapeMetricName performance
2019-04-10 08:47:49 +00:00
Brian Akins
cfcf3c9ba5 Add comments explaining escapeMetricName
Signed-off-by: Brian Akins <brian@akins.org>
2019-04-09 14:10:26 -04:00
Brian Akins
e6bdf13407 Add comments explaining escapeMetricName
Signed-off-by: Brian Akins <brian@akins.org>
2019-04-09 11:58:18 -04:00
Brian Akins
d371436f01 Replace regex in escapeMetricName with loop over runes
Signed-off-by: Brian Akins <brian@akins.org>
2019-04-09 11:58:18 -04:00
Matthias Rampke
178d130388
Merge pull request #193 from bakins/statsd_exporter_events_total
Add metric for count of events by action
2019-04-09 12:13:17 +00:00
Wangchong Zhou
05bca84294
Implement listener for Unixgram sockets
As requested in #189

Signed-off-by: Wangchong Zhou <fffonion@gmail.com>
2019-04-05 16:45:34 -07:00
Brian Akins
1cbc5a9b27 Add metric for count of events by action
Signed-off-by: Brian Akins <brian@akins.org>
2019-04-02 15:20:50 -04:00
Vitaliy Sakhartchouk
2fc89536f4 Break out mapkey generation into function
Signed-off-by: Vitaliy Sakhartchouk <vsakhart@github.com>
2019-03-29 13:25:46 -07:00
Vitaliy Sakhartchouk
2025b47cb1 Allow support for inconsistent label sets by marking metrics
registered as unchecked collectors

Signed-off-by: Vitaliy Sakhartchouk <vsakhart@github.com>
2019-03-29 13:18:31 -07:00
Ivan Izaguirre
c9e5e94ed2 Adds a separate counter for events discarded due to errors
Signed-off-by: Ivan Izaguirre <ivanizag@gmail.com>
2019-03-26 00:44:17 +01:00
Ivan Izaguirre
1c71191aaf Fixes #191: crash on empty metric name
Signed-off-by: Ivan Izaguirre <ivanizag@gmail.com>
2019-03-23 19:38:27 +01:00
SpencerMalone
c73a7b2c9a Scale summaries from milliseconds to seconds.
Fixes #177

Updating exporter tests for new summary unit scaling behavior

Signed-off-by: Spencer Malone <malone.spencer@gmail.com>
2019-01-09 12:37:38 -05:00
Simon Pasquier
8f56cc811d *: add staticcheck target back
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2019-01-04 15:26:57 +01:00
Ivan Mikheykin
699c11ca11 Rework tests to not depend on actual wall clocks
Signed-off-by: Ivan Mikheykin <ivan.mikheykin@flant.com>
2018-12-19 08:24:25 +03:00