1- //! # Resource
1+ //! Representations of entities producing telemetry.
22//!
3- //! A `Resource` is an immutable representation of the entity producing telemetry. For example, a
4- //! process producing telemetry that is running in a container on Kubernetes has a Pod name, it is
5- //! in a namespace, and possibly is part of a Deployment which also has a name. All three of these
6- //! attributes can be included in the `Resource`.
3+ //! A [Resource] is an immutable representation of the entity producing
4+ //! telemetry as attributes. For example, a process producing telemetry that is
5+ //! running in a container on Kubernetes has a Pod name, it is in a namespace
6+ //! and possibly is part of a Deployment which also has a name. All three of
7+ //! these attributes can be included in the `Resource`. Note that there are
8+ //! certain ["standard attributes"] that have prescribed meanings.
79//!
8- //! The primary purpose of resources as a first-class concept in the SDK is decoupling of discovery
9- //! of resource information from exporters. This allows for independent development and easy
10- //! customization for users that need to integrate with closed source environments. When used with
11- //! distributed tracing, a resource can be associated with the [`TracerProvider`] when it is created.
12- //! That association cannot be changed later. When associated with a `TracerProvider`, all `Span`s
13- //! produced by any `Tracer` from the provider are associated with this `Resource`.
14- //!
15- //! [`TracerProvider`]: crate::trace::TracerProvider
10+ //! ["standard attributes"]: https://github.com/open-telemetry/opentelemetry-specification/blob/v1.9.0/specification/resource/semantic_conventions/README.md
1611//!
1712//! # Resource detectors
1813//!
19- //! `ResourceDetector`s are used to detect resource from runtime or environmental variables. The
20- //! following `ResourceDetector`s are provided along with this SDK.
14+ //! [`ResourceDetector`]s are used to detect resource from runtime or
15+ //! environmental variables. The following are provided by default with this
16+ //! SDK.
2117//!
22- //! - EnvResourceDetector, detect resource from environmental variables.
23- //! - OsResourceDetector, detect OS from runtime.
24- //! - ProcessResourceDetector, detect process information
18+ //! - [` EnvResourceDetector`] - detect resource from environmental variables.
19+ //! - [` OsResourceDetector`] - detect OS from runtime.
20+ //! - [` ProcessResourceDetector`] - detect process information.
2521mod env;
2622mod os;
2723mod process;
@@ -38,9 +34,7 @@ use std::collections::{btree_map, BTreeMap};
3834use std:: ops:: Deref ;
3935use std:: time:: Duration ;
4036
41- /// Describes an entity about which identifying information and metadata is exposed.
42- ///
43- /// Items are sorted by their key, and are only overwritten if the value is an empty string.
37+ /// An immutable representation of the entity producing telemetry as attributes.
4438#[ derive( Clone , Debug , PartialEq ) ]
4539pub struct Resource {
4640 attrs : BTreeMap < Key , Value > ,
0 commit comments