From ec1b071bf69c4f3fa76013a280e407d61586d205 Mon Sep 17 00:00:00 2001 From: jiaxiao zhou Date: Fri, 19 Jul 2024 17:39:45 +0000 Subject: [PATCH] resolved more comments Signed-off-by: jiaxiao zhou --- crates/containerd-shim-wasm/src/sandbox/shim/mod.rs | 5 +---- crates/containerd-shim-wasm/src/sandbox/shim/otel.rs | 6 ++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/containerd-shim-wasm/src/sandbox/shim/mod.rs b/crates/containerd-shim-wasm/src/sandbox/shim/mod.rs index 94f634411..a5ce3eb1a 100644 --- a/crates/containerd-shim-wasm/src/sandbox/shim/mod.rs +++ b/crates/containerd-shim-wasm/src/sandbox/shim/mod.rs @@ -14,7 +14,4 @@ mod task_state; pub use cli::Cli; pub(crate) use local::Local; #[cfg(feature = "opentelemetry")] -pub use otel::{ - traces_enabled as otel_traces_enabled, Config as OTLPConfig, - ShutdownGuard as OTLPShutdownGuard, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_PROTOCOL, -}; +pub use otel::{traces_enabled as otel_traces_enabled, Config as OTLPConfig}; diff --git a/crates/containerd-shim-wasm/src/sandbox/shim/otel.rs b/crates/containerd-shim-wasm/src/sandbox/shim/otel.rs index eab77d3e2..576f3e79d 100644 --- a/crates/containerd-shim-wasm/src/sandbox/shim/otel.rs +++ b/crates/containerd-shim-wasm/src/sandbox/shim/otel.rs @@ -39,6 +39,7 @@ use tracing_opentelemetry::OpenTelemetrySpanExt as _; use tracing_subscriber::layer::SubscriberExt as _; use tracing_subscriber::{EnvFilter, Registry}; +const OTEL_EXPORTER_OTLP_PROTOCOL_HTTP_JSON: &str = "http/json"; const OTEL_EXPORTER_OTLP_PROTOCOL_HTTP_PROTOBUF: &str = "http/protobuf"; const OTEL_EXPORTER_OTLP_PROTOCOL_GRPC: &str = "grpc"; const OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: &str = "OTEL_EXPORTER_OTLP_TRACES_PROTOCOL"; @@ -82,7 +83,7 @@ impl Config { /// Initializes the tracer, sets up the telemetry and subscriber layers, and sets the global subscriber. /// /// Note: this function should be called only once and be called by the binary entry point. - pub fn init(&self) -> anyhow::Result { + pub fn init(&self) -> anyhow::Result { let tracer = self.init_tracer()?; let telemetry = tracing_opentelemetry::layer().with_tracer(tracer); set_text_map_propagator(TraceContextPropagator::new()); @@ -145,7 +146,7 @@ impl Config { /// Shutdown of the open telemetry services will automatically called when the OtelConfig instance goes out of scope. #[must_use] -pub struct ShutdownGuard; +struct ShutdownGuard; impl Drop for ShutdownGuard { fn drop(&mut self) { @@ -169,6 +170,7 @@ fn traces_protocol_from_env() -> anyhow::Result { let protocol = match traces_protocol.as_str() { OTEL_EXPORTER_OTLP_PROTOCOL_HTTP_PROTOBUF => Protocol::HttpBinary, OTEL_EXPORTER_OTLP_PROTOCOL_GRPC => Protocol::Grpc, + OTEL_EXPORTER_OTLP_PROTOCOL_HTTP_JSON => Protocol::HttpJson, _ => Err(TraceError::from( "Invalid OTEL_EXPORTER_OTLP_PROTOCOL value", ))?,