-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7187ca9
commit fee7c47
Showing
19 changed files
with
498 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-logging-opentelemetry-parent</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>quarkus-logging-opentelemetry-deployment</artifactId> | ||
<name>Quarkus - Logging - OpenTelemetry - Deployment</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-arc-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-opentelemetry-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-logging-opentelemetry</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5-internal</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<annotationProcessorPaths> | ||
<path> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-extension-processor</artifactId> | ||
<version>${project.version}</version> | ||
</path> | ||
</annotationProcessorPaths> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
24 changes: 24 additions & 0 deletions
24
...in/java/io/quarkus/logging/opentelemetry/deployment/OpenTelemetryLogHandlerProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.quarkus.logging.opentelemetry.deployment; | ||
|
||
import io.quarkus.deployment.Feature; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.annotations.ExecutionTime; | ||
import io.quarkus.deployment.annotations.Record; | ||
import io.quarkus.deployment.builditem.FeatureBuildItem; | ||
import io.quarkus.deployment.builditem.LogHandlerBuildItem; | ||
import io.quarkus.logging.opentelemetry.runtime.OpenTelemetryLogConfig; | ||
import io.quarkus.logging.opentelemetry.runtime.OpenTelemetryLogRecorder; | ||
|
||
class OpenTelemetryLogHandlerProcessor { | ||
|
||
@BuildStep | ||
FeatureBuildItem feature() { | ||
return new FeatureBuildItem(Feature.LOGGING_OPENTELEMETRY); | ||
} | ||
|
||
@BuildStep | ||
@Record(ExecutionTime.RUNTIME_INIT) | ||
LogHandlerBuildItem build(OpenTelemetryLogRecorder recorder, OpenTelemetryLogConfig config) { | ||
return new LogHandlerBuildItem(recorder.initializeHandler(config)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-extensions-parent</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>quarkus-logging-opentelemetry-parent</artifactId> | ||
<packaging>pom</packaging> | ||
<name>Quarkus - Logging - OpenTelemetry</name> | ||
|
||
<modules> | ||
<module>deployment</module> | ||
<module>runtime</module> | ||
</modules> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-logging-opentelemetry-parent</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>quarkus-logging-opentelemetry</artifactId> | ||
<name>Quarkus - Logging - OpenTelemetry - Runtime</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-arc</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-opentelemetry</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-extension-maven-plugin</artifactId> | ||
<version>${project.version}</version> | ||
<executions> | ||
<execution> | ||
<phase>compile</phase> | ||
<goals> | ||
<goal>extension-descriptor</goal> | ||
</goals> | ||
<configuration> | ||
<deployment>${project.groupId}:${project.artifactId}-deployment:${project.version}</deployment> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<annotationProcessorPaths> | ||
<path> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-extension-processor</artifactId> | ||
<version>${project.version}</version> | ||
</path> | ||
</annotationProcessorPaths> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
14 changes: 14 additions & 0 deletions
14
...untime/src/main/java/io/quarkus/logging/opentelemetry/runtime/OpenTelemetryLogConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.quarkus.logging.opentelemetry.runtime; | ||
|
||
import io.quarkus.runtime.annotations.ConfigItem; | ||
import io.quarkus.runtime.annotations.ConfigPhase; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
|
||
@ConfigRoot(phase = ConfigPhase.RUN_TIME, name = "log.handler.open-telemetry") | ||
public class OpenTelemetryLogConfig { | ||
/** | ||
* Determine whether to enable the OpenTelemetry logging handler | ||
*/ | ||
@ConfigItem | ||
public boolean enabled; | ||
} |
55 changes: 55 additions & 0 deletions
55
...ntime/src/main/java/io/quarkus/logging/opentelemetry/runtime/OpenTelemetryLogHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package io.quarkus.logging.opentelemetry.runtime; | ||
|
||
import java.util.logging.Handler; | ||
import java.util.logging.Level; | ||
import java.util.logging.LogRecord; | ||
|
||
import io.opentelemetry.api.OpenTelemetry; | ||
import io.opentelemetry.api.logs.Logger; | ||
import io.opentelemetry.api.logs.Severity; | ||
|
||
public class OpenTelemetryLogHandler extends Handler { | ||
private final Logger openTelemetry; | ||
|
||
public OpenTelemetryLogHandler(OpenTelemetry openTelemetry) { | ||
this.openTelemetry = openTelemetry.getLogsBridge().get("quarkus-log-appender"); | ||
} | ||
|
||
@Override | ||
public void publish(LogRecord record) { | ||
openTelemetry.logRecordBuilder() | ||
.setSeverity(mapSeverity(record.getLevel())) | ||
.setSeverityText(record.getLevel().getName()) | ||
.setBody(record.getMessage()) // TODO check that we didn't need to format it | ||
.setObservedTimestamp(record.getInstant()) | ||
// TODO add attributes | ||
.emit(); | ||
} | ||
|
||
private Severity mapSeverity(Level level) { | ||
if (Level.SEVERE.equals(level)) { | ||
return Severity.ERROR; | ||
} | ||
if (Level.WARNING.equals(level)) { | ||
return Severity.WARN; | ||
} | ||
if (Level.INFO.equals(level) || Level.CONFIG.equals(level)) { | ||
return Severity.INFO; | ||
} | ||
if (Level.FINE.equals(level)) { | ||
return Severity.DEBUG; | ||
} | ||
if (Level.FINER.equals(level) || Level.FINEST.equals(level) || Level.ALL.equals(level)) { | ||
return Severity.TRACE; | ||
} | ||
return Severity.UNDEFINED_SEVERITY_NUMBER; | ||
} | ||
|
||
@Override | ||
public void flush() { | ||
} | ||
|
||
@Override | ||
public void close() throws SecurityException { | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...time/src/main/java/io/quarkus/logging/opentelemetry/runtime/OpenTelemetryLogRecorder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.quarkus.logging.opentelemetry.runtime; | ||
|
||
import java.util.Optional; | ||
import java.util.logging.Handler; | ||
|
||
import io.opentelemetry.api.GlobalOpenTelemetry; | ||
import io.quarkus.runtime.RuntimeValue; | ||
import io.quarkus.runtime.annotations.Recorder; | ||
|
||
@Recorder | ||
public class OpenTelemetryLogRecorder { | ||
public RuntimeValue<Optional<Handler>> initializeHandler(final OpenTelemetryLogConfig config) { | ||
if (!config.enabled) { | ||
return new RuntimeValue<>(Optional.empty()); | ||
} | ||
|
||
OpenTelemetryLogHandler handler = new OpenTelemetryLogHandler(GlobalOpenTelemetry.get()); | ||
|
||
return new RuntimeValue<>(Optional.of(handler)); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
extensions/logging-opentelemetry/runtime/src/main/resources/META-INF/quarkus-extension.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: Logging Opentelemetry | ||
#description: Do something useful. | ||
metadata: | ||
# keywords: | ||
# - logging-opentelemetry | ||
# guide: ... # To create and publish this guide, see https://github.com/quarkiverse/quarkiverse/wiki#documenting-your-extension | ||
# categories: | ||
# - "miscellaneous" | ||
# status: "preview" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.