Skip to content

Commit

Permalink
Minimise breakages for existing users.
Browse files Browse the repository at this point in the history
  • Loading branch information
Luca Palmieri committed May 20, 2022
1 parent d08c9bb commit 2722620
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions opentelemetry-api/src/trace/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::{
Context, Key, KeyValue, Value,
};
use std::borrow::Cow;
use std::iter::FromIterator;
use std::time::SystemTime;

/// The interface for constructing [`Span`]s.
Expand Down Expand Up @@ -325,8 +326,25 @@ impl SpanBuilder {
}
}

/// Assign span attributes
pub fn with_attributes(self, attributes: OrderMap<Key, Value>) -> Self {
/// Assign span attributes from an iterable.
///
/// Check out [`SpanBuilder::with_attributes_map`] to assign span attributes
/// via an [`OrderMap`] instance.
pub fn with_attributes<I>(self, attributes: I) -> Self
where
I: IntoIterator<Item = KeyValue>
{
SpanBuilder {
attributes: Some(OrderMap::from_iter(attributes.into_iter())),
..self
}
}

/// Assign span attributes.
///
/// Check out [`SpanBuilder::with_attributes`] to assign span attributes
/// from an iterable of [`KeyValue`]s.
pub fn with_attributes_map(self, attributes: OrderMap<Key, Value>) -> Self {
SpanBuilder {
attributes: Some(attributes),
..self
Expand Down

0 comments on commit 2722620

Please sign in to comment.