-
Notifications
You must be signed in to change notification settings - Fork 877
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
Swap old Metrics API for currently specified Metrics API #3423
Conversation
Passing off to other cmoputer.
Codecov Report
@@ Coverage Diff @@
## main #3423 +/- ##
============================================
- Coverage 90.94% 90.65% -0.30%
+ Complexity 3258 3194 -64
============================================
Files 369 362 -7
Lines 10035 9904 -131
Branches 1019 998 -21
============================================
- Hits 9126 8978 -148
- Misses 597 613 +16
- Partials 312 313 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just nits, all-in-all looks good
api/metrics/src/main/java/io/opentelemetry/api/metrics/BoundDoubleCounter.java
Show resolved
Hide resolved
api/metrics/src/main/java/io/opentelemetry/api/metrics/BoundDoubleHistogram.java
Outdated
Show resolved
Hide resolved
api/metrics/src/main/java/io/opentelemetry/api/metrics/Counter.java
Outdated
Show resolved
Hide resolved
api/metrics/src/main/java/io/opentelemetry/api/metrics/GlobalMeterProvider.java
Outdated
Show resolved
Hide resolved
api/metrics/src/main/java/io/opentelemetry/api/metrics/BoundDoubleCounter.java
Outdated
Show resolved
Hide resolved
api/metrics/src/main/java/io/opentelemetry/api/metrics/LongCounterBuilder.java
Outdated
Show resolved
Hide resolved
api/metrics/src/main/java/io/opentelemetry/api/metrics/LongUpDownCounterBuilder.java
Outdated
Show resolved
Hide resolved
* | ||
* @param instrumentationName The name of the instrumentation library, not the name of the | ||
* instrument*ed* library. | ||
* @return a tracer instance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😂
/** Returns an assertion for {@link DoubleHistogramPointData}. */ | ||
public static DoubleHistogramPointDataAssert assertThat(DoubleHistogramPointData point) { | ||
return new DoubleHistogramPointDataAssert(point); | ||
} | ||
|
||
/** Returns an assertion for {@link DoubleSummaryPointData}. */ | ||
public static DoubleSummaryPointDataAssert assertThat(DoubleSummaryPointData point) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
api/metrics/src/main/java/io/opentelemetry/api/metrics/DoubleCounterBuilder.java
Outdated
Show resolved
Hide resolved
api/metrics/src/main/java/io/opentelemetry/api/metrics/LongHistogramBuilder.java
Outdated
Show resolved
Hide resolved
/** | ||
* Adds the given {@code increment} to the current value. | ||
* Records a value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this one makes sense to change. same with other add function comment change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went for consistency across instruments here. There's an 'oddity' here where users can actually use aggregators to change what happens when recording values. E.g. by default this would add an increment to current value, but you can use a View
to convert this to a histogram or other behavior, which is why I went with record a value
consistently across instruments.
api/metrics/src/main/java/io/opentelemetry/api/metrics/LongUpDownCounterBuilder.java
Outdated
Show resolved
Hide resolved
api/metrics/src/main/java/io/opentelemetry/api/metrics/BoundDoubleHistogram.java
Show resolved
Hide resolved
|
||
@Override | ||
void unbind(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all the unbind()
s are going to need javadoc without the super interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added, copying previous javadoc. Kinda unhappy with both bind + unbind's documentation on why/how they exists.
Thinking about discussing how (theoretically) if you only use BOUND
instruments you should never see memory allocations in the hot path of your applications as, AFAIK, this is a guarantee from the metrics SDK. However, this is just the API so that guarantee isn't assured, only possible. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, we can't guarantee this in the API javadoc, unfortunately.
* | ||
* @param callback A state-capturing callback used to observe values on-demand. | ||
*/ | ||
void buildWithCallback(Consumer<ObservableDoubleMeasurement> callback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here's the case with both sync and async in the same builder. :)
api/metrics/src/main/java/io/opentelemetry/api/metrics/DoubleUpDownCounterBuilder.java
Outdated
Show resolved
Hide resolved
api/metrics/src/main/java/io/opentelemetry/api/metrics/GlobalMeterProvider.java
Show resolved
Hide resolved
* | ||
* <p>see {@link ObservableDoubleMeasurement} or {@link ObservableLongMeasurement}. | ||
*/ | ||
public interface ObservableMeasurement {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with no methods and no types does this have enough value to keep?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It helped in the SDK implementation. I can remove it, but you don't see the code which uses this yet.
...ters/otlp/trace/src/main/java/io/opentelemetry/exporter/otlp/trace/OtlpGrpcSpanExporter.java
Show resolved
Hide resolved
sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/AbstractInstrumentBuilder.java
Outdated
Show resolved
Hide resolved
sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/view/InstrumentSelector.java
Outdated
Show resolved
Hide resolved
sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/SdkMeterRegistryTest.java
Show resolved
Hide resolved
Just a few minor comments. Looks good! Thanks! |
Co-authored-by: John Watson <jkwatson@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, pending API discussion and a tiny capitalization nit.
@jkwatson I think it's ok to merge first and follow up on the API discussion given this is an alpha artifact and the PR is huge. What do you think? |
This actually needs a rebase, since there have been additional API usages added since it was last rebased against main. |
public static MeterBuilder meterBuilder(String instrumentationName) { | ||
return get().meterBuilder(instrumentationName); | ||
public static void set(MeterProvider provider) { | ||
globalMeterProvider = (provider == null) ? NoopMeterProvider.getInstance() : provider; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Equating null
= NoopMeterProvider.getInstance()
is strange IMO.
I think this should return or throw if null is passed. Throwing is inconsistent with current behavior, so I say return.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Existing behavior is to return a Noop meter provider on "get" if the meter provider is null
. This just short-circuits that on the set
side. i.e this is not a behavioral change.
Additionally, this entire class will disappear once metrics stabilize.
api/metrics/src/main/java/io/opentelemetry/api/metrics/LongUpDownCounterBuilder.java
Outdated
Show resolved
Hide resolved
* | ||
* <p>TODO: Update comment. | ||
* <p>A Meter is generally associated with an instrumentation library, e.g. "I monitor apache | ||
* httpclient". | ||
*/ | ||
@ThreadSafe | ||
public interface Meter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The async instruments are accessible via the buildWithCallback
methods from the respective builders, rather than from the Meter
.
Is this allowed according to the spec?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say so. You still get the builder via the Meter
. The spec isn't supposed to precisely define the language-specific APIs, but the capabilities that must be provided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was deemed a Java-specific deviation to abide by the common builder pattern in Java. I like the simplicity it acheived, but it is something we should discuss and can migrate to having separate builders by-async type instead of a builder per-metric-type and then having the async builder + sync builder coexist.
* | ||
* @param callback A state-capturing callback used to observe values on-demand. | ||
*/ | ||
void buildWithCallback(Consumer<ObservableLongMeasurement> callback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see "observable" somehow incorporated into the naming convention of methods that access async instruments. Its recommended in the spec and I think it better clarifies the async distinction than "callback".
Maybe buildObservable
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec calls this an "observable" I think? In that case, probably migrating to that verbiage would be helpful. I don't want to hold up this PR for that change, though.
sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/SdkMeterProvider.java
Show resolved
Hide resolved
I'm going to merge this, so we can build from it. Thanks, @jsuereth ! |
LabelsProcessor
for views. This will be refactored to match the SDK specifcaiton in follow-up PR.