Resource Data Model
Status: Development
A Resource represents the observed entity for which telemetry is produced. It is defined by a set of Attributes that identify the source of the telemetry, rather than the component that technically produces it (like an auto-instrumentation agent). For example, a process running in a container on Kubernetes is associated to a Pod running on a Node that is a VM, in a namespace, and possibly part of a Deployment. Resource could have attributes to denote information about the Container, the Pod, the Node, the VM or the Deployment. All of these help identify the observed entity. Note that there are certain attributes that have prescribed meanings.
A resource is composed of 0 or more Entities and 0
or more attributes not associated with any entity.
The data model below defines a logical model for an Resource (irrespective of the physical format and encoding of how resource data is recorded).
| Field | Type | Description |
|---|---|---|
| Entities | set<Entity> | Defines the set of Entities associated with this resource. |
| Attributes | map<string, attribute value> | Additional Attributes that identify the resource. MUST not change during the lifetime of the resource. Follows OpenTelemetry attribute definition. |
Identity
Most resources are a composition of Entity.
Entity includes its own notion of identity. The identity of a resource is
the set of entities contained within it. Two resources are considered
different if one contains an entity not found in the other.
Some resources include raw attributes in addition to Entities. Raw attributes are considered identifying on a resource. That is, if the key-value pairs of raw attributes are different, then you can assume the resource is different.
Merging Resources
Note: The current SDK specification outlines a merge algorithm. This specification updates the algorithm to be compliant with entities. This section will replace that section upon stabilization of entities. SDKs SHOULD NOT update their merge algorithm until full Entity SDK support is provided.
Merging resources is an action of joining together the context of observation. That is, we can look at the resource context for a signal and expand that context to include more details (see telescoping identity). As such, a merge SHOULD preserve any identity that already existed on a Resource while adding in new identifying information or descriptive attributes.
Merging An Entity into a Resource
We define the following algorithm for merging an Entity into an existing Resource where e is the incoming entity and E is the set of entities in the resource:
- If
Econtains an entitye'that can be merged (equaltype,identity, andschema_url) withe, apply theentity merge algorithm. - Else if
Econtains an entitye'with equaltypethat cannot be merged (unequalidentityorschema_url), drope'fromEincluding all of its attributes and replace it with incoming entitye - Else insert incoming entity
eintoE, overwriting any existing attributes. - If, at any time, an entity being inserted or merged overwrites any attribute, identifying or descriptive, from a pre-existing Entity
e', drope'’sEntityRef, retaining its other attributes as unassociated attributes.
Merging Resource Attributes into a Resource
When merging a set of attributes into a Resource, the incoming attributes overwrite existing attributes. If any attribute being overwritten is a part of an Entity, the Entity is removed and all non-conflicting attributes of that entity are added to the Resource as unassociated attributes.
Examples
These examples demonstrate how conflicts are resolved during a merge.
Example 1: Entity replaces loose attribute
The conflict between loose attributes and those belonging to an entity. Here when entity is added it removes previous attributes.
Initial Resource:
- Entities: None
- Attributes:
host.name:"old-name"env:"prod"
Entities to Merge (by priority):
host- type:
"host" - identity:
host.id:"H1"
- description:
host.name:"new-name"
- type:
service- type:
"service" - identity:
service.name:"my-svc"
- type:
Resulting Resource:
- Entities:
host- type:
"host" - identity:
host.id:"H1"
- description:
host.name:"new-name"
- type:
service- type:
"service" - identity:
service.name:"my-svc"
- type:
- Attributes:
env:"prod"
Example 2: Loose attribute replaces entity attribute
The conflict between loose attributes and those belonging to an entity. Here when the loose attribute is added, the entity must be removed due to conflict. The removed entity’s other attributes are preserved as raw attributes.
Initial Resource:
- Entities:
host- type:
"host" - identity:
host.id:"H1"
- description:
host.name:"detected-name"
- type:
process- type:
"process" - identity:
process.pid:12345
- type:
- Attributes: None
Resource to Merge:
- Entities: None
- Attributes:
host.id:"h2"env:"prod"
Resulting Resource:
- Entities:
process- type:
"process" - identity:
process.pid:12345
- type:
- Attributes:
host.id:"h2"host.name:"detected-name"env:"prod"
Example 3: Identity & Attribute Conflicts
Replace an existing entity that has the same type but a different identity, and drop a conflicting entity’s EntityRef due to a descriptive attribute key conflict, retaining its remaining attributes as unassociated.
Initial Resource:
- Entities:
host- type:
"host" - identity:
host.id:"H2"
- type:
service- type:
"service" - identity:
service.name:"S1"
- description:
env:"dev"
- type:
- Attributes: None
Entity to Merge:
host- type:
"host" - identity:
host.id:"H1"
- description:
env:"prod"
- type:
Resulting Resource:
- Entities:
host- type:
"host" - identity:
host.id:"H1"
- description:
env:"prod"
- type:
- Attributes:
service.name:"S1"
Feedback
Was this page helpful?
Thank you. Your feedback is appreciated!
Please let us know how we can improve this page. Your feedback is appreciated!