Skip to content

Commit

Permalink
Change Timestamp type to f64 to support nano sec granuality
Browse files Browse the repository at this point in the history
  • Loading branch information
ileixe committed Feb 9, 2022
1 parent e08c2af commit 282125c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tracing-chrometrace"
version = "0.1.3"
version = "0.1.4"
edition = "2018"

authors = ["Youseok Yang <ileixe@gmail.com>"]
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ struct EventDescription {
name: String,
cat: String,
ph: EventType,
ts: u128,
ts: f64,
#[serde(skip_serializing_if = "Option::is_none")]
dur: Option<u128>,
dur: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
tts: Option<u64>,
tts: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
id: Option<String>,
pid: u64,
Expand All @@ -110,7 +110,7 @@ impl EventDescription {

let ts = fields
.remove("ts")
.map_or(start.elapsed().as_micros(), |x| {
.map_or(start.elapsed().as_nanos() as f64 / 1000., |x| {
x.trim_matches('"').parse().unwrap()
});

Expand Down Expand Up @@ -242,7 +242,7 @@ where

let mut extensions = span.extensions_mut();

if let Some(started) = extensions.get_mut::<bool>() {
if extensions.get_mut::<bool>().is_some() {
// If recoding of the span is already started (async case), skip it
return;
} else {
Expand All @@ -267,7 +267,7 @@ where
};
}

fn on_exit(&self, id: &span::Id, ctx: Context<'_, S>) {}
fn on_exit(&self, _id: &span::Id, _ctx: Context<'_, S>) {}

fn on_close(&self, id: span::Id, ctx: Context<'_, S>) {
let span = ctx.span(&id).expect("Span not found, this is a bug");
Expand Down

0 comments on commit 282125c

Please sign in to comment.