Expand description
§OpenTelemetry Log Integration
This crate provides integration with OpenTelemetry for logging purposes. It allows you to initialize and manage loggers that are compatible with the OpenTelemetry SDK.
§Features
- Initialize loggers with specific tags, levels, and exporter endpoints.
- Automatically manage the lifecycle of loggers, ensuring proper shutdown.
§Usage
Add this crate to your Cargo.toml
:
[dependencies]
opentelemetry-log = "0.1"
Import and use the Opentelemetry
struct to manage your loggers:
use opentelemetry_log::Opentelemetry;
#[tokio::main]
async fn main() {
let mut otel = Opentelemetry::new();
otel.init_log("my_app", "info", "http://localhost:4317").unwrap(); // Please do not unwrap in production code
// Your application logic here
}
§Modules
log
: Contains the log initialization logic.
§Structs
Opentelemetry
: Main struct for managing OpenTelemetry loggers.
§Traits
Default
: Provides a default implementation forOpentelemetry
.Drop
: Ensures proper shutdown of loggers whenOpentelemetry
instances are dropped.
§Errors
This crate uses the anyhow
crate for error handling. Ensure you handle errors appropriately
when initializing and using loggers.
Re-exports§
pub use anyhow;
Modules§
- log
- This module provides functionality to initialize and configure a logger that exports logs using OpenTelemetry. The logger can be configured with different levels and exporter endpoints.
Structs§
- Opentelemetry
- Main struct for managing OpenTelemetry loggers, when you init the logger remember to keep this alive for all the lifetime of the application.