Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Able to update OTEL deps to latest even actix-web-opentelemetry using previous OTEL version #1122

Open
helio-frota opened this issue Jan 2, 2025 · 0 comments · May be fixed by #1123
Open
Assignees

Comments

@helio-frota
Copy link
Collaborator

helio-frota commented Jan 2, 2025

During this investigation I noticed that we can update OTEL deps without ending up with a broken build.

Previous commit-comment

git diff ':!*.lock'
diff --git a/Cargo.toml b/Cargo.toml
index 2e75ae2..058cc3a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,19 +13,19 @@ actix-web = "4.3.1"
 actix-web-extras = "0.1"
 actix-web-httpauth = "0.8"
 actix-web-opentelemetry = "0.19"
-actix-web-prom = "0.8.0"
+actix-web-prom = "0.9.0"
 actix-web-static-files = "4.0.1"
 env_logger = "0.11.0"
 log = "0.4.19"

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

 tokio = "1.30.0"
-tokio-stream = "0.1.15"
+tokio-stream = "0.1.17"
 tokio-util = "0.7"
 tracing = "0.1"
 tracing-bunyan-formatter = "0.3.7"
-tracing-opentelemetry = "0.25"
+tracing-opentelemetry = "0.28"
 tracing-subscriber = { version = "0.3.19", default-features = false, features = ["env-filter", "ansi"] }
diff --git a/src/otel.rs b/src/otel.rs
index 63d8a63..e78d920 100644
--- a/src/otel.rs
+++ b/src/otel.rs
@@ -1,7 +1,8 @@
 use opentelemetry::{trace::TracerProvider, KeyValue};

-use opentelemetry_otlp::WithExportConfig;
-use opentelemetry_sdk::Resource;
+use opentelemetry_otlp::{SpanExporter, WithExportConfig};
+// use opentelemetry_otlp::WithExportConfig;
+use opentelemetry_sdk::{trace as sdktrace, Resource};
 use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};

 pub fn init_otlp(name: &str) {
@@ -10,25 +11,45 @@ pub fn init_otlp(name: &str) {
     );

     #[allow(clippy::expect_used)]
-    let provider = opentelemetry_otlp::new_pipeline()
-        .tracing()
-        .with_trace_config(
-            opentelemetry_sdk::trace::Config::default()
-                .with_resource(Resource::new(vec![KeyValue::new(
-                    "service.name",
-                    name.to_string(),
-                )]))
-                .with_sampler(opentelemetry_sdk::trace::Sampler::ParentBased(Box::new(
-                    sampler(),
-                ))),
-        )
-        .with_exporter(
-            opentelemetry_otlp::new_exporter().tonic(), // .with_endpoint("http://jaeger.192.168.39.78.nip.io:4317"),
-                                                        // .with_endpoint("http://0.0.0.0:4317"),
-                                                        //.with_endpoint("http://jaeger:4317"),
-        )
-        .install_batch(opentelemetry_sdk::runtime::Tokio)
-        .expect("unable to setup tracing pipeline");
+    let exporter = SpanExporter::builder()
+        .with_tonic()
+        .with_endpoint("http://infra-jaeger-collector:4317")
+        .build()
+        .expect("unable to setup exporter");
+
+    #[allow(clippy::expect_used)]
+    let provider = sdktrace::TracerProvider::builder()
+        .with_resource(Resource::new(vec![KeyValue::new(
+            "service.name",
+            name.to_string(),
+        )]))
+        .with_batch_exporter(exporter, opentelemetry_sdk::runtime::Tokio)
+        .with_sampler(opentelemetry_sdk::trace::Sampler::ParentBased(Box::new(
+            sampler(),
+        )))
+        .build();
+
+    // let provider = opentelemetry_otlp::new_pipeline()
+    //     .tracing()
+    //     .with_trace_config(
+    //         opentelemetry_sdk::trace::Config::default()
+    //             .with_resource(Resource::new(vec![KeyValue::new(
+    //                 "service.name",
+    //                 name.to_string(),
+    //             )]))
+    //             .with_sampler(opentelemetry_sdk::trace::Sampler::ParentBased(Box::new(
+    //                 sampler(),
+    //             ))),
+    //     )
+    //     .with_exporter(
+    //         opentelemetry_otlp::new_exporter()
+    //             .tonic()
+    //             .with_endpoint("http://jaeger.192.168.39.78.nip.io"),
+    //         // .with_endpoint("http://0.0.0.0:4317"),
+    //         //.with_endpoint("http://jaeger:4317"),
+    //     )
+    //     .install_batch(opentelemetry_sdk::runtime::Tokio)
+    //     .expect("unable to setup tracing pipeline");
@helio-frota helio-frota changed the title Able to update OTEL deps to latest on the extracted example even not updating actix-web-opentelemetry Able to update OTEL deps to latest even not updating actix-web-opentelemetry Jan 2, 2025
@helio-frota helio-frota linked a pull request Jan 3, 2025 that will close this issue
@helio-frota helio-frota self-assigned this Jan 3, 2025
@helio-frota helio-frota changed the title Able to update OTEL deps to latest even not updating actix-web-opentelemetry Able to update OTEL deps to latest even actix-web-opentelemetry using previous OTEL version Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant