Skip to content

Implementation for the ldap connect server metric.#50916

Merged
ahus1 merged 5 commits into
keycloak:mainfrom
ruchikajha95:feature-50840/Add-metric-for-connecting-to-the-LDAP-server-
Jul 16, 2026
Merged

Implementation for the ldap connect server metric.#50916
ahus1 merged 5 commits into
keycloak:mainfrom
ruchikajha95:feature-50840/Add-metric-for-connecting-to-the-LDAP-server-

Conversation

@ruchikajha95

Copy link
Copy Markdown
Contributor

This PR adds a implementation for a metric that tracks LDAP connection attempts.

In LDAPOperationManager.execute() — the method every LDAP operation (search, create, modify, delete, etc.) flows through before talking to the LDAP server.

RESULTS:

image

Closes #50840

Signed-off-by: Ruchika ruchika.jha1@ibm.com

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds LDAP connection-attempt timing and outcome metrics.

Changes:

  • Records connect duration and success/error outcome before LDAP operations.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

tracing.error(e);
throw e;
} finally {
recordLdapRequest(success, startTimeNanos);

@keycloak-github-bot keycloak-github-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@keycloak-github-bot

Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.forms.BruteForceTest#testExceedMaxTemporaryLockouts

Keycloak CI - Base IT (5)

org.opentest4j.AssertionFailedError: Expected error event ==> expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
...

Report flaky test

@ruchikajha95
ruchikajha95 marked this pull request as ready for review July 16, 2026 13:50
@ruchikajha95
ruchikajha95 requested a review from a team as a code owner July 16, 2026 13:50
@ruchikajha95
ruchikajha95 requested review from ahus1 and Copilot July 16, 2026 13:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment on lines +68 to +69
requestTimer.withTags("operation", "connect", "outcome", success ? "success" : "error")
.record(durationNanos, TimeUnit.NANOSECONDS);
ahus1
ahus1 previously approved these changes Jul 16, 2026
@ahus1
ahus1 dismissed their stale review July 16, 2026 14:31

Deprecation is missing the since.

Copilot AI review requested due to automatic review settings July 16, 2026 14:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

tracing.error(e);
throw e;
} finally {
recordLdapRequest(success, startTimeNanos);
@ahus1 ahus1 self-assigned this Jul 16, 2026
Copilot AI review requested due to automatic review settings July 16, 2026 15:30
@ahus1
ahus1 force-pushed the feature-50840/Add-metric-for-connecting-to-the-LDAP-server- branch 2 times, most recently from defd196 to 83b64a6 Compare July 16, 2026 15:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 16, 2026 15:34
@ahus1

ahus1 commented Jul 16, 2026

Copy link
Copy Markdown
Member

@ruchikajha95 - I just now realized that the test-method is actually not a test, but a test in the admin UI to verify that the connection works. This call doesn't include a metrics as of now, and therefore I wasn't able to deprecate the endpoint.

I'll merge it once the build is green.

I still wonder if we would eventually refactor it differently; for example having an LdapMetricProvider that has a MicrometerLdapMetricProvider. But that might be a future refactoring.

@ahus1
ahus1 enabled auto-merge (squash) July 16, 2026 15:35
@ruchikajha95

Copy link
Copy Markdown
Contributor Author

@ruchikajha95 - I just now realized that the test-method is actually not a test, but a test in the admin UI to verify that the connection works. This call doesn't include a metrics as of now, and therefore I wasn't able to deprecate the endpoint.

I'll merge it once the build is green.

I still wonder if we would eventually refactor it differently; for example having an LdapMetricProvider that has a MicrometerLdapMetricProvider. But that might be a future refactoring.

Thanks for the review and for clarifying the test-method . Apologies for the confusion on my end. That makes sense now that it's the Admin UI connection test and not a unit test.
I agree that introducing an abstraction like LdapMetricProvider with a MicrometerLdapMetricProvider implementation would be a cleaner approach down the line.
Thanks again for the feedback and for merging it!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment on lines +73 to +74
requestTimer.withTags("operation", "connect", "outcome", success ? "success" : "error")
.record(durationNanos, TimeUnit.NANOSECONDS);
ruchikajha95 and others added 5 commits July 16, 2026 17:58
Closes keycloak#50840

Signed-off-by: Ruchika <ruchika.jha1@ibm.com>
Closes keycloak#50840

Signed-off-by: Ruchika <ruchika.jha1@ibm.com>
Closes keycloak#50840

Signed-off-by: Ruchika <ruchika.jha1@ibm.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Copilot AI review requested due to automatic review settings July 16, 2026 15:58
@ahus1
ahus1 force-pushed the feature-50840/Add-metric-for-connecting-to-the-LDAP-server- branch from 83b64a6 to 3db9f20 Compare July 16, 2026 15:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@ahus1
ahus1 merged commit c1c17a8 into keycloak:main Jul 16, 2026
91 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add metric for connecting to the LDAP server

3 participants