Skip to content

Commit

Permalink
Minor fixes, stdout to print scope info for logs (#2563)
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas authored Jan 25, 2025
1 parent 879f4d7 commit b3879b6
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
// workspace dictionary.
"words": [
"actix",
"anyvalue",
"appender",
"appenders",
"Bhasin",
Expand Down
5 changes: 4 additions & 1 deletion opentelemetry-stdout/src/logs/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ impl opentelemetry_sdk::logs::LogExporter for LogExporter {
fn print_logs(batch: LogBatch<'_>) {
for (i, log) in batch.iter().enumerate() {
println!("Log #{}", i);
let (record, _library) = log;
let (record, library) = log;

println!("\t Instrumentation Scope: {:?}", library);

if let Some(event_name) = record.event_name() {
println!("\t EventName: {:?}", event_name);
}
Expand Down
3 changes: 1 addition & 2 deletions opentelemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ js-sys = "0.3.63"
default = ["trace", "metrics", "logs", "internal-logs"]
trace = ["pin-project-lite", "futures-sink", "futures-core", "thiserror"]
metrics = []
testing = ["trace", "metrics"]
testing = ["trace"]
logs = []
spec_unstable_logs_enabled = ["logs"]
otel_unstable = []
internal-logs = ["tracing"]

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry/src/global/internal_logging.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(unused_macros)]
///
/// **Note**: These macros (`otel_info!`, `otel_warn!`, `otel_debug!`, and `otel_error!`) are intended to be used
/// **internally within OpenTelemetry code** or for **custom exporters and processors**. They are not designed
/// **internally within OpenTelemetry code** or for **custom exporters, processors and other plugins**. They are not designed
/// for general application logging and should not be used for that purpose.
///
/// Macro for logging informational messages in OpenTelemetry.
Expand Down
1 change: 1 addition & 0 deletions opentelemetry/src/global/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fn global_meter_provider() -> &'static RwLock<GlobalMeterProvider> {

/// Sets the given [`MeterProvider`] instance as the current global meter
/// provider.
/// Libraries should NOT call this function. It is intended for applications/executables.
///
/// **NOTE:** This function should be called before getting [`Meter`] instances via [`meter()`] or [`meter_with_scope()`]. Otherwise, you could get no-op [`Meter`] instances.
pub fn set_meter_provider<P>(new_provider: P)
Expand Down
1 change: 1 addition & 0 deletions opentelemetry/src/global/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ pub fn tracer_with_scope(scope: InstrumentationScope) -> BoxedTracer {
/// It returns the [`TracerProvider`] instance that was previously mounted as global provider
/// (e.g. [`NoopTracerProvider`] if a provider had not been set before).
///
/// Libraries should NOT call this function. It is intended for applications/executables.
/// [`TracerProvider`]: crate::trace::TracerProvider
pub fn set_tracer_provider<P, T, S>(new_provider: P) -> GlobalTracerProvider
where
Expand Down

0 comments on commit b3879b6

Please sign in to comment.