Skip to content

Commit

Permalink
Allow O(1) get operations for SpanBuilder::attributes [breaking] (#799)
Browse files Browse the repository at this point in the history
* Use index_map::IndexMap instead of Vec<KeyValue> to store SpanBuilder's attributes.

* Test suite compiles.

* Rustfmt

* Wrap IndexMap to expose only the methods that are insertion-order preserving.

* Raise MSRV to 1.51 to get support for const generics.

* Fix doctest.

* Fix lint.

* Add specialised implementations to make it easier to work with KeyValue iterators/collections.

* Bump MSRV to get access to array::map.

* Minimise breakages for existing users.

* Fix invocation.

* Rustfmt
  • Loading branch information
Luca Palmieri authored May 21, 2022
1 parent 7534891 commit a767fd3
Show file tree
Hide file tree
Showing 8 changed files with 714 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.49.0
toolchain: 1.55.0
override: true
- name: Run tests
run: cargo --version &&
Expand Down
1 change: 1 addition & 0 deletions opentelemetry-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ lazy_static = "1.4"
pin-project = { version = "1.0.2", optional = true }
thiserror = "1"
tokio-stream = { version = "0.1", optional = true }
indexmap = "1"

[package.metadata.docs.rs]
all-features = true
Expand Down
2 changes: 2 additions & 0 deletions opentelemetry-api/src/trace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,15 @@ use thiserror::Error;

mod context;
pub mod noop;
mod order_map;
mod span;
mod span_context;
mod tracer;
mod tracer_provider;

pub use self::{
context::{get_active_span, mark_span_as_active, FutureExt, SpanRef, TraceContextExt},
order_map::OrderMap,
span::{Span, SpanKind, Status},
span_context::{SpanContext, SpanId, TraceFlags, TraceId, TraceState},
tracer::{SamplingDecision, SamplingResult, SpanBuilder, Tracer},
Expand Down
Loading

0 comments on commit a767fd3

Please sign in to comment.