File tree Expand file tree Collapse file tree 6 files changed +16
-7
lines changed
src/main/java/com/logtail/logback Expand file tree Collapse file tree 6 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ repositories {
77}
88
99dependencies {
10- implementation ' com.logtail:logback-logtail:0.3.4 '
10+ implementation ' com.logtail:logback-logtail:0.3.5 '
1111 implementation ' ch.qos.logback:logback-classic:1.2.11'
1212 implementation ' ch.qos.logback:logback-core:1.2.11'
1313 implementation ' com.fasterxml.jackson.core:jackson-databind:2.13.5'
Original file line number Diff line number Diff line change 22 <appender name =" Logtail" class =" com.logtail.logback.LogtailAppender" >
33 <appName >Better Stack Gradle example app</appName >
44 <sourceToken ><!-- YOUR SOURCE TOKEN --> </sourceToken >
5+ <ingestUrl >https://<!-- YOUR INGESTING HOST --> </ingestUrl >
56 <mdcFields >requestId,requestTime</mdcFields >
67 <mdcTypes >string,int</mdcTypes >
78 <objectMapperModule >com.fasterxml.jackson.datatype.jsr310.JavaTimeModule</objectMapperModule >
Original file line number Diff line number Diff line change 2626 <dependency >
2727 <groupId >com.logtail</groupId >
2828 <artifactId >logback-logtail</artifactId >
29- <version >0.3.4 </version >
29+ <version >0.3.5 </version >
3030 </dependency >
3131 <dependency >
3232 <groupId >ch.qos.logback</groupId >
Original file line number Diff line number Diff line change 22 <appender name =" Logtail" class =" com.logtail.logback.LogtailAppender" >
33 <appName >Better Stack Maven example app</appName >
44 <sourceToken ><!-- YOUR SOURCE TOKEN --> </sourceToken >
5+ <ingestUrl >https://<!-- YOUR INGESTING HOST --> </ingestUrl >
56 <mdcFields >requestId,requestTime</mdcFields >
67 <mdcTypes >string,int</mdcTypes >
78 <objectMapperModule >com.fasterxml.jackson.datatype.jsr310.JavaTimeModule</objectMapperModule >
Original file line number Diff line number Diff line change 1111 <groupId >com.logtail</groupId >
1212 <artifactId >logback-logtail</artifactId >
1313 <packaging >jar</packaging >
14- <version >0.3.4 </version >
14+ <version >0.3.5 </version >
1515
1616 <name >${project.groupId} :${project.artifactId} </name >
1717 <description >Logback Java appender for sending logs to BetterStack.com</description >
Original file line number Diff line number Diff line change @@ -161,7 +161,9 @@ protected boolean flushLogs(int flushedSize) {
161161
162162 try {
163163 if (retries > maxRetries ) {
164- batch .subList (0 , flushedSize ).clear ();
164+ synchronized (batch ) {
165+ batch .subList (0 , flushedSize ).clear ();
166+ }
165167 logger .error ("Dropped batch of {} logs." , flushedSize );
166168 warnAboutMaxQueueSize = true ;
167169 retries = 0 ;
@@ -187,7 +189,9 @@ protected boolean flushLogs(int flushedSize) {
187189 return false ;
188190 }
189191
190- batch .subList (0 , flushedSize ).clear ();
192+ synchronized (batch ) {
193+ batch .subList (0 , flushedSize ).clear ();
194+ }
191195 warnAboutMaxQueueSize = true ;
192196 retries = 0 ;
193197
@@ -246,9 +250,12 @@ protected HttpURLConnection getHttpURLConnection() throws IOException {
246250 }
247251
248252 protected String batchToJson (int flushedSize ) throws JsonProcessingException {
253+ List <ILoggingEvent > snapshot ;
254+ synchronized (batch ) {
255+ snapshot = new ArrayList <>(batch .subList (0 , flushedSize ));
256+ }
249257 return this .dataMapper .writeValueAsString (
250- new ArrayList <>(batch .subList (0 , flushedSize ))
251- .stream ()
258+ snapshot .stream ()
252259 .map (this ::buildPostData )
253260 .collect (Collectors .toList ())
254261 );
You can’t perform that action at this time.
0 commit comments