Skip to content

Commit

Permalink
resolved more comments
Browse files Browse the repository at this point in the history
Signed-off-by: jiaxiao zhou <[email protected]>
  • Loading branch information
Mossaka committed Jul 19, 2024
1 parent f3a280e commit ec1b071
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 1 addition & 4 deletions crates/containerd-shim-wasm/src/sandbox/shim/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
6 changes: 4 additions & 2 deletions crates/containerd-shim-wasm/src/sandbox/shim/otel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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<ShutdownGuard> {
pub fn init(&self) -> anyhow::Result<impl Drop> {
let tracer = self.init_tracer()?;
let telemetry = tracing_opentelemetry::layer().with_tracer(tracer);
set_text_map_propagator(TraceContextPropagator::new());
Expand Down Expand Up @@ -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) {
Expand All @@ -169,6 +170,7 @@ fn traces_protocol_from_env() -> anyhow::Result<Protocol> {
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",
))?,
Expand Down

0 comments on commit ec1b071

Please sign in to comment.