apple / apple/swift-statsd-client
Add a small "debounce" before emitting metrics
- Dominant language
- Swift
- Stars
- 71
- Forks
- 23
- Avg merge
- 5d 4h
- Merged PRs (30d)
- 2
Description
Today when we report a metric the statsd client emits it immediately.
```swift
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.
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue identifies public increment(by:) and its client.emit(Metric(...)) call as the entry point. Read that path and determine the intended debounce behavior under concurrent counter updates; done should prevent every +1 from causing an immediate send while preserving counter reporting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- observability-sre
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100