Github user janhoy commented on a diff in the pull request:
https://github.com/apache/lucene-solr/pull/457#discussion_r224121574
--- Diff:
solr/core/src/java/org/apache/solr/security/AuthenticationPlugin.java ---
@@ -52,11 +80,73 @@
public abstract boolean doAuthenticate(ServletRequest request,
ServletResponse response,
FilterChain filterChain) throws Exception;
+ /**
+ * This method is called by SolrDispatchFilter in order to initiate
authentication.
+ * It does some standard metrics counting.
+ */
+ public final boolean authenticate(ServletRequest request,
ServletResponse response, FilterChain filterChain) throws Exception {
+ Timer.Context timer = requestTimes.time();
+ requests.inc();
+ try {
+ return doAuthenticate(request, response, filterChain);
+ } catch(Exception e) {
+ numErrors.mark();
+ throw e;
+ } finally {
+ long elapsed = timer.stop();
+ totalTime.inc(elapsed);
+ }
+ }
/**
* Cleanup any per request data
*/
public void closeRequest() {
}
+ @Override
+ public void initializeMetrics(SolrMetricManager manager, String
registryName, String tag, final String scope) {
+ this.metricManager = manager;
+ this.registryName = registryName;
+ // Metrics
+ registry = manager.registry(registryName);
+ numErrors = manager.meter(this, registryName, "errors",
getCategory().toString(), scope);
+ numTimeouts = manager.meter(this, registryName, "timeouts",
getCategory().toString(), scope);
+ requests = manager.counter(this, registryName, "requests",
getCategory().toString(), scope);
+ numAuthenticated = manager.counter(this, registryName,
"authenticated", getCategory().toString(), scope);
+ numPassThrough = manager.counter(this, registryName, "passThrough",
getCategory().toString(), scope);
+ numWrongCredentials = manager.counter(this, registryName,
"failWrongCredentials", getCategory().toString(), scope);
--- End diff --
Done
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]