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

Treat log's key-values as attributes in log bridge #1628

Merged
merged 12 commits into from
May 2, 2024
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ futures-util = { version = "0.3", default-features = false }
hyper = { version = "0.14", default-features = false }
http = { version = "0.2", default-features = false }
isahc = { version = "1.4", default-features = false }
log = "0.4"
log = "0.4.21"
once_cell = "1.13"
ordered-float = "4.0"
pin-project-lite = "0.2"
Expand Down
6 changes: 5 additions & 1 deletion opentelemetry-appender-log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ edition = "2021"

[dependencies]
opentelemetry = { version = "0.22", path = "../opentelemetry", features = ["logs"]}
log = { workspace = true, features = ["kv_unstable", "std"]}
log = { workspace = true, features = ["kv", "std"]}
serde = { workspace = true, optional = true, features = ["std"] }

[features]
logs_level_enabled = ["opentelemetry/logs_level_enabled"]
with_serde = ["log/kv_serde", "serde"]
default = ["logs_level_enabled"]

[dev-dependencies]
opentelemetry_sdk = { path = "../opentelemetry-sdk", features = [ "testing", "logs_level_enabled" ] }
log = { workspace = true, features = ["kv_serde"] }
tokio = { workspace = true }
serde = { workspace = true, features = ["std", "derive"] }
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ async fn main() {
log::set_max_level(Level::Info.to_level_filter());

// Emit logs using macros from the log crate.
error!("hello from {}. My price is {}", "apple", 2.99);
let user = "apple";
let price = 2.99;

error!(user, price; "hello from {user}. My price is {price}");
warn!("warn!");
info!("test log!");

Expand Down
Loading
Loading