Skip to content

Commit dac7c39

Browse files
committed
feat: add timestamp in pipe mode #23
1 parent 03a5df5 commit dac7c39

File tree

3 files changed

+156
-0
lines changed

3 files changed

+156
-0
lines changed

Cargo.lock

Lines changed: 151 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ strip = false
1414
lto = false
1515

1616
[dependencies]
17+
chrono = "0.4.39"
1718
clap = { version = "4.5.30", features = ["derive"] }
1819
core-foundation = "0.10.0"
1920
libc = "0.2.170"

src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ fn main() -> Result<(), Box<dyn Error>> {
4646

4747
loop {
4848
let doc = sampler.get_metrics(args.interval.max(100))?;
49+
50+
let mut doc = serde_json::to_value(&doc)?;
51+
doc["timestamp"] = serde_json::to_value(chrono::Utc::now().to_rfc3339())?;
4952
let doc = serde_json::to_string(&doc)?;
53+
5054
println!("{}", doc);
5155

5256
counter += 1;

0 commit comments

Comments
 (0)