diff --git a/Cargo.toml b/Cargo.toml index 5ee4b67..feb2cde 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ license = "Apache-2.0" readme = "README.md" repository = "https://github.com/tisonkun/logforth" rust-version = "1.71.0" -version = "0.7.0" +version = "0.7.1" [package.metadata.docs.rs] all-features = true diff --git a/src/append/mod.rs b/src/append/mod.rs index 97b0778..29889bb 100644 --- a/src/append/mod.rs +++ b/src/append/mod.rs @@ -29,7 +29,7 @@ use crate::layout::Layout; #[cfg(feature = "fastrace")] mod fastrace; #[cfg(feature = "opentelemetry")] -mod opentelemetry; +pub mod opentelemetry; #[cfg(feature = "rolling_file")] pub mod rolling_file; mod stdio; diff --git a/src/append/opentelemetry.rs b/src/append/opentelemetry.rs index 7c55da2..31aca46 100644 --- a/src/append/opentelemetry.rs +++ b/src/append/opentelemetry.rs @@ -28,6 +28,14 @@ use opentelemetry_sdk::logs::LoggerProvider; use crate::append::Append; +#[non_exhaustive] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum OpentelemetryWireProtocol { + Grpc, + HttpBinary, + HttpJson, +} + #[derive(Debug)] pub struct OpentelemetryLog { name: String, @@ -41,14 +49,14 @@ impl OpentelemetryLog { name: impl Into, category: impl Into, otlp_endpoint: impl Into, - protocol: Protocol, + protocol: OpentelemetryWireProtocol, ) -> Result { let name = name.into(); let category = category.into(); let otlp_endpoint = otlp_endpoint.into(); let exporter = match protocol { - Protocol::Grpc => opentelemetry_otlp::new_exporter() + OpentelemetryWireProtocol::Grpc => opentelemetry_otlp::new_exporter() .tonic() .with_endpoint(otlp_endpoint) .with_protocol(Protocol::Grpc) @@ -56,7 +64,7 @@ impl OpentelemetryLog { opentelemetry_otlp::OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT, )) .build_log_exporter(), - Protocol::HttpBinary => opentelemetry_otlp::new_exporter() + OpentelemetryWireProtocol::HttpBinary => opentelemetry_otlp::new_exporter() .http() .with_endpoint(otlp_endpoint) .with_protocol(Protocol::HttpBinary) @@ -64,7 +72,7 @@ impl OpentelemetryLog { opentelemetry_otlp::OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT, )) .build_log_exporter(), - Protocol::HttpJson => opentelemetry_otlp::new_exporter() + OpentelemetryWireProtocol::HttpJson => opentelemetry_otlp::new_exporter() .http() .with_endpoint(otlp_endpoint) .with_protocol(Protocol::HttpJson)