Skip to content

Commit

Permalink
chore(dependencies): update opentelemetry to latest version
Browse files Browse the repository at this point in the history
Signed-off-by: Dotan Simha <[email protected]>
  • Loading branch information
dotansimha committed Jan 24, 2024
1 parent 13cd1cc commit 72564c6
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 46 deletions.
5 changes: 3 additions & 2 deletions minitrace-opentelemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ keywords = ["tracing", "span", "datadog", "jaeger", "opentelemetry"]
futures = { version = "0.3", features = ["executor"] }
log = "0.4"
minitrace = { version = "0.6.2", path = "../minitrace" }
opentelemetry = { version = "0.20", features = ["trace"] }
opentelemetry = { version = "0.21", features = ["trace"] }
opentelemetry_sdk = { version = "0.21", features = ["trace"] }

[dev-dependencies]
opentelemetry-otlp = { version = "0.13", features = ["trace"] }
opentelemetry-otlp = { version = "0.14", features = ["trace"] }
rand = "0.8"
tokio = { version = "1", features = ["rt-multi-thread"] }
21 changes: 11 additions & 10 deletions minitrace-opentelemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,22 @@ use minitrace::prelude::*;
use minitrace_opentelemetry::OpenTelemetryReporter;
use opentelemetry_otlp::{SpanExporter, ExportConfig, Protocol, TonicConfig};
use opentelemetry::trace::SpanKind;
use opentelemetry::sdk::Resource;
use opentelemetry_sdk::Resource;
use opentelemetry::KeyValue;
use opentelemetry::InstrumentationLibrary;
use opentelemetry_otlp::WithExportConfig;
// Initialize reporter
let reporter = OpenTelemetryReporter::new(
SpanExporter::new_tonic(
ExportConfig {
endpoint: "http://127.0.0.1:4317".to_string(),
protocol: Protocol::Grpc,
timeout: Duration::from_secs(opentelemetry_otlp::OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT),
},
TonicConfig::default(),
)
.unwrap(),
opentelemetry_otlp::new_exporter()
.tonic()
.with_endpoint("http://127.0.0.1:4317".to_string())
.with_protocol(opentelemetry_otlp::Protocol::Grpc)
.with_timeout(Duration::from_secs(
opentelemetry_otlp::OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT,
))
.build_span_exporter()
.expect("initialize oltp exporter"),
SpanKind::Server,
Cow::Owned(Resource::new([KeyValue::new("service.name", "asynchronous")])),
InstrumentationLibrary::new("example-crate", Some(env!("CARGO_PKG_VERSION")), None::<&'static str>, None),
Expand Down
16 changes: 8 additions & 8 deletions minitrace-opentelemetry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ use std::time::UNIX_EPOCH;
use minitrace::collector::EventRecord;
use minitrace::collector::Reporter;
use minitrace::prelude::*;
use opentelemetry::sdk::export::trace::SpanData;
use opentelemetry::sdk::export::trace::SpanExporter;
use opentelemetry::sdk::trace::EvictedHashMap;
use opentelemetry::sdk::trace::EvictedQueue;
use opentelemetry::sdk::Resource;
use opentelemetry::trace::Event;
use opentelemetry::trace::SpanContext;
use opentelemetry::trace::SpanKind;
Expand All @@ -25,6 +20,10 @@ use opentelemetry::Key;
use opentelemetry::KeyValue;
use opentelemetry::StringValue;
use opentelemetry::Value;
use opentelemetry_sdk::export::trace::SpanData;
use opentelemetry_sdk::export::trace::SpanExporter;
use opentelemetry_sdk::trace::EvictedQueue;
use opentelemetry_sdk::Resource;

/// [OpenTelemetry](https://github.com/open-telemetry/opentelemetry-rust) reporter for `minitrace`.
///
Expand Down Expand Up @@ -63,6 +62,7 @@ impl OpenTelemetryReporter {
false,
TraceState::default(),
),
dropped_attributes_count: 0,
parent_span_id: span.parent_id.0.into(),
name: span.name.clone(),
start_time: UNIX_EPOCH + Duration::from_nanos(span.begin_time_unix_ns),
Expand All @@ -79,10 +79,10 @@ impl OpenTelemetryReporter {
.collect()
}

fn convert_properties(properties: &[(Cow<'static, str>, Cow<'static, str>)]) -> EvictedHashMap {
let mut map = EvictedHashMap::new(u32::MAX, properties.len());
fn convert_properties(properties: &[(Cow<'static, str>, Cow<'static, str>)]) -> Vec<KeyValue> {
let mut map = Vec::new();
for (k, v) in properties {
map.insert(KeyValue::new(
map.push(KeyValue::new(
cow_to_otel_key(k.clone()),
cow_to_otel_value(v.clone()),
));
Expand Down
5 changes: 3 additions & 2 deletions minitrace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ minitrace-jaeger = { version = "0.6.2", path = "../minitrace-jaeger" }
minitrace-opentelemetry = { version = "0.6.2", path = "../minitrace-opentelemetry" }
mockall = "0.11"
once_cell = "1"
opentelemetry = { version = "0.20", features = ["trace"] }
opentelemetry-otlp = { version = "0.13", features = ["trace"] }
opentelemetry = { version = "0.21", features = ["trace"] }
opentelemetry-otlp = { version = "0.14", features = ["trace"] }
opentelemetry_sdk = { version = "0.21" }
rand = "0.8"
rustracing = "0.6"
serial_test = "2"
Expand Down
23 changes: 11 additions & 12 deletions minitrace/examples/asynchronous.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::time::Duration;
use minitrace::collector::Config;
use minitrace::collector::Reporter;
use minitrace::prelude::*;
use opentelemetry_otlp::WithExportConfig;

fn parallel_job() -> Vec<tokio::task::JoinHandle<()>> {
let mut v = Vec::with_capacity(4);
Expand Down Expand Up @@ -85,19 +86,17 @@ impl ReportAll {
"select",
),
opentelemetry: minitrace_opentelemetry::OpenTelemetryReporter::new(
opentelemetry_otlp::SpanExporter::new_tonic(
opentelemetry_otlp::ExportConfig {
endpoint: "http://127.0.0.1:4317".to_string(),
protocol: opentelemetry_otlp::Protocol::Grpc,
timeout: Duration::from_secs(
opentelemetry_otlp::OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT,
),
},
opentelemetry_otlp::TonicConfig::default(),
)
.expect("initialize oltp exporter"),
opentelemetry_otlp::new_exporter()
.tonic()
.with_endpoint("http://127.0.0.1:4317".to_string())
.with_protocol(opentelemetry_otlp::Protocol::Grpc)
.with_timeout(Duration::from_secs(
opentelemetry_otlp::OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT,
))
.build_span_exporter()
.expect("initialize oltp exporter"),
opentelemetry::trace::SpanKind::Server,
Cow::Owned(opentelemetry::sdk::Resource::new([
Cow::Owned(opentelemetry_sdk::Resource::new([
opentelemetry::KeyValue::new("service.name", "asynchronous(opentelemetry)"),
])),
opentelemetry::InstrumentationLibrary::new(
Expand Down
23 changes: 11 additions & 12 deletions minitrace/examples/synchronous.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::time::Duration;
use minitrace::collector::Config;
use minitrace::collector::Reporter;
use minitrace::prelude::*;
use opentelemetry_otlp::WithExportConfig;

fn func1(i: u64) {
let _guard = LocalSpan::enter_with_local_parent("func1");
Expand Down Expand Up @@ -61,19 +62,17 @@ impl ReportAll {
"select",
),
opentelemetry: minitrace_opentelemetry::OpenTelemetryReporter::new(
opentelemetry_otlp::SpanExporter::new_tonic(
opentelemetry_otlp::ExportConfig {
endpoint: "http://127.0.0.1:4317".to_string(),
protocol: opentelemetry_otlp::Protocol::Grpc,
timeout: Duration::from_secs(
opentelemetry_otlp::OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT,
),
},
opentelemetry_otlp::TonicConfig::default(),
)
.expect("initialize oltp exporter"),
opentelemetry_otlp::new_exporter()
.tonic()
.with_endpoint("http://127.0.0.1:4317".to_string())
.with_protocol(opentelemetry_otlp::Protocol::Grpc)
.with_timeout(Duration::from_secs(
opentelemetry_otlp::OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT,
))
.build_span_exporter()
.expect("initialize oltp exporter"),
opentelemetry::trace::SpanKind::Server,
Cow::Owned(opentelemetry::sdk::Resource::new([
Cow::Owned(opentelemetry_sdk::Resource::new([
opentelemetry::KeyValue::new("service.name", "synchronous(opentelemetry)"),
])),
opentelemetry::InstrumentationLibrary::new(
Expand Down

0 comments on commit 72564c6

Please sign in to comment.