Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a small "debounce" before emitting metrics #25

Open
ktoso opened this issue Oct 7, 2020 · 0 comments
Open

Add a small "debounce" before emitting metrics #25

ktoso opened this issue Oct 7, 2020 · 0 comments
Labels
kind/enhancement Improvements to existing feature.

Comments

@ktoso
Copy link
Member

ktoso commented Oct 7, 2020

Today when we report a metric the statsd client emits it immediately.

    public func increment(by amount: Int64) {
        self._increment(by: amount)
        // https://github.com/b/statsd_spec#counters
        // A counter is a gauge calculated at the server. Metrics sent by the client increment or decrement the value of the gauge rather than giving its current value.
        // Counters may also have an associated sample rate, given as a decimal of the number of samples per event count. For example, a sample rate of 1/10 would be exported as 0.1.
        // Valid counter values are in the range (-2^63^, 2^63^).
        _ = self.client.emit(Metric(name: self.id, value: amount, type: .counter))
    }

This can be overwhelmed easily when we hit counters from many many threads constantly, as each +1 will cause a metric send.

It may be better to debounce a metric a little bit before emitting it.

@ktoso ktoso added the kind/enhancement Improvements to existing feature. label Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements to existing feature.
Projects
None yet
Development

No branches or pull requests

1 participant