Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vmm: imporve observability to vmm-task & vmm-sandboxer #146

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.74"
components = ["rustfmt", "clippy", "llvm-tools"]
channel = "1.78"
components = ["rustfmt", "clippy", "llvm-tools"]
9 changes: 7 additions & 2 deletions vmm/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ serde = "1.0.139"
lazy_static = "1.4.0"
nix = "0.24.1"
anyhow = "1.0.66"
log = { version = "0.4.17", features = ["std"] }
ttrpc = { version = "0.7", features = ["async"] }
protobuf = "3.2"
async-trait = "0.1"
regex = "1.5.6"

tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["json", "env-filter"] }

opentelemetry = { version = "0.20.0", features = ["rt-tokio"] }
opentelemetry-otlp = "0.13.0"

[build-dependencies]
ttrpc-codegen = { git = "https://github.com/kuasar-io/ttrpc-rust.git", branch = "v0.7.1-kuasar" }
tonic-build = "0.7.2"
tonic-build = "0.7.2"
1 change: 1 addition & 0 deletions vmm/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub use containerd_sandbox::data::Io;
pub mod api;
pub mod mount;
pub mod storage;
pub mod tracer;

pub const KUASAR_STATE_DIR: &str = "/run/kuasar/state";

Expand Down
2 changes: 1 addition & 1 deletion vmm/common/src/mount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ use std::{
use anyhow::{anyhow, Result};
use fs::read_to_string;
use lazy_static::lazy_static;
use log::debug;
use nix::{errno::Errno, libc, mount::MsFlags, NixPath};
use regex::Regex;
use tracing::debug;

pub const MNT_NOFOLLOW: i32 = 0x8;
pub const MNT_OPTION_MAX_LEN: usize = 4096;
Expand Down
36 changes: 36 additions & 0 deletions vmm/common/src/tracer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright 2024 The Kuasar Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

use opentelemetry::sdk::{trace, trace::Tracer, Resource};
use tracing_subscriber::EnvFilter;

pub fn init_otlp_tracer(otlp_service_name: &str) -> anyhow::Result<Tracer> {
let tracer = opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(opentelemetry_otlp::new_exporter().tonic())
.with_trace_config(trace::config().with_resource(Resource::new(vec![
opentelemetry::KeyValue::new("service.name", otlp_service_name.to_string()),
])))
.install_batch(opentelemetry::runtime::Tokio)?;
Ok(tracer)
}

pub fn init_logger_filter(log_level: &str) -> anyhow::Result<EnvFilter> {
let filter = EnvFilter::from_default_env()
.add_directive(format!("containerd_sandbox={}", log_level).parse()?)
.add_directive(format!("vmm_sandboxer={}", log_level).parse()?);
Ok(filter)
}
Loading
Loading