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

Add/Update Metrics TCK #186

Merged
merged 5 commits into from
Jun 26, 2024
Merged

Add/Update Metrics TCK #186

merged 5 commits into from
Jun 26, 2024

Conversation

yasmin-aumeeruddy
Copy link
Contributor

@yasmin-aumeeruddy yasmin-aumeeruddy commented Jun 12, 2024

  • Uses the logging exporter instead of the in-memory exporter.
  • Updates metrics TCK to include the JVM metrics
  • Changes the in-memory Metrics exporter to filter by metric names instead of metric types. This was done as multiple JVM metrics would be exported with the same metric type so it was no longer a unique identifier for the test metrics.

@Emily-Jiang
Copy link
Member

@yasmin-aumeeruddy please resolve the conflicts

@yasmin-aumeeruddy yasmin-aumeeruddy changed the title Remove in-memory exporter Update TCK Jun 17, 2024
@Emily-Jiang
Copy link
Member

@yasmin-aumeeruddy please fix the build error?

@Emily-Jiang Emily-Jiang self-requested a review June 17, 2024 09:40
Copy link
Member

@Emily-Jiang Emily-Jiang left a comment

Choose a reason for hiding this comment

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

The build error needs to be resolved.

Copy link
Member

@donbourne donbourne left a comment

Choose a reason for hiding this comment

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

LGTM

@Emily-Jiang Emily-Jiang changed the title Update TCK Add/Update Metrics TCK Jun 24, 2024
private static final String JUL_INFO_MESSAGE = "a very distinguishable info message";
private static final String JUL_WARN_MESSAGE = "a very distinguishable warning message";

private static final String SYS_OUT = "SystemOut";
Copy link
Member

Choose a reason for hiding this comment

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

This only applies to Open Liberty, so should be removed

void julInfoTest() throws IOException {
julLogger.log(Level.INFO, JUL_INFO_MESSAGE);
try {
Assert.assertTrue(checkMessage(SYS_OUT + ".*" + "INFO" + ".*" + JUL_INFO_MESSAGE));
Copy link
Member

Choose a reason for hiding this comment

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

remove SYS_OUT, but you'll need to add something else in the line to avoid matching with the logs from the runtime (since you actually want to match against the logs from OTel bridge).


@Test
void julWarnTest() throws IOException {
julLogger.log(Level.WARNING, JUL_INFO_MESSAGE);
Copy link
Member

Choose a reason for hiding this comment

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

JUL_INFO_MESSAGE -> JUL_WARN_MESSAGE

void julWarnTest() throws IOException {
julLogger.log(Level.WARNING, JUL_INFO_MESSAGE);
try {
Assert.assertTrue(checkMessage(SYS_OUT + ".*" + "WARN" + ".*" + JUL_INFO_MESSAGE));
Copy link
Member

Choose a reason for hiding this comment

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

JUL_INFO_MESSAGE -> JUL_WARN_MESSAGE

BufferedReader reader = new BufferedReader(new FileReader(logFilePath));
String line;
while ((line = reader.readLine()) != null) {
if (line.contains(logMessage)) {
Copy link
Member

Choose a reason for hiding this comment

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

String contains method doesn't do regex matching -- need to use matches instead.

Comment on lines 48 to 47
.addAsLibrary(TestLibraries.AWAITILITY_LIB)
.addAsResource(new StringAsset(
"otel.sdk.disabled=false\notel.logs.exporter=none\notel.traces.exporter=none"),
"META-INF/microprofile-config.properties")
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you need any of these lines anymore

Comment on lines 48 to 47
.addAsLibrary(TestLibraries.AWAITILITY_LIB)
.addAsResource(new StringAsset(
"otel.sdk.disabled=false\notel.logs.exporter=none\notel.traces.exporter=none"),
"META-INF/microprofile-config.properties")
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you need any of these lines anymore

Comment on lines 48 to 47
.addAsLibrary(TestLibraries.AWAITILITY_LIB)
.addAsResource(new StringAsset(
"otel.sdk.disabled=false\notel.logs.exporter=none\notel.traces.exporter=none"),
"META-INF/microprofile-config.properties")
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you need any of these lines anymore

Comment on lines 48 to 47
.addAsLibrary(TestLibraries.AWAITILITY_LIB)
.addAsResource(new StringAsset(
"otel.sdk.disabled=false\notel.logs.exporter=none\notel.traces.exporter=none"),
"META-INF/microprofile-config.properties")
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you need any of these lines anymore

If you want to run the metrics tests, you can specify all tests in the `tck-suite.xml`. E.g.
== Running the tests

The jvm metrics tests require runtime configuration to enable metric reading at a runtime level. The metrics must be sent to stdout in the tests. Ensure logs written to stdout are captured in a file and set the system property `log.file.path` to the file containing the log output when running the logs TCK. Configure the runtime with `otel.metrics.exporter=console`/`OTEL_METRICS_EXPORTER=CONSOLE` and `otel.sdk.disabled=false`/`OTEL_SDK_DISABLED=FALSE` as a system property or environment variable. For example:
Copy link
Member

Choose a reason for hiding this comment

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

jvm -> JVM

void julWarnTest() throws IOException {
julLogger.log(Level.WARNING, JUL_WARN_MESSAGE);
try {
Assert.assertTrue(checkMessage(".*INFO.*" + JUL_WARN_MESSAGE + ".*scopeInfo:.*"));
Copy link
Member

Choose a reason for hiding this comment

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

does OTel show "INFO" when we log a warning? would have expected WARN or WARNING

Add jvm metrics to TCK

Remove log appender dependencies

create test for http metrics (#197)

Change exporter for jvm metrics

separate metric tests for runtime tests

Update logs tck
Comment on lines 54 to 56
The JVM metrics tests require runtime configuration to enable metric reading at a runtime level. The metrics must be sent to stdout in the tests. Ensure logs written to stdout are captured in a file and set the system property `log.file.path` to the file containing the log output when running the logs TCK. Configure the runtime with `otel.metrics.exporter=logging`/`OTEL_METRICS_EXPORTER=LOGGING` and `otel.sdk.disabled=false`/`OTEL_SDK_DISABLED=FALSE` as a system property or environment variable.
The metric export interval `otel.metric.export.interval`/`OTEL_METRIC_EXPORT_INTERVAL` should be configured as well and it is recommended to be set to a value of `3000` (i.e., 3 seconds).
Note: it is recommended to set `otel.traces.exporter` / `OTEL_TRACES_EXPORTER` and `otel.logs.exporter` / `OTEL_LOGS_EXPORTER` to `none` for the execution of the metric tests. For example:
Copy link
Member

Choose a reason for hiding this comment

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

i'd suggest combining these, since they all must be configured with system property or env var...

The JVM metrics tests require runtime configuration to enable metric reading at a runtime level. The metrics must be sent to stdout in the tests. Ensure logs written to stdout are captured in a file and set the system property log.file.path to the file containing the log output when running the logs TCK. Configure the runtime with the following as system properties / environment variables:

  • otel.sdk.disabled=false/OTEL_SDK_DISABLED=FALSE
  • otel.metrics.exporter=logging/OTEL_METRICS_EXPORTER=LOGGING
  • otel.traces.exporter=none/OTEL_TRACES_EXPORTER=none
  • otel.logs.exporter=none/OTEL_LOGS_EXPORTER=none
  • otel.metric.export.interval=3000/OTEL_METRIC_EXPORT_INTERVAL=3000

@donbourne donbourne merged commit 0db1488 into main Jun 26, 2024
6 of 7 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.

4 participants