diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationFramework.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationFramework.java index 2c3b0331b6e..ee382b36959 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationFramework.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationFramework.java @@ -55,14 +55,27 @@ public final class AuthorizationFramework extends PluginFramework. */ package org.opengrok.indexer.framework; @@ -56,7 +56,8 @@ public class PluginClassLoader extends ClassLoader { "org.opengrok.indexer.authorization.plugins.*", "org.opengrok.indexer.authorization.AuthorizationException", "org.opengrok.indexer.util.*", - "org.opengrok.indexer.logger.*" + "org.opengrok.indexer.logger.*", + "org.opengrok.indexer.Metrics" }; private static final String[] PACKAGE_BLACKLIST = new String[]{ diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java index 87217f3858b..7e204897bb6 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java @@ -18,7 +18,7 @@ */ /* - * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * Portions Copyright (c) 2018, Chris Fraire . */ package org.opengrok.indexer.search; @@ -73,9 +73,8 @@ import org.opengrok.indexer.web.ProjectHelper; /** - * This is an encapsulation of the details on how to search in the index - * database. - * This is used for searching from the command line tool and also via the JSON interface. + * This is an encapsulation of the details on how to search in the index database. + * This is used for searching via the REST API. * * @author Trond Norbye 2005 * @author Lubos Kosco - upgrade to lucene 3.x, 4.x, 5.x diff --git a/opengrok-indexer/src/test/java/org/opengrok/indexer/authorization/AuthorizationFrameworkReloadTest.java b/opengrok-indexer/src/test/java/org/opengrok/indexer/authorization/AuthorizationFrameworkReloadTest.java index f45222295b2..3b504f55e9c 100644 --- a/opengrok-indexer/src/test/java/org/opengrok/indexer/authorization/AuthorizationFrameworkReloadTest.java +++ b/opengrok-indexer/src/test/java/org/opengrok/indexer/authorization/AuthorizationFrameworkReloadTest.java @@ -146,7 +146,7 @@ public void run() { } // Double check that at least one reload() was done. - long reloads = (long) Metrics.getRegistry().counter("authorization_stack_reload").count(); + long reloads = (long) Metrics.getRegistry().counter("authorization.stack.reload").count(); assertTrue(reloads > 0); } diff --git a/plugins/src/main/java/opengrok/auth/plugin/ldap/LdapFacade.java b/plugins/src/main/java/opengrok/auth/plugin/ldap/LdapFacade.java index 908198d2881..56cd5596c68 100644 --- a/plugins/src/main/java/opengrok/auth/plugin/ldap/LdapFacade.java +++ b/plugins/src/main/java/opengrok/auth/plugin/ldap/LdapFacade.java @@ -22,6 +22,8 @@ */ package opengrok.auth.plugin.ldap; +import java.time.Duration; +import java.time.Instant; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -41,9 +43,11 @@ import javax.naming.directory.SearchControls; import javax.naming.directory.SearchResult; +import io.micrometer.core.instrument.Timer; import opengrok.auth.plugin.configuration.Configuration; import opengrok.auth.plugin.util.WebHook; import opengrok.auth.plugin.util.WebHooks; +import org.opengrok.indexer.Metrics; public class LdapFacade extends AbstractLdapProvider { @@ -103,6 +107,10 @@ public class LdapFacade extends AbstractLdapProvider { private long errorTimestamp = 0; private boolean reported = false; + private final Timer ldapLookupTimer = Timer.builder("ldap.latency"). + description("LDAP lookup latency"). + register(Metrics.getRegistry()); + /** * Interface for converting LDAP results into user defined types. * @@ -290,7 +298,10 @@ public SearchControls getSearchControls() { * @return results transformed with mapper */ private LdapSearchResult lookup(String dn, String filter, String[] attributes, AttributeMapper mapper) throws LdapException { - return lookup(dn, filter, attributes, mapper, 0); + Instant start = Instant.now(); + LdapSearchResult res = lookup(dn, filter, attributes, mapper, 0); + ldapLookupTimer.record(Duration.between(start, Instant.now())); + return res; } private String getSearchDescription(String dn, String filter, String[] attributes) {