From 1cb39edbb6467375f71f5dab25ccbc49ac9bf1d5 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Mon, 25 Nov 2024 22:33:31 -0800 Subject: [PATCH] Prepare crates for otel v0.27.0 (#130) --- Cargo.toml | 14 ++++---- opentelemetry-aws/CHANGELOG.md | 4 +++ opentelemetry-aws/Cargo.toml | 10 ++++-- .../src/trace/xray_propagator.rs | 4 +-- opentelemetry-contrib/CHANGELOG.md | 5 +++ opentelemetry-contrib/Cargo.toml | 2 +- .../src/trace/exporter/jaeger_json.rs | 6 ++-- opentelemetry-datadog/CHANGELOG.md | 7 ++++ opentelemetry-datadog/Cargo.toml | 2 +- .../benches/datadog_exporter.rs | 6 ++-- opentelemetry-datadog/src/exporter/intern.rs | 6 +++- opentelemetry-datadog/src/exporter/mod.rs | 36 ++++++++++--------- .../src/exporter/model/mod.rs | 8 ++--- opentelemetry-etw-logs/CHANGELOG.md | 6 ++++ opentelemetry-etw-logs/Cargo.toml | 6 ++-- opentelemetry-etw-logs/src/logs/converters.rs | 1 + opentelemetry-etw-logs/src/logs/exporter.rs | 7 ++-- .../src/logs/reentrant_logprocessor.rs | 6 ++-- opentelemetry-etw-metrics/CHANGELOG.md | 2 ++ opentelemetry-etw-metrics/Cargo.toml | 16 ++++++--- opentelemetry-resource-detectors/CHANGELOG.md | 7 ++++ opentelemetry-resource-detectors/Cargo.toml | 2 +- opentelemetry-stackdriver/CHANGELOG.md | 6 ++++ opentelemetry-stackdriver/Cargo.toml | 9 +++-- .../proto/google/api/client.proto | 17 +++++++++ opentelemetry-stackdriver/src/lib.rs | 18 +++++----- opentelemetry-stackdriver/src/proto/api.rs | 18 ++++++++++ opentelemetry-user-events-logs/CHANGELOG.md | 6 ++++ opentelemetry-user-events-logs/Cargo.toml | 4 +-- .../src/logs/exporter.rs | 9 ++--- .../src/logs/reentrant_logprocessor.rs | 4 +-- opentelemetry-user-events-metrics/Cargo.toml | 16 ++++++--- .../src/tracepoint/mod.rs | 2 +- opentelemetry-zpages/CHANGELOG.md | 6 ++++ opentelemetry-zpages/Cargo.toml | 2 +- 35 files changed, 201 insertions(+), 79 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 285391ff..9d0b6ff1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,10 +12,10 @@ resolver = "2" debug = 1 [workspace.dependencies] -opentelemetry = "0.26" -opentelemetry-appender-tracing = "0.26" -opentelemetry-http = "0.26" -opentelemetry-proto = { version = "0.26", default-features = false } -opentelemetry_sdk = { version = "0.26", default-features = false } -opentelemetry-stdout = "0.26" -opentelemetry-semantic-conventions = { version = "0.26", features = ["semconv_experimental"] } +opentelemetry = "0.27" +opentelemetry-appender-tracing = "0.27" +opentelemetry-http = "0.27" +opentelemetry-proto = { version = "0.27", default-features = false } +opentelemetry_sdk = { version = "0.27", default-features = false } +opentelemetry-stdout = "0.27" +opentelemetry-semantic-conventions = { version = "0.27", features = ["semconv_experimental"] } diff --git a/opentelemetry-aws/CHANGELOG.md b/opentelemetry-aws/CHANGELOG.md index a4dec980..dff53287 100644 --- a/opentelemetry-aws/CHANGELOG.md +++ b/opentelemetry-aws/CHANGELOG.md @@ -2,6 +2,10 @@ ## vNext +## v0.15.0 + +- Bump opentelemetry and opentelemetry_sdk versions to 0.27.0 + ## v0.14.0 ### Changed diff --git a/opentelemetry-aws/Cargo.toml b/opentelemetry-aws/Cargo.toml index abd01b6f..80a4ac9f 100644 --- a/opentelemetry-aws/Cargo.toml +++ b/opentelemetry-aws/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "opentelemetry-aws" -version = "0.14.0" +version = "0.15.0" description = "AWS exporters and propagators for OpenTelemetry" homepage = "https://github.com/open-telemetry/opentelemetry-rust-contrib/tree/main/opentelemetry-aws" repository = "https://github.com/open-telemetry/opentelemetry-rust-contrib/tree/main/opentelemetry-aws" @@ -19,15 +19,17 @@ all-features = true rustdoc-args = ["--cfg", "docsrs"] [features] -default = ["trace"] +default = ["trace", "internal-logs"] trace = ["opentelemetry/trace", "opentelemetry_sdk/trace"] detector-aws-lambda = ["dep:opentelemetry-semantic-conventions"] +internal-logs = ["tracing"] [dependencies] once_cell = "1.12" opentelemetry = { workspace = true } opentelemetry_sdk = { workspace = true, optional = true } opentelemetry-semantic-conventions = { workspace = true, optional = true } +tracing = {version = "0.1", optional = true} [dev-dependencies] opentelemetry_sdk = { workspace = true, features = ["testing"] } @@ -36,3 +38,7 @@ opentelemetry-stdout = { workspace = true, features = ["trace"] } hyper = { version = "1.4.1" } tokio = { version = "1.0", features = ["macros", "rt"] } sealed_test = "1.1.0" + +[package.metadata.cargo-machete] +ignored = ["tracing"] + diff --git a/opentelemetry-aws/src/trace/xray_propagator.rs b/opentelemetry-aws/src/trace/xray_propagator.rs index 10ca0b6c..fd9b9871 100644 --- a/opentelemetry-aws/src/trace/xray_propagator.rs +++ b/opentelemetry-aws/src/trace/xray_propagator.rs @@ -40,7 +40,7 @@ use once_cell::sync::Lazy; use opentelemetry::{ - global::{self, Error}, + otel_error, propagation::{text_map_propagator::FieldIter, Extractor, Injector, TextMapPropagator}, trace::{SpanContext, SpanId, TraceContextExt, TraceError, TraceFlags, TraceId, TraceState}, Context, @@ -139,7 +139,7 @@ pub fn span_context_from_str(value: &str) -> Option { )) } Err(trace_state_err) => { - global::handle_error(Error::Trace(TraceError::Other(Box::new(trace_state_err)))); + otel_error!(name: "SpanContextFromStr", error = format!("{:?}", TraceError::Other(Box::new(trace_state_err)))); None //todo: assign an error type instead of using None } } diff --git a/opentelemetry-contrib/CHANGELOG.md b/opentelemetry-contrib/CHANGELOG.md index fb8ec5b0..391f6046 100644 --- a/opentelemetry-contrib/CHANGELOG.md +++ b/opentelemetry-contrib/CHANGELOG.md @@ -2,6 +2,11 @@ ## vNext +## v0.19.0 + +- Bump opentelemetry and opentelemetry_sdk versions to 0.27 +- Bump opentelemetry-semantic-conventions version to 0.27 + ## v0.18.0 ### Changed diff --git a/opentelemetry-contrib/Cargo.toml b/opentelemetry-contrib/Cargo.toml index a948af31..af570326 100644 --- a/opentelemetry-contrib/Cargo.toml +++ b/opentelemetry-contrib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "opentelemetry-contrib" -version = "0.18.0" +version = "0.19.0" description = "Rust contrib repo for OpenTelemetry" homepage = "https://github.com/open-telemetry/opentelemetry-rust-contrib/tree/main/opentelemetry-contrib" repository = "https://github.com/open-telemetry/opentelemetry-rust-contrib/tree/main/opentelemetry-contrib" diff --git a/opentelemetry-contrib/src/trace/exporter/jaeger_json.rs b/opentelemetry-contrib/src/trace/exporter/jaeger_json.rs index a81c26c7..8ff54b86 100644 --- a/opentelemetry-contrib/src/trace/exporter/jaeger_json.rs +++ b/opentelemetry-contrib/src/trace/exporter/jaeger_json.rs @@ -12,6 +12,7 @@ use opentelemetry::trace::SpanId; ))] use opentelemetry::trace::TraceError; use opentelemetry::trace::TracerProvider as _; +use opentelemetry::InstrumentationScope; use opentelemetry_sdk::{ export::trace::{ExportResult, SpanData, SpanExporter}, runtime::RuntimeChannel, @@ -52,11 +53,11 @@ impl JaegerJsonExporter { let runtime = self.runtime.clone(); let provider_builder = TracerProvider::builder().with_batch_exporter(self, runtime); let provider = provider_builder.build(); - let tracer = provider - .tracer_builder("opentelemetry") + let scope = InstrumentationScope::builder("opentelemetry") .with_version(env!("CARGO_PKG_VERSION")) .with_schema_url(SCHEMA_URL) .build(); + let tracer = provider.tracer_with_scope(scope); let _ = opentelemetry::global::set_tracer_provider(provider); tracer @@ -211,6 +212,7 @@ fn opentelemetry_value_to_json(value: &opentelemetry::Value) -> (&str, serde_jso opentelemetry::Value::F64(f) => ("float64", serde_json::json!(f)), opentelemetry::Value::String(s) => ("string", serde_json::json!(s.as_str())), v @ opentelemetry::Value::Array(_) => ("string", serde_json::json!(v.to_string())), + &_ => ("", serde_json::json!("".to_string())), } } diff --git a/opentelemetry-datadog/CHANGELOG.md b/opentelemetry-datadog/CHANGELOG.md index e852a715..3eac2e55 100644 --- a/opentelemetry-datadog/CHANGELOG.md +++ b/opentelemetry-datadog/CHANGELOG.md @@ -2,6 +2,13 @@ ## vNext +## v0.15.0 + +### Changed + +- Bump opentelemetry and opentelemetry_sdk versions to 0.27 +- Bump opentelemetry-http and opentelemetry-semantic-conventions versions to 0.27 + ## v0.14.0 ### Changed diff --git a/opentelemetry-datadog/Cargo.toml b/opentelemetry-datadog/Cargo.toml index f50fd806..7ac6755f 100644 --- a/opentelemetry-datadog/Cargo.toml +++ b/opentelemetry-datadog/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "opentelemetry-datadog" -version = "0.14.0" +version = "0.15.0" description = "Datadog exporters and propagators for OpenTelemetry" homepage = "https://github.com/open-telemetry/opentelemetry-rust-contrib/tree/main/opentelemetry-datadog" repository = "https://github.com/open-telemetry/opentelemetry-rust-contrib/tree/main/opentelemetry-datadog" diff --git a/opentelemetry-datadog/benches/datadog_exporter.rs b/opentelemetry-datadog/benches/datadog_exporter.rs index 2d9b3dda..d97c3bcd 100644 --- a/opentelemetry-datadog/benches/datadog_exporter.rs +++ b/opentelemetry-datadog/benches/datadog_exporter.rs @@ -4,7 +4,7 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; use http::Request; use opentelemetry::{ trace::{SpanContext, SpanId, SpanKind, Status, TraceFlags, TraceId, TraceState}, - Array, InstrumentationLibrary, KeyValue, Value, + Array, InstrumentationScope, KeyValue, Value, }; use opentelemetry_datadog::{new_pipeline, ApiVersion}; use opentelemetry_http::HttpClient; @@ -150,7 +150,7 @@ fn get_span(trace_id: u128, parent_span_id: u64, span_id: u64, rng: &mut ThreadR ]; let events = SpanEvents::default(); let links = SpanLinks::default(); - let instrumentation_lib = InstrumentationLibrary::builder("component").build(); + let instrumentation_scope = InstrumentationScope::builder("component").build(); SpanData { span_context, @@ -164,7 +164,7 @@ fn get_span(trace_id: u128, parent_span_id: u64, span_id: u64, rng: &mut ThreadR events, links, status: Status::Ok, - instrumentation_lib, + instrumentation_scope, } } diff --git a/opentelemetry-datadog/src/exporter/intern.rs b/opentelemetry-datadog/src/exporter/intern.rs index d620f82b..61defaa6 100644 --- a/opentelemetry-datadog/src/exporter/intern.rs +++ b/opentelemetry-datadog/src/exporter/intern.rs @@ -10,7 +10,7 @@ use std::{ type InternHasher = ahash::AHasher; #[cfg(all(feature = "intern-std", not(feature = "intern-ahash")))] -type InternHasher = std::hash::DefaultHasher; +type InternHasher = std::collections::hash_map::DefaultHasher; #[derive(PartialEq)] pub(crate) enum InternValue<'a> { @@ -36,7 +36,9 @@ impl<'a> Hash for InternValue<'a> { } } opentelemetry::Array::String(x) => x.hash(state), + &_ => {} }, + &_ => {} }, } } @@ -110,7 +112,9 @@ impl<'a> InternValue<'a> { opentelemetry::Array::String(x) => { Self::write_generic_array(payload, reusable_buffer, x) } + _ => Self::write_empty_array(payload), }, + _ => Self::write_empty_array(payload), }, } } diff --git a/opentelemetry-datadog/src/exporter/mod.rs b/opentelemetry-datadog/src/exporter/mod.rs index 97b1ff42..7e490c7a 100644 --- a/opentelemetry-datadog/src/exporter/mod.rs +++ b/opentelemetry-datadog/src/exporter/mod.rs @@ -4,10 +4,12 @@ mod model; pub use model::ApiVersion; pub use model::Error; pub use model::FieldMappingFn; +use opentelemetry::InstrumentationScope; use crate::exporter::model::FieldMapping; use futures_core::future::BoxFuture; use http::{Method, Request, Uri}; +use opentelemetry::trace::TracerProvider as _; use opentelemetry::{global, trace::TraceError, KeyValue}; use opentelemetry_http::{HttpClient, ResponseExt}; use opentelemetry_sdk::{ @@ -287,14 +289,12 @@ impl DatadogPipelineBuilder { let mut provider_builder = TracerProvider::builder().with_simple_exporter(exporter); provider_builder = provider_builder.with_config(config); let provider = provider_builder.build(); - let tracer = opentelemetry::trace::TracerProvider::tracer_builder( - &provider, - "opentelemetry-datadog", - ) - .with_version(env!("CARGO_PKG_VERSION")) - .with_schema_url(semcov::SCHEMA_URL) - .with_attributes(None) - .build(); + let scope = InstrumentationScope::builder("opentelemetry-datadog") + .with_version(env!("CARGO_PKG_VERSION")) + .with_schema_url(semcov::SCHEMA_URL) + .with_attributes(None) + .build(); + let tracer = provider.tracer_with_scope(scope); let _ = global::set_tracer_provider(provider); Ok(tracer) } @@ -307,14 +307,12 @@ impl DatadogPipelineBuilder { let mut provider_builder = TracerProvider::builder().with_batch_exporter(exporter, runtime); provider_builder = provider_builder.with_config(config); let provider = provider_builder.build(); - let tracer = opentelemetry::trace::TracerProvider::tracer_builder( - &provider, - "opentelemetry-datadog", - ) - .with_version(env!("CARGO_PKG_VERSION")) - .with_schema_url(semcov::SCHEMA_URL) - .with_attributes(None) - .build(); + let scope = InstrumentationScope::builder("opentelemetry-datadog") + .with_version(env!("CARGO_PKG_VERSION")) + .with_schema_url(semcov::SCHEMA_URL) + .with_attributes(None) + .build(); + let tracer = provider.tracer_with_scope(scope); let _ = global::set_tracer_provider(provider); Ok(tracer) } @@ -459,6 +457,12 @@ fn mapping_debug(f: &Option) -> String { .to_string() } +impl opentelemetry::trace::ExportError for model::Error { + fn exporter_name(&self) -> &'static str { + "DatadogExporter" + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/opentelemetry-datadog/src/exporter/model/mod.rs b/opentelemetry-datadog/src/exporter/model/mod.rs index aeabc453..670c31e4 100644 --- a/opentelemetry-datadog/src/exporter/model/mod.rs +++ b/opentelemetry-datadog/src/exporter/model/mod.rs @@ -71,7 +71,7 @@ fn default_service_name_mapping<'a>(_span: &'a SpanData, config: &'a ModelConfig } fn default_name_mapping<'a>(span: &'a SpanData, _config: &'a ModelConfig) -> &'a str { - span.instrumentation_lib.name.as_ref() + span.instrumentation_scope.name() } fn default_resource_mapping<'a>(span: &'a SpanData, _config: &'a ModelConfig) -> &'a str { @@ -198,6 +198,7 @@ impl ApiVersion { #[cfg(test)] pub(crate) mod tests { use super::*; + use opentelemetry::InstrumentationScope; use opentelemetry::{ trace::{SpanContext, SpanId, SpanKind, Status, TraceFlags, TraceId, TraceState}, KeyValue, @@ -205,7 +206,6 @@ pub(crate) mod tests { use opentelemetry_sdk::{ self, trace::{SpanEvents, SpanLinks}, - InstrumentationLibrary, }; use std::time::{Duration, SystemTime}; @@ -228,7 +228,7 @@ pub(crate) mod tests { let attributes = vec![KeyValue::new("span.type", "web")]; let events = SpanEvents::default(); let links = SpanLinks::default(); - let instrumentation_lib = InstrumentationLibrary::builder("component").build(); + let instrumentation_scope = InstrumentationScope::builder("component").build(); trace::SpanData { span_context, @@ -242,7 +242,7 @@ pub(crate) mod tests { events, links, status: Status::Ok, - instrumentation_lib, + instrumentation_scope, } } diff --git a/opentelemetry-etw-logs/CHANGELOG.md b/opentelemetry-etw-logs/CHANGELOG.md index f767692b..4e45b1dd 100644 --- a/opentelemetry-etw-logs/CHANGELOG.md +++ b/opentelemetry-etw-logs/CHANGELOG.md @@ -2,6 +2,12 @@ ## vNext +## v0.6.0 + +### Changed + +- Bump opentelemetry and opentelemetry_sdk versions to 0.27 + ## v0.5.0 ### Changed diff --git a/opentelemetry-etw-logs/Cargo.toml b/opentelemetry-etw-logs/Cargo.toml index 154dc298..88aff812 100644 --- a/opentelemetry-etw-logs/Cargo.toml +++ b/opentelemetry-etw-logs/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "opentelemetry-etw-logs" description = "OpenTelemetry logs exporter to ETW (Event Tracing for Windows)" -version = "0.5.0" +version = "0.6.0" edition = "2021" homepage = "https://github.com/open-telemetry/opentelemetry-rust-contrib/tree/main/opentelemetry-etw-logs" repository = "https://github.com/open-telemetry/opentelemetry-rust-contrib/tree/main/opentelemetry-etw-logs" @@ -30,8 +30,8 @@ microbench = "0.5" [features] logs_level_enabled = [ - "opentelemetry/logs_level_enabled", - "opentelemetry_sdk/logs_level_enabled", + "opentelemetry/spec_unstable_logs_enabled", + "opentelemetry_sdk/spec_unstable_logs_enabled", ] default = ["logs_level_enabled"] diff --git a/opentelemetry-etw-logs/src/logs/converters.rs b/opentelemetry-etw-logs/src/logs/converters.rs index 43354e33..7e8fa1ca 100644 --- a/opentelemetry-etw-logs/src/logs/converters.rs +++ b/opentelemetry-etw-logs/src/logs/converters.rs @@ -17,6 +17,7 @@ impl IntoJson for AnyValue { AnyValue::Bytes(_value) => todo!("No support for AnyValue::Bytes yet."), AnyValue::ListAny(value) => value.as_json_value(), AnyValue::Map(value) => value.as_json_value(), + &_ => Value::Null, } } } diff --git a/opentelemetry-etw-logs/src/logs/exporter.rs b/opentelemetry-etw-logs/src/logs/exporter.rs index 2c203f14..debb6df2 100644 --- a/opentelemetry-etw-logs/src/logs/exporter.rs +++ b/opentelemetry-etw-logs/src/logs/exporter.rs @@ -174,13 +174,13 @@ impl ETWExporter { pub(crate) fn export_log_data( &self, log_record: &opentelemetry_sdk::logs::LogRecord, - instrumentation: &opentelemetry::InstrumentationLibrary, + instrumentation: &opentelemetry::InstrumentationScope, ) -> opentelemetry_sdk::export::logs::ExportResult { let level = self.get_severity_level(log_record.severity_number.unwrap_or(Severity::Debug)); let keyword = match self .exporter_config - .get_log_keyword_or_default(instrumentation.name.as_ref()) + .get_log_keyword_or_default(instrumentation.name().as_ref()) { Some(keyword) => keyword, _ => return Ok(()), @@ -342,7 +342,7 @@ impl opentelemetry_sdk::export::logs::LogExporter for ETWExporter { async fn export( &mut self, batch: opentelemetry_sdk::export::logs::LogBatch<'_>, - ) -> opentelemetry::logs::LogResult<()> { + ) -> opentelemetry_sdk::logs::LogResult<()> { for (log_record, instrumentation) in batch.iter() { let _ = self.export_log_data(log_record, instrumentation); } @@ -401,6 +401,7 @@ fn add_attribute_to_event(event: &mut tld::EventBuilder, key: &Key, value: &AnyV 0, ); } + &_ => {} } } diff --git a/opentelemetry-etw-logs/src/logs/reentrant_logprocessor.rs b/opentelemetry-etw-logs/src/logs/reentrant_logprocessor.rs index 7057a717..868c12c4 100644 --- a/opentelemetry-etw-logs/src/logs/reentrant_logprocessor.rs +++ b/opentelemetry-etw-logs/src/logs/reentrant_logprocessor.rs @@ -1,8 +1,8 @@ use std::fmt::Debug; -use opentelemetry::logs::LogResult; -use opentelemetry::InstrumentationLibrary; +use opentelemetry::InstrumentationScope; use opentelemetry_sdk::logs::LogRecord; +use opentelemetry_sdk::logs::LogResult; #[cfg(feature = "logs_level_enabled")] use opentelemetry_sdk::export::logs::LogExporter; @@ -33,7 +33,7 @@ impl ReentrantLogProcessor { } impl opentelemetry_sdk::logs::LogProcessor for ReentrantLogProcessor { - fn emit(&self, data: &mut LogRecord, instrumentation: &InstrumentationLibrary) { + fn emit(&self, data: &mut LogRecord, instrumentation: &InstrumentationScope) { _ = self.event_exporter.export_log_data(data, instrumentation); } diff --git a/opentelemetry-etw-metrics/CHANGELOG.md b/opentelemetry-etw-metrics/CHANGELOG.md index 8a7e3fa4..12067a2a 100644 --- a/opentelemetry-etw-metrics/CHANGELOG.md +++ b/opentelemetry-etw-metrics/CHANGELOG.md @@ -2,6 +2,8 @@ ## vNext +## v0.6.0 + - Bump opentelemetry and opentelemetry_sdk versions to 0.27 - Bump opentelemetry-proto version to 0.27 - Uses internal logging from `opentelemetry` crate, which routes internal logs diff --git a/opentelemetry-etw-metrics/Cargo.toml b/opentelemetry-etw-metrics/Cargo.toml index bb176ee9..a3eef4cb 100644 --- a/opentelemetry-etw-metrics/Cargo.toml +++ b/opentelemetry-etw-metrics/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "opentelemetry-etw-metrics" -version = "0.5.0" +version = "0.6.0" edition = "2021" description = "OpenTelemetry metrics exporter to ETW (Event Tracing for Windows)" homepage = "https://github.com/open-telemetry/opentelemetry-rust-contrib/tree/main/opentelemetry-etw-metrics" @@ -11,12 +11,20 @@ license = "Apache-2.0" rust-version = "1.71.1" [dependencies] -opentelemetry = { version = "0.27", features = ["metrics"] } -opentelemetry_sdk = { version = "0.27", features = ["metrics", "rt-tokio"] } -opentelemetry-proto = { version = "0.27", features = ["gen-tonic", "metrics"] } +opentelemetry = { workspace = true, features = ["metrics"] } +opentelemetry_sdk = { workspace = true, features = ["metrics", "rt-tokio"] } +opentelemetry-proto = { workspace = true, features = ["gen-tonic", "metrics"] } async-trait = "0.1" prost = "0.13" tracelogging = "1.2.1" +tracing = {version = "0.1", optional = true} [dev-dependencies] tokio = { version = "1.0", features = ["full"] } + +[features] +internal-logs = ["tracing"] +default = ["internal-logs"] + +[package.metadata.cargo-machete] +ignored = ["tracing"] diff --git a/opentelemetry-resource-detectors/CHANGELOG.md b/opentelemetry-resource-detectors/CHANGELOG.md index 568afc11..fe5bdaba 100644 --- a/opentelemetry-resource-detectors/CHANGELOG.md +++ b/opentelemetry-resource-detectors/CHANGELOG.md @@ -2,6 +2,13 @@ ## vNext +## v0.6.0 + +### Changed + +- Bump opentelemetry and opentelemetry_sdk versions to 0.27 +- Bump opentelemetry-semantic-conventions version to 0.27 + ## v0.5.0 ### Changed diff --git a/opentelemetry-resource-detectors/Cargo.toml b/opentelemetry-resource-detectors/Cargo.toml index c410beee..78a441ba 100644 --- a/opentelemetry-resource-detectors/Cargo.toml +++ b/opentelemetry-resource-detectors/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "opentelemetry-resource-detectors" -version = "0.5.0" +version = "0.6.0" edition = "2021" description = "A collection of community supported resource detectors for OpenTelemetry" homepage = "https://github.com/open-telemetry/opentelemetry-rust-contrib/tree/main/opentelemetry-resource-detectors" diff --git a/opentelemetry-stackdriver/CHANGELOG.md b/opentelemetry-stackdriver/CHANGELOG.md index 2c1a4fa2..edc597a9 100644 --- a/opentelemetry-stackdriver/CHANGELOG.md +++ b/opentelemetry-stackdriver/CHANGELOG.md @@ -2,6 +2,12 @@ ## vNext +## v0.24.0 + +### Changed + +- Update to opentelemetry v0.27.0, opentelemetry_sdk v0.27.0, opentelemetry-semantic-conventions v0.27.0 + ## v0.23.0 ### Changed diff --git a/opentelemetry-stackdriver/Cargo.toml b/opentelemetry-stackdriver/Cargo.toml index 540c281a..40fd2e47 100644 --- a/opentelemetry-stackdriver/Cargo.toml +++ b/opentelemetry-stackdriver/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "opentelemetry-stackdriver" -version = "0.23.0" +version = "0.24.0" description = "A Rust opentelemetry exporter that uploads traces to Google Stackdriver trace." documentation = "https://docs.rs/opentelemetry-stackdriver/" repository = "https://github.com/open-telemetry/opentelemetry-rust-contrib" @@ -22,6 +22,7 @@ prost-types = "0.13" thiserror = "1.0.30" tonic = { version = "0.12", features = ["gzip", "tls", "transport"] } once_cell = { version = "1.19", optional = true } +tracing = { version = "0.1", optional = true } # Futures futures-core = "0.3" @@ -29,11 +30,12 @@ futures-util = { version = "0.3", default-features = false, features = ["alloc"] futures-channel = { version = "0.3", default-features = false, features = ["std"] } [features] -default = ["gcp-authorizer", "tls-native-roots"] +default = ["gcp-authorizer", "tls-native-roots", "internal-logs"] gcp-authorizer = ["dep:gcp_auth"] tls-native-roots = ["tonic/tls-roots"] tls-webpki-roots = ["tonic/tls-webpki-roots"] propagator = ["once_cell"] +internal-logs = ["tracing"] [dev-dependencies] reqwest = "0.12" @@ -43,3 +45,6 @@ tonic-build = "0.12" walkdir = "2.3.2" futures-util = { version = "0.3", default-features = false } opentelemetry = { workspace = true, features = ["testing"] } + +[package.metadata.cargo-machete] +ignored = ["tracing"] diff --git a/opentelemetry-stackdriver/proto/google/api/client.proto b/opentelemetry-stackdriver/proto/google/api/client.proto index 21157588..6003be53 100644 --- a/opentelemetry-stackdriver/proto/google/api/client.proto +++ b/opentelemetry-stackdriver/proto/google/api/client.proto @@ -124,6 +124,9 @@ message CommonLanguageSettings { // The destination where API teams want this client library to be published. repeated ClientLibraryDestination destinations = 2; + + // Configuration for which RPCs should be generated in the GAPIC client. + SelectiveGapicGeneration selective_gapic_generation = 3; } // Details about how and where to publish client libraries. @@ -272,6 +275,12 @@ message PythonSettings { // This feature will be enabled by default 1 month after launching the // feature in preview packages. bool rest_async_io_enabled = 1; + + // Enables generation of protobuf code using new types that are more + // Pythonic which are included in `protobuf>=5.29.x`. This feature will be + // enabled by default 1 month after launching the feature in preview + // packages. + bool protobuf_pythonic_types_enabled = 2; } // Some settings. @@ -443,3 +452,11 @@ enum ClientLibraryDestination { // Publish the library to package managers like nuget.org and npmjs.com. PACKAGE_MANAGER = 20; } + +// This message is used to configure the generation of a subset of the RPCs in +// a service for client libraries. +message SelectiveGapicGeneration { + // An allowlist of the fully qualified names of RPCs that should be included + // on public client surfaces. + repeated string methods = 1; +} diff --git a/opentelemetry-stackdriver/src/lib.rs b/opentelemetry-stackdriver/src/lib.rs index 054afeee..03cc72a0 100644 --- a/opentelemetry-stackdriver/src/lib.rs +++ b/opentelemetry-stackdriver/src/lib.rs @@ -27,15 +27,12 @@ use async_trait::async_trait; use futures_core::future::BoxFuture; use futures_util::stream::StreamExt; use opentelemetry::{ - global::handle_error, + otel_error, trace::{SpanId, TraceError}, Key, KeyValue, Value, }; use opentelemetry_sdk::{ - export::{ - trace::{ExportResult, SpanData, SpanExporter}, - ExportError, - }, + export::trace::{ExportResult, SpanData, SpanExporter}, Resource, }; use opentelemetry_semantic_conventions as semconv; @@ -379,9 +376,9 @@ where self.pending_count.fetch_sub(1, Ordering::Relaxed); if let Err(e) = self.authorizer.authorize(&mut req, &self.scopes).await { - handle_error(TraceError::from(Error::Authorizer(e.into()))); + otel_error!(name: "ExportAuthorizeError", error = format!("{:?}", TraceError::from(Error::Authorizer(e.into())))); } else if let Err(e) = self.trace_client.batch_write_spans(req).await { - handle_error(TraceError::from(Error::Transport(e.into()))); + otel_error!(name: "ExportTransportError", error = format!("{:?}", TraceError::from(Error::Transport(e.into())))); } let client = match &mut self.log_client { @@ -403,9 +400,9 @@ where }); if let Err(e) = self.authorizer.authorize(&mut req, &self.scopes).await { - handle_error(TraceError::from(Error::from(e))); + otel_error!(name: "ExportAuthorizeError", error = format!("{:?}", TraceError::from(Error::Authorizer(e.into())))); } else if let Err(e) = client.client.write_log_entries(req).await { - handle_error(TraceError::from(Error::Transport(e.into()))); + otel_error!(name: "ExportTransportError", error = format!("{:?}", TraceError::from(Error::Transport(e.into())))); } } } @@ -491,6 +488,7 @@ impl From for AttributeValue { Value::I64(v) => attribute_value::Value::IntValue(v), Value::String(v) => attribute_value::Value::StringValue(to_truncate(v.to_string())), Value::Array(_) => attribute_value::Value::StringValue(to_truncate(v.to_string())), + _ => attribute_value::Value::StringValue(to_truncate("".to_string())), }; AttributeValue { value: Some(new_value), @@ -517,7 +515,7 @@ pub enum Error { Transport(#[source] Box), } -impl ExportError for Error { +impl opentelemetry::trace::ExportError for Error { fn exporter_name(&self) -> &'static str { "stackdriver" } diff --git a/opentelemetry-stackdriver/src/proto/api.rs b/opentelemetry-stackdriver/src/proto/api.rs index f0a744b1..7d5ef1a4 100644 --- a/opentelemetry-stackdriver/src/proto/api.rs +++ b/opentelemetry-stackdriver/src/proto/api.rs @@ -444,6 +444,9 @@ pub struct CommonLanguageSettings { /// The destination where API teams want this client library to be published. #[prost(enumeration = "ClientLibraryDestination", repeated, tag = "2")] pub destinations: ::prost::alloc::vec::Vec, + /// Configuration for which RPCs should be generated in the GAPIC client. + #[prost(message, optional, tag = "3")] + pub selective_gapic_generation: ::core::option::Option, } /// Details about how and where to publish client libraries. #[derive(Clone, PartialEq, ::prost::Message)] @@ -609,6 +612,12 @@ pub mod python_settings { /// feature in preview packages. #[prost(bool, tag = "1")] pub rest_async_io_enabled: bool, + /// Enables generation of protobuf code using new types that are more + /// Pythonic which are included in `protobuf>=5.29.x`. This feature will be + /// enabled by default 1 month after launching the feature in preview + /// packages. + #[prost(bool, tag = "2")] + pub protobuf_pythonic_types_enabled: bool, } } /// Settings for Node client libraries. @@ -743,6 +752,15 @@ pub mod method_settings { pub total_poll_timeout: ::core::option::Option<::prost_types::Duration>, } } +/// This message is used to configure the generation of a subset of the RPCs in +/// a service for client libraries. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SelectiveGapicGeneration { + /// An allowlist of the fully qualified names of RPCs that should be included + /// on public client surfaces. + #[prost(string, repeated, tag = "1")] + pub methods: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} /// The organization for which the client libraries are being published. /// Affects the url where generated docs are published, etc. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] diff --git a/opentelemetry-user-events-logs/CHANGELOG.md b/opentelemetry-user-events-logs/CHANGELOG.md index 6d1ea744..494ba268 100644 --- a/opentelemetry-user-events-logs/CHANGELOG.md +++ b/opentelemetry-user-events-logs/CHANGELOG.md @@ -2,6 +2,12 @@ ## vNext +## v0.8.0 + +### Changed + +- Bump opentelemetry and opentelemetry_sdk versions to 0.27 + ## v0.7.0 ### Changed diff --git a/opentelemetry-user-events-logs/Cargo.toml b/opentelemetry-user-events-logs/Cargo.toml index 23c102ff..6e377e0a 100644 --- a/opentelemetry-user-events-logs/Cargo.toml +++ b/opentelemetry-user-events-logs/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "opentelemetry-user-events-logs" description = "OpenTelemetry-Rust exporter to userevents" -version = "0.7.0" +version = "0.8.0" edition = "2021" homepage = "https://github.com/open-telemetry/opentelemetry-rust-contrib/tree/main/opentelemetry-user-events-logs" repository = "https://github.com/open-telemetry/opentelemetry-rust-contrib/tree/main/opentelemetry-user-events-logs" @@ -26,5 +26,5 @@ tracing-subscriber = { version = "0.3.0", default-features = false, features = [ microbench = "0.5" [features] -logs_level_enabled = ["opentelemetry/logs_level_enabled", "opentelemetry_sdk/logs_level_enabled"] +logs_level_enabled = ["opentelemetry/spec_unstable_logs_enabled", "opentelemetry_sdk/spec_unstable_logs_enabled"] default = ["logs_level_enabled"] diff --git a/opentelemetry-user-events-logs/src/logs/exporter.rs b/opentelemetry-user-events-logs/src/logs/exporter.rs index 75b0c651..ed72daad 100644 --- a/opentelemetry-user-events-logs/src/logs/exporter.rs +++ b/opentelemetry-user-events-logs/src/logs/exporter.rs @@ -167,7 +167,7 @@ impl UserEventsExporter { pub(crate) fn export_log_data( &self, log_record: &opentelemetry_sdk::logs::LogRecord, - instrumentation: &opentelemetry::InstrumentationLibrary, + instrumentation: &opentelemetry::InstrumentationScope, ) -> opentelemetry_sdk::export::logs::ExportResult { let mut level: Level = Level::Invalid; if log_record.severity_number.is_some() { @@ -176,7 +176,7 @@ impl UserEventsExporter { let keyword = self .exporter_config - .get_log_keyword_or_default(instrumentation.name.as_ref()); + .get_log_keyword_or_default(instrumentation.name().as_ref()); if keyword.is_none() { return Ok(()); @@ -194,7 +194,7 @@ impl UserEventsExporter { EBW.with(|eb| { let mut eb = eb.borrow_mut(); let event_tags: u32 = 0; // TBD name and event_tag values - eb.reset(instrumentation.name.as_ref(), event_tags as u16); + eb.reset(instrumentation.name().as_ref(), event_tags as u16); eb.opcode(Opcode::Info); eb.add_value("__csver__", 0x0401u16, FieldFormat::HexInt, 0); @@ -268,6 +268,7 @@ impl UserEventsExporter { AnyValue::Bytes(value) => String::from_utf8_lossy(value).to_string(), AnyValue::ListAny(_value) => "".to_string(), AnyValue::Map(_value) => "".to_string(), + &_ => "".to_string(), }, FieldFormat::Default, 0, @@ -316,7 +317,7 @@ impl opentelemetry_sdk::export::logs::LogExporter for UserEventsExporter { async fn export( &mut self, batch: opentelemetry_sdk::export::logs::LogBatch<'_>, - ) -> opentelemetry::logs::LogResult<()> { + ) -> opentelemetry_sdk::logs::LogResult<()> { for (record, instrumentation) in batch.iter() { let _ = self.export_log_data(record, instrumentation); } diff --git a/opentelemetry-user-events-logs/src/logs/reentrant_logprocessor.rs b/opentelemetry-user-events-logs/src/logs/reentrant_logprocessor.rs index 3cada92a..afa4cc4b 100644 --- a/opentelemetry-user-events-logs/src/logs/reentrant_logprocessor.rs +++ b/opentelemetry-user-events-logs/src/logs/reentrant_logprocessor.rs @@ -1,6 +1,6 @@ use std::fmt::Debug; -use opentelemetry::logs::LogResult; +use opentelemetry_sdk::logs::LogResult; #[cfg(feature = "logs_level_enabled")] use opentelemetry_sdk::export::logs::LogExporter; @@ -29,7 +29,7 @@ impl opentelemetry_sdk::logs::LogProcessor for ReentrantLogProcessor { fn emit( &self, record: &mut opentelemetry_sdk::logs::LogRecord, - instrumentation: &opentelemetry::InstrumentationLibrary, + instrumentation: &opentelemetry::InstrumentationScope, ) { _ = self.event_exporter.export_log_data(record, instrumentation); } diff --git a/opentelemetry-user-events-metrics/Cargo.toml b/opentelemetry-user-events-metrics/Cargo.toml index add80acc..3f17bbc0 100644 --- a/opentelemetry-user-events-metrics/Cargo.toml +++ b/opentelemetry-user-events-metrics/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "opentelemetry-user-events-metrics" -version = "0.7.0" +version = "0.8.0" description = "OpenTelemetry metrics exporter to user events" homepage = "https://github.com/open-telemetry/opentelemetry-rust-contrib/tree/main/opentelemetry-user-events-metrics" repository = "https://github.com/open-telemetry/opentelemetry-rust-contrib/tree/main/opentelemetry-user-events-metrics" @@ -11,12 +11,20 @@ edition = "2021" rust-version = "1.71.1" [dependencies] -opentelemetry = { version = "0.27", features = ["metrics"] } -opentelemetry_sdk = { version = "0.27", features = ["metrics", "rt-tokio"] } -opentelemetry-proto = { version = "0.27", features = ["gen-tonic", "metrics"] } +opentelemetry = { workspace = true, features = ["metrics"] } +opentelemetry_sdk = { workspace = true, features = ["metrics", "rt-tokio"] } +opentelemetry-proto = { workspace = true, features = ["gen-tonic", "metrics"] } eventheader = { version = "= 0.4.0" } async-trait = "0.1" prost = "0.13" +tracing = {version = "0.1", optional = true} [dev-dependencies] tokio = { version = "1.0", features = ["full"] } + +[features] +internal-logs = ["tracing"] +default = ["internal-logs"] + +[package.metadata.cargo-machete] +ignored = ["tracing"] \ No newline at end of file diff --git a/opentelemetry-user-events-metrics/src/tracepoint/mod.rs b/opentelemetry-user-events-metrics/src/tracepoint/mod.rs index 1f41fe68..70fec823 100644 --- a/opentelemetry-user-events-metrics/src/tracepoint/mod.rs +++ b/opentelemetry-user-events-metrics/src/tracepoint/mod.rs @@ -46,7 +46,7 @@ pub fn write(trace_point: &ehi::TracepointState, buffer: &[u8]) -> i32 { } if PROTOBUF_VERSION.len() != 8 { - otel_debug!(name: "TracePointWriteError", reason = "Version must be char[8].", version = PROTOBUF_VERSION); + otel_debug!(name: "TracePointWriteError", reason = "Version must be char[8].", version = format!("{:?}", PROTOBUF_VERSION)); return -1; } diff --git a/opentelemetry-zpages/CHANGELOG.md b/opentelemetry-zpages/CHANGELOG.md index 86216c41..754f2b44 100644 --- a/opentelemetry-zpages/CHANGELOG.md +++ b/opentelemetry-zpages/CHANGELOG.md @@ -2,6 +2,12 @@ ## vNext +## v0.12.0 + +### Changed + +- Bump opentelemetry version to 0.26, opentelemetry_sdk version to 0.27 + ## v0.11.0 ### Changed diff --git a/opentelemetry-zpages/Cargo.toml b/opentelemetry-zpages/Cargo.toml index 7825e905..22db03f9 100644 --- a/opentelemetry-zpages/Cargo.toml +++ b/opentelemetry-zpages/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "opentelemetry-zpages" -version = "0.11.0" +version = "0.12.0" description = "ZPages implementation for OpenTelemetry" homepage = "https://github.com/open-telemetry/opentelemetry-rust-contrib/tree/main/opentelemetry-zpages" repository = "https://github.com/open-telemetry/opentelemetry-rust-contrib/tree/main/opentelemetry-zpages"