Skip to content

[DO NOT MERGE] Entity Prototype for SDK Specification #7434

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

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

Conversation

jsuereth
Copy link
Contributor

@jsuereth jsuereth commented Jun 20, 2025

Replaces #6855

Implementation of OTEP#264

  • Updates OTLP Resource Marshaler code for OTLP 1.7 (which includes entity ref).
  • Puts new entity code in io.opentelemetry.sdk.resources.internal
  • Resource and ResourceBuilder do NOT follow other data class conventions in the SDK (of being a pure interface), so we are
    unable to have this code anywhere but inside the SDK to make everything work.
  • Adds entity merge algorithm, partitioned into three key components.
  • Updates toString tests to be more flexible
  • Creates an entity incubator package
    • Adds bare minimum EntityProvider
    • Adds minimal EntityDetector
    • Adds two implementation of EntityDetector for service and telemetry.sdk

Context

TODOs

  • Figure out where to put Entity classes
  • Figure out what to do about Resource in the SDK. Bincompat prevents many good design options.
  • Update telemetry.sdk and service resource attributes to be entities and include a SchemaURL.
  • EntityDetector mechanism and wiring
  • EntityProvider or ResourceProvider in the SDK, similar to TraceProvider, MeterProvider, etc.

The current design represents a "middle ground" for binary compatibility given the state of Resource today in the SDK.

jsuereth added 9 commits June 18, 2025 10:13
- Create Entity/EntityBuilder class in internal package
- Update serialization code

Need to discuss how to work with Resource going forward.
- Remove ResourceWithEntity, no way to keep bincompat that way
- Update toString tests to be a lot more forgiving, but preserve intent
@jsuereth jsuereth changed the title [DO NOT MERGE] Reboot the Entity Prototype [DO NOT MERGE] Entity Prototype for SDK Specification Jun 20, 2025
Copy link

codecov bot commented Jun 20, 2025

Codecov Report

Attention: Patch coverage is 73.87387% with 145 lines in your changes missing coverage. Please review.

Project coverage is 89.64%. Comparing base (cc2844d) to head (7a7c426).
Report is 44 commits behind head on main.

Files with missing lines Patch % Lines
...cubator/entities/CurrentThreadExecutorService.java 11.90% 36 Missing and 1 partial ⚠️
...entelemetry/sdk/resources/internal/EntityUtil.java 75.42% 18 Missing and 11 partials ⚠️
...n/incubator/ObfuscatedExtendedOpenTelemerySdk.java 49.05% 27 Missing ⚠️
...ion/incubator/entities/SdkResourceSharedState.java 85.50% 5 Missing and 5 partials ⚠️
...ion/incubator/ExtendedOpenTelemetrySdkBuilder.java 70.96% 9 Missing ⚠️
...etry/api/incubator/entities/NoopEntityBuilder.java 0.00% 6 Missing ⚠️
...try/api/incubator/entities/NoopEntityProvider.java 0.00% 4 Missing ⚠️
...xtension/incubator/entities/SdkEntityProvider.java 66.66% 4 Missing ⚠️
...try/exporter/internal/otlp/EntityRefMarshaler.java 90.00% 0 Missing and 3 partials ⚠️
...k/extension/incubator/entities/SdkEntityState.java 57.14% 3 Missing ⚠️
... and 8 more

❌ Your patch check has failed because the patch coverage (73.87%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7434      +/-   ##
============================================
- Coverage     89.75%   89.64%   -0.11%     
- Complexity     6980     7203     +223     
============================================
  Files           797      826      +29     
  Lines         21165    21926     +761     
  Branches       2057     2118      +61     
============================================
+ Hits          18996    19656     +660     
- Misses         1505     1589      +84     
- Partials        664      681      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

jsuereth added 4 commits July 5, 2025 15:01
- Creates an API matching EntityProvider OTEP
- Updates EntityDetector to be ResourceDetector
- Creates synchronous "update resource with this entity" method.
- Adds wiring for incubating API + incubating SDK

Note: Still have some thoughts and ideas about a formal API, this may still change.
- Remove `Entity` and only expose `EntityBuilder` similar to how we do `LogRecord`s.
- Have methods on `Resource` which determine if you're attaching the entity, simplify "remove" or just ignore for now.
…OpenTelemetry API.

- Update shared state in SDK to use Supplier<Resource> instead of Resource
- Add helper utils to expose private methods to supply the supplier
- Create new ExtendedOpenTelemetry* API/SDK and end-to-end test.
Copy link
Member

@jack-berg jack-berg left a comment

Choose a reason for hiding this comment

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

Left a variety of comments, but the only material ones are about naming.

* @param entityType the type of entity to remove.
* @return true if entity was found and removed.
*/
public boolean removeEntity(String entityType);
Copy link
Member

Choose a reason for hiding this comment

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

So can multiple instrumentations compete to add or remove an entity with the same type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. This API is here to explore the browser-SIGs needs where session has changed and needs to be replaced.

The current addOrUpdate method does NOT replace an entity if the ID has changed, you must manually remove it.

This is the "footgun" we're worried about in Entities SIG and need to explore.

@@ -18,28 +18,29 @@
*/
final class LoggerSharedState {
private final Object lock = new Object();
private final Resource resource;
private final Supplier<Resource> resourceSupplier;
Copy link
Member

Choose a reason for hiding this comment

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

👍

* @param supplier The supplier of {@link Resource}.
* @since 1.X.0
*/
SdkLoggerProviderBuilder setResourceSupplier(Supplier<Resource> supplier) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't see these new Sdk{Signal}ProviderBuilder#setResourceSupplier methods being exercised. How do these fit into the puzzle?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

jsuereth and others added 5 commits July 10, 2025 09:52
…internal/otlp/EntityRefMarshaler.java

Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com>
…iderBuilder.java

Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com>
- Hide more methods (no incubating methods in public APIs that are not internal)
- Update builder API to use attributes directly
- Use static instances in Noop API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants