Skip to content

Commit

Permalink
Merge branch 'main' into enable-enabled-tracing-appender
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb authored Nov 27, 2024
2 parents 376e2bb + 1cb39ed commit 2034c32
Show file tree
Hide file tree
Showing 35 changed files with 200 additions and 78 deletions.
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
4 changes: 4 additions & 0 deletions opentelemetry-aws/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## vNext

## v0.15.0

- Bump opentelemetry and opentelemetry_sdk versions to 0.27.0

## v0.14.0

### Changed
Expand Down
10 changes: 8 additions & 2 deletions opentelemetry-aws/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"] }
Expand All @@ -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"]

4 changes: 2 additions & 2 deletions opentelemetry-aws/src/trace/xray_propagator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -139,7 +139,7 @@ pub fn span_context_from_str(value: &str) -> Option<SpanContext> {
))
}
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
}
}
Expand Down
5 changes: 5 additions & 0 deletions opentelemetry-contrib/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-contrib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 4 additions & 2 deletions opentelemetry-contrib/src/trace/exporter/jaeger_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -52,11 +53,11 @@ impl<R: JaegerJsonRuntime> JaegerJsonExporter<R> {
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
Expand Down Expand Up @@ -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())),
}
}

Expand Down
7 changes: 7 additions & 0 deletions opentelemetry-datadog/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-datadog/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-datadog/benches/datadog_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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,
}
}

Expand Down
6 changes: 5 additions & 1 deletion opentelemetry-datadog/src/exporter/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand All @@ -36,7 +36,9 @@ impl<'a> Hash for InternValue<'a> {
}
}
opentelemetry::Array::String(x) => x.hash(state),
&_ => {}
},
&_ => {}
},
}
}
Expand Down Expand Up @@ -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),
},
}
}
Expand Down
36 changes: 20 additions & 16 deletions opentelemetry-datadog/src/exporter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down Expand Up @@ -459,6 +457,12 @@ fn mapping_debug(f: &Option<FieldMapping>) -> String {
.to_string()
}

impl opentelemetry::trace::ExportError for model::Error {
fn exporter_name(&self) -> &'static str {
"DatadogExporter"
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
8 changes: 4 additions & 4 deletions opentelemetry-datadog/src/exporter/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -198,14 +198,14 @@ impl ApiVersion {
#[cfg(test)]
pub(crate) mod tests {
use super::*;
use opentelemetry::InstrumentationScope;
use opentelemetry::{
trace::{SpanContext, SpanId, SpanKind, Status, TraceFlags, TraceId, TraceState},
KeyValue,
};
use opentelemetry_sdk::{
self,
trace::{SpanEvents, SpanLinks},
InstrumentationLibrary,
};
use std::time::{Duration, SystemTime};

Expand All @@ -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,
Expand All @@ -242,7 +242,7 @@ pub(crate) mod tests {
events,
links,
status: Status::Ok,
instrumentation_lib,
instrumentation_scope,
}
}

Expand Down
6 changes: 6 additions & 0 deletions opentelemetry-etw-logs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## vNext

## v0.6.0

### Changed

- Bump opentelemetry and opentelemetry_sdk versions to 0.27

## v0.5.0

### Changed
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-etw-logs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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"]

Expand Down
1 change: 1 addition & 0 deletions opentelemetry-etw-logs/src/logs/converters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions opentelemetry-etw-logs/src/logs/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(()),
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -401,6 +401,7 @@ fn add_attribute_to_event(event: &mut tld::EventBuilder, key: &Key, value: &AnyV
0,
);
}
&_ => {}
}
}

Expand Down
Loading

0 comments on commit 2034c32

Please sign in to comment.