Skip to content

Commit 9e8de33

Browse files
Merge branch 'CortexFlow:feature/ebpf-core' into feature/ebpf-core
2 parents 8a5f3f7 + ccfa242 commit 9e8de33

25 files changed

Lines changed: 201 additions & 411 deletions

core/Cargo.lock

Lines changed: 124 additions & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[workspace]
22
resolver = "3"
33
members = [
4+
"common",
45
"api",
56
"src/components/conntracker",
67
"src/components/identity",

core/api/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ tonic = "0.14.0"
2323
tonic-prost = "0.14.0"
2424
tracing = "0.1.41"
2525
aya = "0.13.1"
26+
cortexbrain-common = { path = "../common" }
2627
tonic-reflection = "0.14.0"
2728
tonic-build = "0.14.0"
2829
tracing-subscriber = "0.3.19"

core/api/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ WORKDIR /usr/src/app/agent
2121

2222
# Copy Cargo manifest and sources
2323
COPY . .
24+
COPY common ../common
2425

2526
# Fetch dependencies and build release
2627
RUN cargo fetch

core/api/src/main.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// module imports
22
use tonic::transport::{Error, Server};
3-
use tracing_subscriber::{fmt::format::FmtSpan, EnvFilter};
3+
use cortexbrain_common::logger;
44

55
mod agent;
66
mod api;
@@ -20,16 +20,7 @@ use tracing::{error, info};
2020
#[main]
2121
async fn main() -> Result<(), Error> {
2222
//init tracing subscriber
23-
tracing_subscriber::fmt()
24-
.with_max_level(tracing::Level::INFO)
25-
.with_target(false)
26-
.with_level(true)
27-
.with_span_events(FmtSpan::NONE)
28-
.with_file(false)
29-
.pretty()
30-
.with_env_filter(EnvFilter::new("info"))
31-
.with_line_number(false)
32-
.init();
23+
logger::init_default_logger();
3324

3425
info!("Starting agent server...");
3526
info!("fetching data");

core/common/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "cortexbrain-common"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
tracing = "0.1"
8+
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
9+
anyhow = "1.0"

core/common/src/constants.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// Environment variable name for the BPF program file path.
2+
/// Used by all components to load their eBPF programs.
3+
pub const BPF_PATH: &str = "BPF_PATH";
4+
5+
/// Environment variable name for the BPF map pinning path.
6+
/// Used for sharing maps between eBPF programs.
7+
pub const PIN_MAP_PATH: &str = "PIN_MAP_PATH";

core/common/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub mod constants;
2+
pub mod logger;

core/common/src/logger.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
use tracing_subscriber::{fmt::format::FmtSpan, EnvFilter};
2+
3+
/// Initialize the default logger configuration used across CortexBrain components.
4+
///
5+
/// This configures tracing with:
6+
/// - INFO level logging
7+
/// - Pretty formatting
8+
/// - No target, file, or line number information
9+
/// - Environment-based filtering
10+
pub fn init_default_logger() {
11+
tracing_subscriber::fmt()
12+
.with_max_level(tracing::Level::INFO)
13+
.with_target(false)
14+
.with_level(true)
15+
.with_span_events(FmtSpan::NONE)
16+
.with_file(false)
17+
.pretty()
18+
.with_env_filter(EnvFilter::new("info"))
19+
.with_line_number(false)
20+
.init();
21+
}
22+
23+
/// Initialize logger without timestamp information.
24+
/// Used by components that don't need timestamp logging.
25+
pub fn init_logger_without_time() {
26+
tracing_subscriber::fmt()
27+
.with_max_level(tracing::Level::INFO)
28+
.with_target(false)
29+
.with_level(true)
30+
.with_span_events(FmtSpan::NONE)
31+
.with_file(false)
32+
.without_time()
33+
.pretty()
34+
.with_env_filter(EnvFilter::new("info"))
35+
.with_line_number(false)
36+
.init();
37+
}

core/src/components/identity/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
2727
libc = "0.2.172"
2828
bytemuck = {version ="1.23.0",features = ["derive"]}
2929
bytemuck_derive = "1.10.1"
30+
cortexbrain-common = { path = "../../../common" }
3031
nix = { version = "0.30.1", features = ["net"] }
3132
kube = {version = "2.0.1",features = ["client"]}
3233
k8s-openapi = {version ="0.26.0", features = ["v1_34"]}

0 commit comments

Comments
 (0)