Comments (3)
Thank you for the write up! I don't use statsd myself these days so this will likely need to be implemented by the community.
Some notes on the potential implementation.
- I would prefer that sampling was enabled or disabled at the client level, not individual methods. This way, there are no changes required to the Cadence API besides an extra method on the
StatsdClientBuilder
-.sample_rate(f64)
or similar. - I'm not sure which types of metrics should be sampled: Just counters? Counters and timers? Feedback welcome here!
- Code that implements sampling shouldn't slow down anything if not enabled.
- If an RNG is used (kinda seems like it has to be), it should be possible to seed it in order to make tests easier to write and reason about.
- Sampling should probably be behind a feature flag since it will introduce a dependency on the
rand
crate but I don't feel strongly about this. - There should be a limit on the values used for sample rate. I don't want the sample rate included end the metric string to end up looking like
@0.100000000001
or something. Not sure how to do this without truncating the float alaprintln!("{:.2}", 0.01);
. Maybe we can introduce some sort ofSampleRate
type that knows how many digits to use to display itself based on thetotal
argument below.let r = SampleRate::from(samples_per, total);
from cadence.
Thanks for the feedback! 😊
- The sample really needs to be done at the method level I think. For example, if I am counting new connections, I might sample that at
0.1
but for individual network reads / writes, I might want to sample at0.01
or even0.001
. Some things you wouldn't want to sample at all if they happen infrequently enough, or you really want the most accurate picture possible. Libraries that support this tend to have_timing
and_timing_with_sample_rate
where_timing
just calls_timing_with_sample_rate
with a rate of1.0
. - Counters and timers are the only things I've used with a sample rate. I don't think it makes sense for a Gauge.
- Generally the sampling logic is short circuited. If the sample rate is
1.0
, then it will always be sampled - there's no need to make a call torand()
or similar. - Great point, we'd definitely want to be able to seed that for testing
- I think it's fine to put it behind a feature flag, but would prefer that feature was on by default. I think most people would be okay with the
rand
crate dependency and it gives the "least surprise". Those that don't want it and know they don't, can easily turn it off by disabling the feature flag. - I'm not sure if the spec defines a max sample rate. We'd definitely want to do something akin to
format!
to make sure we get nice sane rates. I don't think it's the total sample rate that's the problem, but more how to prevent the precision issues (at least in what we send tostatsd
or display)
from cadence.
Very interested in this feature!
from cadence.
Related Issues (20)
- Make client methods generic on value type
- create migration guide
- Bump minimum Rust version due to Criterion deps
- Add f64 constructors to histograms and distributions
- Add tests for multiple types for each metric in cadence-macros
- Update all examples to have multiple types for each metric
- Datadog Event stream support HOT 1
- Create example of using conversion traits with custom type
- Add tags to all metrics HOT 5
- Instrumented allocator to verify heap allocations
- Remove client uses of Arc
- Remove MetricError description implementation
- Define parts of the API covered by semver
- Edition 2021 update
- Add support for incrementing and decrementing a gauge HOT 2
- Distribution missing tags from StatsdClientBuilder HOT 3
- Support for metrics aggregation HOT 3
- Option to observe write errors HOT 4
- Expose network-level telemetry HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cadence.