Skip to content

Commit

Permalink
Rename logs_level_enabled flag to spec_unstable_logs_enabled (#2291)
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb authored Nov 11, 2024
1 parent 0cc2cd5 commit b833118
Show file tree
Hide file tree
Showing 21 changed files with 35 additions and 29 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ It's important to regularly review and remove the `otel_unstable` flag from the
The potential features include:

- Stable and non-experimental features that compliant to specification, and have a feature flag to minimize compilation size. Example: feature flags for signals (like `logs`, `traces`, `metrics`) and runtimes (`rt-tokio`, `rt-tokio-current-thread`, `rt-async-std`).
- Stable and non-experimental features, although not part of the specification, are crucial for enhancing the tracing/log crate's functionality or boosting performance. These features are also subject to discussion and approval by the OpenTelemetry Rust Maintainers. An example of such a feature is `logs_level_enabled`.
- Stable and non-experimental features, although not part of the specification, are crucial for enhancing the tracing/log crate's functionality or boosting performance. These features are also subject to discussion and approval by the OpenTelemetry Rust Maintainers.

All such features should adhere to naming convention `<signal>_<feature_name>`

Expand Down
1 change: 1 addition & 0 deletions opentelemetry-appender-log/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Bump MSRV to 1.70 [#2179](https://github.com/open-telemetry/opentelemetry-rust/pull/2179)
- [2193](https://github.com/open-telemetry/opentelemetry-rust/pull/2193) `opentelemetry-appender-log`: Output experimental code attributes
- **Breaking** [2291](https://github.com/open-telemetry/opentelemetry-rust/pull/2291) Rename `logs_level_enabled flag` to `spec_unstable_logs_enabled`. Please enable this updated flag if the feature is needed. This flag will be removed once the feature is stabilized in the specifications.

## v0.26.0
Released 2024-Sep-30
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-appender-log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ opentelemetry-semantic-conventions = { path = "../opentelemetry-semantic-convent
] }

[features]
logs_level_enabled = ["opentelemetry/logs_level_enabled"]
spec_unstable_logs_enabled = ["opentelemetry/spec_unstable_logs_enabled"]
with-serde = ["log/kv_serde", "serde"]
experimental_metadata_attributes = ["dep:opentelemetry-semantic-conventions"]

[dev-dependencies]
opentelemetry_sdk = { path = "../opentelemetry-sdk", features = [
"testing",
"logs_level_enabled",
"spec_unstable_logs_enabled",
] }
opentelemetry-stdout = { path = "../opentelemetry-stdout", features = ["logs"] }
log = { workspace = true, features = ["kv_serde"] }
Expand Down
10 changes: 5 additions & 5 deletions opentelemetry-appender-log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
//!
//! This library provides the following Cargo features:
//!
//! - `logs_level_enabled`: Allow users to control the log level.
//! - `spec_unstable_logs_enabled`: Allow users to control the log level.
//! - `with-serde`: Support complex values as attributes without stringifying them.
//!
//! [Logs Bridge API]: https://opentelemetry.io/docs/specs/otel/logs/bridge-api/
Expand Down Expand Up @@ -117,11 +117,11 @@ where
L: Logger + Send + Sync,
{
fn enabled(&self, _metadata: &Metadata) -> bool {
#[cfg(feature = "logs_level_enabled")]
#[cfg(feature = "spec_unstable_logs_enabled")]
return self
.logger
.event_enabled(severity_of_level(_metadata.level()), _metadata.target());
#[cfg(not(feature = "logs_level_enabled"))]
#[cfg(not(feature = "spec_unstable_logs_enabled"))]
true
}

Expand Down Expand Up @@ -770,9 +770,9 @@ mod tests {
// As a result of using `with_simple_exporter` while building the logger provider,
// the processor used is a `SimpleLogProcessor` which has an implementation of `event_enabled`
// that always returns true.
#[cfg(feature = "logs_level_enabled")]
#[cfg(feature = "spec_unstable_logs_enabled")]
assert!(otel_log_appender.enabled(&log::Metadata::builder().build()));
#[cfg(not(feature = "logs_level_enabled"))]
#[cfg(not(feature = "spec_unstable_logs_enabled"))]
assert!(otel_log_appender.enabled(&log::Metadata::builder().build()));
}

Expand Down
1 change: 1 addition & 0 deletions opentelemetry-appender-tracing/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## vNext

- Bump MSRV to 1.70 [#2179](https://github.com/open-telemetry/opentelemetry-rust/pull/2179)
- **Breaking** [2291](https://github.com/open-telemetry/opentelemetry-rust/pull/2291) Rename `logs_level_enabled flag` to `spec_unstable_logs_enabled`. Please enable this updated flag if the feature is needed. This flag will be removed once the feature is stabilized in the specifications.

## v0.26.0
Released 2024-Sep-30
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-appender-tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ pprof = { version = "0.13", features = ["flamegraph", "criterion"] }

[features]
experimental_metadata_attributes = ["dep:tracing-log"]
logs_level_enabled = ["opentelemetry/logs_level_enabled"]
spec_unstable_logs_enabled = ["opentelemetry/spec_unstable_logs_enabled"]


[[bench]]
name = "logs"
harness = false
required-features = ["logs_level_enabled"]
required-features = ["spec_unstable_logs_enabled"]
2 changes: 1 addition & 1 deletion opentelemetry-appender-tracing/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ where
self.logger.emit(log_record);
}

#[cfg(feature = "logs_level_enabled")]
#[cfg(feature = "spec_unstable_logs_enabled")]
fn event_enabled(
&self,
_event: &tracing_core::Event<'_>,
Expand Down
2 changes: 2 additions & 0 deletions opentelemetry-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@

- Users calling public APIs that return these constructs (e.g, LoggerProvider::shutdown(), MeterProvider::force_flush()) should now import them from the SDK instead of the API.
- Developers creating custom exporters should ensure they import these constructs from the SDK, not the API.
- [2291](https://github.com/open-telemetry/opentelemetry-rust/pull/2291) Rename `logs_level_enabled flag` to `spec_unstable_logs_enabled`. Please enable this updated flag if the feature is needed. This flag will be removed once the feature is stabilized in the specifications.


- **BREAKING**: `Temporality` enum moved from `opentelemetry_sdk::metrics::data::Temporality` to `opentelemetry_sdk::metrics::Temporality`.

Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ default = ["trace", "metrics", "logs", "internal-logs"]
trace = ["opentelemetry/trace", "rand", "async-trait", "percent-encoding"]
jaeger_remote_sampler = ["trace", "opentelemetry-http", "http", "serde", "serde_json", "url"]
logs = ["opentelemetry/logs", "async-trait", "serde_json"]
logs_level_enabled = ["logs", "opentelemetry/logs_level_enabled"]
spec_unstable_logs_enabled = ["logs", "opentelemetry/spec_unstable_logs_enabled"]
metrics = ["opentelemetry/metrics", "glob", "async-trait"]
testing = ["opentelemetry/testing", "trace", "metrics", "logs", "rt-async-std", "rt-tokio", "rt-tokio-current-thread", "tokio/macros", "tokio/rt-multi-thread"]
rt-tokio = ["tokio", "tokio-stream"]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-sdk/src/export/logs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::logs::LogRecord;
use crate::logs::{LogError, LogResult};
use crate::Resource;
use async_trait::async_trait;
#[cfg(feature = "logs_level_enabled")]
#[cfg(feature = "spec_unstable_logs_enabled")]
use opentelemetry::logs::Severity;
use opentelemetry::InstrumentationScope;
use std::fmt::Debug;
Expand Down Expand Up @@ -85,7 +85,7 @@ pub trait LogExporter: Send + Sync + Debug {
async fn export(&mut self, batch: LogBatch<'_>) -> LogResult<()>;
/// Shuts down the exporter.
fn shutdown(&mut self) {}
#[cfg(feature = "logs_level_enabled")]
#[cfg(feature = "spec_unstable_logs_enabled")]
/// Chek if logs are enabled.
fn event_enabled(&self, _level: Severity, _target: &str, _name: &str) -> bool {
// By default, all logs are enabled
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
//!
//! For `logs` the following feature flags are available:
//!
//! * `logs_level_enabled`: control the log level
//! * `spec_unstable_logs_enabled`: control the log level
//!
//! Support for recording and exporting telemetry asynchronously and perform
//! metrics aggregation can be added via the following flags:
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-sdk/src/logs/log_emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{export::logs::LogExporter, runtime::RuntimeChannel, Resource};
use crate::{logs::LogError, logs::LogResult};
use opentelemetry::{otel_debug, trace::TraceContextExt, Context, InstrumentationScope};

#[cfg(feature = "logs_level_enabled")]
#[cfg(feature = "spec_unstable_logs_enabled")]
use opentelemetry::logs::Severity;

use std::time::SystemTime;
Expand Down Expand Up @@ -282,7 +282,7 @@ impl opentelemetry::logs::Logger for Logger {
}
}

#[cfg(feature = "logs_level_enabled")]
#[cfg(feature = "spec_unstable_logs_enabled")]
fn event_enabled(&self, level: Severity, target: &str) -> bool {
let provider = self.provider();

Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-sdk/src/logs/log_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use futures_util::{
future::{self, Either},
{pin_mut, stream, StreamExt as _},
};
#[cfg(feature = "logs_level_enabled")]
#[cfg(feature = "spec_unstable_logs_enabled")]
use opentelemetry::logs::Severity;
use opentelemetry::{otel_debug, otel_error, otel_warn, InstrumentationScope};

Expand Down Expand Up @@ -61,7 +61,7 @@ pub trait LogProcessor: Send + Sync + Debug {
/// After shutdown returns the log processor should stop processing any logs.
/// It's up to the implementation on when to drop the LogProcessor.
fn shutdown(&self) -> LogResult<()>;
#[cfg(feature = "logs_level_enabled")]
#[cfg(feature = "spec_unstable_logs_enabled")]
/// Check if logging is enabled
fn event_enabled(&self, _level: Severity, _target: &str, _name: &str) -> bool {
// By default, all logs are enabled
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-stdout/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ rustdoc-args = ["--cfg", "docsrs"]
default = ["trace", "metrics", "logs"]
trace = ["opentelemetry/trace", "opentelemetry_sdk/trace", "futures-util"]
metrics = ["async-trait", "opentelemetry/metrics", "opentelemetry_sdk/metrics"]
logs = ["opentelemetry/logs", "opentelemetry_sdk/logs", "async-trait", "thiserror", "opentelemetry_sdk/logs_level_enabled"]
logs = ["opentelemetry/logs", "opentelemetry_sdk/logs", "async-trait", "thiserror", "opentelemetry_sdk/spec_unstable_logs_enabled"]
populate-logs-event-name = []

[dependencies]
Expand Down
2 changes: 2 additions & 0 deletions opentelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ let counter = meter.u64_counter("my_counter").build();
- Moved `MetricError` enum from `opentelemetry::metrics::MetricError` to `opentelemetry_sdk::metrics::MetricError`
- Moved `MetricResult` type alias from `opentelemetry::metrics::MetricResult` to `opentelemetry_sdk::metrics::MetricResult`
These changes shouldn't directly affect the users of OpenTelemetry crate, as these constructs are used in SDK and Exporters. If you are an author of an sdk component/plug-in, like an exporter etc. please use these types from sdk. Refer [CHANGELOG.md](https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-sdk/CHANGELOG.md) for more details, under same version section.
- **Breaking** [2291](https://github.com/open-telemetry/opentelemetry-rust/pull/2291) Rename `logs_level_enabled flag` to `spec_unstable_logs_enabled`. Please enable this updated flag if the feature is needed. This flag will be removed once the feature is stabilized in the specifications.


## v0.26.0
Released 2024-Sep-30
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ trace = ["pin-project-lite"]
metrics = []
testing = ["trace", "metrics"]
logs = []
logs_level_enabled = ["logs"]
spec_unstable_logs_enabled = ["logs"]
otel_unstable = []
internal-logs = ["tracing"]

[dev-dependencies]
opentelemetry_sdk = { path = "../opentelemetry-sdk", features = ["logs_level_enabled"]} # for documentation tests
opentelemetry_sdk = { path = "../opentelemetry-sdk", features = ["spec_unstable_logs_enabled"]} # for documentation tests
criterion = { workspace = true }
rand = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion opentelemetry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
//! The default feature flags are ["trace", "metrics", "logs"]
//!
//! The following feature flags provides additional configuration for `logs`:
//! * `logs_level_enabled`: Allow users to control the log level
//! * `spec_unstable_logs_enabled`: Allow users to control the log level
//!
//! The following feature flags enable APIs defined in OpenTelemetry specification that is in experimental phase:
//! * `otel_unstable`: Includes unstable APIs.
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry/src/logs/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::borrow::Cow;

use crate::{logs::LogRecord, InstrumentationScope};

#[cfg(feature = "logs_level_enabled")]
#[cfg(feature = "spec_unstable_logs_enabled")]
use super::Severity;

/// The interface for emitting [`LogRecord`]s.
Expand All @@ -20,7 +20,7 @@ pub trait Logger {
/// [`Context`]: crate::Context
fn emit(&self, record: Self::LogRecord);

#[cfg(feature = "logs_level_enabled")]
#[cfg(feature = "spec_unstable_logs_enabled")]
/// Check if the given log level is enabled.
fn event_enabled(&self, level: Severity, target: &str) -> bool;
}
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry/src/logs/noop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl Logger for NoopLogger {
NoopLogRecord {}
}
fn emit(&self, _record: Self::LogRecord) {}
#[cfg(feature = "logs_level_enabled")]
#[cfg(feature = "spec_unstable_logs_enabled")]
fn event_enabled(&self, _level: super::Severity, _target: &str) -> bool {
false
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if rustup component add clippy; then
-Dwarnings
done

cargo_feature opentelemetry "trace,metrics,logs,logs_level_enabled,testing"
cargo_feature opentelemetry "trace,metrics,logs,spec_unstable_logs_enabled,testing"

cargo_feature opentelemetry-otlp "default"
cargo_feature opentelemetry-otlp "default,tls"
Expand Down
4 changes: 2 additions & 2 deletions stress/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ doc = false
ctrlc = "3.2.5"
lazy_static = "1.4.0"
num_cpus = "1.15.0"
opentelemetry = { path = "../opentelemetry", features = ["metrics", "logs", "trace", "logs_level_enabled"] }
opentelemetry_sdk = { path = "../opentelemetry-sdk", features = ["metrics", "logs", "trace", "logs_level_enabled"] }
opentelemetry = { path = "../opentelemetry", features = ["metrics", "logs", "trace", "spec_unstable_logs_enabled"] }
opentelemetry_sdk = { path = "../opentelemetry-sdk", features = ["metrics", "logs", "trace", "spec_unstable_logs_enabled"] }
opentelemetry-appender-tracing = { path = "../opentelemetry-appender-tracing"}
rand = { version = "0.8.4", features = ["small_rng"] }
tracing = { workspace = true, features = ["std"]}
Expand Down

0 comments on commit b833118

Please sign in to comment.