-
Notifications
You must be signed in to change notification settings - Fork 22
Add monitoring API for per-issuer validation statistics #182
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
lint
[lint] reported by reviewdog 🐶
[lint] reported by reviewdog 🐶
[lint] reported by reviewdog 🐶
[lint] reported by reviewdog 🐶
[lint] reported by reviewdog 🐶
[lint] reported by reviewdog 🐶
[lint] reported by reviewdog 🐶
[lint] reported by reviewdog 🐶
| int result = scitoken_deserialize(expired_token.c_str(), &token, nullptr, &err_msg); |
[lint] reported by reviewdog 🐶
| std::cout << "Token deserialization/validation failed (expected): " |
[lint] reported by reviewdog 🐶
[lint] reported by reviewdog 🐶
[lint] reported by reviewdog 🐶
scitokens-cpp/src/test_monitoring_comprehensive.cpp
Lines 73 to 74 in e27ae90
| std::cout << "\n--- Test 2: Testing DDoS protection with multiple invalid issuers ---\n"; | |
[lint] reported by reviewdog 🐶
| scitoken_deserialize(fake_token.c_str(), &temp_token, nullptr, &err_msg); |
[lint] reported by reviewdog 🐶
[lint] reported by reviewdog 🐶
[lint] reported by reviewdog 🐶
[lint] reported by reviewdog 🐶
bbockelm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot - please address the first round of changes from my review and from the linter.
Addressed all review feedback in commit ed86d9a:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot - address linter requests. |
Applied clang-format to all modified source files to address linter violations. Fixed in commit 6126b35. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
6126b35 to
d4e7332
Compare
- Fix include order in test_monitoring_comprehensive.cpp - Fix trailing whitespace in multiple files - Fix line wrapping for long lines in test files
- Move monitoring tests from src/ to test/ directory - Add MonitoringStats helper class to parse JSON and validate counters - Add integration tests for monitoring API: - MonitoringCountersIncrease: Verify counters increase after validation - MonitoringFailedIssuerLookup404: Test 404 response handling - MonitoringFailedDNSLookup: Test DNS lookup failure - MonitoringFailedTCPConnection: Test TCP connection failure (port 1) - MonitoringDurationTracking: Verify duration increases over validations - Fix duration unit from nanoseconds to seconds in verify_async_continue - Update CMakeLists.txt to build monitoring tests with gtest
- Add sync/async validation started counters (sync_validations_started, async_validations_started) separate from result counters - Add sync/async duration tracking (sync_total_time_ns, async_total_time_ns) - Update blocking verify() to track sync starts and update duration every 50ms via select timeout, only calling verify_async_continue on actual I/O - Update verify_async() to track async starts - Add m_is_sync flag to AsyncStatus to prevent double-counting - Add MAX_SELECT_TIMEOUT_US constant (50ms) for periodic checks - Update get_json() to output new sync/async fields - Update tests to parse new JSON fields
- Add monitoring.file config option to enable periodic JSON file output - Add monitoring.file_interval_s config option (default 60s) - Use atomic flag for fast-path check in hot verify() path - Use mutex-protected string for actual file path access - Write to temp file then atomic rename for safe updates - Silently ignore write errors (best-effort monitoring) - Integrate with existing scitoken_config_* API instead of dedicated functions - Add tests for configuration and file output
bbockelm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Monitoring API Implementation - Complete ✅
Successfully implemented a monitoring API in the C interface to track per-issuer validation statistics with all code review feedback addressed.
Latest Changes
Changes from Code Review
IssuerLookupExceptionandTokenExpiredExceptionfor proper error classificationMAX_SELECT_TIMEOUT_USconstant instead of magic number for maintainabilityFeatures Implemented
API
Implementation Details
src/scitokens_monitoring.cpp): Thread-safe statistics collection with mutex protectionIssuerLookupExceptionandTokenExpiredExceptioninstead of string matchingverify()methods track timing with 50ms select timeout for responsivenessStatistics Tracked
Per issuer:
Global:
Test Programs
scitokens-test-monitoring: Basic API verificationscitokens-test-monitoring-comprehensive: DDoS protection and validation flow testingOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.