Skip to content

Add configurable rate limit for health endpoint - #15

Open
solarname17 wants to merge 3 commits into
Mahesh-Langote:mainfrom
solarname17:main
Open

Add configurable rate limit for health endpoint#15
solarname17 wants to merge 3 commits into
Mahesh-Langote:mainfrom
solarname17:main

Conversation

@solarname17

@solarname17 solarname17 commented Jun 12, 2026

Copy link
Copy Markdown

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-minute in their application.yml.

Fixes #14

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

  • Manual Application Test

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

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
Comment thread README.md

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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: 120

It would also be helpful to document the default value (e.g., 60 requests per minute) when this property is not specified.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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}")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

No validation against <= 0. A misconfigured 0 would permanently block all callers. Add a @PostConstruct guard or @validated constraint.

Comment thread README.md
## License

MIT License

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] Allow users to configure the Health Endpoint rate limit

2 participants