Make message and forward async to avoid contention and losing logs#22
Open
Make message and forward async to avoid contention and losing logs#22
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #22 +/- ##
==========================================
- Coverage 88.88% 88.01% -0.88%
==========================================
Files 8 9 +1
Lines 279 342 +63
==========================================
+ Hits 248 301 +53
- Misses 24 29 +5
- Partials 7 12 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7387f7c to
23d1f5d
Compare
23d1f5d to
6edcc38
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces significant improvements to the audit server's asynchronous processing and error handling for notifications and forwarding, as well as new tests for these features. The main changes include refactoring notification and forwarding to be handled asynchronously via a side queue, adding configuration options and metrics for this queue, improving UDP forwarder timeout handling, and updating tests to reflect the new async behavior.
Asynchronous Processing and Queue Management:
sideQueueand background workers to handle notifications (messenger.Send) and forwarding (forwarder.Forward) asynchronously inAuditServer. This decouples these potentially slow operations from the main request processing path, improving throughput and reliability. ([[1]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-214cde7b7434e7b07bb1f44bb1792ef3255bd9fba5b33b7dc41aa306d990908eR1-R47),[[2]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-1367c9b0c20c80ea4c787543aa30a8f9e4524359e9f774a5ea08682da9fae5a7R135-R138),[[3]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-1367c9b0c20c80ea4c787543aa30a8f9e4524359e9f774a5ea08682da9fae5a7L148-R201))async.queue_size,async.timeout) with sensible defaults, and exposed a metric (sideDrops) to track dropped tasks when the queue is full. ([[1]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-1367c9b0c20c80ea4c787543aa30a8f9e4524359e9f774a5ea08682da9fae5a7R228-R241),[[2]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-1367c9b0c20c80ea4c787543aa30a8f9e4524359e9f774a5ea08682da9fae5a7R135-R138),[[3]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-1367c9b0c20c80ea4c787543aa30a8f9e4524359e9f774a5ea08682da9fae5a7R317-R327))Error Handling and Default Behavior:
[[1]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-1367c9b0c20c80ea4c787543aa30a8f9e4524359e9f774a5ea08682da9fae5a7L148-R201),[[2]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500L163-R180),[[3]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500L698-R809),[[4]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500L889-R1018))[[1]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-1367c9b0c20c80ea4c787543aa30a8f9e4524359e9f774a5ea08682da9fae5a7R250-R257),[[2]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500R354-R447))UDP Forwarder Improvements:
[[1]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-a14c4239c1b85a957fd71e7038cf38822e97afc3d2edf4169414bc28d8b12248R18-R19),[[2]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-a14c4239c1b85a957fd71e7038cf38822e97afc3d2edf4169414bc28d8b12248R35-R49),[[3]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-1367c9b0c20c80ea4c787543aa30a8f9e4524359e9f774a5ea08682da9fae5a7L255-R287),[[4]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-1367c9b0c20c80ea4c787543aa30a8f9e4524359e9f774a5ea08682da9fae5a7R303-R305))Testing Enhancements:
[[1]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500R354-R447),[[2]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500L698-R809),[[3]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500L727-R838),[[4]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500R920-R955),[[5]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500L889-R1018))Reactand rule evaluation to measure performance improvements from async processing. ([pkg/auditserver/bench_test.goR1-R43](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-4928cc6308985a8649cab17eed8ed131a67a8eae2b52cc12ab89f89715d18318R1-R43))Miscellaneous:
[[1]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500R63-R79),[[2]](https://github.com/ncode/vault-audit-filter/pull/22/files#diff-b894c5214cd453e7d99616e679bc60172cd313bea6ceaa0446a704ea8d737500R920-R955))References: