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

RSDK-9345 Deduplicate noisy logs #4564

Merged
merged 15 commits into from
Jan 13, 2025
Merged

Conversation

benjirewis
Copy link
Member

@benjirewis benjirewis commented Nov 18, 2024

RSDK-9345

Main changes:

  • Stops outputting logs from the same sublogger that have already been output 3 times in the past 10 seconds
  • Outputs an "aggregation" log for any logs deemed noisy (see above point) at the end of 10 seconds before another log is output
  • Parses new disable_log_deduplication JSON flag to potentially disable the logic described in the above two points

Testing changes:

  • Small changes to existing logging tests
  • Adds tests for log entry hashkeying
  • Adds tests for log entry hashkeying

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Nov 18, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Nov 19, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Dec 12, 2024
@benjirewis benjirewis changed the title POC dedupe-logs RSDK-9345 Deduplicate noisy logs Dec 12, 2024
@benjirewis benjirewis force-pushed the dedupe-logs branch 2 times, most recently from d55ea23 to afe9b2e Compare December 23, 2024 19:37
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Dec 23, 2024
assertLogMatches(t, notStdout,
`2023-10-30T13:19:45.806Z INFO impl logging/impl_test.go:132 foo {"key":"value"}`)

// TODO(benji): Add the following assertions to test more deduplication logic.
Copy link
Member Author

Choose a reason for hiding this comment

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

Still working on testing a bit, but thought I'd throw this into review before the holiday.

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Dec 23, 2024
@benjirewis benjirewis marked this pull request as ready for review December 23, 2024 21:27
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 9, 2025
@benjirewis
Copy link
Member Author

Still adding remaining tests and then will re-request review.

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 10, 2025
@benjirewis
Copy link
Member Author

Still adding remaining tests and then will re-request review.

Added and requested.

Copy link
Member

@cheukt cheukt left a comment

Choose a reason for hiding this comment

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

LGTM


imp.testHelper()
for _, appender := range imp.appenders {
err := appender.Write(collapsedEntry.Entry, collapsedEntry.Fields)
Copy link
Member Author

Choose a reason for hiding this comment

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

The level of the aggregation log that's output here is equivalent to the most recent noisy log's level. You'll see in the test I wrote that this means that if I log 3 identical INFO logs followed by a 4th identical ERROR log, the aggregation log will appear as ERROR level. This is sort of strange, but I'm inclined to not care too much about this case since most identical logs will not differ in level. I suppose this raises the question of whether or not level should be considered as part of identicality but I'll stick to the scope for now.

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with the behavior you described.

@@ -106,6 +106,10 @@ func FromProto(proto *pb.RobotConfig, logger logging.Logger) (*Config, error) {
cfg.MaintenanceConfig = maintenanceConfig
}

if proto.DisableLogDeduplication {
Copy link
Member

Choose a reason for hiding this comment

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

I agree this is correct because cfg is default initialized, but this feels like the seedling of a bug. cfg.DisableLogDeduplication = proto.DisableLogDeduplication is less lines and isn't prone to the default initialization value assumption.

Copy link
Member Author

Choose a reason for hiding this comment

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

...I have no idea what I was thinking here haha. Switched to cfg.DisableLogDeduplication = proto.DisableLogDeduplication.

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 10, 2025
@benjirewis benjirewis merged commit b559adf into viamrobotics:main Jan 13, 2025
17 checks passed
@benjirewis benjirewis deleted the dedupe-logs branch January 13, 2025 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants