Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Implement memory metrics #652

Merged
merged 11 commits into from
Jan 14, 2023
Merged

Conversation

roberttoyonaga
Copy link
Contributor

@roberttoyonaga roberttoyonaga commented Dec 15, 2022

Description:
This PR updates the implementation for the metrics process.runtime.jvm.memory.limit , process.runtime.jvm.memory.usage_after_last_gc , process.runtime.jvm.memory.committed, process.runtime.jvm.memory.init, process.runtime.jvm.memory.usage

This was a part of a larger PR here.

jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/Constants.java has been kept the same as it was in the larger PR because it is used in all of the smaller constituent PRs. This will hopefully also avoid some conflicts as the PRs are sequentially merged. As a result, there are some constants that are defined, but not used in this PR.

Some of the attribute key-value pairs outlined here are not present with the current implementation. This is because they require additional JFR data, or new events. In the future, when JFR is updated, these handlers should be revisited and updated to cover all the missing attribute key-value pairs.

@roberttoyonaga roberttoyonaga requested a review from a team December 15, 2022 20:08
@roberttoyonaga roberttoyonaga marked this pull request as draft December 15, 2022 20:08
@roberttoyonaga roberttoyonaga marked this pull request as ready for review December 15, 2022 20:12
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.

A couple of minor comments.

@roberttoyonaga roberttoyonaga requested review from jack-berg and removed request for kittylyst and breedx-splk January 9, 2023 17:09
metricReader = InMemoryMetricReader.create();
meterProvider = SdkMeterProvider.builder().registerMetricReader(metricReader).build();
GlobalOpenTelemetry.set(OpenTelemetrySdk.builder().setMeterProvider(meterProvider).build());
JfrMetrics.enable(meterProvider);
Copy link
Member

Choose a reason for hiding this comment

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

Side note: This abstract base class needs some work:

  • Should be renamed to something more descriptive, maybe AbstractJfrTest
  • Should not have state which is shared across all tests. Right now that's required because JfrMetrics can't be cancelled once started. We should change that.
  • Should be put in a common place where it can be used by each of the different testing suites, rather than repeated in each test suite

Can do all this in a future PR.

Copy link
Contributor Author

@roberttoyonaga roberttoyonaga Jan 13, 2023

Choose a reason for hiding this comment

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

Yup I agree with all those points.

Right now that's required because JfrMetrics can't be cancelled once started

Maybe @BeforeEach test I can reinitialize JFR streaming and all openTelemetry variables, and @AfterEach test the JFR streaming can be ended. I think that should be enough for tests to fully clean up after themselves.

Should be put in a common place where it can be used by each of the different testing suites

I was trying to figure out a good way of doing this today. Maybe something related to test fixtures. I'll have to investigate more.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update:
I renamed the base test class to AbstractJfrTest. I was able to get the testFixtures working. So now the class resides in a single place, instead of being duplicated for each GC type.

.isEqualTo(Attributes.of(ATTR_GC, "MarkSweepCompact", ATTR_ACTION, END_OF_MAJOR_GC));
}
assertThat(pointData.getAttributes())
.isEqualTo(Attributes.of(ATTR_GC, "PS MarkSweep", ATTR_ACTION, END_OF_MAJOR_GC));
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

There's a comment below that is no longer true:

// TODO: Need a reliable way to test old and young gen GC in isolation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left that comment in because, although we can reliably test different collectors independently, there still isn't any code that enforces young vs old gen collection for GCs that divide up the heap.

@@ -1,11 +1,20 @@
plugins {
id("otel.java-conventions")
id("java-library")
id("java-test-fixtures")
Copy link
Member

Choose a reason for hiding this comment

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

TIL about java-test-fixtures. Nice!

Copy link
Member

Choose a reason for hiding this comment

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

@trask trask merged commit f4b776d into open-telemetry:main Jan 14, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants