diff --git a/README.md b/README.md index 819a13a..66584d8 100644 --- a/README.md +++ b/README.md @@ -21,36 +21,37 @@ This appender uses [BigQueue](https://github.com/bulldog2011/bigqueue) implement If you use Gradle, add the dependency to your project as follows: ```java -implementation 'io.logz.sender:logzio-java-sender:2.0.0' +implementation 'io.logz.sender:logzio-java-sender:${logzio-sender-version}' ``` ### Parameters -| Parameter | Default | Explained | -| ------------------ | ------------------------------------ | ----- | -| **token** | *None* | Your Logz.io token, which can be found under "settings" in your account. -| **logzioType** | *java* | The [log type](http://support.logz.io/support/solutions/articles/6000103063-what-is-type-) for that sender | -| **drainTimeoutSec** | *5* | How often the sender should drain the queue (in seconds) | -| **logzioUrl** | *https://listener.logz.io:8071* | Logz.io URL, that can be found under "Log Shipping -> Libraries" in your account. -| **socketTimeout** | *10 * 1000* | The socket timeout during log shipment | -| **connectTimeout** | *10 * 1000* | The connection timeout during log shipment | -| **debug** | *false* | Print some debug messages to stdout to help to diagnose issues | -| **compressRequests** | *false* | Boolean. `true` if logs are compressed in gzip format before sending. `false` if logs are sent uncompressed. | -| **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. | +| **logzioType** | *java* | The [log type](http://support.logz.io/support/solutions/articles/6000103063-what-is-type-) for that sender | +| **drainTimeoutSec** | *5* | How often the sender should drain the queue (in seconds) | +| **logzioUrl** | *https://listener.logz.io:8071* | Logz.io URL, that can be found under "Log Shipping -> Libraries" in your account. | +| **socketTimeout** | *10 * 1000* | The socket timeout during log shipment | +| **connectTimeout** | *10 * 1000* | The connection timeout during log shipment | +| **debug** | *false* | Print some debug messages to stdout to help to diagnose issues | +| **compressRequests** | *false* | Boolean. `true` if logs are compressed in gzip format before sending. `false` if logs are sent uncompressed. | +| **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. | +| **withOpentelemetryContext** | `true` | Boolean. Add trace_id, span_id, service_name fields to logs when opentelemetry context is available. | #### Parameters for in-memory queue -| Parameter | Default | Explained | -| ------------------ | ------------------------------------ | ----- | -| **inMemoryQueueCapacityInBytes** | *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.| -| **logsCountLimit** | *-1* | The number of logs in the memory queue before dropping new logs. Default value is -1 (the sender will not limit the queue by logs count)| +| Parameter | Default | Explained | +|----------------------------------|---------------------|------------------------------------------------------------------------------------------------------------------------------------------| +| **inMemoryQueueCapacityInBytes** | *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. | +| **logsCountLimit** | *-1* | The number of logs in the memory queue before dropping new logs. Default value is -1 (the sender will not limit the queue by logs count) | #### Parameters for disk queue -| Parameter | Default | Explained | -| ------------------ | ------------------------------------ | ----- | -| **queueDir** | *None* | Where the sender should store the queue. It should be at least one folder in path.| -| **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 | -| **checkDiskSpaceInterval** | *1000* | How often the should disk queue check for space (in milliseconds) | +| Parameter | Default | Explained | +|------------------------------------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **queueDir** | *None* | Where the sender should store the queue. It should be at least one folder in path. | +| **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 | +| **checkDiskSpaceInterval** | *1000* | How often the should disk queue check for space (in milliseconds) | @@ -135,8 +136,10 @@ public class LogzioSenderExample { ## Release notes -- 2.1.0 - - Upgrade packages versions + - 2.2.0 + - Add `WithOpentelemetryContext` parameter to add `trace_id`, `span_id`, `service_name` fields to logs when opentelemetry context is available. + - 2.1.0 + - Upgrade packages versions - 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** diff --git a/logzio-sender-test/pom.xml b/logzio-sender-test/pom.xml index 5c9606c..0b5efbe 100644 --- a/logzio-sender-test/pom.xml +++ b/logzio-sender-test/pom.xml @@ -5,7 +5,7 @@ logzio-java-sender io.logz.sender - 2.1.0 + 2.2.0 4.0.0 diff --git a/logzio-sender/pom.xml b/logzio-sender/pom.xml index 2f72709..c9662ac 100644 --- a/logzio-sender/pom.xml +++ b/logzio-sender/pom.xml @@ -5,7 +5,7 @@ logzio-java-sender io.logz.sender - 2.1.0 + 2.2.0 4.0.0 @@ -84,6 +84,21 @@ + + io.opentelemetry + opentelemetry-api + 1.10.0 + + + io.opentelemetry + opentelemetry-semconv + 1.26.0-alpha + + + io.opentelemetry + opentelemetry-sdk + 1.10.0 + org.ikasan bigqueue diff --git a/logzio-sender/src/main/java/io/logz/sender/LogzioSender.java b/logzio-sender/src/main/java/io/logz/sender/LogzioSender.java index 504ea8c..9ecbbcd 100644 --- a/logzio-sender/src/main/java/io/logz/sender/LogzioSender.java +++ b/logzio-sender/src/main/java/io/logz/sender/LogzioSender.java @@ -18,6 +18,10 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; +import io.opentelemetry.api.common.Attributes; +import io.opentelemetry.api.trace.Span; +import io.opentelemetry.api.trace.SpanContext; +import io.opentelemetry.sdk.resources.Resource; public class LogzioSender { private static final int MAX_SIZE_IN_BYTES = 3 * 1024 * 1024; // 3 MB @@ -37,10 +41,11 @@ public class LogzioSender { private ScheduledExecutorService tasksExecutor; private final AtomicBoolean drainRunning = new AtomicBoolean(false); private final HttpsSyncSender httpsSyncSender; + private final boolean withOpentelemetryContext; private LogzioSender(HttpsRequestConfiguration httpsRequestConfiguration, int drainTimeout, boolean debug, SenderStatusReporter reporter, ScheduledExecutorService tasksExecutor, - LogsQueue logsQueue, String exceedMaxSizeAction) throws LogzioParameterErrorException { + LogsQueue logsQueue, String exceedMaxSizeAction, boolean withOpentelemetryContext) throws LogzioParameterErrorException { if (logsQueue == null || reporter == null || httpsRequestConfiguration == null) { throw new LogzioParameterErrorException("logsQueue=" + logsQueue + " reporter=" + reporter @@ -55,6 +60,7 @@ private LogzioSender(HttpsRequestConfiguration httpsRequestConfiguration, int dr this.reporter = reporter; httpsSyncSender = new HttpsSyncSender(httpsRequestConfiguration, reporter); this.tasksExecutor = tasksExecutor; + this.withOpentelemetryContext = withOpentelemetryContext; debug("Created new LogzioSender class"); } @@ -67,7 +73,7 @@ private String validateAndGetExceedMaxSizeAction(String exceedMaxSizeAction) thr } private static LogzioSender getLogzioSender(HttpsRequestConfiguration httpsRequestConfiguration, int drainTimeout, boolean debug, SenderStatusReporter reporter, - ScheduledExecutorService tasksExecutor, LogsQueue logsQueue, String exceedMaxSizeAction) + ScheduledExecutorService tasksExecutor, LogsQueue logsQueue, String exceedMaxSizeAction, boolean withOpentelemetryContext) throws LogzioParameterErrorException { String tokenHash = Hashing.sha256() .hashString(httpsRequestConfiguration.getLogzioToken(), StandardCharsets.UTF_8) @@ -85,7 +91,7 @@ private static LogzioSender getLogzioSender(HttpsRequestConfiguration httpsReque } LogzioSender logzioSender = new LogzioSender(httpsRequestConfiguration, drainTimeout, debug, reporter, - tasksExecutor, logsQueue, exceedMaxSizeAction); + tasksExecutor, logsQueue, exceedMaxSizeAction, withOpentelemetryContext); logzioSenderInstances.put(tokenAndTypePair, logzioSender); return logzioSender; } else { @@ -102,6 +108,20 @@ private static LogzioSender getLogzioSender(HttpsRequestConfiguration httpsReque } } + private void addOpenTelemetryContext(JsonObject jsonMessage) { + Span currentSpan = Span.current(); + if (currentSpan != null) { + SpanContext spanContext = currentSpan.getSpanContext(); + if (spanContext.isValid()) { + jsonMessage.addProperty("trace_id", spanContext.getTraceId()); + jsonMessage.addProperty("span_id", spanContext.getSpanId()); + Resource resource = Resource.getDefault(); + Attributes attributes = resource.getAttributes(); + String serviceName = attributes.get(io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME); + jsonMessage.addProperty("service_name", serviceName); + } + } + } public void start() { tasksExecutor.scheduleWithFixedDelay(this::drainQueueAndSend, 0, drainTimeout, TimeUnit.SECONDS); } @@ -145,7 +165,9 @@ public void clearQueue() throws IOException { } public void send(JsonObject jsonMessage) { - + if (this.withOpentelemetryContext) { + addOpenTelemetryContext(jsonMessage); + } // check for oversized message int jsonByteLength = jsonMessage.toString().getBytes(StandardCharsets.UTF_8).length; String jsonMessageField = jsonMessage.get("message").getAsString(); @@ -280,6 +302,12 @@ public static class Builder { private DiskQueue.Builder diskQueueBuilder; private HttpsRequestConfiguration httpsRequestConfiguration; private String exceedMaxSizeAction = "cut"; + private boolean withOpentelemetryContext = true; + + public Builder setWithOpentelemetryContext(boolean withOpentelemetryContext) { + this.withOpentelemetryContext = withOpentelemetryContext; + return this; + } public Builder setExceedMaxSizeAction(String exceedMaxSizeAction) { this.exceedMaxSizeAction = exceedMaxSizeAction; @@ -342,7 +370,8 @@ public LogzioSender build() throws LogzioParameterErrorException, IOException { reporter, tasksExecutor, getLogsQueue(), - exceedMaxSizeAction + exceedMaxSizeAction, + withOpentelemetryContext ); } diff --git a/logzio-sender/src/test/java/io/logz/sender/DiskQueueTest.java b/logzio-sender/src/test/java/io/logz/sender/DiskQueueTest.java index d0b2f79..03d3621 100644 --- a/logzio-sender/src/test/java/io/logz/sender/DiskQueueTest.java +++ b/logzio-sender/src/test/java/io/logz/sender/DiskQueueTest.java @@ -27,9 +27,9 @@ public class DiskQueueTest extends LogzioSenderTest { protected Builder getLogzioSenderBuilder(String token, String type, Integer drainTimeout, Integer socketTimeout, Integer serverTimeout, ScheduledExecutorService tasks, - boolean compressRequests) throws LogzioParameterErrorException { + boolean compressRequests, boolean withOpentelemetryContext) throws LogzioParameterErrorException { Builder logzioSenderBuilder = super.getLogzioSenderBuilder(token, type, drainTimeout, - socketTimeout, serverTimeout, tasks, compressRequests); + socketTimeout, serverTimeout, tasks, compressRequests, withOpentelemetryContext); if (queueDir == null) { queueDir = TestEnvironment.createTempDirectory(); @@ -70,7 +70,7 @@ public void testSenderCantWriteToEmptyDirectory() { try { setQueueDir(tempDirectory); Builder testSenderBuilder = getLogzioSenderBuilder(token, type, drainTimeout, 10 * 1000, - 10 * 1000, tasks, false); + 10 * 1000, tasks, false, false); LogzioSender testSender = createLogzioSender(testSenderBuilder); throw new LogzioParameterErrorException("Should not reach here", "fail"); } catch (LogzioParameterErrorException | IOException e) { @@ -95,7 +95,7 @@ public void testSenderCreatesDirectoryWhichDoesNotExists() throws Exception { assertFalse(queueDir.exists()); setQueueDir(queueDir); Builder testSenderBuilder = getLogzioSenderBuilder(token, type, drainTimeout, - 10 * 1000, 10 * 1000, tasks, false); + 10 * 1000, 10 * 1000, tasks, false, false); LogzioSender testSender = createLogzioSender(testSenderBuilder); testSender.send(createJsonMessage(loggerName, message1)); assertTrue(queueDir.exists()); diff --git a/logzio-sender/src/test/java/io/logz/sender/InMemoryQueueTest.java b/logzio-sender/src/test/java/io/logz/sender/InMemoryQueueTest.java index 67369d2..ffe4b7e 100644 --- a/logzio-sender/src/test/java/io/logz/sender/InMemoryQueueTest.java +++ b/logzio-sender/src/test/java/io/logz/sender/InMemoryQueueTest.java @@ -20,10 +20,10 @@ public class InMemoryQueueTest extends LogzioSenderTest { @Override protected Builder getLogzioSenderBuilder(String token, String type, Integer drainTimeout, Integer socketTimeout, Integer serverTimeout, - ScheduledExecutorService tasks, boolean compressRequests) + ScheduledExecutorService tasks, boolean compressRequests, boolean withOpentelemetryContext) throws LogzioParameterErrorException { Builder logzioSenderBuilder = super.getLogzioSenderBuilder(token, type, drainTimeout, - socketTimeout, serverTimeout, tasks, compressRequests); + socketTimeout, serverTimeout, tasks, compressRequests, withOpentelemetryContext); setCapacityInBytes(logzioSenderBuilder, defaultCapacityInBytes); return logzioSenderBuilder; } @@ -59,7 +59,7 @@ public void checkCapacityReachedToSizeBelowCapacity() throws LogzioParameterErro int logSize = log.toString().getBytes(StandardCharsets.UTF_8).length; ScheduledExecutorService tasks = Executors.newScheduledThreadPool(3); Builder testSenderBuilder = getLogzioSenderBuilder(token, type, drainTimeout, 10 * 1000, - 10 * 1000, tasks, false); + 10 * 1000, tasks, false, false); setCapacityInBytes(testSenderBuilder, logSize * successfulLogs); LogzioSender testSender = createLogzioSender(testSenderBuilder); sleepSeconds(drainTimeout - 1); @@ -87,7 +87,7 @@ public void checkLogMessageCountLimitWithCapacityInBytes() throws LogzioParamete JsonObject log = createJsonMessage(loggerName, message); ScheduledExecutorService tasks = Executors.newScheduledThreadPool(3); Builder testSenderBuilder = getLogzioSenderBuilder(token, type, drainTimeout, 10 * 1000, - 10 * 1000, tasks, false); + 10 * 1000, tasks, false, false); setLogsCountLimit(testSenderBuilder, successfulLogs); LogzioSender testSender = createLogzioSender(testSenderBuilder); sleepSeconds(drainTimeout - 1); diff --git a/logzio-sender/src/test/java/io/logz/sender/LogzioSenderTest.java b/logzio-sender/src/test/java/io/logz/sender/LogzioSenderTest.java index 71bf237..1071189 100644 --- a/logzio-sender/src/test/java/io/logz/sender/LogzioSenderTest.java +++ b/logzio-sender/src/test/java/io/logz/sender/LogzioSenderTest.java @@ -4,6 +4,12 @@ import io.logz.sender.exceptions.LogzioParameterErrorException; import io.logz.test.MockLogzioBulkListener; import io.logz.test.TestEnvironment; +import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.api.trace.SpanKind; +import io.opentelemetry.sdk.OpenTelemetrySdk; +import io.opentelemetry.sdk.trace.SdkTracerProvider; + + import org.junit.jupiter.api.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -17,8 +23,13 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; +import io.opentelemetry.api.trace.Span; +import io.opentelemetry.api.trace.Tracer; +import io.opentelemetry.context.Scope; + import static io.logz.sender.LogzioTestSenderUtil.LOGLEVEL; import static io.logz.sender.LogzioTestSenderUtil.createJsonMessage; +import static org.junit.jupiter.api.Assertions.*; public abstract class LogzioSenderTest { protected MockLogzioBulkListener mockListener; @@ -59,7 +70,7 @@ protected void sleepSeconds(int seconds) { protected LogzioSender.Builder getLogzioSenderBuilder(String token, String type, Integer drainTimeout, Integer socketTimeout, Integer serverTimeout, ScheduledExecutorService tasks, - boolean compressRequests) + boolean compressRequests, boolean withOpentelemetryContext) throws LogzioParameterErrorException { LogzioTestStatusReporter logy = new LogzioTestStatusReporter(logger); HttpsRequestConfiguration httpsRequestConfiguration = HttpsRequestConfiguration @@ -74,6 +85,7 @@ protected LogzioSender.Builder getLogzioSenderBuilder(String token, String type, return LogzioSender .builder() .setDebug(false) + .setWithOpentelemetryContext(withOpentelemetryContext) .setTasksExecutor(tasks) .setDrainTimeoutSec(drainTimeout) .setReporter(logy) @@ -92,6 +104,71 @@ protected String random(int numberOfChars) { return UUID.randomUUID().toString().substring(0, numberOfChars - 1); } + /** + * 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 openTelemetryContextInjectionEnabledNoContext() throws Exception { + String token = "testToken"; + String type = "testType"; + int drainTimeout = 2; + LogzioSender.Builder testSenderBuilder = getLogzioSenderBuilder(token, type, drainTimeout, + 10 * 1000, 10 * 1000, tasks, false, true); + LogzioSender testSender = createLogzioSender(testSenderBuilder); + + JsonObject jsonMessage = createJsonMessage("testLogger", "Test message"); + + testSender.send(jsonMessage); + + assertFalse(jsonMessage.has("trace_id")); + assertFalse(jsonMessage.has("span_id")); + assertFalse(jsonMessage.has("service_name")); + } + + @Test + public void openTelemetryContextInjection() throws Exception { + OpenTelemetry openTelemetry = initOpenTelemetry(); + Tracer tracer = openTelemetry.getTracer("test"); + Span span = tracer.spanBuilder("test").setSpanKind(SpanKind.CLIENT).startSpan(); + try (Scope scope = span.makeCurrent()) { + String token = "testToken"; + String type = "testType"; + int drainTimeout = 2; + LogzioSender.Builder testSenderBuilder = getLogzioSenderBuilder(token, type, drainTimeout, + 10 * 1000, 10 * 1000, tasks, false, true); + LogzioSender testSender = createLogzioSender(testSenderBuilder); + + JsonObject jsonMessage = createJsonMessage("testLogger", "Test message"); + + testSender.send(jsonMessage); + + assertTrue(jsonMessage.has("trace_id")); + assertTrue(jsonMessage.has("span_id")); + assertTrue(jsonMessage.has("service_name")); + assertEquals(span.getSpanContext().getTraceId(), jsonMessage.get("trace_id").getAsString()); + assertEquals(span.getSpanContext().getSpanId(), jsonMessage.get("span_id").getAsString()); + } finally { + span.end(); + } + } + @Test public void simpleAppending() throws Exception { String token = "aBcDeFgHiJkLmNoPqRsT"; @@ -101,7 +178,7 @@ public void simpleAppending() throws Exception { String message1 = "Testing.." + random(5); String message2 = "Warning test.." + random(5); LogzioSender.Builder testSenderBuilder = getLogzioSenderBuilder(token, type, drainTimeout, - 10 * 1000, 10 * 1000, tasks, false); + 10 * 1000, 10 * 1000, tasks, false,false); LogzioSender testSender = createLogzioSender(testSenderBuilder); testSender.send(createJsonMessage(loggerName, message1)); testSender.send(createJsonMessage(loggerName, message2)); @@ -120,7 +197,7 @@ public void malformedBulk() throws Exception { String message1 = "Testing.." + random(5); String message2 = "Warning test.." + random(5); LogzioSender.Builder testSenderBuilder = getLogzioSenderBuilder(token, type, drainTimeout, - 10 * 1000, 10 * 1000, tasks, false); + 10 * 1000, 10 * 1000, tasks, false,false); LogzioSender testSender = createLogzioSender(testSenderBuilder); testSender.send(createJsonMessage(loggerName, message1)); testSender.send(createJsonMessage(loggerName, message2)); @@ -141,7 +218,7 @@ public void simpleByteArrayAppending() throws Exception { String message1 = "Testing.." + random(5); String message2 = "Warning test.." + random(5); LogzioSender.Builder testSenderBuilder = getLogzioSenderBuilder(token, type, drainTimeout, - 10 * 1000, 10 * 1000, tasks, false); + 10 * 1000, 10 * 1000, tasks, false,false); LogzioSender testSender = createLogzioSender(testSenderBuilder); testSender.send(createJsonMessage(loggerName, message1).toString().getBytes(StandardCharsets.UTF_8)); testSender.send(createJsonMessage(loggerName, message2).toString().getBytes(StandardCharsets.UTF_8)); @@ -160,7 +237,7 @@ public void simpleGzipAppending() throws Exception { String message1 = "Testing.." + random(5); String message2 = "Warning test.." + random(5); LogzioSender.Builder testSenderBuilder = getLogzioSenderBuilder(token, type, drainTimeout, 10 * 1000, - 10 * 1000, tasks, true); + 10 * 1000, tasks, true,false); LogzioSender testSender = createLogzioSender(testSenderBuilder); testSender.send(createJsonMessage(loggerName, message1)); testSender.send(createJsonMessage(loggerName, message2)); @@ -179,7 +256,7 @@ public void multipleQueueDrains() throws Exception { String message1 = "Testing first drain - " + random(5); String message2 = "And the second drain" + random(5); LogzioSender.Builder testSenderBuilder = getLogzioSenderBuilder(token, type, drainTimeout, 10 * 1000, - 10 * 1000, tasks, false); + 10 * 1000, tasks, false, false); LogzioSender testSender = createLogzioSender(testSenderBuilder); testSender.send(createJsonMessage(loggerName, message1)); sleepSeconds(2 * drainTimeout); @@ -200,7 +277,7 @@ public void longDrainTimeout() throws Exception { String message1 = "Sending one log - " + random(5); String message2 = "And one more important one - " + random(5); LogzioSender.Builder testSenderBuilder = getLogzioSenderBuilder(token, type, drainTimeout, 10 * 1000, - 10 * 1000, tasks, false); + 10 * 1000, tasks, false, false); LogzioSender testSender = createLogzioSender(testSenderBuilder); testSender.send(createJsonMessage(loggerName, message1)); testSender.send(createJsonMessage(loggerName, message2)); @@ -222,7 +299,7 @@ public void fsPercentDrop() throws Exception { String message1 = "First log that will be dropped - " + random(5); String message2 = "And a second drop - " + random(5); LogzioSender.Builder testSenderBuilder = getLogzioSenderBuilder(token, type, drainTimeoutSec, 10 * 1000, - 10 * 1000, tasks, false); + 10 * 1000, tasks, false, false); setZeroThresholdQueue(testSenderBuilder); LogzioSender testSender = createLogzioSender(testSenderBuilder); // verify the thread that checks for space made at least one check @@ -244,7 +321,7 @@ public void serverCrash() throws Exception { String message2 = "Log during drop - " + random(5); String message3 = "Log after drop - " + random(5); LogzioSender.Builder testSenderBuilder = getLogzioSenderBuilder(token, type, drainTimeout, 10 * 1000, - 10 * 1000, tasks, false); + 10 * 1000, tasks, false, false); LogzioSender testSender = createLogzioSender(testSenderBuilder); testSender.send(createJsonMessage(loggerName, message1)); sleepSeconds(2 * drainTimeout); @@ -273,7 +350,7 @@ public void getTimeoutFromServer() throws Exception { String message2 = "Log that would timeout and then being re-sent - " + random(5); int socketTimeout = serverTimeout / 2; LogzioSender.Builder testSenderBuilder = getLogzioSenderBuilder(token, type, drainTimeout, socketTimeout, - serverTimeout, tasks, false); + serverTimeout, tasks, false, false); LogzioSender testSender = createLogzioSender(testSenderBuilder); testSender.send(createJsonMessage(loggerName, message1)); sleepSeconds(2 * drainTimeout); @@ -309,7 +386,7 @@ public void getExceptionFromServer() throws Exception { String message1 = "Log that will be sent - " + random(5); String message2 = "Log that would get exception and be sent again - " + random(5); LogzioSender.Builder testSenderBuilder = getLogzioSenderBuilder(token, type, drainTimeout, 10 * 1000, - 10 * 1000, tasks, false); + 10 * 1000, tasks, false, false); LogzioSender testSender = createLogzioSender(testSenderBuilder); testSender.send(createJsonMessage(loggerName, message1)); sleepSeconds(2 * drainTimeout); @@ -413,7 +490,7 @@ public void checkExceedingMaxSizeBytesLogWithDrop() throws LogzioParameterErrorE private LogzioSender getLogzioSenderWithAndExceedMaxSizeAction(String token, String type, int drainTimeout, int logSize, ScheduledExecutorService tasks, String exceedMaxSizeAction) throws LogzioParameterErrorException, IOException { LogzioSender.Builder testSenderBuilder = getLogzioSenderBuilder(token, type, drainTimeout, 10 * 1000, - 10 * 1000, tasks, false); + 10 * 1000, tasks, false, false); testSenderBuilder.setExceedMaxSizeAction(exceedMaxSizeAction); return createLogzioSender(testSenderBuilder); } diff --git a/pom.xml b/pom.xml index d2c7d62..8238e3a 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ io.logz.sender logzio-java-sender pom - 2.1.0 + 2.2.0 Logz.io Logs Sender Send your log messages to your logz.io account in an encrypted, non-blocking manner.