Skip to content

Commit 1546440

Browse files
authored
Use HashMap instead of IndexMap in LogRecord (#1353)
1 parent 74d294c commit 1546440

File tree

6 files changed

+19
-683
lines changed

6 files changed

+19
-683
lines changed

opentelemetry/CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

33
## vNext
44

5+
### Changed
6+
7+
Modified `AnyValue.Map` to be backed by `HashMap` instead of custom `OrderMap`,
8+
which internally used `IndexMap`. There was no requirement to maintain the order
9+
of entries, so moving from `IndexMap` to `HashMap` offers slight performance
10+
gains, and avoids `IndexMap` dependency. This affects `body` and `attributes` of
11+
`LogRecord`.
12+
[#1353](https://github.com/open-telemetry/opentelemetry-rust/pull/1353)
13+
14+
### Removed
15+
16+
Removed `OrderMap` type as there was no requirement to use this over regular
17+
`HashMap`.
18+
[#1353](https://github.com/open-telemetry/opentelemetry-rust/pull/1353)
19+
520
## [v0.21.0](https://github.com/open-telemetry/opentelemetry-rust/compare/v0.20.0...v0.21.0)
621

722
This release should been seen as 1.0-rc4 following 1.0-rc3 in v0.20.0. Refer to CHANGELOG.md in individual creates for details on changes made in different creates.

opentelemetry/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ rustdoc-args = ["--cfg", "docsrs"]
2323
[dependencies]
2424
futures-core = "0.3"
2525
futures-sink = "0.3"
26-
indexmap = "2.0"
2726
once_cell = "1.12.0"
2827
pin-project-lite = { version = "0.2", optional = true }
2928
thiserror = "1.0.7"

opentelemetry/src/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,6 @@ pub use context::{Context, ContextGuard};
212212

213213
mod common;
214214

215-
mod order_map;
216-
217-
pub use order_map::OrderMap;
218-
219215
#[cfg(any(feature = "testing", test))]
220216
#[doc(hidden)]
221217
pub mod testing;

opentelemetry/src/logs/record.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::{
22
trace::{SpanContext, SpanId, TraceContextExt, TraceFlags, TraceId},
3-
Array, Key, OrderMap, StringValue, Value,
3+
Array, Key, StringValue, Value,
44
};
5-
use std::{borrow::Cow, time::SystemTime};
5+
use std::{borrow::Cow, collections::HashMap, time::SystemTime};
66

77
#[derive(Debug, Clone)]
88
#[non_exhaustive]
@@ -90,7 +90,7 @@ pub enum AnyValue {
9090
/// An array of `Any` values
9191
ListAny(Vec<AnyValue>),
9292
/// A map of string keys to `Any` values, arbitrarily nested.
93-
Map(OrderMap<Key, AnyValue>),
93+
Map(HashMap<Key, AnyValue>),
9494
}
9595

9696
macro_rules! impl_trivial_from {
@@ -133,7 +133,7 @@ impl<K: Into<Key>, V: Into<AnyValue>> FromIterator<(K, V)> for AnyValue {
133133
/// Creates an [`AnyValue::Map`] value from a sequence of key-value pairs
134134
/// that can be converted into a `Key` and `AnyValue` respectively.
135135
fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self {
136-
AnyValue::Map(OrderMap::from_iter(
136+
AnyValue::Map(HashMap::from_iter(
137137
iter.into_iter().map(|(k, v)| (k.into(), v.into())),
138138
))
139139
}

0 commit comments

Comments
 (0)