-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make background interval config public (#225)
* feat: make background interval config public Signed-off-by: andylokandy <[email protected]> * fix Signed-off-by: andylokandy <[email protected]> * fix Signed-off-by: andylokandy <[email protected]> * fix Signed-off-by: andylokandy <[email protected]> --------- Signed-off-by: andylokandy <[email protected]>
- Loading branch information
1 parent
eb84d3d
commit f34070b
Showing
21 changed files
with
273 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use std::time::Duration; | ||
|
||
use minitrace::collector::Config; | ||
use minitrace::collector::ConsoleReporter; | ||
use minitrace::prelude::*; | ||
|
||
fn main() { | ||
minitrace::set_reporter(ConsoleReporter, Config::default()); | ||
|
||
{ | ||
let parent = SpanContext::random(); | ||
let mut root = Span::root("light work", parent); | ||
let _span_guard = root.set_local_parent(); | ||
|
||
expensive_work(Duration::from_millis(50)); | ||
|
||
// Cancel the trace to avoid reporting if it's too short. | ||
if root.elapsed() < Some(Duration::from_millis(100)) { | ||
root.cancel(); | ||
} | ||
}; | ||
|
||
{ | ||
let parent = SpanContext::random(); | ||
let mut root = Span::root("heavy work", parent); | ||
let _span_guard = root.set_local_parent(); | ||
|
||
expensive_work(Duration::from_millis(200)); | ||
|
||
// This trace will be reported. | ||
if root.elapsed() < Some(Duration::from_millis(100)) { | ||
root.cancel(); | ||
} | ||
}; | ||
|
||
minitrace::flush(); | ||
} | ||
|
||
#[trace] | ||
fn expensive_work(time: Duration) { | ||
std::thread::sleep(time); | ||
} |
Oops, something went wrong.