Skip to content

Commit

Permalink
update opentelemtry dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
lennart-k committed Dec 21, 2024
1 parent 9ca941b commit b6f58f2
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 58 deletions.
85 changes: 53 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ tokio = { version = "1", features = [
] }
url = "2.5"
base64 = "0.22"
thiserror = "1.0"
thiserror = "2.0"
quick-xml = { version = "0.37", features = [
"serde",
"serde-types",
Expand Down Expand Up @@ -114,12 +114,12 @@ sqlx = { workspace = true }
async-trait = { workspace = true }
tracing-actix-web = { workspace = true }

opentelemetry = "0.26"
opentelemetry-otlp = "0.26"
opentelemetry_sdk = { version = "0.26", features = ["rt-tokio"] }
opentelemetry = "0.27"
opentelemetry-otlp = "0.27"
opentelemetry_sdk = { version = "0.27", features = ["rt-tokio"] }

opentelemetry-semantic-conventions = "0.26"
tracing-opentelemetry = "0.27"
opentelemetry-semantic-conventions = "0.27"
tracing-opentelemetry = "0.28"
tracing-subscriber = { version = "0.3", features = [
"env-filter",
"fmt",
Expand Down
37 changes: 17 additions & 20 deletions src/setup_tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use opentelemetry::trace::TracerProvider;
use opentelemetry::KeyValue;
use opentelemetry_otlp::WithExportConfig;
use opentelemetry_sdk::propagation::TraceContextPropagator;
use opentelemetry_sdk::trace::{self, BatchConfig, Tracer};
use opentelemetry_sdk::{runtime, Resource};
use opentelemetry_sdk::trace::Tracer;
use opentelemetry_sdk::Resource;
use opentelemetry_semantic_conventions::resource::{SERVICE_NAME, SERVICE_VERSION};
use opentelemetry_semantic_conventions::SCHEMA_URL;
use std::time::Duration;
Expand All @@ -16,25 +16,22 @@ use tracing_subscriber::util::SubscriberInitExt;
use tracing_subscriber::EnvFilter;

pub fn init_tracer() -> Tracer {
let otel_exporter = opentelemetry_otlp::new_exporter()
.tonic()
.with_timeout(Duration::from_secs(1));
let otel_exporter = opentelemetry_otlp::SpanExporter::builder()
.with_tonic()
.with_timeout(Duration::from_secs(1))
.build()
.unwrap();

let tracer_provider = opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(otel_exporter)
.with_trace_config(
trace::Config::default().with_resource(Resource::from_schema_url(
[
KeyValue::new(SERVICE_NAME, env!("CARGO_PKG_NAME")),
KeyValue::new(SERVICE_VERSION, env!("CARGO_PKG_VERSION")),
],
SCHEMA_URL,
)),
)
.with_batch_config(BatchConfig::default())
.install_batch(runtime::Tokio)
.expect("Failed to install tracer");
let tracer_provider = opentelemetry_sdk::trace::TracerProvider::builder()
.with_batch_exporter(otel_exporter, opentelemetry_sdk::runtime::Tokio)
.with_resource(Resource::from_schema_url(
[
KeyValue::new(SERVICE_NAME, env!("CARGO_PKG_NAME")),
KeyValue::new(SERVICE_VERSION, env!("CARGO_PKG_VERSION")),
],
SCHEMA_URL,
))
.build();

global::set_tracer_provider(tracer_provider.clone());
tracer_provider.tracer("rustical")
Expand Down

0 comments on commit b6f58f2

Please sign in to comment.