Skip to content

Commit

Permalink
Update logs tck to remove in-memory exporter
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yasmin-aumeeruddy committed Jun 26, 2024
1 parent 5d217d4 commit 495a4c9
Show file tree
Hide file tree
Showing 32 changed files with 937 additions and 214 deletions.
73 changes: 73 additions & 0 deletions 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# This is a combination of 3 commits.
# This is the 1st commit message:

Update logs TCK

Update logs tck to remove in-memory exporter

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

#Update logs tck

# This is the commit message #2:

#Update logs tck

# This is the commit message #3:

Update logs tck

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Fri Apr 12 15:43:50 2024 +0100
#
# interactive rebase in progress; onto 5d217d4
# Last commands done (3 commands done):
# squash 41ef585 Update logs tck
# squash 202d0d4 Update logs tck
# No commands remaining.
# You are currently rebasing branch 'logs-tck' on '5d217d4'.
#
# Changes to be committed:
# modified: tck/logs/README.adoc
# modified: tck/logs/pom.xml
# renamed: tck/logs/src/main/java/org/eclipse/microprofile/telemetry/logs/tck/application/LogAppenderTest.java -> tck/logs/src/main/java/org/eclipse/microprofile/telemetry/logs/tck/application/JulTest.java
# modified: tck/logs/src/main/java/org/eclipse/microprofile/telemetry/logs/tck/config/ServerInstanceTest.java
# deleted: tck/logs/src/main/resources/logback.xml
# modified: tck/metrics/README.adoc
# new file: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/BasicHttpClient.java
# renamed: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/ConfigAsset.java -> tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/ConfigAsset.java
# new file: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/TestLibraries.java
# renamed: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/TestUtils.java -> tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/TestUtils.java
# renamed: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/AsyncDoubleCounterTest.java -> tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/AsyncDoubleCounterTest.java
# renamed: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/AsyncLongCounterTest.java -> tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/AsyncLongCounterTest.java
# renamed: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleCounterTest.java -> tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleCounterTest.java
# renamed: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleGaugeTest.java -> tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleGaugeTest.java
# renamed: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleHistogramTest.java -> tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleHistogramTest.java
# renamed: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/DoubleUpDownCounterTest.java -> tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/DoubleUpDownCounterTest.java
# renamed: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongCounterTest.java -> tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongCounterTest.java
# renamed: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongGaugeTest.java -> tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongGaugeTest.java
# renamed: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongHistogramTest.java -> tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongHistogramTest.java
# renamed: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/cdi/LongUpDownCounterTest.java -> tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/cdi/LongUpDownCounterTest.java
# renamed: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/exporter/InMemoryMetricExporter.java -> tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/exporter/InMemoryMetricExporter.java
# renamed: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/exporter/InMemoryMetricExporterProvider.java -> tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/exporter/InMemoryMetricExporterProvider.java
# new file: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/application/http/HttpHistogramTest.java
# new file: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmClassesTest.java
# new file: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmCpuTest.java
# new file: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmGarbageCollectionTest.java
# new file: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmMemoryTest.java
# new file: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/JvmThreadTest.java
# new file: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/MetricsReader.java
# renamed: tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/TestLibraries.java -> tck/metrics/src/main/java/org/eclipse/microprofile/telemetry/metrics/tck/jvm/TestLibraries.java
#
8 changes: 8 additions & 0 deletions tck/logs/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ To test that the OpenTelemetry instance is set properly at runtime initializatio
</suite>
----

== Logging File Configuration
OpenTelemetry logs are 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. For example:

[source, xml]
----
log.file.path=console.log
----

== Configuration in Apache Maven pom.xml
If you use Apache Maven then the tests are run via the `maven-surefire-plugin`

Expand Down
30 changes: 0 additions & 30 deletions tck/logs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,36 +46,6 @@
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-extension-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-instrumentation-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry.semconv</groupId>
<artifactId>opentelemetry-semconv</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/io.opentelemetry.instrumentation/opentelemetry-logback-appender-1.0 -->
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-logback-appender-1.0</artifactId>
<version>2.2.0-alpha</version>
</dependency>
<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/jul-to-slf4j -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>2.0.13</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

package org.eclipse.microprofile.telemetry.logs.tck.application;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.jboss.arquillian.container.test.api.Deployment;
Expand All @@ -28,16 +32,17 @@
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.testng.Assert;
import org.testng.annotations.Test;

import io.opentelemetry.api.OpenTelemetry;
import jakarta.inject.Inject;

public class LogAppenderTest extends Arquillian {
public class JulTest extends Arquillian {

@Deployment
public static WebArchive createDeployment() {
return ShrinkWrap.create(WebArchive.class)
.addAsLibrary(TestLibraries.AWAITILITY_LIB)
.addAsResource(new StringAsset(
"otel.sdk.disabled=false\notel.metrics.exporter=none\notel.traces.exporter=none\notel.logs.exporter=logging\notel.service.name=openliberty"),
"META-INF/microprofile-config.properties")
Expand All @@ -49,13 +54,46 @@ public static WebArchive createDeployment() {

private static final Logger julLogger = Logger.getLogger("jul-logger");

private static final String logFilePath = System.getProperty("log.file.path");

private static final String JUL_INFO_MESSAGE = "a very distinguishable info message";
private static final String JUL_WARN_MESSAGE = "a very distinguishable warning message";

@Test
void julTest() throws InterruptedException {
void julInfoTest() throws IOException {
julLogger.log(Level.INFO, JUL_INFO_MESSAGE);
try {
Assert.assertTrue(checkMessage(".*INFO.*" + JUL_INFO_MESSAGE + ".*scopeInfo:.*"));
} catch (IOException e) {
}
}

@Test
void julWarnTest() throws IOException {
julLogger.log(Level.WARNING, JUL_WARN_MESSAGE);
try {
Assert.assertTrue(checkMessage(".*WARN.*" + JUL_WARN_MESSAGE + ".*scopeInfo:.*"));
} catch (IOException e) {
}
}

julLogger.info("A JUL log message");
julLogger.info("A JUL log message");
julLogger.info("A JUL log message");
julLogger.info("A JUL log message");
Thread.sleep(10000);
public boolean checkMessage(String logMessage) throws IOException {
try {
try {
Thread.sleep(5000);
BufferedReader reader = new BufferedReader(new FileReader(logFilePath));
String line;
while ((line = reader.readLine()) != null) {
if (line.matches(logMessage)) {
return true;
}
}
return false;
} catch (IOException e) {
return false;
}
} catch (InterruptedException e) {
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public class ServerInstanceTest extends Arquillian {
@Deployment
public static WebArchive createDeployment() {
return ShrinkWrap.create(WebArchive.class)
.addAsLibrary(TestLibraries.AWAITILITY_LIB)
.addAsResource(new StringAsset(
"otel.service.name=" + serviceNameUnused),
"META-INF/microprofile-config.properties")
Expand Down

This file was deleted.

11 changes: 0 additions & 11 deletions tck/logs/src/main/resources/logback.xml

This file was deleted.

31 changes: 29 additions & 2 deletions tck/metrics/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,34 @@ To enable the tests in your project you need to add the following dependency to
----

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:


[source, xml]
----
otel.sdk.disabled=false
otel.metrics.exporter=console
log.file.path=console.log
----

To run the JVM metrics tests, include the following content in the `tck-suite.xml` in your project:

[source, xml]
----
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="microprofile-telemetry-metrics-TCK" verbose="2" configfailurepolicy="continue" >
<test name="telemetry-metrics-tests" verbose="10">
<packages>
<package name="org.eclipse.microprofile.telemetry.metrics.tck.jvm.*" />
</packages>
</test>
</suite>
----

The remaining metrics tests must use an OpenTelemetry SDK instance that is configured by the configuration properties set in the application. Ensure that `otel.sdk.disabled` and `otel.metrics.exporter` are NOT set by the runtime. To run the application metrics tests, include the following content in the `tck-suite.xml` in your project:

[source, xml]
----
Expand All @@ -58,7 +85,7 @@ If you want to run the metrics tests, you can specify all tests in the `tck-suit
<suite name="microprofile-telemetry-metrics-TCK" verbose="2" configfailurepolicy="continue" >
<test name="telemetry-metrics-tests" verbose="10">
<packages>
<package name="org.eclipse.microprofile.telemetry.metrics.tck.*" />
<package name="org.eclipse.microprofile.telemetry.metrics.tck.application.*" />
</packages>
</test>
</suite>
Expand Down

This file was deleted.

Loading

0 comments on commit 495a4c9

Please sign in to comment.