Skip to content

Conversation

zeitlinger
Copy link
Member

Fixes #7495

jsuereth and others added 30 commits July 16, 2025 09:18
- 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
- fix reflective method lookup
- also add unit test in the right project.
- 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.
…internal/otlp/EntityRefMarshaler.java

Co-authored-by: jack-berg <[email protected]>
- 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
…lemetrySdk.getOpenTelemetrySdk() to return the extended instance
Copy link

codecov bot commented Jul 16, 2025

Codecov Report

❌ Patch coverage is 84.72222% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.97%. Comparing base (29a7fe8) to head (4b7c986).
⚠️ Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
.../extension/incubator/ExtendedOpenTelemetrySdk.java 54.54% 5 Missing ⚠️
...ion/incubator/ExtendedOpenTelemetrySdkBuilder.java 90.90% 3 Missing ⚠️
...telemetry/api/incubator/ExtendedOpenTelemetry.java 0.00% 1 Missing ⚠️
...ension/incubator/fileconfig/SdkConfigProvider.java 0.00% 1 Missing ⚠️
...main/java/io/opentelemetry/sdk/IncubatingUtil.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7496      +/-   ##
============================================
- Coverage     89.99%   89.97%   -0.02%     
- Complexity     7078     7093      +15     
============================================
  Files           803      807       +4     
  Lines         21405    21449      +44     
  Branches       2086     2087       +1     
============================================
+ Hits          19263    19299      +36     
- Misses         1479     1488       +9     
+ Partials        663      662       -1     

☔ 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.

@zeitlinger
Copy link
Member Author

Alternative is #7500

@zeitlinger zeitlinger marked this pull request as draft July 18, 2025 08:17
@zeitlinger zeitlinger self-assigned this Jul 18, 2025
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.incubator.config.ConfigProvider;

/** Extension to {@link OpenTelemetry} that supports getting {@link ConfigProvider}. */
Copy link
Member

Choose a reason for hiding this comment

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

Let's keep the language generic enough to support evolving use cases.

Suggested change
/** Extension to {@link OpenTelemetry} that supports getting {@link ConfigProvider}. */
/** Extended {@link OpenTelemetry} with experimental APIs. */

*** MODIFIED CLASS: PUBLIC NON_FINAL (<- FINAL) io.opentelemetry.sdk.OpenTelemetrySdk (not serializable)
Copy link
Member

Choose a reason for hiding this comment

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

Worth calling out attention to this, but I think this is fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

The alternative PR doesn't need this

import javax.annotation.concurrent.ThreadSafe;

/** A new interface for creating OpenTelemetrySdk that supports getting {@link ConfigProvider}. */
public class ExtendedOpenTelemetrySdk extends OpenTelemetrySdk
Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, we could skip extending OpenTelemetrySdk and avoid awkwardness of trying to figure mesh together builder and constructors. OpenTelemetrySdk doesn't do much anyway so not much to repeat.

Maybe do something like have ExtendedOpenTelemetrySdk accept a delegate OpenTelemetrySdk instance during initialization and skip the builder pattern? Usage could be something like:

ExtendedOpenTelemetrySdk sdk = ExtendedOpenTelemetrySdk.create(OpenTelemetrySdk, SdkConfigProvider);

Copy link
Member Author

Choose a reason for hiding this comment

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

The goal (IMO) is to have AutoConfiguredOpenTelemetrySdk.getOpenTelemetrySdk() return the instance that we can work with - so that library users don't have to jump through hoops to have the correct instance.

* @param configurator A callback fleshing out tracers.
* @return this
*/
public ExtendedOpenTelemetrySdkBuilder withTracerProvider(
Copy link
Member

Choose a reason for hiding this comment

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

What do we get from these withers?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is from the entity PR where it's actually needed

@@ -82,7 +83,7 @@ private DeclarativeConfiguration() {}
*
* @throws DeclarativeConfigException if unable to parse or interpret
*/
public static OpenTelemetrySdk parseAndCreate(InputStream inputStream) {
public static ExtendedOpenTelemetrySdk parseAndCreate(InputStream inputStream) {
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 cool - frees up callers from needing to worry about initializing SdkConfigProvider

.matches("OpenTelemetrySdk\\{tracerProvider=SdkTracerProvider\\{.*}.*}")
.matches("OpenTelemetrySdk\\{.*, meterProvider=SdkMeterProvider\\{.*}.*}")
.matches("OpenTelemetrySdk\\{.*, loggerProvider=SdkLoggerProvider\\{.*}.*}")
.matches("OpenTelemetrySdk\\{.*, propagators=DefaultContextPropagators\\{.*}}");
Copy link
Member

Choose a reason for hiding this comment

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

Meh yeah this is probably an overdue improvement 😉

private IncubatingUtil() {}

@Nullable
static OpenTelemetrySdk createExtendedOpenTelemetrySdk() {
Copy link
Member

Choose a reason for hiding this comment

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

What's going on here?

Copy link
Member Author

Choose a reason for hiding this comment

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

forgot to delete this

@zeitlinger
Copy link
Member Author

@jack-berg please check if you like the alternative without API changes better: #7500

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.

Add ExtendedOpenTelemetry
3 participants