Struct opentelemetry_sdk::Resource
source · [−]pub struct Resource { /* private fields */ }
Expand description
An immutable representation of the entity producing telemetry as attributes.
Implementations
sourceimpl Resource
impl Resource
sourcepub fn new<T: IntoIterator<Item = KeyValue>>(kvs: T) -> Self
pub fn new<T: IntoIterator<Item = KeyValue>>(kvs: T) -> Self
Create a new Resource
from key value pairs.
Values are de-duplicated by key, and the first key-value pair with a non-empty string value will be retained
sourcepub fn from_schema_url<KV, S>(kvs: KV, schema_url: S) -> Selfwhere
KV: IntoIterator<Item = KeyValue>,
S: Into<Cow<'static, str>>,
pub fn from_schema_url<KV, S>(kvs: KV, schema_url: S) -> Selfwhere
KV: IntoIterator<Item = KeyValue>,
S: Into<Cow<'static, str>>,
Create a new Resource
from a key value pairs and schema url.
Values are de-duplicated by key, and the first key-value pair with a non-empty string value will be retained.
schema_url must be a valid URL using HTTP or HTTPS protocol.
sourcepub fn from_detectors(
timeout: Duration,
detectors: Vec<Box<dyn ResourceDetector>>
) -> Self
pub fn from_detectors(
timeout: Duration,
detectors: Vec<Box<dyn ResourceDetector>>
) -> Self
Create a new Resource
from resource detectors.
timeout will be applied to each detector.
sourcepub fn merge<T: Deref<Target = Self>>(&self, other: T) -> Self
pub fn merge<T: Deref<Target = Self>>(&self, other: T) -> Self
Create a new Resource
by combining two resources.
Key value pairs
Keys from the other
resource have priority over keys from this resource, even if the
updated value is empty.
Schema url
If both of the resource are not empty. Schema url is determined by the following rules, in order:
- If this resource has a schema url, it will be used.
- If this resource does not have a schema url, and the other resource has a schema url, it will be used.
- If both resources have a schema url and it’s the same, it will be used.
- If both resources have a schema url and it’s different, the schema url will be empty.
- If both resources do not have a schema url, the schema url will be empty.
sourcepub fn schema_url(&self) -> Option<&str>
pub fn schema_url(&self) -> Option<&str>
Return the schema url of the resource. If the resource does not have a schema url, return None
.
sourcepub fn iter(&self) -> Iter<'_>ⓘNotable traits for Iter<'a>impl<'a> Iterator for Iter<'a> type Item = (&'a Key, &'a Value);
pub fn iter(&self) -> Iter<'_>ⓘNotable traits for Iter<'a>impl<'a> Iterator for Iter<'a> type Item = (&'a Key, &'a Value);
Gets an iterator over the attributes of this resource, sorted by key.
Trait Implementations
sourceimpl<'a> IntoIterator for &'a Resource
impl<'a> IntoIterator for &'a Resource
sourceimpl IntoIterator for Resource
impl IntoIterator for Resource
sourceimpl PartialEq<Resource> for Resource
impl PartialEq<Resource> for Resource
impl StructuralPartialEq for Resource
Auto Trait Implementations
impl RefUnwindSafe for Resource
impl Send for Resource
impl Sync for Resource
impl Unpin for Resource
impl UnwindSafe for Resource
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more