mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 20:15:07 +08:00
stops profiling in a file by default
This commit is contained in:
parent
91a8f74763
commit
ce6e6ec2c5
@ -36,23 +36,10 @@ fn default_layer() -> LogRouteType {
|
|||||||
|
|
||||||
/// does all the setup before meilisearch is launched
|
/// does all the setup before meilisearch is launched
|
||||||
fn setup(opt: &Opt) -> anyhow::Result<LogRouteHandle> {
|
fn setup(opt: &Opt) -> anyhow::Result<LogRouteHandle> {
|
||||||
let now = time::OffsetDateTime::now_utc();
|
|
||||||
let format = time::format_description::parse("[year]-[month]-[day]_[hour]:[minute]:[second]")?;
|
|
||||||
let trace_file = format!("{}-indexing-trace.json", now.format(&format)?);
|
|
||||||
|
|
||||||
let file = std::fs::File::create(&trace_file)
|
|
||||||
.with_context(|| format!("could not create trace file at '{}'", trace_file))?;
|
|
||||||
#[cfg(not(feature = "stats_alloc"))]
|
|
||||||
let (mut trace, layer) = tracing_trace::Trace::new(file);
|
|
||||||
#[cfg(feature = "stats_alloc")]
|
|
||||||
let (mut trace, layer) = tracing_trace::Trace::with_stats_alloc(file, &ALLOC);
|
|
||||||
|
|
||||||
let (route_layer, route_layer_handle) = tracing_subscriber::reload::Layer::new(default_layer());
|
let (route_layer, route_layer_handle) = tracing_subscriber::reload::Layer::new(default_layer());
|
||||||
let route_layer: tracing_subscriber::reload::Layer<_, _> = route_layer;
|
let route_layer: tracing_subscriber::reload::Layer<_, _> = route_layer;
|
||||||
|
|
||||||
let subscriber = tracing_subscriber::registry()
|
let subscriber = tracing_subscriber::registry().with(route_layer).with(
|
||||||
.with(route_layer)
|
|
||||||
.with(
|
|
||||||
tracing_subscriber::fmt::layer()
|
tracing_subscriber::fmt::layer()
|
||||||
.with_line_number(true)
|
.with_line_number(true)
|
||||||
.with_span_events(tracing_subscriber::fmt::format::FmtSpan::ACTIVE)
|
.with_span_events(tracing_subscriber::fmt::format::FmtSpan::ACTIVE)
|
||||||
@ -60,27 +47,8 @@ fn setup(opt: &Opt) -> anyhow::Result<LogRouteHandle> {
|
|||||||
tracing_subscriber::filter::LevelFilter::from_str(&opt.log_level.to_string())
|
tracing_subscriber::filter::LevelFilter::from_str(&opt.log_level.to_string())
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
),
|
),
|
||||||
)
|
|
||||||
.with(
|
|
||||||
layer.with_filter(
|
|
||||||
tracing_subscriber::filter::Targets::new()
|
|
||||||
.with_target("indexing::", tracing::Level::TRACE),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
tokio::task::spawn(async move {
|
|
||||||
loop {
|
|
||||||
match tokio::time::timeout(std::time::Duration::from_secs(1), trace.receive()).await {
|
|
||||||
Ok(Ok(ControlFlow::Continue(()))) => continue,
|
|
||||||
Ok(Ok(ControlFlow::Break(_))) => break,
|
|
||||||
Ok(Err(_)) => todo!(),
|
|
||||||
Err(_) => trace.flush().unwrap(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while trace.try_receive().is_ok() {}
|
|
||||||
trace.flush().unwrap();
|
|
||||||
});
|
|
||||||
|
|
||||||
// set the subscriber as the default for the application
|
// set the subscriber as the default for the application
|
||||||
tracing::subscriber::set_global_default(subscriber).unwrap();
|
tracing::subscriber::set_global_default(subscriber).unwrap();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user