Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] Entity prototype (OTEP#264) in JS #5258

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dyladan
Copy link
Member

@dyladan dyladan commented Dec 12, 2024

Implements https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/entities/0264-resource-and-entities.md

See https://github.com/open-telemetry/opentelemetry-java/pull/6855/files for similar implementation in Java

Important Changes

  1. Deprecate resource attribute promise in favor of a Record<string, AttributeValue | Promise<AttributeValue>>. This allows us to consider all attributes, sync or async, in a single object. Takes advantage of JS object ordering guarantees for merging logic. See also Consolidate sync and async resource interfaces #3582
  2. Add Entity implementation. Entity consists of type (string), schema_url (string), identity (key-value map), and attributes (key-value map). Identity is immutable. Attributes may change over the lifetime of the process. IMPORTANT: identity attributes MUST BE SYNCHRONOUS. This is required for the merge behavior.
  3. Add EntityRefs to Resource. EntityRef is a reference to an entity which contains a name, schema url, and 2 lists of identifying and non-identifying attribute keys. Those keys reference resource attributes.
  4. Detectors now return plain objects which conform to a type. Removing the Resource class from detector returns avoids transitive dependency version conflicts.
  5. Detectors MAY return resource attributes and/or any number of entities. Entities are merged in "left to right" order (earlier entries in the list take precedence). If multiple entity detectors exist, their returned entities are also merged in "left to right" order.

@dyladan dyladan requested a review from a team as a code owner December 12, 2024 18:43
@dyladan dyladan marked this pull request as draft December 12, 2024 18:43
Copy link

codecov bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.65%. Comparing base (e4d9c21) to head (c1135eb).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5258      +/-   ##
==========================================
- Coverage   94.67%   94.65%   -0.02%     
==========================================
  Files         315      315              
  Lines        8012     8012              
  Branches     1617     1617              
==========================================
- Hits         7585     7584       -1     
- Misses        427      428       +1     
Files with missing lines Coverage Δ
packages/opentelemetry-resources/src/Resource.ts 100.00% <ø> (ø)

... and 1 file with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant