Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structured logging with ziggurat #238

Merged
merged 15 commits into from
Sep 3, 2021
Merged

Structured logging with ziggurat #238

merged 15 commits into from
Sep 3, 2021

Conversation

anmol1vw13
Copy link
Contributor

No description provided.

@anmol1vw13 anmol1vw13 changed the title Structured logging Structured logging with ziggurat Aug 30, 2021
@@ -30,8 +30,6 @@
[io.opentracing.contrib/opentracing-rabbitmq-client "0.1.11" :exclusions [com.rabbitmq/amqp-client]]
[org.apache.httpcomponents/fluent-hc "4.5.13"]
[org.apache.kafka/kafka-streams "2.8.0" :exclusions [org.slf4j/slf4j-log4j12 log4j]]
[org.apache.logging.log4j/log4j-core "2.14.1"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we removing these? Both loggings should be behind feature toggle initially.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have text and json logging behind feature flag. Having both implementations present was causing none of them to be picked for some reason (Didn't debug further). Hence removed log4j altogether.

Copy link
Contributor

@hogaur hogaur Sep 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have text and json logging behind feature flag

What do you mean? Text logs are supported how? Will this not be backward incompatible?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason why we cannot have multiple slf4j implementations

SLF4J API is designed to bind with one and only one underlying logging framework at a time. If more than one binding is present on the class path, SLF4J will emit a warning, listing the location of those bindings.

When multiple bindings are available on the class path, select one and only one binding you wish to use, and remove the other bindings. For example, if you have both slf4j-simple-2.0.0-alpha5.jar and slf4j-nop-2.0.0-alpha5.jar on the class path and you wish to use the nop (no-operation) binding, then remove slf4j-simple-2.0.0-alpha5.jar from the class path.

The list of locations that SLF4J provides in this warning usually provides sufficient information to identify the dependency transitively pulling in an unwanted SLF4J binding into your project. In your project's pom.xml file, exclude this SLF4J binding when declaring the unscrupulous dependency.

Multiple bindings

Copy link
Contributor

@shubhang93 shubhang93 Sep 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean? Text logs are supported how? Will this not be backward incompatible?

text logs with MDC are supported via logback itself, for reference please check logback.test.xml in this PR. To ensure multiple bindings are not present we have added a section in the doc. We will add in the upgrade guide as well

</then>
</if>

<root level="error">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be level="info"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by default info makes sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

info will printout kakfa info logs during tests, in the older log4j2.test.xml the level was set to error

@@ -85,4 +85,5 @@
:value-deserializer-class-config "org.apache.kafka.common.serialization.ByteArrayDeserializer"}}
:tracer {:enabled [true :bool]
:custom-provider ""}
:new-relic {:report-errors false}}}
:new-relic {:report-errors false}
:log-format "text"}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default log format in test should be json?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

json wouldn't be required in tests. It isn't very readable

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say use default log format as json

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use "test" as :text ?

</jsonFormatter>
<!-- <context>api</context> -->
<timestampFormat>yyyy-MM-dd'T'HH:mm:ss.SSS'Z'</timestampFormat>
<timestampFormatTimezoneId>UTC</timestampFormatTimezoneId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this make sense to hardcode the timezone?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should let it pick the timezone and not hardcode

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have removed it

@@ -39,7 +39,8 @@
:http-server {:middlewares {:swagger {:enabled false}}
:port 8080
:thread-count 100}
:new-relic {:report-errors false}}})
:new-relic {:report-errors false}
:log-format "text"}})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default should be json.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initially it would be better if the default were text. This will allow users to make a gradual shift to JSON logging

@@ -247,6 +253,7 @@
(try
(let [derived-modes (validate-modes modes stream-routes batch-routes actor-routes)]
(initialize-config)
(set-properties-for-structured-logging)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be part of initialize-config rather than being a function here in this namespace.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed it.

src/ziggurat/init.clj Outdated Show resolved Hide resolved
Anmol Vijaywargiya and others added 3 commits September 3, 2021 10:51
* Add structured logs to ziggurat logs

* Fix linting

* changes log formats and removes timezone block

* adds logging context to mapper flow and rabbitmq consume flow

* Resolve PR comments

Co-authored-by: Anmol Vijaywargiya <anmol.vijaywargiya@go-jek.com>
Co-authored-by: shubhang.balkundi <2932-shubhang.balkundi@users.noreply.source.golabs.io>
@anmol1vw13 anmol1vw13 merged commit baaee63 into master Sep 3, 2021
@mjayprateek mjayprateek deleted the structured_logging branch February 7, 2022 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants