chore: remove source of duplicate properties in JSON log #1228
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The
EventSource
logs contain noise in the form of duplicate propertieseventName
eventSourceName
E.g.
The following are the original contiguous logs:
No Duplicates
Duplicates
The Problem
Each type of
EventSource
decorates the logs witheventName
andeventSourceName
before logging the specific type of webhook being set up:argo-events/eventsources/sources/webhook/start.go
Lines 147 to 149 in 0e577da
argo-events/eventsources/sources/github/start.go
Lines 291 to 293 in b0ab8bb
argo-events/eventsources/sources/slack/start.go
Lines 315 to 318 in b0ab8bb
However, each one of these calls
webhook.NewRoute
, which again decorates the logs with theeventName
andeventSourceName
:argo-events/eventsources/common/webhook/webhook.go
Line 48 in 0e577da
The Fix
Ideally this decoration would happen in one common place (i.e.
webhook.NewRoute
) so developers aren't relied upon to remember to add this decoration with each newEventSource
.However:
EventSource
already adds these properties, so the easy fix is to pass the logger in unchanged towebhook.NewRoute()
- i.e. no.With()
modifications (done in this PR).EventSource
s (e.g. Kafka) don't use this commonwebhook.NewRoute
function, so the decoration would need to happen at the specificEventSource
regardless.Links
Related Zap issue: uber-go/zap#622
Checklist
We are trialing it before adopting, happy to update this once/if we officially use argo-events.