|
22 | 22 | */
|
23 | 23 | package opengrok.auth.plugin.ldap;
|
24 | 24 |
|
| 25 | +import java.time.Duration; |
| 26 | +import java.time.Instant; |
25 | 27 | import java.util.ArrayList;
|
26 | 28 | import java.util.HashMap;
|
27 | 29 | import java.util.List;
|
|
41 | 43 | import javax.naming.directory.SearchControls;
|
42 | 44 | import javax.naming.directory.SearchResult;
|
43 | 45 |
|
| 46 | +import io.micrometer.core.instrument.Timer; |
44 | 47 | import opengrok.auth.plugin.configuration.Configuration;
|
45 | 48 | import opengrok.auth.plugin.util.WebHook;
|
46 | 49 | import opengrok.auth.plugin.util.WebHooks;
|
| 50 | +import org.opengrok.indexer.Metrics; |
47 | 51 |
|
48 | 52 | public class LdapFacade extends AbstractLdapProvider {
|
49 | 53 |
|
@@ -103,6 +107,10 @@ public class LdapFacade extends AbstractLdapProvider {
|
103 | 107 | private long errorTimestamp = 0;
|
104 | 108 | private boolean reported = false;
|
105 | 109 |
|
| 110 | + private final Timer ldapLookupTimer = Timer.builder("ldap.latency"). |
| 111 | + description("LDAP lookup latency"). |
| 112 | + register(Metrics.getRegistry()); |
| 113 | + |
106 | 114 | /**
|
107 | 115 | * Interface for converting LDAP results into user defined types.
|
108 | 116 | *
|
@@ -290,7 +298,10 @@ public SearchControls getSearchControls() {
|
290 | 298 | * @return results transformed with mapper
|
291 | 299 | */
|
292 | 300 | 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; |
294 | 305 | }
|
295 | 306 |
|
296 | 307 | private String getSearchDescription(String dn, String filter, String[] attributes) {
|
|
0 commit comments