mirror of https://github.com/fralalonde/dipstick
Get rid of skeptic templates for better code highlighting
This commit is contained in:
parent
bc334ded3f
commit
770b7e498d
|
@ -11,7 +11,7 @@ documentation = "https://docs.rs/dipstick"
|
|||
homepage = "https://github.com/fralalonde/dipstick"
|
||||
repository = "https://github.com/fralalonde/dipstick"
|
||||
readme = "README.md"
|
||||
keywords = ["metrics", "statsd", "graphite", "timer", "monitoring"]
|
||||
keywords = ["metrics", "statsd", "graphite", "timer", "prometheus"]
|
||||
license = "MIT/Apache-2.0"
|
||||
|
||||
[badges]
|
||||
|
|
69
HANDBOOK.md
69
HANDBOOK.md
|
@ -53,17 +53,21 @@ Usable either through the time! macro, the closure form or explicit calls to sta
|
|||
While timers internal precision are in nanoseconds, their accuracy depends on platform OS and hardware.
|
||||
Timer's default output format is milliseconds but is scalable up or down.
|
||||
|
||||
```$rust,skt-run
|
||||
let app_metrics = Stream::to_stdout().input();
|
||||
let timer = app_metrics.timer("my_timer");
|
||||
time!(timer, {/* slow code here */} );
|
||||
timer.time(|| {/* slow code here */} );
|
||||
|
||||
let start = timer.start();
|
||||
/* slow code here */
|
||||
timer.stop(start);
|
||||
|
||||
timer.interval_us(123_456);
|
||||
```rust
|
||||
extern crate dipstick;
|
||||
use dipstick::*;
|
||||
fn main() {
|
||||
let app_metrics = Stream::to_stdout().input();
|
||||
let timer = app_metrics.timer("my_timer");
|
||||
time!(timer, {/* slow code here */} );
|
||||
timer.time(|| {/* slow code here */} );
|
||||
|
||||
let start = timer.start();
|
||||
/* slow code here */
|
||||
timer.stop(start);
|
||||
|
||||
timer.interval_us(123_456);
|
||||
}
|
||||
```
|
||||
|
||||
### Level
|
||||
|
@ -84,11 +88,15 @@ Aggregated statistics may also append identifiers to the metric's name.
|
|||
Names should exclude characters that can interfere with namespaces, separator and output protocols.
|
||||
A good convention is to stick with lowercase alphanumeric identifiers of less than 12 characters.
|
||||
|
||||
```$rust,skt-run
|
||||
let app_metrics = Stream::to_stdout().input();
|
||||
let db_metrics = app_metrics.add_prefix("database");
|
||||
let _db_timer = db_metrics.timer("db_timer");
|
||||
let _db_counter = db_metrics.counter("db_counter");
|
||||
```rust
|
||||
extern crate dipstick;
|
||||
use dipstick::*;
|
||||
fn main() {
|
||||
let app_metrics = Stream::to_stdout().input();
|
||||
let db_metrics = app_metrics.add_prefix("database");
|
||||
let _db_timer = db_metrics.timer("db_timer");
|
||||
let _db_counter = db_metrics.counter("db_counter");
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
@ -112,7 +120,11 @@ Notes about labels:
|
|||
|
||||
Metric inputs are usually setup statically upon application startup.
|
||||
|
||||
```$rust,skt-run
|
||||
```rust
|
||||
#[macro_use]
|
||||
extern crate dipstick;
|
||||
use dipstick::*;
|
||||
|
||||
metrics!("my_app" => {
|
||||
COUNTER_A: Counter = "counter_a";
|
||||
});
|
||||
|
@ -130,10 +142,14 @@ The static metric definition macro is just `lazy_static!` wrapper.
|
|||
If necessary, metrics can also be defined "dynamically".
|
||||
This is more flexible but has a higher runtime cost, which may be alleviated with the optional caching mechanism.
|
||||
|
||||
```$rust,skt-run
|
||||
let user_name = "john_day";
|
||||
let app_metrics = Log::to_log().cached(512).input();
|
||||
app_metrics.gauge(&format!("gauge_for_user_{}", user_name)).value(44);
|
||||
```rust
|
||||
extern crate dipstick;
|
||||
use dipstick::*;
|
||||
fn main() {
|
||||
let user_name = "john_day";
|
||||
let app_metrics = Log::to_log().cached(512).input();
|
||||
app_metrics.gauge(&format!("gauge_for_user_{}", user_name)).value(44);
|
||||
}
|
||||
```
|
||||
|
||||
Alternatively, you may use `Labels` to output context-dependent metrics.
|
||||
|
@ -186,11 +202,16 @@ If enabled, buffering is usually a best-effort affair, to safely limit the amoun
|
|||
Some outputs such as statsd also have the ability to sample metrics.
|
||||
If enabled, sampling is done using pcg32, a fast random algorithm with reasonable entropy.
|
||||
|
||||
```$rust,skt-run,no_run
|
||||
let _app_metrics = Statsd::send_to("server:8125")?.sampled(Sampling::Random(0.01)).input();
|
||||
```rust
|
||||
extern crate dipstick;
|
||||
use dipstick::*;
|
||||
fn main() {
|
||||
let _app_metrics = Statsd::send_to("localhost:8125").expect("connected")
|
||||
.sampled(Sampling::Random(0.01))
|
||||
.input();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Intermediates
|
||||
|
||||
### Proxy
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
Templates
|
||||
|
||||
Use `cargo test --features="skeptic"` to run the examples in the README using the `skeptic` crate.
|
||||
|
||||
```rust,skt-run
|
||||
#[macro_use]
|
||||
extern crate dipstick;
|
||||
use dipstick::*;
|
||||
fn main() -> Result<()> {{
|
||||
{}
|
||||
Ok(())
|
||||
}}
|
||||
```
|
||||
|
||||
```rust,skt-plain
|
||||
{}
|
||||
```
|
25
README.md
25
README.md
|
@ -44,24 +44,33 @@ These are all best done by downstream timeseries visualization and monitoring to
|
|||
|
||||
Here's a basic aggregating & auto-publish counter metric:
|
||||
|
||||
```$rust,skt-run
|
||||
let bucket = AtomicBucket::new();
|
||||
bucket.set_drain(Stream::to_stdout());
|
||||
bucket.flush_every(std::time::Duration::from_secs(3));
|
||||
let counter = bucket.counter("counter_a");
|
||||
counter.count(8);
|
||||
```rust
|
||||
extern crate dipstick;
|
||||
use dipstick::*;
|
||||
|
||||
fn main() {
|
||||
let bucket = AtomicBucket::new();
|
||||
bucket.set_drain(Stream::to_stdout());
|
||||
bucket.flush_every(std::time::Duration::from_secs(3));
|
||||
let counter = bucket.counter("counter_a");
|
||||
counter.count(8);
|
||||
}
|
||||
```
|
||||
|
||||
Persistent apps wanting to declare static metrics will prefer using the `metrics!` macro:
|
||||
|
||||
```$rust,skt-run
|
||||
```rust
|
||||
#[macro_use]
|
||||
extern crate dipstick;
|
||||
use dipstick::*;
|
||||
|
||||
metrics! { METRICS = "my_app" => {
|
||||
pub COUNTER: Counter = "my_counter";
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
METRICS.set_target(Graphite::send_to("localhost:2003").unwrap().input());
|
||||
METRICS.set_target(Graphite::send_to("localhost:2003").expect("connected").input());
|
||||
COUNTER.count(32);
|
||||
}
|
||||
```
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
Templates
|
||||
|
||||
Use `cargo test --features="skeptic"` to run the examples in the README using the `skeptic` crate.
|
||||
|
||||
```rust,skt-run
|
||||
#[macro_use]
|
||||
extern crate dipstick;
|
||||
use dipstick::*;
|
||||
fn main() -> std::result::Result<(), Box<std::error::Error>> {{
|
||||
{}
|
||||
Ok(())
|
||||
}}
|
||||
```
|
||||
|
||||
```rust,skt-plain
|
||||
{}
|
||||
```
|
Loading…
Reference in New Issue