Skip to content

Commit

Permalink
Update logs TCK
Browse files Browse the repository at this point in the history
  • Loading branch information
yasmin-aumeeruddy committed May 16, 2024
1 parent 0121a43 commit ce9ecee
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<groupId>org.eclipse.microprofile.telemetry</groupId>
<artifactId>microprofile-telemetry-parent</artifactId>
<version>1.2-SNAPSHOT</version>
<version>2.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>MicroProfile Telemetry</name>
<url>https://microprofile.io/project/eclipse/microprofile-telemetry</url>
Expand Down
2 changes: 1 addition & 1 deletion spec/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>org.eclipse.microprofile.telemetry</groupId>
<artifactId>microprofile-telemetry-parent</artifactId>
<version>1.2-SNAPSHOT</version>
<version>2.0-SNAPSHOT</version>
</parent>

<artifactId>microprofile-telemetry-spec</artifactId>
Expand Down
18 changes: 6 additions & 12 deletions tck/logs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>org.eclipse.microprofile.telemetry</groupId>
<artifactId>microprofile-telemetry-tck-parent</artifactId>
<version>1.2-SNAPSHOT</version>
<version>2.0-SNAPSHOT</version>
</parent>

<artifactId>microprofile-telemetry-logs-tck</artifactId>
Expand Down Expand Up @@ -50,11 +50,6 @@
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-extension-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>jakarta.enterprise.concurrent</groupId>
<artifactId>jakarta.enterprise.concurrent-api</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-instrumentation-annotations</artifactId>
Expand All @@ -77,12 +72,11 @@
<version>1.5.5</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.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,7 @@

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

import java.io.File;
import java.util.logging.Logger;

import org.eclipse.microprofile.telemetry.logs.tck.TestLibraries;
Expand All @@ -31,6 +32,7 @@
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
import org.slf4j.bridge.SLF4JBridgeHandler;
import org.testng.Assert;
import org.testng.annotations.Test;
Expand All @@ -40,17 +42,30 @@
import io.opentelemetry.sdk.autoconfigure.spi.logs.ConfigurableLogRecordExporterProvider;
import jakarta.inject.Inject;

//Log from application to OpenTelemetry
//When logging something, it will be logged to Open Telemetry
public class LogAppenderTest extends Arquillian {
@Deployment
public static WebArchive createDeployment() {
File[] slf4jFiles = Maven.resolver().resolve("org.slf4j:jul-to-slf4j:2.0.13").withTransitivity().asFile();
File[] telemetryLogbackFiles = Maven.resolver()
.resolve("io.opentelemetry.instrumentation:opentelemetry-logback-appender-1.0:2.2.0-alpha")
.withTransitivity().asFile();
File[] logbackFiles =
Maven.resolver().resolve("ch.qos.logback:logback-classic:1.5.5").withTransitivity().asFile();

return ShrinkWrap.create(WebArchive.class)
.addClasses(InMemoryLogRecordExporter.class, InMemoryLogRecordExporterProvider.class)
.addAsLibrary(TestLibraries.AWAITILITY_LIB)
.addAsLibraries(slf4jFiles)
.addAsLibraries(telemetryLogbackFiles)
.addAsLibraries(logbackFiles)
.addAsServiceProvider(ConfigurableLogRecordExporterProvider.class,
InMemoryLogRecordExporterProvider.class)
.addAsResource(new StringAsset(
"otel.sdk.disabled=false\notel.metrics.exporter=\notel.traces.exporter=none\notel.logs.exporter=in-memory"),
"otel.sdk.disabled=false\notel.metrics.exporter=none\notel.traces.exporter=none\notel.logs.exporter=in-memory\notel.blrp.max.export.batch.size=1\notel.blrp.schedule.delay=30"),
"META-INF/microprofile-config.properties")
.addAsResource("logback.xml")
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}

Expand All @@ -60,7 +75,7 @@ public static WebArchive createDeployment() {
@Inject
private InMemoryLogRecordExporter memoryExporter;

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

@Test
void julTest() throws InterruptedException {
Expand All @@ -71,6 +86,8 @@ void julTest() throws InterruptedException {
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
julLogger.info("A JUL log message");
Assert.assertEquals(memoryExporter.getFinishedLogRecordItems(1).get(0).getBody(), "A JUL log message");

Assert.assertTrue(
memoryExporter.getFinishedLogRecordItems(1).get(0).getBody().toString().contains("A JUL log message"));
}
}
11 changes: 11 additions & 0 deletions tck/logs/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="OpenTelemetry"
class="io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender">
<captureExperimentalAttributes>true</captureExperimentalAttributes>
<captureKeyValuePairAttributes>true</captureKeyValuePairAttributes>
</appender>
<root level="INFO">
<appender-ref ref="OpenTelemetry"/>
</root>
</configuration>
4 changes: 2 additions & 2 deletions tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
<parent>
<groupId>org.eclipse.microprofile.telemetry</groupId>
<artifactId>microprofile-telemetry-parent</artifactId>
<version>1.2-SNAPSHOT</version>
<version>2.0-SNAPSHOT</version>
</parent>

<artifactId>microprofile-telemetry-tck-parent</artifactId>
<version>1.2-SNAPSHOT</version>
<version>2.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>MicroProfile Telemetry TCK</name>

Expand Down

0 comments on commit ce9ecee

Please sign in to comment.