Skip to content

Commit d571f74

Browse files
addressed review topics
1 parent 3f3a8e6 commit d571f74

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

infinite-tracing/src/minitrace_glue.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ use serde_json::json;
33
use once_cell::sync::Lazy;
44

55

6-
static EMPTY_MAP: Lazy<serde_json::Map<String, serde_json::Value>> = Lazy::new(|| serde_json::Map::with_capacity(0));
7-
8-
96
pub fn setup_minitrace(output_fn: impl std::io::Write + Send + 'static) {
107
let json_reporter = JsonReporter::new(output_fn);
118
minitrace::set_reporter(json_reporter, Config::default());
@@ -38,7 +35,7 @@ impl<WriteImpl: std::io::Write + Send + 'static> Reporter for JsonReporter<Write
3835
let mut timestamp = "<MISSING TIMESTAMP>";
3936
let mut file = "";
4037
let mut line = "";
41-
let mut structured_fields = None; // Lazy initialization to squeeze a little bit of performance
38+
let mut structured_fields = serde_json::Map::new();
4239
for (property_key, property_value) in &event.properties {
4340
match property_key.as_ref() {
4441
"timestamp" => timestamp = property_value,
@@ -47,7 +44,6 @@ impl<WriteImpl: std::io::Write + Send + 'static> Reporter for JsonReporter<Write
4744
"line" => line = property_value,
4845
_ => {
4946
structured_fields
50-
.get_or_insert_with(|| serde_json::Map::new())
5147
.insert(property_key.to_string(), json!(property_value));
5248
}
5349
}
@@ -56,7 +52,7 @@ impl<WriteImpl: std::io::Write + Send + 'static> Reporter for JsonReporter<Write
5652
"time": timestamp,
5753
"target": target,
5854
"logging.googleapis.com/sourceLocation": {"FILE": file, "LINE": line},
59-
"span": structured_fields.as_ref().unwrap_or(&*EMPTY_MAP),
55+
"span": structured_fields,
6056
"traceId": trace_id,
6157
"severity": severity,
6258
"message": message,

0 commit comments

Comments
 (0)