Implement session check usage tracking for /check endpoint#106
Implement session check usage tracking for /check endpoint#106
Conversation
|
@copilot i've noticed that the flush() function makes a copy and then clears the original - before confirming that the logs were able to be persisted. Though not critical and i understand that this is mainly for performance reasons - is there an elegant way to walk back the logs on failure or change the order without affecting the performance too much. |
Good point! I've improved the flush() function to handle persistence failures more gracefully. The solution:
Key changes in commit 115d2fc:
This ensures data isn't lost while maintaining the performance benefits of async persistence. |
4cb4071 to
7877f55
Compare
# This is the 1st commit message: Implement session check usage tracking feature - Add UsageTrackingConfig to Config struct - Create CheckUsageTracker for in-memory logging and periodic flushing - Integrate logging into httpHandlerCheck function - Add unit tests for usage tracking functionality - Update example configuration file Co-authored-by: bosvos <2437699+bosvos@users.noreply.github.com> # This is the commit message #2: Add documentation for usage tracking feature - Add comprehensive usage tracking documentation - Update doc.go with configuration example - Document security considerations and log format Co-authored-by: bosvos <2437699+bosvos@users.noreply.github.com> # This is the commit message #3: Improve flush() resilience to handle persistence failures gracefully Co-authored-by: bosvos <2437699+bosvos@users.noreply.github.com> # This is the commit message #4: Only keep userid for auth check logs # This is the commit message #5: Moved usage tracker to authaus Clean up .gitignore
7877f55 to
966e6e9
Compare
LeonLeibbrandt
left a comment
There was a problem hiding this comment.
LGTM.
Make sure you update the go.mod file before merging.
FritzOnFire
left a comment
There was a problem hiding this comment.
Two small changes, but everything else LGTM
| /tools/listanddiff/go_build_listanddiff_go.exe | ||
| /tools/listanddiff/listanddiff.exe | ||
| /tools/listanddiff/output.csv |
There was a problem hiding this comment.
We should never have any executables in this repo. So we should rather change this to *.exe
| type ImqsCentral struct { | ||
| Config *Config | ||
| Central *authaus.Central | ||
| //UsageTracker *CheckUsageTracker |
There was a problem hiding this comment.
I think we can remove this line.
This PR implements a comprehensive session check usage tracking system that monitors calls to the
/checkendpoint for user activity analysis. The implementation provides in-memory logging with periodic flushing to persistent storage.Key Features
Implementation Details
The solution adds a new
UsageTrackingconfiguration section:{ "UsageTracking": { "enabled": false, "flush_interval": 60 } }Key components:
CheckUsageTracker: Manages in-memory storage and periodic flushingCheckLogEntry: Structured log entry with all required fieldshttpHandlerCheck: Logs successful requests after validationSecurity & Performance Considerations
Testing & Documentation
The feature is disabled by default for backward compatibility and can be easily enabled in production environments.
Fixes #105.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
Refs: ASG-4837