#[micromegas_main]Expand description
micromegas_main: Creates a tokio runtime with proper micromegas tracing callbacks and telemetry setup
This is a drop-in replacement for #[tokio::main] that automatically configures:
- Tokio runtime with proper micromegas tracing thread lifecycle callbacks
- Telemetry guard with sensible defaults (ctrl-c handling, debug level)
- Automatic authentication configuration from environment variables
§Authentication
The macro automatically configures telemetry authentication based on environment variables:
- API Key: Set
MICROMEGAS_INGESTION_API_KEY=your-key - OIDC Client Credentials: Set
MICROMEGAS_OIDC_TOKEN_ENDPOINT,MICROMEGAS_OIDC_CLIENT_ID,MICROMEGAS_OIDC_CLIENT_SECRET - No auth: If no env vars are set, telemetry is sent unauthenticated (requires
--disable-authon ingestion server)
§Parameters
interop_max_level: Optional interop max level override (e.g., “info”, “debug”, “warn”)max_level_override: Optional max level override (e.g., “info”, “debug”, “warn”)
§Examples
ⓘ
use micromegas::tracing::prelude::*;
#[micromegas_main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
info!("Server starting - telemetry already configured!");
Ok(())
}
#[micromegas_main(interop_max_level = "info")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
info!("Server starting with info interop level!");
Ok(())
}
#[micromegas_main(max_level_override = "warn", interop_max_level = "info")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
info!("Server starting with both level overrides!");
Ok(())
}