Exporting traces to jaeger.
This commit is contained in:
parent
cddefdb963
commit
e1fbe36297
@ -12,7 +12,10 @@ path = "src/main.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nom = "7.1.1"
|
nom = "7.1.1"
|
||||||
|
opentelemetry = "0.17.0"
|
||||||
|
opentelemetry-jaeger = "0.16.0"
|
||||||
tracing = "0.1.37"
|
tracing = "0.1.37"
|
||||||
|
tracing-opentelemetry = "0.17.2"
|
||||||
tracing-subscriber = {version="0.3.16", features=["env-filter"]}
|
tracing-subscriber = {version="0.3.16", features=["env-filter"]}
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
26
src/main.rs
26
src/main.rs
@ -1,8 +1,10 @@
|
|||||||
#![feature(round_char_boundary)]
|
#![feature(round_char_boundary)]
|
||||||
use crate::parser::document;
|
use crate::parser::document;
|
||||||
use tracing_subscriber::fmt::format::FmtSpan;
|
|
||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
mod parser;
|
mod parser;
|
||||||
|
use tracing_subscriber::fmt;
|
||||||
|
use tracing_subscriber::layer::SubscriberExt;
|
||||||
|
use tracing_subscriber::util::SubscriberInitExt;
|
||||||
|
|
||||||
const TEST_DOC: &'static str = include_str!("../toy_language.txt");
|
const TEST_DOC: &'static str = include_str!("../toy_language.txt");
|
||||||
|
|
||||||
@ -16,17 +18,25 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
fn init_telemetry() -> Result<(), Box<dyn std::error::Error>> {
|
fn init_telemetry() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let env_filter = EnvFilter::try_from_default_env().unwrap_or(EnvFilter::new("WARN"));
|
let env_filter = EnvFilter::try_from_default_env().unwrap_or(EnvFilter::new("WARN"));
|
||||||
let format = tracing_subscriber::fmt::format()
|
|
||||||
|
let stdout = fmt::Layer::new()
|
||||||
.pretty()
|
.pretty()
|
||||||
.with_file(true)
|
.with_file(true)
|
||||||
.with_line_number(true)
|
.with_line_number(true)
|
||||||
.with_thread_ids(false)
|
.with_thread_ids(false)
|
||||||
.with_target(false);
|
.with_target(false);
|
||||||
let subscriber = tracing_subscriber::fmt()
|
|
||||||
.event_format(format)
|
opentelemetry::global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());
|
||||||
.with_span_events(FmtSpan::ENTER | FmtSpan::EXIT)
|
let tracer = opentelemetry_jaeger::new_pipeline()
|
||||||
.with_env_filter(env_filter)
|
.with_service_name("toy_language")
|
||||||
.finish();
|
.install_simple()?;
|
||||||
tracing::subscriber::set_global_default(subscriber)?;
|
|
||||||
|
let opentelemetry = tracing_opentelemetry::layer().with_tracer(tracer);
|
||||||
|
|
||||||
|
tracing_subscriber::registry()
|
||||||
|
.with(env_filter)
|
||||||
|
.with(opentelemetry)
|
||||||
|
.with(stdout)
|
||||||
|
.try_init()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user