Skip to content

Fix Groovy OpenTelemetrySdk builder loading#8407

Open
ADITYA-CODE-SOURCE wants to merge 2 commits into
open-telemetry:mainfrom
ADITYA-CODE-SOURCE:issue-8198-groovy-builder
Open

Fix Groovy OpenTelemetrySdk builder loading#8407
ADITYA-CODE-SOURCE wants to merge 2 commits into
open-telemetry:mainfrom
ADITYA-CODE-SOURCE:issue-8198-groovy-builder

Conversation

@ADITYA-CODE-SOURCE
Copy link
Copy Markdown
Contributor

Fixes #8198

This avoids eager Groovy linkage of incubator-dependent SDK code by resolving IncubatingUtil.createExtendedOpenTelemetrySdk(...) reflectively in OpenTelemetrySdkBuilder instead of calling it directly.

Also adds a Groovy regression test covering OpenTelemetrySdk.builder().build() without incubator classes on the runtime classpath.

}

@Test
void builder_fromGroovyWithoutIncubator() throws Exception {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Could rename the test to buildFromGroovyWithoutIncubator

Comment on lines +177 to +182
if (cause instanceof RuntimeException) {
throw (RuntimeException) cause;
}
if (cause instanceof Error) {
throw (Error) cause;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add some comments justifying the reasons for this handling?

try {
return (OpenTelemetrySdk)
requireNonNull(CREATE_EXTENDED_OPEN_TELEMETRY_SDK_METHOD)
.invoke(null, openTelemetrySdk, configProvider);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Looking at the javadoc for invoke, it throws 3 checked exceptions:

  • IllegalAccessException
  • IllegalArgumentException
  • InvocationTargetException

Might be good to add handling for IllegalArgumentException (although it is less likely since arguments are controlled).

* io.opentelemetry.sdk.internal.SdkConfigProvider)}.
*/
OpenTelemetrySdkBuilder setConfigProvider(SdkConfigProvider configProvider) {
OpenTelemetrySdkBuilder setConfigProvider(Object configProvider) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Question: Why was this changed to Object?

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.

Can't build OpenTelemetrySdk in groovy

2 participants