Struct opentelemetry_sdk::Resource
source · pub struct Resource { /* private fields */ }
Expand description
An immutable representation of the entity producing telemetry as attributes.
Utilizes Arc
for efficient sharing and cloning.
Implementations§
source§impl Resource
impl Resource
sourcepub fn empty() -> Self
pub fn empty() -> Self
Creates an empty resource. This is the basic constructor that initializes a resource with no attributes and no schema URL.
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) -> Self
pub fn from_schema_url<KV, S>(kvs: KV, schema_url: S) -> Self
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
.
Trait Implementations§
source§impl<'a> IntoIterator for &'a Resource
impl<'a> IntoIterator for &'a Resource
impl StructuralPartialEq for Resource
Auto Trait Implementations§
impl Freeze for Resource
impl RefUnwindSafe for Resource
impl Send for Resource
impl Sync for Resource
impl Unpin for Resource
impl UnwindSafe for Resource
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)