Skip to content

Commit

Permalink
Use HashMap instead of IndexMap in LogRecord (#1353)
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas committed Nov 9, 2023
1 parent 74d294c commit 1546440
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 683 deletions.
15 changes: 15 additions & 0 deletions opentelemetry/CHANGELOG.md
Expand Up @@ -2,6 +2,21 @@

## vNext

### Changed

Modified `AnyValue.Map` to be backed by `HashMap` instead of custom `OrderMap`,
which internally used `IndexMap`. There was no requirement to maintain the order
of entries, so moving from `IndexMap` to `HashMap` offers slight performance
gains, and avoids `IndexMap` dependency. This affects `body` and `attributes` of
`LogRecord`.
[#1353](https://github.com/open-telemetry/opentelemetry-rust/pull/1353)

### Removed

Removed `OrderMap` type as there was no requirement to use this over regular
`HashMap`.
[#1353](https://github.com/open-telemetry/opentelemetry-rust/pull/1353)

## [v0.21.0](https://github.com/open-telemetry/opentelemetry-rust/compare/v0.20.0...v0.21.0)

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.
Expand Down
1 change: 0 additions & 1 deletion opentelemetry/Cargo.toml
Expand Up @@ -23,7 +23,6 @@ rustdoc-args = ["--cfg", "docsrs"]
[dependencies]
futures-core = "0.3"
futures-sink = "0.3"
indexmap = "2.0"
once_cell = "1.12.0"
pin-project-lite = { version = "0.2", optional = true }
thiserror = "1.0.7"
Expand Down
4 changes: 0 additions & 4 deletions opentelemetry/src/lib.rs
Expand Up @@ -212,10 +212,6 @@ pub use context::{Context, ContextGuard};

mod common;

mod order_map;

pub use order_map::OrderMap;

#[cfg(any(feature = "testing", test))]
#[doc(hidden)]
pub mod testing;
Expand Down
8 changes: 4 additions & 4 deletions opentelemetry/src/logs/record.rs
@@ -1,8 +1,8 @@
use crate::{
trace::{SpanContext, SpanId, TraceContextExt, TraceFlags, TraceId},
Array, Key, OrderMap, StringValue, Value,
Array, Key, StringValue, Value,
};
use std::{borrow::Cow, time::SystemTime};
use std::{borrow::Cow, collections::HashMap, time::SystemTime};

#[derive(Debug, Clone)]
#[non_exhaustive]
Expand Down Expand Up @@ -90,7 +90,7 @@ pub enum AnyValue {
/// An array of `Any` values
ListAny(Vec<AnyValue>),
/// A map of string keys to `Any` values, arbitrarily nested.
Map(OrderMap<Key, AnyValue>),
Map(HashMap<Key, AnyValue>),
}

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

0 comments on commit 1546440

Please sign in to comment.