Skip to content

Commit b3a1542

Browse files
Vladimir Kotalahornace
authored andcommitted
add LDAP lookup latency timer
1 parent d7ff4a9 commit b3a1542

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/framework/PluginClassLoader.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2020, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opengrok.indexer.framework;
@@ -56,7 +56,8 @@ public class PluginClassLoader extends ClassLoader {
5656
"org.opengrok.indexer.authorization.plugins.*",
5757
"org.opengrok.indexer.authorization.AuthorizationException",
5858
"org.opengrok.indexer.util.*",
59-
"org.opengrok.indexer.logger.*"
59+
"org.opengrok.indexer.logger.*",
60+
"org.opengrok.indexer.Metrics"
6061
};
6162

6263
private static final String[] PACKAGE_BLACKLIST = new String[]{

plugins/src/main/java/opengrok/auth/plugin/ldap/LdapFacade.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
*/
2323
package opengrok.auth.plugin.ldap;
2424

25+
import java.time.Duration;
26+
import java.time.Instant;
2527
import java.util.ArrayList;
2628
import java.util.HashMap;
2729
import java.util.List;
@@ -41,9 +43,11 @@
4143
import javax.naming.directory.SearchControls;
4244
import javax.naming.directory.SearchResult;
4345

46+
import io.micrometer.core.instrument.Timer;
4447
import opengrok.auth.plugin.configuration.Configuration;
4548
import opengrok.auth.plugin.util.WebHook;
4649
import opengrok.auth.plugin.util.WebHooks;
50+
import org.opengrok.indexer.Metrics;
4751

4852
public class LdapFacade extends AbstractLdapProvider {
4953

@@ -103,6 +107,10 @@ public class LdapFacade extends AbstractLdapProvider {
103107
private long errorTimestamp = 0;
104108
private boolean reported = false;
105109

110+
private final Timer ldapLookupTimer = Timer.builder("ldap.latency").
111+
description("LDAP lookup latency").
112+
register(Metrics.getRegistry());
113+
106114
/**
107115
* Interface for converting LDAP results into user defined types.
108116
*
@@ -290,7 +298,10 @@ public SearchControls getSearchControls() {
290298
* @return results transformed with mapper
291299
*/
292300
private <T> LdapSearchResult<T> lookup(String dn, String filter, String[] attributes, AttributeMapper<T> mapper) throws LdapException {
293-
return lookup(dn, filter, attributes, mapper, 0);
301+
Instant start = Instant.now();
302+
LdapSearchResult<T> res = lookup(dn, filter, attributes, mapper, 0);
303+
ldapLookupTimer.record(Duration.between(start, Instant.now()));
304+
return res;
294305
}
295306

296307
private String getSearchDescription(String dn, String filter, String[] attributes) {

0 commit comments

Comments
 (0)