Skip to content

Commit

Permalink
Disabled test and default configs for logs
Browse files Browse the repository at this point in the history
Optimize level mapping by using comparison on intValue()
  • Loading branch information
loicmathieu authored and brunobat committed Sep 16, 2024
1 parent 1630974 commit 7f1c86f
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.quarkus.opentelemetry.deployment.logs;

import io.opentelemetry.sdk.logs.export.LogRecordExporter;
import io.quarkus.opentelemetry.deployment.common.InMemoryLogRecordExporter;
import io.quarkus.opentelemetry.deployment.common.InMemoryLogRecordExporterProvider;
import io.quarkus.test.QuarkusUnitTest;
import jakarta.enterprise.inject.Instance;
import jakarta.inject.Inject;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import static org.assertj.core.api.Assertions.assertThat;

public class OtelLogsDisabledTest {
@RegisterExtension
static final QuarkusUnitTest TEST = new QuarkusUnitTest()
.setArchiveProducer(
() -> ShrinkWrap.create(JavaArchive.class)
.add(new StringAsset(
"quarkus.otel.logs.enabled=false\n" +
"quarkus.otel.traces.enabled=false\n"),
"application.properties"));


@Inject
Instance<LogRecordExporter> logRecordExporter;

@Test
public void testLogRecordExporter() {
assertThat(logRecordExporter.isUnsatisfied()).isTrue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ quarkus.otel.metrics.exporter=in-memory
quarkus.otel.metric.export.interval=300ms

# Logs
quarkus.otel.logs.exporter=in-memory
quarkus.otel.logs.exporter=in-memory
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,26 @@ public SmallRyeConfigBuilder configBuilder(final SmallRyeConfigBuilder builder)
fallbacks.put("quarkus.otel.exporter.otlp.metrics.proxy-options.host", "quarkus.otel.exporter.otlp.proxy-options.host");
fallbacks.put("quarkus.otel.exporter.otlp.metrics.proxy-options.port", "quarkus.otel.exporter.otlp.proxy-options.port");

//Logs
fallbacks.put("quarkus.otel.exporter.otlp.logs.endpoint", "quarkus.otel.exporter.otlp.endpoint");
fallbacks.put("quarkus.otel.exporter.otlp.logs.headers", "quarkus.otel.exporter.otlp.headers");
fallbacks.put("quarkus.otel.exporter.otlp.logs.compression", "quarkus.otel.exporter.otlp.compression");
fallbacks.put("quarkus.otel.exporter.otlp.logs.timeout", "quarkus.otel.exporter.otlp.timeout");
fallbacks.put("quarkus.otel.exporter.otlp.logs.protocol", "quarkus.otel.exporter.otlp.protocol");
fallbacks.put("quarkus.otel.exporter.otlp.logs.key-cert.keys", "quarkus.otel.exporter.otlp.key-cert.keys");
fallbacks.put("quarkus.otel.exporter.otlp.logs.key-cert.certs", "quarkus.otel.exporter.otlp.key-cert.certs");
fallbacks.put("quarkus.otel.exporter.otlp.logs.trust-cert.certs", "quarkus.otel.exporter.otlp.trust-cert.certs");
fallbacks.put("quarkus.otel.exporter.otlp.logs.tls-configuration-name",
"quarkus.otel.exporter.otlp.tls-configuration-name");
fallbacks.put("quarkus.otel.exporter.otlp.logs.proxy-options.enabled",
"quarkus.otel.exporter.otlp.proxy-options.enabled");
fallbacks.put("quarkus.otel.exporter.otlp.logs.proxy-options.username",
"quarkus.otel.exporter.otlp.proxy-options.username");
fallbacks.put("quarkus.otel.exporter.otlp.logs.proxy-options.password",
"quarkus.otel.exporter.otlp.proxy-options.password");
fallbacks.put("quarkus.otel.exporter.otlp.logs.proxy-options.host", "quarkus.otel.exporter.otlp.proxy-options.host");
fallbacks.put("quarkus.otel.exporter.otlp.logs.proxy-options.port", "quarkus.otel.exporter.otlp.proxy-options.port");

return builder.withInterceptors(new FallbackConfigSourceInterceptor(fallbacks));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ public void publish(LogRecord record) {
}

private Severity mapSeverity(Level level) {
if (Level.SEVERE.equals(level)) {
if (level.intValue() == Level.SEVERE.intValue()) {
return Severity.ERROR;
}
if (Level.WARNING.equals(level)) {
if (level.intValue() == Level.WARNING.intValue()) {
return Severity.WARN;
}
if (Level.INFO.equals(level) || Level.CONFIG.equals(level)) {
if (level.intValue() <= Level.INFO.intValue() && level.intValue() >= Level.CONFIG.intValue()) {
return Severity.INFO;
}
if (Level.FINE.equals(level)) {
if (level.intValue() == Level.FINE.intValue()) {
return Severity.DEBUG;
}
if (Level.FINER.equals(level) || Level.FINEST.equals(level) || Level.ALL.equals(level)) {
if (level.intValue() <= Level.FINER.intValue()) {
return Severity.TRACE;
}
return Severity.UNDEFINED_SEVERITY_NUMBER;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
io.quarkus.opentelemetry.runtime.logs.spi.LogsExporterCDIProvider
io.quarkus.opentelemetry.runtime.logs.spi.LogsExporterCDIProvider

0 comments on commit 7f1c86f

Please sign in to comment.