Skip to content

Commit 5e447d0

Browse files
authored
chore: Switch from unmaintained hex dependency to const-hex (#3053)
1 parent 8d46c40 commit 5e447d0

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ tonic = { version = "0.13", default-features = false }
4545
tonic-build = "0.13"
4646
tokio = { version = "1", default-features = false }
4747
tokio-stream = "0.1"
48-
# Using `tracing 0.1.40` because 0.1.39 (which is yanked) introduces the ability to set event names in macros,
48+
# Using `tracing 0.1.40` because 0.1.39 (which is yanked) introduces the ability to set event names in macros,
4949
# required for OpenTelemetry's internal logging macros.
5050
tracing = { version = ">=0.1.40", default-features = false }
5151
# `tracing-core >=0.1.33` is required for compatibility with `tracing >=0.1.40`.
52-
tracing-core = { version = ">=0.1.33", default-features = false }
52+
tracing-core = { version = ">=0.1.33", default-features = false }
5353
tracing-subscriber = { version = "0.3", default-features = false }
5454
url = { version = "2.5", default-features = false }
5555
anyhow = "1.0.94"
@@ -59,7 +59,7 @@ ctor = "0.2.9"
5959
ctrlc = "3.2.5"
6060
futures-channel = "0.3"
6161
futures-sink = "0.3"
62-
hex = "0.4.3"
62+
const-hex = "1.14.1"
6363
lazy_static = "1.4.0"
6464
num-format = "0.4.4"
6565
num_cpus = "1.15.0"

opentelemetry-proto/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ testing = ["opentelemetry/testing"]
4949
# add ons
5050
internal-logs = ["opentelemetry/internal-logs"]
5151
with-schemars = ["schemars"]
52-
with-serde = ["serde", "hex", "base64"]
52+
with-serde = ["serde", "const-hex", "base64"]
5353

5454
[dependencies]
5555
tonic = { workspace = true, optional = true, features = ["codegen", "prost"] }
@@ -58,7 +58,7 @@ opentelemetry = { version = "0.30", default-features = false, path = "../opentel
5858
opentelemetry_sdk = { version = "0.30", default-features = false, path = "../opentelemetry-sdk" }
5959
schemars = { workspace = true, optional = true }
6060
serde = { workspace = true, optional = true, features = ["serde_derive"] }
61-
hex = { workspace = true, optional = true }
61+
const-hex = { workspace = true, optional = true }
6262
base64 = { workspace = true, optional = true }
6363

6464
[dev-dependencies]

opentelemetry-proto/src/proto.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(crate) mod serializers {
1616
where
1717
S: Serializer,
1818
{
19-
let hex_string = hex::encode(bytes);
19+
let hex_string = const_hex::encode(bytes);
2020
serializer.serialize_str(&hex_string)
2121
}
2222

@@ -37,7 +37,7 @@ pub(crate) mod serializers {
3737
where
3838
E: de::Error,
3939
{
40-
hex::decode(value).map_err(E::custom)
40+
const_hex::decode(value).map_err(E::custom)
4141
}
4242
}
4343

opentelemetry-proto/tests/json_serde.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ mod json_serde {
6161
dropped_attributes_count: 0,
6262
}),
6363
spans: vec![Span {
64-
trace_id: hex::decode("5b8efff798038103d269b633813fc60c").unwrap(),
65-
span_id: hex::decode("eee19b7ec3c1b174").unwrap(),
64+
trace_id: const_hex::decode("5b8efff798038103d269b633813fc60c")
65+
.unwrap(),
66+
span_id: const_hex::decode("eee19b7ec3c1b174").unwrap(),
6667
trace_state: String::new(),
67-
parent_span_id: hex::decode("eee19b7ec3c1b173").unwrap(),
68+
parent_span_id: const_hex::decode("eee19b7ec3c1b173").unwrap(),
6869
flags: 0,
6970
name: String::from("I'm a server span"),
7071
kind: 2,
@@ -267,10 +268,11 @@ mod json_serde {
267268
dropped_attributes_count: 1,
268269
}),
269270
spans: vec![Span {
270-
trace_id: hex::decode("5b8efff798038103d269b633813fc60c").unwrap(),
271-
span_id: hex::decode("eee19b7ec3c1b174").unwrap(),
271+
trace_id: const_hex::decode("5b8efff798038103d269b633813fc60c")
272+
.unwrap(),
273+
span_id: const_hex::decode("eee19b7ec3c1b174").unwrap(),
272274
trace_state: String::from("browser=firefox,os=linux"),
273-
parent_span_id: hex::decode("eee19b7ec3c1b173").unwrap(),
275+
parent_span_id: const_hex::decode("eee19b7ec3c1b173").unwrap(),
274276
flags: 1,
275277
name: String::from("I'm a server span"),
276278
kind: 2,
@@ -308,9 +310,9 @@ mod json_serde {
308310
}],
309311
dropped_events_count: 1,
310312
links: vec![Link {
311-
trace_id: hex::decode("5b8efff798038103d269b633813fc60b")
313+
trace_id: const_hex::decode("5b8efff798038103d269b633813fc60b")
312314
.unwrap(),
313-
span_id: hex::decode("eee19b7ec3c1b172").unwrap(),
315+
span_id: const_hex::decode("eee19b7ec3c1b172").unwrap(),
314316
trace_state: String::from("food=pizza,color=red"),
315317
attributes: vec![KeyValue {
316318
key: String::from("my.link.attr"),
@@ -1272,8 +1274,9 @@ mod json_serde {
12721274
],
12731275
dropped_attributes_count: 0,
12741276
flags: 0,
1275-
trace_id: hex::decode("5b8efff798038103d269b633813fc60c").unwrap(),
1276-
span_id: hex::decode("eee19b7ec3c1b174").unwrap(),
1277+
trace_id: const_hex::decode("5b8efff798038103d269b633813fc60c")
1278+
.unwrap(),
1279+
span_id: const_hex::decode("eee19b7ec3c1b174").unwrap(),
12771280
}],
12781281
schema_url: String::new(),
12791282
}],

0 commit comments

Comments
 (0)