mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 09:17:30 +03:00
mononoke: do not upload traces if tracing is disabled
Summary: It has a few benefits. Firstly, we won't get misleading empty trace ids in the logs. Secondly, uploading traces takes a noticeable amount of time that affects the overall latency. That is especially noticeable for getfiles requests. Reviewed By: farnz Differential Revision: D8158917 fbshipit-source-id: b4fe2183d9157f4d7c52e25e4efef9a06bb1b5ac
This commit is contained in:
parent
bce740ec29
commit
dd37633300
@ -210,10 +210,18 @@ fn add_common_stats_and_send_to_scuba(
|
||||
remote: Remote,
|
||||
args: Option<String>,
|
||||
) -> BoxFuture<(), ()> {
|
||||
futures_trace::global::context()
|
||||
.upload_trace_async(remote)
|
||||
let trace_upload = if futures_trace::global::is_enabled() {
|
||||
futures_trace::global::context()
|
||||
.upload_trace_async(remote)
|
||||
.map(|id| Some(id))
|
||||
.boxify()
|
||||
} else {
|
||||
Ok(None).into_future().boxify()
|
||||
};
|
||||
|
||||
trace_upload
|
||||
.then(move |res| {
|
||||
let trace_id = res.unwrap_or_else(|_| "upload failed".into());
|
||||
let trace_id = res.unwrap_or_else(|_| Some("upload failed".into()));
|
||||
if let Some(ref scuba) = scuba {
|
||||
sample.add(
|
||||
"time_elapsed_ms",
|
||||
@ -221,7 +229,9 @@ fn add_common_stats_and_send_to_scuba(
|
||||
);
|
||||
sample.add("poll_time_us", stats.poll_time.as_micros_unchecked());
|
||||
sample.add("poll_count", stats.poll_count);
|
||||
sample.add("trace", trace_id);
|
||||
if let Some(trace_id) = trace_id {
|
||||
sample.add("trace", trace_id);
|
||||
}
|
||||
if let Some(args) = args {
|
||||
sample.add("args", args);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user