Add configurable rate limit for health endpoint - #15
Conversation
Replace hardcoded rate limit with configurable property - Added @value injection for logdispatch.health.rate-limit-per-minute - Updated rate limit logic to use dynamic property - Updated comments and error message
Add rate limit configuration property to application.yml
Document rate limit configuration property in README
There was a problem hiding this comment.
Could we update the README with an example showing how users can configure logdispatch.health.rate-limit-per-minute after adding the starter dependency? This will make the new feature easier to discover and use.
For example, the README could mention the new optional configuration:
logdispatch:
server-url: "https://your-apm-server.com/api/v1/ingest/logs"
api-key: "your-secret-api-key"
masked-headers: "authorization,cookie,x-api-key"
health:
rate-limit-per-minute: 120It would also be helpful to document the default value (e.g., 60 requests per minute) when this property is not specified.
There was a problem hiding this comment.
Library modules should not ship application.yml — this can conflict with the consuming app's config. The default is already covered by the @value fallback. Please remove this file.
| private final ConcurrentHashMap<String, AtomicInteger> requestCounts = new ConcurrentHashMap<>(); | ||
| private long currentWindowStart = System.currentTimeMillis(); | ||
| private static final int MAX_REQUESTS_PER_MINUTE = 60; | ||
| @Value("${logdispatch.health.rate-limit-per-minute:60}") |
There was a problem hiding this comment.
No validation against <= 0. A misconfigured 0 would permanently block all callers. Add a @PostConstruct guard or @validated constraint.
| ## License | ||
|
|
||
| MIT License | ||
|
|
There was a problem hiding this comment.
This section is placed after ## License — configuration docs should come before license. Also, please add a YAML usage example (as suggested in the existing review comment).
Description
Add configurable rate limit for health endpoint.
Previously the rate limit was hardcoded to 60. Now clients can configure
logdispatch.health.rate-limit-per-minutein their application.yml.Fixes #14
Type of change
How Has This Been Tested?
Checklist: