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

Tidy up jfr-streaming #127

Merged
merged 4 commits into from
Dec 2, 2021
Merged

Conversation

jack-berg
Copy link
Member

Was going through the the new jfr-streaming module and noticed some things I thought could use tidying up. In summary:

  • Initialize instruments in constructors instead of init() method.
  • After all instrument initialization is done in constructors, can drop unused init() method
  • Remove unused constants.
  • Use java 11 var where appropriate.
  • Make classes static inner classes where appropriate. As a result, can make several constants private.
  • Change AbstractThreadDispathingHandler#createPerThreadSummarizer to return Consumer<RecordedEvent>. The difference in each thread is just in how they consumer recorded events - no need for each of these responses to require their own getEventName() implementation.
  • The logs told me that there was a conflict where multiple instruments for runtime.jvm.network.duration and runtime.jvm.network.io. Determined that the read and write handlers both were creating instruments with the same name. I differentiated them to include read / write in the metric name, eg, ``runtime.jvm.network.write.duration`. (On a related not, @jsuereth, these instruments had the same name but different descriptions, yet still conflicted. Does this match your expectations?)

@jack-berg jack-berg requested a review from a team October 28, 2021 22:25
@jack-berg
Copy link
Member Author

/cc @kittylyst

@trask
Copy link
Member

trask commented Oct 28, 2021

  • Initialize instruments in constructors instead of init() method.
  • After all instrument initialization is done in constructors, can drop unused init() method

check out #121 (comment) (maybe add a comment on those methods so we don't keep trying to remove them 😄)

@jack-berg
Copy link
Member Author

check out #121 (comment) (maybe add a comment on those methods so we don't keep trying to remove them 😄)

Interesting! @kittylyst what hooks into the init() method? And what kind of stuff needs to be done in init() vs constructor?

@jsuereth
Copy link
Contributor

jsuereth commented Nov 3, 2021

The logs told me that there was a conflict where multiple instruments for runtime.jvm.network.duration and runtime.jvm.network.io. Determined that the read and write handlers both were creating instruments with the same name. I differentiated them to include read / write in the metric name, eg, ``runtime.jvm.network.write.duration`. (On a related not, @jsuereth, these instruments had the same name but different descriptions, yet still conflicted. Does this match your expectations?)

No, we should not differentiate that way. Instead read/write need to be an attribute. The conflict is likely due to the description/unit being different. To the extent we register one instrument and "bind" those attributes, that'd be ideal.

private static final String METRIC_NAME_DURATION = "runtime.jvm.network.write.duration";
private static final String METRIC_NAME_BYTES = "runtime.jvm.network.write.io";
private static final String DESCRIPTION_BYTES = "Bytes Written";
private static final String DESCRIPTION_DURATION = "Write Duration";
Copy link
Contributor

Choose a reason for hiding this comment

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

This is likely the issue between duration read. This needs to be a more generic description about duration of a network operation.

Copy link
Member Author

@jack-berg jack-berg Nov 3, 2021

Choose a reason for hiding this comment

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

Cool yeah that did the trick 👍

Fixed in most recent commit.

private BoundDoubleHistogram machineHistogram;
private final BoundDoubleHistogram userHistogram;
private final BoundDoubleHistogram systemHistogram;
private final BoundDoubleHistogram machineHistogram;

public OverallCPULoadHandler(Meter otelMeter) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we revert the removal of init I think we can merge this and follow up on that. Quarkus preinitializing classes was the reason to have an init method - ideally we can find some way to improve, possibly on the Quarkus side, to avoid forcing the pattern on us but I think we can try that later

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'm fine with doing that I just want to understand what problem it solves. It would make sense to me if the init methods accepted a Meter, so that the metric instruments could be initialized after the metric sdk was setup, but that wasn't happening.

meter
.histogramBuilder(METRIC_NAME)
.setDescription(DESCRIPTION)
.setUnit(ONE)
Copy link
Member Author

Choose a reason for hiding this comment

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

Noticed that user CPU usage unit is percentage while system and machine CPU usage unit is "1". Seems off.

Copy link
Member

Choose a reason for hiding this comment

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

the unit for user CPU usage was just updated in #140, probably just missed it for system and machine

@anuraaga anuraaga merged commit cd2c935 into open-telemetry:main Dec 2, 2021
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