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

Use HashMap instead of IndexMap in LogRecord #1353

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions opentelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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 @@
/// 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 @@
/// 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(

Check warning on line 136 in opentelemetry/src/logs/record.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry/src/logs/record.rs#L136

Added line #L136 was not covered by tests
iter.into_iter().map(|(k, v)| (k.into(), v.into())),
))
}
Expand Down
Loading
Loading