Skip to content

Commit 3278de6

Browse files
authored
chore: update Datadog to otel 0.26 (#120)
1 parent dc6492d commit 3278de6

File tree

3 files changed

+48
-18
lines changed

3 files changed

+48
-18
lines changed

opentelemetry-datadog/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ intern-std = []
2727
[dependencies]
2828
indexmap = "2.0"
2929
once_cell = "1.12"
30-
opentelemetry = { version = "0.24", features = ["trace"] }
31-
opentelemetry_sdk = { version = "0.24", features = ["trace"] }
32-
opentelemetry-http = { version = "0.13" }
30+
opentelemetry = { workspace = true }
31+
opentelemetry_sdk = { workspace = true, features = ["trace"] }
32+
opentelemetry-http = { workspace = true }
3333
opentelemetry-semantic-conventions = { workspace = true }
3434
rmp = "0.8"
3535
url = "2.2"
@@ -48,7 +48,7 @@ async-trait = "0.1"
4848
base64 = "0.13"
4949
bytes = "1"
5050
futures-util = { version = "0.3", default-features = false, features = ["io"] }
51-
opentelemetry_sdk = { version = "0.24", features = ["trace", "testing"] }
51+
opentelemetry_sdk = { workspace = true, features = ["trace", "testing"] }
5252
criterion = "0.5"
5353
rand = "0.8"
5454
hyper = "1"

opentelemetry-datadog/examples/agent_sampling.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use opentelemetry::{
22
global::{self, shutdown_tracer_provider},
33
trace::{SamplingResult, Span, TraceContextExt, Tracer},
4-
Key,
4+
Key, KeyValue, Value,
55
};
66
use opentelemetry_datadog::{new_pipeline, ApiVersion, DatadogTraceStateBuilder};
77
use opentelemetry_sdk::trace::{self, RandomIdGenerator, ShouldSample};
@@ -11,8 +11,14 @@ use std::time::Duration;
1111
fn bar() {
1212
let tracer = global::tracer("component-bar");
1313
let mut span = tracer.start("bar");
14-
span.set_attribute(Key::new("span.type").string("sql"));
15-
span.set_attribute(Key::new("sql.query").string("SELECT * FROM table"));
14+
span.set_attribute(KeyValue::new(
15+
Key::new("span.type"),
16+
Value::String("sql".into()),
17+
));
18+
span.set_attribute(KeyValue::new(
19+
Key::new("sql.query"),
20+
Value::String("SELECT * FROM table".into()),
21+
));
1622
thread::sleep(Duration::from_millis(6));
1723
span.end()
1824
}
@@ -62,10 +68,19 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
6268

6369
tracer.in_span("foo", |cx| {
6470
let span = cx.span();
65-
span.set_attribute(Key::new("span.type").string("web"));
66-
span.set_attribute(Key::new("http.url").string("http://localhost:8080/foo"));
67-
span.set_attribute(Key::new("http.method").string("GET"));
68-
span.set_attribute(Key::new("http.status_code").i64(200));
71+
span.set_attribute(KeyValue::new(
72+
Key::new("span.type"),
73+
Value::String("web".into()),
74+
));
75+
span.set_attribute(KeyValue::new(
76+
Key::new("http.url"),
77+
Value::String("http://localhost:8080/foo".into()),
78+
));
79+
span.set_attribute(KeyValue::new(
80+
Key::new("http.method"),
81+
Value::String("GET".into()),
82+
));
83+
span.set_attribute(KeyValue::new(Key::new("http.status_code"), Value::I64(200)));
6984

7085
thread::sleep(Duration::from_millis(6));
7186
bar();

opentelemetry-datadog/examples/datadog.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use opentelemetry::{
22
global::{self, shutdown_tracer_provider},
33
trace::{Span, TraceContextExt, Tracer},
4-
Key,
4+
Key, KeyValue, Value,
55
};
66
use opentelemetry_datadog::{new_pipeline, ApiVersion};
77
use std::thread;
@@ -10,8 +10,14 @@ use std::time::Duration;
1010
fn bar() {
1111
let tracer = global::tracer("component-bar");
1212
let mut span = tracer.start("bar");
13-
span.set_attribute(Key::new("span.type").string("sql"));
14-
span.set_attribute(Key::new("sql.query").string("SELECT * FROM table"));
13+
span.set_attribute(KeyValue::new(
14+
Key::new("span.type"),
15+
Value::String("sql".into()),
16+
));
17+
span.set_attribute(KeyValue::new(
18+
Key::new("sql.query"),
19+
Value::String("SELECT * FROM table".into()),
20+
));
1521
thread::sleep(Duration::from_millis(6));
1622
span.end()
1723
}
@@ -24,10 +30,19 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
2430

2531
tracer.in_span("foo", |cx| {
2632
let span = cx.span();
27-
span.set_attribute(Key::new("span.type").string("web"));
28-
span.set_attribute(Key::new("http.url").string("http://localhost:8080/foo"));
29-
span.set_attribute(Key::new("http.method").string("GET"));
30-
span.set_attribute(Key::new("http.status_code").i64(200));
33+
span.set_attribute(KeyValue::new(
34+
Key::new("span.type"),
35+
Value::String("web".into()),
36+
));
37+
span.set_attribute(KeyValue::new(
38+
Key::new("http.url"),
39+
Value::String("http://localhost:8080/foo".into()),
40+
));
41+
span.set_attribute(KeyValue::new(
42+
Key::new("http.method"),
43+
Value::String("GET".into()),
44+
));
45+
span.set_attribute(KeyValue::new(Key::new("http.status_code"), Value::I64(200)));
3146

3247
thread::sleep(Duration::from_millis(6));
3348
bar();

0 commit comments

Comments
 (0)