Skip to content

Commit

Permalink
changes log formats and removes timezone block
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhang.balkundi committed Sep 2, 2021
1 parent 9a1ad20 commit af6296a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(cemerick.pomegranate.aether/register-wagon-factory!
"http" #(org.apache.maven.wagon.providers.http.HttpWagon.))

(defproject tech.gojek/ziggurat "4.1.0"
(defproject tech.gojek/ziggurat "4.2.0-alpha.1"
:description "A stream processing framework to build stateless applications on kafka"
:url "https://github.com/gojektech/ziggurat"
:license {:name "Apache License, Version 2.0"
Expand Down
10 changes: 4 additions & 6 deletions resources/logback.test.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
<configuration>
<property name="type" value="${ZIGGURAT_LOG_FORMAT:-text}" />
<property name="type" value="${ZIGGURAT_LOG_FORMAT:-text}"/>

<if condition = 'property("type").equals("json")'>
<if condition='property("type").equals("json")'>
<then>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="cambium.logback.json.FlatJsonLayout">
<jsonFormatter class="ch.qos.logback.contrib.jackson.JacksonJsonFormatter">
<prettyPrint>false</prettyPrint>
</jsonFormatter>
<!-- <context>api</context> -->
<timestampFormat>yyyy-MM-dd'T'HH:mm:ss.SSS'Z'</timestampFormat>
<timestampFormatTimezoneId>UTC</timestampFormatTimezoneId>
<appendLineSeparator>true</appendLineSeparator>
</layout>
</encoder>
</appender>
</then>
</if>

<if condition = 'property("type").equals("text")'>
<if condition='property("type").equals("text")'>
<then>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>
%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg { %mdc }%n
[%-5level] %d [%t] %c:%M: %m { %mdc }%n
</pattern>
</layout>
</appender>
Expand Down
14 changes: 7 additions & 7 deletions src/ziggurat/kafka_consumer/consumer_handler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
(producer/retry batch-payload))
([batch current-retry-count topic-entity]
(when (pos? (count batch))
(let [message (map->MessagePayload {:message batch
:retry-count current-retry-count
(let [message (map->MessagePayload {:message batch
:retry-count current-retry-count
:topic-entity topic-entity})]
(producer/retry message)))))

Expand All @@ -50,18 +50,18 @@
batch-size (count batch)]
(try
(when (not-empty batch)
(clog/info {:batch-size batch-size} "Processing the batch")
(clog/info {:batch-size batch-size} (format "[Consumer Group: %s] Processing the batch with %d messages" topic-entity batch-size))
;(log/infof "[Consumer Group: %s] Processing the batch with %d messages" topic-entity batch-size)
(let [start-time (Instant/now)
result (batch-handler batch)
time-taken-in-millis (.toMillis (Duration/between start-time (Instant/now)))]
(let [start-time (Instant/now)
result (batch-handler batch)
time-taken-in-millis (.toMillis (Duration/between start-time (Instant/now)))]
(validate-batch-processing-result result)
(let [messages-to-be-retried (:retry result)
to-be-retried-count (count messages-to-be-retried)
skip-count (count (:skip result))
success-count (- batch-size (+ to-be-retried-count skip-count))]

(clog/info {:messages-successfully-processed success-count :messages-skipped skip-count :messages-to-be-retried to-be-retried-count} "Batch processing complete")
(clog/info {:messages-successfully-processed success-count :messages-skipped skip-count :messages-to-be-retried to-be-retried-count} (format "[Consumer Group: %s] Processed the batch with success: [%d], skip: [%d] and retries: [%d] \n" topic-entity success-count skip-count to-be-retried-count))
;(log/infof "[Consumer Group: %s] Processed the batch with success: [%d], skip: [%d] and retries: [%d] \n" topic-entity success-count skip-count to-be-retried-count)
(publish-batch-process-metrics topic-entity batch-size success-count skip-count to-be-retried-count time-taken-in-millis)
(retry messages-to-be-retried current-retry-count topic-entity))))
Expand Down

0 comments on commit af6296a

Please sign in to comment.