Skip to content

Add a small "debounce" before emitting metrics #25

@ktoso

Description

@ktoso

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/enhancementImprovements to existing feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions