Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/containerd-shimkit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ opentelemetry-otlp = { version = "0.16.0", default-features = false, features =
"grpc-tonic",
"http-proto",
"reqwest-client",
"reqwest-rustls",
"trace",
], optional = true }
opentelemetry_sdk = { version = "0.23", default-features = false, features = [
Expand Down
15 changes: 10 additions & 5 deletions crates/containerd-shimkit/src/sandbox/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,18 @@ where
}

#[cfg(feature = "opentelemetry")]
if otel_traces_enabled() {
// Only initialize OTEL in serve mode (empty action).
if otel_traces_enabled() && flags.action.is_empty() {
// opentelemetry uses tokio, so we need to initialize a runtime
async {
let otlp_config = OtlpConfig::build_from_env().expect("Failed to build OtelConfig.");
let _guard = otlp_config
.init()
.expect("Failed to initialize OpenTelemetry.");
let _guard = OtlpConfig::build_from_env()
.and_then(|c| c.init())
.map_err(|e| {
eprintln!(
"Failed to initialize OpenTelemetry (continuing without tracing): {e}"
)
})
.ok();
tokio::task::block_in_place(move || {
shim_main_inner::<I>(name, config);
});
Expand Down
2 changes: 1 addition & 1 deletion crates/containerd-shimkit/src/sandbox/shim/otel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,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<impl Drop> {
pub fn init(&self) -> anyhow::Result<impl Drop + use<>> {
let tracer = self.init_tracer()?;
let telemetry = tracing_opentelemetry::layer().with_tracer(tracer);
set_text_map_propagator(TraceContextPropagator::new());
Expand Down
Loading