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

Refactor advice API #5848

Merged
merged 1 commit into from
Oct 6, 2023
Merged

Conversation

jack-berg
Copy link
Member

The explicit bucket boundaries advice API is now stable: open-telemetry/opentelemetry-specification#3694

Before it stabilized, there was a change made to adjust advice from encapsulating 1 or more parameters to being a class / category of parameter. The idea was to be able to offer simplified ergonomics to users:

// From this:
meter.histogramBuilder("foo")
  .setAdvice(advice -> advice
    .setExplicitBucketBoundaries(...)
    .setAttributes(..));

// to something like this:
meter.histogramBuilder("foo")
  .setExplicitBucketBoundariesAdvice(...)
  .setAttributesAdvice(...);

Would like to try to get our explicit bucket boundary stable, but first want to explore this as an option and collect feedback.

@jack-berg jack-berg requested a review from a team September 21, 2023 19:38
@trask
Copy link
Member

trask commented Sep 21, 2023

// From this:
meter.histogramBuilder("foo")
  .setAdvice(advice -> advice
    .setExplicitBucketBoundaries(...)
    .setAttributes(..));

// to something like this:
meter.histogramBuilder("foo")
  .setExplicitBucketBoundariesAdvice(...)
  .setAttributesAdvice(...);

the second one looks simpler, so 👍🤷‍♂️ (but no really strong feelings)

one thing that's nice about the single setAdvice() method is that it gives one place to explain the whole advice story, but since the advice story differs a bit per advice type, maybe that's not much of an advantage(?)

@jack-berg
Copy link
Member Author

Yeah I'm kind of a partial to the API proposed here. Another reason to go with separate methods is that the pattern of passing in a consumer to configure parameters may not be intuitive for every user.

@trask
Copy link
Member

trask commented Sep 26, 2023

Another reason to go with separate methods is that the pattern of passing in a consumer to configure parameters may not be intuitive for every user.

ya, I've noticed confusion about the autoconfiguration builder which uses this pattern

@jack-berg
Copy link
Member Author

@open-telemetry/java-approvers PTAL. Would like to get this in for the next release so we can stabilize the API in the following. Or, potentially stabilize in the next release with this updated API.

@@ -109,7 +101,7 @@ public ObservableDoubleMeasurement buildObserver() {
}

@Override
public DoubleCounterAdviceConfigurer setAttributes(List<AttributeKey<?>> attributes) {
public ExtendedDoubleCounterBuilder setAttributesAdvice(List<AttributeKey<?>> attributes) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we return this external interface without causing trouble for people using this class without the incubator code present?

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 incubator code is always present on the classpath. Its just an implementation dependency instead of api, so users have to add it as a dependency of their own to access the extended behavior. Including the incubator as a implementation dependency is acceptable because its not part of the public API of the SDK, and it doesn't include any transitive dependencies that would make it questionable.

Copy link
Contributor

@jkwatson jkwatson left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me. one question about returning an interface from another, optional module.

@jack-berg jack-berg merged commit 92abcb8 into open-telemetry:main Oct 6, 2023
17 of 18 checks passed
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.

3 participants