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

Micrometer instrumentation, part 2 #5001

Merged
merged 5 commits into from
Jan 10, 2022

Conversation

mateuszrzeszutek
Copy link
Member

Continuation of #4919

This PR contains the implementations of following micrometer instruments:

  • DistributionSummary
  • FunctionCounter
  • FunctionTimer

LongTaskTimer and custom Meter are still missing, they'll be added in the next PR.

new OpenTelemetryDistributionSummary(
id, clock, distributionStatisticConfig, scale, otelMeter);
if (distributionSummary.isUsingMicrometerHistograms()) {
HistogramGauges.registerWithCommonFormat(distributionSummary, this);
Copy link
Member

Choose a reason for hiding this comment

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

ah, this is the magic that registers the internal gauges back with our meter registry

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, exactly!

countMeterName = id.getName() + "." + Statistic.COUNT.getTagValueRepresentation();
totalTimeMeterName = id.getName() + "." + Statistic.TOTAL_TIME.getTagValueRepresentation();

asyncInstrumentRegistry.buildLongCounter(
Copy link
Contributor

Choose a reason for hiding this comment

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

@jack-berg I think this is a good use case for an async batch API

Copy link
Member

Choose a reason for hiding this comment

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

What advantage do you seek from a batch API vs the existing API here?

}

void removeDoubleCounter(String name, Attributes attributes) {
synchronized (doubleCounters) {
Copy link
Member

Choose a reason for hiding this comment

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

#nit: can move the synchronization to inside removeMeasurement to DRY up the code a bit.

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately errorprone doesn't allow to compile it (because of @GuardedBy), so I have to duplicate this synchronized block.

@Override
public double max() {
UnsupportedReadLogger.logWarning();
return Double.NaN;
Copy link
Member

Choose a reason for hiding this comment

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

Do you want to return Double.NaN here or 0?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I would prefer returning NaN everywhere - since it clearly implies that the value returned by this method should not ever be used.

@Override
public double totalTime(TimeUnit unit) {
UnsupportedReadLogger.logWarning();
return Double.NaN;
Copy link
Member

Choose a reason for hiding this comment

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

Double.NaN or 0?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@jack-berg jack-berg left a comment

Choose a reason for hiding this comment

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

Couple of minor comments but looks good.

@mateuszrzeszutek mateuszrzeszutek merged commit 6d221e1 into open-telemetry:main Jan 10, 2022
@mateuszrzeszutek mateuszrzeszutek deleted the micrometer-2 branch January 10, 2022 12:23
@mateuszrzeszutek
Copy link
Member Author

Merged that PR to unblock the next one (since there's a couple of approvals here); if you have any further comments, don't hesitate to add them here - I can address them in later PRs.

RashmiRam pushed a commit to RashmiRam/opentelemetry-auto-instr-java that referenced this pull request May 23, 2022
* Micrometer instrumentation, part 2

* use double counter instead of gauge in FunctionTimer

* code review suggestions

* fix errorprone

* rebase and fix compilation failure
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.

4 participants