Use correct version of opentelemetry
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
6ac399a41b
commit
cbdda8a561
@ -1,16 +1,18 @@
|
|||||||
use hoc::{config::Settings, telemetry};
|
use hoc::{config::Settings, telemetry};
|
||||||
use std::net::TcpListener;
|
use std::net::TcpListener;
|
||||||
|
|
||||||
fn init() {
|
fn init() -> opentelemetry_jaeger::Uninstall {
|
||||||
dotenv::dotenv().ok();
|
dotenv::dotenv().ok();
|
||||||
openssl_probe::init_ssl_cert_env_vars();
|
openssl_probe::init_ssl_cert_env_vars();
|
||||||
|
|
||||||
telemetry::init_subscriber(telemetry::get_subscriber("hoc", "info"))
|
let (subscriber, uninstall) = telemetry::get_subscriber("hoc", "info");
|
||||||
|
telemetry::init_subscriber(subscriber);
|
||||||
|
uninstall
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::main]
|
#[actix_rt::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
init();
|
let _uninstall = init();
|
||||||
|
|
||||||
// TODO: error handling
|
// TODO: error handling
|
||||||
let settings = Settings::load().expect("Cannot load config");
|
let settings = Settings::load().expect("Cannot load config");
|
||||||
|
@ -1,27 +1,32 @@
|
|||||||
use opentelemetry::global;
|
use opentelemetry::global;
|
||||||
|
use opentelemetry_jaeger::Uninstall;
|
||||||
use tracing::{subscriber::set_global_default, Subscriber};
|
use tracing::{subscriber::set_global_default, Subscriber};
|
||||||
use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer};
|
use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer};
|
||||||
use tracing_log::LogTracer;
|
use tracing_log::LogTracer;
|
||||||
use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};
|
use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};
|
||||||
|
|
||||||
pub fn get_subscriber(name: &str, env_filter: &str) -> impl Subscriber + Send + Sync {
|
// TODO: don't pass `Uninstall` around...
|
||||||
|
pub fn get_subscriber(name: &str, env_filter: &str) -> (impl Subscriber + Send + Sync, Uninstall) {
|
||||||
let env_filter =
|
let env_filter =
|
||||||
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(env_filter));
|
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(env_filter));
|
||||||
|
|
||||||
let formatting_layer = BunyanFormattingLayer::new(name.to_string(), std::io::stdout);
|
let formatting_layer = BunyanFormattingLayer::new(name.to_string(), std::io::stdout);
|
||||||
|
|
||||||
global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());
|
global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());
|
||||||
let (tracer, _) = opentelemetry_jaeger::new_pipeline()
|
let (tracer, uninstall) = opentelemetry_jaeger::new_pipeline()
|
||||||
.with_service_name(name)
|
.with_service_name(name)
|
||||||
.install()
|
.install()
|
||||||
.expect("cannot install jaeger pipeline");
|
.expect("cannot install jaeger pipeline");
|
||||||
let telemetry = tracing_opentelemetry::layer().with_tracer(tracer);
|
let telemetry = tracing_opentelemetry::layer().with_tracer(tracer);
|
||||||
|
|
||||||
Registry::default()
|
(
|
||||||
.with(telemetry)
|
Registry::default()
|
||||||
.with(env_filter)
|
.with(telemetry)
|
||||||
.with(JsonStorageLayer)
|
.with(env_filter)
|
||||||
.with(formatting_layer)
|
.with(JsonStorageLayer)
|
||||||
|
.with(formatting_layer),
|
||||||
|
uninstall,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_subscriber(subscriber: impl Subscriber + Send + Sync) {
|
pub fn init_subscriber(subscriber: impl Subscriber + Send + Sync) {
|
||||||
|
Loading…
Reference in New Issue
Block a user