feat(telemetry): configure otlp endpoint from flag

This commit is contained in:
Daniel Lundin 2024-12-24 01:27:41 +01:00
parent 441c38b3d5
commit b1f701ddf2
Signed by: dln
SSH key fingerprint: SHA256:dQy1Xj3UiqJYpKR5ggQ2bxgz4jCH8IF+k3AB8o0kmdI
7 changed files with 175 additions and 140 deletions

View file

@ -14,12 +14,15 @@ use patagia_controller::context::ControllerContext;
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Cli {}
struct Cli {
#[arg(long = "telemetry-otlp-endpoint", default_value = "http://localhost:4317", value_name = "OTEL_EXPORTER_OTLP_ENDPOINT")]
otlp_endpoint: Option<String>,
}
#[tokio::main]
async fn main() -> Result<()> {
let _args = Cli::parse();
let _tracing = instrumentation::init_tracing_subscriber()?;
let args = Cli::parse();
let _tracing = instrumentation::init_tracing(args.otlp_endpoint.as_ref())?;
tracing::info!("Patagia Controller");

View file

@ -30,6 +30,8 @@ pub(crate) async fn version(
tracing::info_span!("Hello, span!");
tracing::info!(monotonic_counter.version_calls = 1);
async move {
tracing::info!("Someone made a request to /version");
tokio::time::sleep(std::time::Duration::from_millis(200)).await;