Skip to main content

force_flush

Function force_flush 

Source
pub fn force_flush() -> AppResult<()>
Examples found in repository?
examples/otel.rs (line 20)
7async fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let endpoint = std::env::var("OTEL_EXPORTER_OTLP_ENDPOINT")
9        .unwrap_or_else(|_| "http://localhost:4317".to_owned());
10    let correlation_id = example_correlation_id();
11
12    telemetry::init(&TelemetryConfig {
13        log_level: "info".to_owned(),
14        log_format: LogFormat::Compact,
15        otlp_endpoint: Some(endpoint),
16    })?;
17
18    emit_outbox_span(&correlation_id);
19    emit_function_span(&correlation_id);
20    telemetry::force_flush()?;
21
22    println!("OTEL_EXAMPLE_CORRELATION_ID={correlation_id}");
23    Ok(())
24}