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

Remove -alpha artifacts from runtime classpath of stable components #6944

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

jack-berg
Copy link
Member

@jack-berg jack-berg commented Dec 11, 2024

Related to #6970.

Remove -alpha artifacts (especially opentelemetry-api-incubator) from the runtime classpath of stable components.

Approach is:

  • Switch from implementation to compileOnly dependencies
  • Adjust internals to detect whether -alpha artifact is present on classpath (i.e. provided by the user) and toggle behavior based on whether it is or isnt
  • To ensure safety when -alpha artifacts are not provided by user, make sure main test suite runs without -alpha artifacts.
  • To ensure safety when -alpha artifacts are present, introduce new test suite including the -alpha artifacts, and test the impacted behavior

This is related to a possible adjustment of our versioning guidelines. If we went in this direction, a user adding only stable dependencies could always run ./gradlew dependencies and will not see any -alpha artifacts on the runtime classpath.

Copy link

codecov bot commented Dec 11, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 24 lines in your changes missing coverage. Please review.

Project coverage is 89.94%. Comparing base (d95c4ea) to head (ed35f93).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
...pentelemetry/sdk/trace/ExtendedSdkSpanBuilder.java 63.63% 16 Missing ⚠️
...elemetry/sdk/logs/ExtendedSdkLogRecordBuilder.java 63.63% 8 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6944      +/-   ##
============================================
- Coverage     90.10%   89.94%   -0.17%     
- Complexity     6602     6639      +37     
============================================
  Files           730      746      +16     
  Lines         19843    20016     +173     
  Branches       1955     1963       +8     
============================================
+ Hits          17880    18003     +123     
- Misses         1369     1419      +50     
  Partials        594      594              

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

Comment on lines 39 to 45
try {
Class.forName("io.opentelemetry.api.incubator.trace.ExtendedTracer");
return IncubatingUtil.createIncubatingTracer(
sharedState, instrumentationScopeInfo, tracerConfig);
} catch (Exception e) {
return new SdkTracer(sharedState, instrumentationScopeInfo, tracerConfig);
}
Copy link
Member

Choose a reason for hiding this comment

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

maybe?

Suggested change
try {
Class.forName("io.opentelemetry.api.incubator.trace.ExtendedTracer");
return IncubatingUtil.createIncubatingTracer(
sharedState, instrumentationScopeInfo, tracerConfig);
} catch (Exception e) {
return new SdkTracer(sharedState, instrumentationScopeInfo, tracerConfig);
}
if (IncubatingUtil.isPresent()) {
return IncubatingUtil.createIncubatingTracer(
sharedState, instrumentationScopeInfo, tracerConfig);
} else {
return new SdkTracer(sharedState, instrumentationScopeInfo, tracerConfig);
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup yup that's my plan

Copy link
Member Author

Choose a reason for hiding this comment

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

Tried this and a bunch of different variations of it.

The organization of methods is pretty finicky to get this to work, and it appears that by placing the isPresent() check in the same class file as the createIncubatingTracer method, the JVM tries to load the incubating classes required by createIncubatingTracer even if isPresent() is false.

Based on the stack trace, I think what is happening is the JVM reaches isPresent(), and tries to load all classes required by all methods in IncubatingUtil.

This problem occurs even if I use fully qualified class named in createINcubatingTracer, rather than imports.


Another thing to think about is how graal interacts with this increased use of reflection. I believe we'll have to add new reflect-config.json files to inform the graal runtime.

@@ -23,4 +42,63 @@ void incubatingApiIsLoadedViaReflection() {
assertThat(MeterProvider.noop().get("test").counterBuilder("test"))
.isInstanceOf(ExtendedLongCounterBuilder.class);
}

@Test
void incubatingLogSdk() {
Copy link
Member Author

@jack-berg jack-berg Dec 19, 2024

Choose a reason for hiding this comment

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

Not sure why, but these new graal nativeTest woked without any additional reflect-config.json entries, despite new reflective access in the SDK via Class.forName. 🤔

@jack-berg jack-berg marked this pull request as ready for review December 19, 2024 18:48
@jack-berg jack-berg requested a review from a team as a code owner December 19, 2024 18:48
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.

2 participants