Skip to content

Define an Entity Merge algorithm (from OTEP #264)#4768

Open
jsuereth wants to merge 14 commits intoopen-telemetry:mainfrom
jsuereth:wip-entity-merge
Open

Define an Entity Merge algorithm (from OTEP #264)#4768
jsuereth wants to merge 14 commits intoopen-telemetry:mainfrom
jsuereth:wip-entity-merge

Conversation

@jsuereth
Copy link
Contributor

@jsuereth jsuereth commented Dec 1, 2025

Changes

Adds the merge algorithm specified in OTEP#264 to the Resource + Entity data model specification (both still in development).

This merge algorithm has been used in Entity prototypes for the past year and has not seen any change. It's been adaptable enough to handle several re-architectures of SDKs through prototyping, so we're confident in pushing it forward into the specification.

A few caveats:

  • See the note on Resource DataModel about conflicting merge algorithms. This one currently focused only on merging entities into resource when there is a known set of entities in the existing resource.
  • I've split the merge algorithm into two: The Entity portion about eligibility of merging and descriptive attribute merging, and then the more robust resource section.

Link to prototypes:

@jsuereth jsuereth requested review from a team as code owners December 1, 2025 15:05
@jsuereth jsuereth added spec:resource Related to the specification/resource directory area:data-model For issues related to data model labels Dec 1, 2025
@jsuereth jsuereth moved this to Phase 1: Resource <-> Entity Mapping in Entities: Phase 1 Dec 1, 2025
resource.

- Construct a set of existing entities on the resource, `E`.
- For each entity, `new_entity`, in priority order (highest first),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does an SDK determine the relative priority of entities?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resource detection configuration

- For each entity, `new_entity`, in priority order (highest first),
do one of the following:
- If an entity `e'` exsits in `E` with the same entity type as `new_entity`:
- Perform a [Entity DataModel Merge](../entities/data-model.md#merging-of-entities), if applicable, otherwise ignore `new_entity`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if applicable

nit: maybe rephrase to "if they are mergeable"? If applicable confused me here.

otherwise ignore new_entity.

Do we consider this an error (e.g. surfaced using the SDK error handler or logged as a warning in the collector)? This makes it sound like these cases should be silently ignored.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is considered to be an error case (or at least a misconfiguration). I think the term "ignore" just relates to what the SDK should construct in order to emit telemetry. Logging an error is also acceptable

@github-actions
Copy link

This PR was marked stale. It will be closed in 14 days without additional activity.

@github-actions github-actions bot added the Stale label Dec 30, 2025
@jsuereth jsuereth removed the Stale label Jan 8, 2026
@jsuereth jsuereth moved this from Phase 1: Resource <-> Entity Mapping to In Progress in Entities: Phase 1 Jan 26, 2026
## Merging of Entities

Entities MAY be merged if and only if their types are the same, their
identity attributes are exactly the same AND their schema_url is the same.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you see a possibility to relax the last requirement a bit? For example can we aim for: "schema_url is the same or schemas are compatible", where "schemas are compatible" if attributes used by Entities are unchanged between schema versions? I understand it is more work to check compatibility but it makes merging much more widely possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in that event, we expect the following:

  • The SDK/Collector has no way of knowing if a schema_url is compatible with another, without looking at the schema.
  • If we have to look at the schema, we can convert the version succesffuly, and then we can merge two entities that are at the same version.

So while we do want to allow schema_url based conversions, the merge algorithm for Entities can be defined much more simply and we leave room for version-conversion prior to this.


### Merging Entities into a Resource

We define the following algorithm for merging entities into an existing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fairly complicated algorithm. Can you please add a few examples to demonstrate what it is doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:data-model For issues related to data model spec:resource Related to the specification/resource directory

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

6 participants