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

Copy ConfigProperties, ConfigurationException to opentelemetry-sdk-co… #5500

Closed

Conversation

jack-berg
Copy link
Member

In the 6/1 Java SIG we discussed an alternative to opentelemetry-java-instrumentation#8604 in which the environment resource logic and EnvironmentResourceProvider implementation of ResourceProvider SPI are moved opentelemetry-sdk-common. The argument is that having this logic in the core of the SDK is more aligned with the spec language.

The prerequisite of that is that we ConfigProperties, ConfigurationException to opentelemetry-sdk-common to avoid the circular dependency: :sdk:common -> :sdk-extensions:autoconfigure-spi -> :sdk:common

This PR shows what moving ConfigProperties, ConfigurationException looks like. Here's a summary:

  • Copy ConfigProperties interface to :sdk:common
  • Modify the :sdk-extensions:autoconfigure-spi version of ConfigProperties to extend the :sdk:common ConfigProperties. Override all the methods, retaining the same contracts, to keep japicmp happy.
  • Add a new internal ConfigurationPropertiesBridge class to :sdk-extensions:autoconfigure-spi. This implements the :sdk-extensions:autoconfigure-spi version of ConfigurationProperties, and accepts the :sdk:common as a delegate.
  • Change all test code to use ConfigurationPropertiesBridge instead of DefaultConfigurationProperties

It feels a bit strange to have two interfaces named ConfigProperties, and that the SPI interfaces accept the :sdk-extensions:autoconfigure-spi version to maintain backwards compatibility. But this should be a transparent change for users, as long as they're not using the internal DefaultConfigurationProperties class.

WDYT? Is the payoff of having the environment resource more appropriately placed in :sdk:common enough to justify the awkwardness of having two identical ConfigurationProperties interfaces?

@jack-berg jack-berg requested a review from a team June 1, 2023 21:44
import javax.annotation.Nullable;

/** Properties used for configuration of the OpenTelemetry SDK components. */
public interface ConfigProperties {
Copy link
Member Author

Choose a reason for hiding this comment

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

A small variation of this would be to make this version of ConfigProperties internal and not expose the EnvironmentResource#create(ConfigProperties) method. Would mean you can only access the environment resource using the environment variables and system properties obtains from System.* calls - no customizing by providing your own ConfigProperties implementation (except in the SPI).

Copy link
Contributor

Choose a reason for hiding this comment

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

That might be a preferable starting point, then if we get requests for customization, we can consider exposing it? Still thinking through the implications of changing the parent interface on the one in the spi module. 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

then if we get requests for customization, we can consider exposing it?

That was my thought.. but on second thought, it may not work. If we move the :sdk:common version to an internal package, then the version in :sdk-extensions:autoconfigure-spi will extend an internal interface. If we later wanted to change :sdk:common to be public facing, I'm pretty sure japicmp would complain.

@jack-berg
Copy link
Member Author

Closing in favor #5554.

@jack-berg jack-berg closed this Jun 20, 2023
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