From 508268d48c787377a47cd069581c6a523e624deb Mon Sep 17 00:00:00 2001 From: Yotam loewenbach Date: Mon, 30 Dec 2024 13:25:03 +0700 Subject: [PATCH 01/11] Fix existing unit tests (remove ref to `JAVA_HOME`) --- .../java/io/logz/logback/LogzioLogbackAppenderTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/io/logz/logback/LogzioLogbackAppenderTest.java b/src/test/java/io/logz/logback/LogzioLogbackAppenderTest.java index f84198b..bcd1c0a 100644 --- a/src/test/java/io/logz/logback/LogzioLogbackAppenderTest.java +++ b/src/test/java/io/logz/logback/LogzioLogbackAppenderTest.java @@ -137,8 +137,8 @@ public void validateAdditionalFields() throws Exception { int drainTimeout = 1; String message1 = "Just a log - " + random(5); Map additionalFields = new HashMap<>(); - String additionalFieldsString = "java_home=$JAVA_HOME;testing=yes;message=override"; - additionalFields.put("java_home", System.getenv("JAVA_HOME")); + String additionalFieldsString = "java_home=java_home;testing=yes;message=override"; + additionalFields.put("java_home", "java_home"); additionalFields.put("testing", "yes"); Logger testLogger = createLogger(logzioLogbackAppender, token, type, loggerName, drainTimeout, false, false, additionalFieldsString, false); @@ -343,13 +343,13 @@ public void checkExactStackTrace() throws Exception { @Test public void testTokenAndLogzioUrlFromSystemEnvironment() { - String token = System.getenv("JAVA_HOME"); + String token = "token"; String type = "testType" + random(8); String loggerName = "testLogger" + random(8); int drainTimeout = 1; String message1 = "Just a log - " + random(5); - Logger testLogger = createLogger(logzioLogbackAppender, "$JAVA_HOME", type, loggerName, drainTimeout, false, false, null, false); + Logger testLogger = createLogger(logzioLogbackAppender, token, type, loggerName, drainTimeout, false, false, null, false); testLogger.info(message1); From 33b6e68116d3118e2c2cf8cb184623c959f24ed5 Mon Sep 17 00:00:00 2001 From: Yotam loewenbach Date: Mon, 30 Dec 2024 14:50:43 +0700 Subject: [PATCH 02/11] docs + changelog --- README.md | 66 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 5be92ba..d89787c 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ JDK 11 and above: io.logz.logback logzio-logback-appender - 2.0.1 + 2.1.0 ``` @@ -60,27 +60,28 @@ Logback appender also requires logback classic: ``` ### Parameters -| Parameter | Default | Explained | -| ------------------ | ------------------------------------ | ----- | -| **token** | *None* | Your Logz.io token, which can be found under "settings" in your account, If the value begins with `$` then the appender looks for an environment variable or system property with the name specified. For example: `$LOGZIO_TOKEN` will look for environment variable named `LOGZIO_TOKEN` | -| **logzioType** | *java* | The [log type](https://docs.logz.io/user-guide/log-shipping/built-in-log-types.html) for that appender, it must not contain spaces | -| **logzioUrl** | *https://listener.logz.io:8071* | The url that the appender sends to. If your account is in the EU you must use https://listener-eu.logz.io:8071 | -| **drainTimeoutSec** | *5* | How often the appender should drain the queue (in seconds) | -| **socketTimeout** | *10 * 1000* | The socket timeout during log shipment | -| **connectTimeout** | *10 * 1000* | The connection timeout during log shipment | -| **addHostname** | *false* | Optional. If true, then a field named 'hostname' will be added holding the host name of the machine. If from some reason there's no defined hostname, this field won't be added | -| **additionalFields** | *None* | Optional. Allows to add additional fields to the JSON message sent. The format is "fieldName1=fieldValue1;fieldName2=fieldValue2". You can optionally inject an environment variable value using the following format: "fieldName1=fieldValue1;fieldName2=$ENV_VAR_NAME". In that case, the environment variable should be the only value. In case the environment variable can't be resolved, the field will be omitted. | -| **debug** | *false* | Print some debug messages to stdout to help to diagnose issues | -| **line** | *false* | Print the line of code that generated this log | -| **compressRequests** | *false* | Boolean. `true` if logs are compressed in gzip format before sending. `false` if logs are sent uncompressed. | -| **format** | *text* | Optional. `json` if the logged message is to be parsed as a JSON (in such a way that each JSON node will be a field in logz.io) or `text` if the logged message is to be treated as plain text. -| **exceedMaxSizeAction** | *"cut"* | String. cut to truncate the message field or drop to drop log that exceed the allowed maximum size for logzio. If the log size exceeding the maximum size allowed after truncating the message field, the log will be dropped. | +| Parameter | Default | Explained | +|-----------------------------|---------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **token** | *None* | Your Logz.io token, which can be found under "settings" in your account, If the value begins with `$` then the appender looks for an environment variable or system property with the name specified. For example: `$LOGZIO_TOKEN` will look for environment variable named `LOGZIO_TOKEN` | +| **logzioType** | *java* | The [log type](https://docs.logz.io/user-guide/log-shipping/built-in-log-types.html) for that appender, it must not contain spaces | +| **logzioUrl** | *https://listener.logz.io:8071* | The url that the appender sends to. If your account is in the EU you must use https://listener-eu.logz.io:8071 | +| **drainTimeoutSec** | *5* | How often the appender should drain the queue (in seconds) | +| **socketTimeout** | *10 * 1000* | The socket timeout during log shipment | +| **connectTimeout** | *10 * 1000* | The connection timeout during log shipment | +| **addHostname** | *false* | Optional. If true, then a field named 'hostname' will be added holding the host name of the machine. If from some reason there's no defined hostname, this field won't be added | +| **additionalFields** | *None* | Optional. Allows to add additional fields to the JSON message sent. The format is "fieldName1=fieldValue1;fieldName2=fieldValue2". You can optionally inject an environment variable value using the following format: "fieldName1=fieldValue1;fieldName2=$ENV_VAR_NAME". In that case, the environment variable should be the only value. In case the environment variable can't be resolved, the field will be omitted. | +| **addOpentelemetryContext** | *true* | Optional. Add `trace_id`, `span_id`, `service_name` fields to logs when opentelemetry context is available. | +| **debug** | *false* | Print some debug messages to stdout to help to diagnose issues | +| **line** | *false* | Print the line of code that generated this log | +| **compressRequests** | *false* | Boolean. `true` if logs are compressed in gzip format before sending. `false` if logs are sent uncompressed. | +| **format** | *text* | Optional. `json` if the logged message is to be parsed as a JSON (in such a way that each JSON node will be a field in logz.io) or `text` if the logged message is to be treated as plain text. | +| **exceedMaxSizeAction** | *"cut"* | String. cut to truncate the message field or drop to drop log that exceed the allowed maximum size for logzio. If the log size exceeding the maximum size allowed after truncating the message field, the log will be dropped. | #### Parameters for in-memory queue -| Parameter | Default | Explained | -| ------------------ | ------------------------------------ | ----- | -| **inMemoryQueueCapacityBytes** | *1024 * 1024 * 100* | The amount of memory(bytes) we are allowed to use for the memory queue. If the value is -1 the sender will not limit the queue size.| -| **inMemoryLogsCountCapacity** | *-1* | Number of logs we are allowed to have in the queue before dropping logs. If the value is -1 the sender will not limit the number of logs allowed.| -| **inMemoryQueue** | *false* | Set to true if the appender uses in memory queue. By default the appender uses disk queue| +| Parameter | Default | Explained | +| ------------------ |-----------------------| ----- | +| **inMemoryQueueCapacityBytes** | *1024 * 1024 * 100* | The amount of memory(bytes) we are allowed to use for the memory queue. If the value is -1 the sender will not limit the queue size.| +| **inMemoryLogsCountCapacity** | *-1* | Number of logs we are allowed to have in the queue before dropping logs. If the value is -1 the sender will not limit the number of logs allowed.| +| **inMemoryQueue** | *false* | Set to true if the appender uses in memory queue. By default the appender uses disk queue| #### Parameters for disk queue @@ -162,6 +163,24 @@ Will send a log to Logz.io that looks like this: } ``` +## Add opentelemetry context +If you're sending traces with OpenTelemetry instrumentation (auto or manual), you can correlate your logs with the trace context. That way, your logs will have traces data in it, such as service name, span id and trace id (version >= `2.2.0`). This feature is enabled by default, To disable it, set the `addOpentelemetryContext` option in your configuration to `false`, like in this example: + +```xml + + + yourlogziopersonaltokenfromsettings + myAwesomeType + https://listener.logz.io:8071 + false + + + + + + +``` + ## Build and test locally 1. Clone the repository: ```bash @@ -175,7 +194,10 @@ Will send a log to Logz.io that looks like this: ``` ### Release notes -- 2.0.1 + - 2.1.0 + - Updated LogzioSender version to `2.2.0` + - Add `addOpentelemetryContext` option, to add `trace_id`, `span_id`, `service_name` fields to logs when opentelemetry context is available. + - 2.0.1 - Updated LogzioSender version to `2.0.1` - Add `User-Agent` header with logz.io information - 2.0.0 - **THIS IS A SNAPSHOT RELEASE - SUPPORTED WITH JDK 11 AND ABOVE** From 71c5506a6bc6c0dd7490bc3d6dfb1d42e5c77874 Mon Sep 17 00:00:00 2001 From: Yotam loewenbach Date: Mon, 30 Dec 2024 14:51:08 +0700 Subject: [PATCH 03/11] Add `addOpentelemetryContext` option --- src/main/java/io/logz/logback/LogzioLogbackAppender.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/io/logz/logback/LogzioLogbackAppender.java b/src/main/java/io/logz/logback/LogzioLogbackAppender.java index dff56cd..8703247 100644 --- a/src/main/java/io/logz/logback/LogzioLogbackAppender.java +++ b/src/main/java/io/logz/logback/LogzioLogbackAppender.java @@ -70,6 +70,7 @@ public class LogzioLogbackAppender extends UnsynchronizedAppenderBase encoder = null; private String exceedMaxSizeAction = "cut"; + private boolean addOpentelemetryContext = true; public LogzioLogbackAppender() { super(); @@ -229,6 +230,12 @@ public void setExceedMaxSizeAction(String exceedMaxSizeAction) { this.exceedMaxSizeAction = exceedMaxSizeAction; } } + public boolean isAddOpentelemetryContext() { + return addOpentelemetryContext; + } + public void setAddOpentelemetryContext(boolean addOpentelemetryContext) { + this.addOpentelemetryContext = addOpentelemetryContext; + } @Override public void start() { @@ -288,6 +295,7 @@ private LogzioSender.Builder getSenderBuilder(HttpsRequestConfiguration conf) { .setHttpsRequestConfiguration(conf) .setReporter(new StatusReporter()) .setTasksExecutor(context.getScheduledExecutorService()) +// .setWithOpentelemetryContext(addOpentelemetryContext) .setExceedMaxSizeAction(exceedMaxSizeAction); } From 330dd8977e9d0abf00262620caae60a705dff9ca Mon Sep 17 00:00:00 2001 From: Yotam loewenbach Date: Tue, 31 Dec 2024 13:56:14 +0700 Subject: [PATCH 04/11] Update dependencies --- pom.xml | 8 ++++---- src/main/java/io/logz/logback/LogzioLogbackAppender.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 9b69b56..5bdcb32 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.logz.logback logzio-logback-appender - 2.0.1 + 2.1.0 jar Logz.io Logback Appender @@ -173,7 +173,7 @@ io.logz.sender logzio-sender - ${logzio-sender-version} + 2.2.0 org.slf4j @@ -195,13 +195,13 @@ org.assertj assertj-core - 3.4.1 + 3.24.2 test io.logz.sender logzio-sender-test - ${logzio-sender-version} + 2.2.0 test diff --git a/src/main/java/io/logz/logback/LogzioLogbackAppender.java b/src/main/java/io/logz/logback/LogzioLogbackAppender.java index 8703247..4884a85 100644 --- a/src/main/java/io/logz/logback/LogzioLogbackAppender.java +++ b/src/main/java/io/logz/logback/LogzioLogbackAppender.java @@ -295,7 +295,7 @@ private LogzioSender.Builder getSenderBuilder(HttpsRequestConfiguration conf) { .setHttpsRequestConfiguration(conf) .setReporter(new StatusReporter()) .setTasksExecutor(context.getScheduledExecutorService()) -// .setWithOpentelemetryContext(addOpentelemetryContext) + .setWithOpentelemetryContext(addOpentelemetryContext) .setExceedMaxSizeAction(exceedMaxSizeAction); } From c3734f87a3b227be671913f79e1188b4d72ae6d6 Mon Sep 17 00:00:00 2001 From: Yotam loewenbach Date: Tue, 31 Dec 2024 15:03:51 +0700 Subject: [PATCH 05/11] Add new unit tests --- .../logback/LogzioLogbackAppenderTest.java | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/src/test/java/io/logz/logback/LogzioLogbackAppenderTest.java b/src/test/java/io/logz/logback/LogzioLogbackAppenderTest.java index bcd1c0a..4f015e3 100644 --- a/src/test/java/io/logz/logback/LogzioLogbackAppenderTest.java +++ b/src/test/java/io/logz/logback/LogzioLogbackAppenderTest.java @@ -6,6 +6,10 @@ import ch.qos.logback.core.spi.DeferredProcessingAware; import io.logz.sender.com.google.gson.Gson; import io.logz.test.MockLogzioBulkListener; +import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.api.trace.Tracer; +import io.opentelemetry.sdk.OpenTelemetrySdk; +import io.opentelemetry.sdk.trace.SdkTracerProvider; import net.logstash.logback.composite.AbstractFieldJsonProvider; import net.logstash.logback.composite.AbstractPatternJsonProvider; import net.logstash.logback.composite.loggingevent.LogLevelJsonProvider; @@ -33,6 +37,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; +import io.opentelemetry.api.trace.Span; +import io.opentelemetry.context.Scope; + + @RunWith(Parameterized.class) public class LogzioLogbackAppenderTest extends BaseLogbackAppenderTest { private LogzioLogbackAppender logzioLogbackAppender; @@ -59,6 +67,122 @@ public LogzioLogbackAppenderTest(QueueType queueType) { this.queueType = queueType; } + /** + * Initializes the OpenTelemetry SDK with a logging span exporter and the W3C Trace Context + * propagator. + * + * @return A ready-to-use {@link OpenTelemetry} instance. + */ + protected OpenTelemetry initOpenTelemetry() { + SdkTracerProvider sdkTracerProvider = + SdkTracerProvider.builder() + .build(); + + OpenTelemetrySdk sdk = + OpenTelemetrySdk.builder() + .setTracerProvider(sdkTracerProvider) + .build(); + + Runtime.getRuntime().addShutdownHook(new Thread(sdkTracerProvider::close)); + return sdk; + } + + @Test + public void openTelemetryContext_Enabled() { + String token = "token"; + String type = "type" + random(8); + String loggerName = "otelLogger" + random(8); + int drainTimeout = 1; + logzioLogbackAppender.setAddOpentelemetryContext(true); + Logger testLogger = createLogger( + logzioLogbackAppender, + token, + type, + loggerName, + drainTimeout, + false, + false, + null, + false + ); + + OpenTelemetry openTelemetry = initOpenTelemetry(); + Tracer tracer = openTelemetry.getTracer("test"); + Span span = tracer.spanBuilder("test").startSpan(); + try (Scope scope = span.makeCurrent()) { + String message = "Test log with OTel context "; + testLogger.info(message); + sleepSeconds(drainTimeout * 2); + MockLogzioBulkListener.LogRequest logRequest = mockListener.assertLogReceivedByMessage(message); + mockListener.assertLogReceivedIs(logRequest, token, type, loggerName, Level.INFO.levelStr); + String traceId = logRequest.getStringFieldOrNull("trace_id"); + String spanId = logRequest.getStringFieldOrNull("span_id"); + String serviceName = logRequest.getStringFieldOrNull("service_name"); + + assertThat(traceId) + .as("Check 'trace_id' is present when addOpentelemetryContext=true") + .isNotNull(); + assertThat(spanId) + .as("Check 'span_id' is present when addOpentelemetryContext=true") + .isNotNull(); + assertThat(serviceName) + .as("Check 'service_name' is present when addOpentelemetryContext=true") + .isNotNull(); + } finally { + span.end(); + } + } + + @Test + public void openTelemetryContext_Disabled() { + String token = "token"; + String type = "type" ; + String loggerName = "otelLogger" + random(8); + int drainTimeout = 1; + + logzioLogbackAppender.setAddOpentelemetryContext(false); + Logger testLogger = createLogger( + logzioLogbackAppender, + token, + type, + loggerName, + drainTimeout, + false, + false, + null, + false + ); + OpenTelemetry openTelemetry = initOpenTelemetry(); + Tracer tracer = openTelemetry.getTracer("test"); + Span span = tracer.spanBuilder("test").startSpan(); + + try (Scope scope = span.makeCurrent()) { + String message = "Test log with OTel context disabled"; + testLogger.info(message); + + sleepSeconds(drainTimeout * 2); + + mockListener.assertNumberOfReceivedMsgs(1); + MockLogzioBulkListener.LogRequest logRequest = mockListener.assertLogReceivedByMessage(message); + mockListener.assertLogReceivedIs(logRequest, token, type, loggerName, Level.INFO.levelStr); + + String traceId = logRequest.getStringFieldOrNull("trace_id"); + String spanId = logRequest.getStringFieldOrNull("span_id"); + String serviceName = logRequest.getStringFieldOrNull("service_name"); + + assertThat(traceId) + .as("Check 'trace_id' should NOT be present when addOpentelemetryContext=false") + .isNull(); + assertThat(spanId) + .as("Check 'span_id' should NOT be present when addOpentelemetryContext=false") + .isNull(); + assertThat(serviceName) + .as("Check 'service_name' should NOT be present when addOpentelemetryContext=false") + .isNull(); + } finally { + span.end(); + } + } @Test public void validateJsonMessage(){ String token = "validateJsonMessageToken"; From c3fd472b03583bd647d8fc70334fd89306b5266a Mon Sep 17 00:00:00 2001 From: Yotam loewenbach Date: Tue, 31 Dec 2024 15:04:36 +0700 Subject: [PATCH 06/11] format tables docs --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d89787c..41acfda 100644 --- a/README.md +++ b/README.md @@ -77,20 +77,20 @@ Logback appender also requires logback classic: | **format** | *text* | Optional. `json` if the logged message is to be parsed as a JSON (in such a way that each JSON node will be a field in logz.io) or `text` if the logged message is to be treated as plain text. | | **exceedMaxSizeAction** | *"cut"* | String. cut to truncate the message field or drop to drop log that exceed the allowed maximum size for logzio. If the log size exceeding the maximum size allowed after truncating the message field, the log will be dropped. | #### Parameters for in-memory queue -| Parameter | Default | Explained | -| ------------------ |-----------------------| ----- | -| **inMemoryQueueCapacityBytes** | *1024 * 1024 * 100* | The amount of memory(bytes) we are allowed to use for the memory queue. If the value is -1 the sender will not limit the queue size.| -| **inMemoryLogsCountCapacity** | *-1* | Number of logs we are allowed to have in the queue before dropping logs. If the value is -1 the sender will not limit the number of logs allowed.| -| **inMemoryQueue** | *false* | Set to true if the appender uses in memory queue. By default the appender uses disk queue| +| Parameter | Default | Explained | +|--------------------------------|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------| +| **inMemoryQueueCapacityBytes** | *1024 * 1024 * 100* | The amount of memory(bytes) we are allowed to use for the memory queue. If the value is -1 the sender will not limit the queue size. | +| **inMemoryLogsCountCapacity** | *-1* | Number of logs we are allowed to have in the queue before dropping logs. If the value is -1 the sender will not limit the number of logs allowed. | +| **inMemoryQueue** | *false* | Set to true if the appender uses in memory queue. By default the appender uses disk queue | #### Parameters for disk queue -| Parameter | Default | Explained | -| ------------------ | ------------------------------------ | ----- | -| **fileSystemFullPercentThreshold** | *98* | The percent of used file system space at which the sender will stop queueing. When we will reach that percentage, the file system in which the queue is stored will drop all new logs until the percentage of used space drops below that threshold. Set to -1 to never stop processing new logs | -| **gcPersistedQueueFilesIntervalSeconds** | *30* | How often the disk queue should clean sent logs from disk | -| **bufferDir**(deprecated, use queueDir) | *System.getProperty("java.io.tmpdir")* | Where the appender should store the queue | -| **queueDir** | *System.getProperty("java.io.tmpdir")* | Where the appender should store the queue | +| Parameter | Default | Explained | +|------------------------------------------|----------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **fileSystemFullPercentThreshold** | *98* | The percent of used file system space at which the sender will stop queueing. When we will reach that percentage, the file system in which the queue is stored will drop all new logs until the percentage of used space drops below that threshold. Set to -1 to never stop processing new logs | +| **gcPersistedQueueFilesIntervalSeconds** | *30* | How often the disk queue should clean sent logs from disk | +| **bufferDir**(deprecated, use queueDir) | *System.getProperty("java.io.tmpdir")* | Where the appender should store the queue | +| **queueDir** | *System.getProperty("java.io.tmpdir")* | Where the appender should store the queue | ### Code Example From fdbf05ec5ea5e1129c518c56ad3fc8ee8ef0c2df Mon Sep 17 00:00:00 2001 From: Yotam loewenbach Date: Thu, 2 Jan 2025 15:33:31 +0700 Subject: [PATCH 07/11] Update version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0375195..2c5ef28 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.logz.logback logzio-logback-appender - 2.1.0 + 2.2.0 jar Logz.io Logback Appender From 980fcd9f9c88df153c960dd02acb20a120a702d4 Mon Sep 17 00:00:00 2001 From: Yotam loewenbach Date: Thu, 2 Jan 2025 16:06:19 +0700 Subject: [PATCH 08/11] Refactor logger names --- .../java/io/logz/logback/LogzioLogbackAppenderTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/io/logz/logback/LogzioLogbackAppenderTest.java b/src/test/java/io/logz/logback/LogzioLogbackAppenderTest.java index 006fef3..2e24200 100644 --- a/src/test/java/io/logz/logback/LogzioLogbackAppenderTest.java +++ b/src/test/java/io/logz/logback/LogzioLogbackAppenderTest.java @@ -110,7 +110,7 @@ public void openTelemetryContext_Enabled() { Tracer tracer = openTelemetry.getTracer("test"); Span span = tracer.spanBuilder("test").startSpan(); try (Scope scope = span.makeCurrent()) { - String message = "Test log with OTel context "; + String message = "Test log"; testLogger.info(message); sleepSeconds(drainTimeout * 2); MockLogzioBulkListener.LogRequest logRequest = mockListener.assertLogReceivedByMessage(message); @@ -136,7 +136,7 @@ public void openTelemetryContext_Enabled() { @Test public void openTelemetryContext_Disabled() { String token = "token"; - String type = "type" ; + String type = "type" + random(8); String loggerName = "otelLogger" + random(8); int drainTimeout = 1; @@ -157,7 +157,7 @@ public void openTelemetryContext_Disabled() { Span span = tracer.spanBuilder("test").startSpan(); try (Scope scope = span.makeCurrent()) { - String message = "Test log with OTel context disabled"; + String message = "Test log"; testLogger.info(message); sleepSeconds(drainTimeout * 2); From 2e83fe058a008b143da6bce2da25bd7ab0a5b833 Mon Sep 17 00:00:00 2001 From: Yotam loewenbach Date: Thu, 2 Jan 2025 16:31:32 +0700 Subject: [PATCH 09/11] refactor test log messages --- src/test/java/io/logz/logback/LogzioLogbackAppenderTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/io/logz/logback/LogzioLogbackAppenderTest.java b/src/test/java/io/logz/logback/LogzioLogbackAppenderTest.java index 2e24200..fd6e7ca 100644 --- a/src/test/java/io/logz/logback/LogzioLogbackAppenderTest.java +++ b/src/test/java/io/logz/logback/LogzioLogbackAppenderTest.java @@ -110,7 +110,7 @@ public void openTelemetryContext_Enabled() { Tracer tracer = openTelemetry.getTracer("test"); Span span = tracer.spanBuilder("test").startSpan(); try (Scope scope = span.makeCurrent()) { - String message = "Test log"; + String message = "Simple log line - "+random(5); testLogger.info(message); sleepSeconds(drainTimeout * 2); MockLogzioBulkListener.LogRequest logRequest = mockListener.assertLogReceivedByMessage(message); @@ -157,7 +157,7 @@ public void openTelemetryContext_Disabled() { Span span = tracer.spanBuilder("test").startSpan(); try (Scope scope = span.makeCurrent()) { - String message = "Test log"; + String message = "Simple log line - "+random(5); testLogger.info(message); sleepSeconds(drainTimeout * 2); From 94933e8681f5b3b1d9b83ea85df8ac96c3f9b6d1 Mon Sep 17 00:00:00 2001 From: Yotam loewenbach Date: Sun, 5 Jan 2025 12:40:30 +0700 Subject: [PATCH 10/11] Use `logzio-sender-version` instead of static version --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 2c5ef28..5ed9417 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ - 2.1.0 + 2.2.0 @@ -173,7 +173,7 @@ io.logz.sender logzio-sender - 2.2.0 + ${logzio-sender-version} org.slf4j @@ -195,7 +195,7 @@ io.logz.sender logzio-sender-test - 2.2.0 + ${logzio-sender-version} test From e32d5d84a2a16f5ebc867ef598b2becdef65a63c Mon Sep 17 00:00:00 2001 From: Yotam loewenbach Date: Mon, 6 Jan 2025 10:54:20 +0700 Subject: [PATCH 11/11] Update readme dep versions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6909b1c..08ae5e4 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ JDK 11 and above: io.logz.logback logzio-logback-appender - 2.1.0 + 2.2.0 ```