1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! Encore's tracing subscriber layers.
//!
//! Compose [`layer`] with a subscriber and install it explicitly. To forward
//! `log` records to the subscriber, optionally install `tracing_log::LogTracer`
//! once in the application:
//!
//! ```no_run
//! use tracing_subscriber::prelude::*;
//!
//! let subscriber = tracing_subscriber::registry()
//! .with(encore::telemetry::tracing::layer());
//! tracing::subscriber::set_global_default(subscriber)?;
//! tracing_log::LogTracer::init()?;
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! [`logs_layer`] prints Encore-format events for the supervisor to collect;
//! [`traces_layer`] records spans into Encore's collector. Neither installs a
//! subscriber or global logger.
/// Console events and collector spans. The application installs the subscriber.
/// Console events in Encore's log format, without initializing the runtime.
/// Info and above are enabled, as are runtime events selected by `RUST_LOG`
/// or `ENCORE_RUNTIME_LOG` (default debug). Spans are not exported.
/// Without an Encore runtime, call [`crate::telemetry::log::flush`] before exiting.
///
/// ```no_run
/// use tracing_subscriber::prelude::*;
/// tracing::subscriber::set_global_default(
/// tracing_subscriber::registry().with(encore::telemetry::tracing::logs_layer()),
/// )?;
/// tracing::info!("finished");
/// encore::telemetry::log::flush();
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```
/// Encore collector spans with per-entry OpenTelemetry context activation.
/// Events are excluded from this layer, not from sibling console layers.