mlbiscoc commented on code in PR #3636:
URL: https://github.com/apache/solr/pull/3636#discussion_r2334583402
##########
solr/core/src/java/org/apache/solr/security/AuthenticationPlugin.java:
##########
@@ -163,24 +163,59 @@ public SolrMetricsContext getSolrMetricsContext() {
return solrMetricsContext;
}
- // TODO SOLR-17458: Migrate to Otel
@Override
public void initializeMetrics(
SolrMetricsContext parentContext, Attributes attributes, String scope) {
this.solrMetricsContext = parentContext.getChildContext(this);
+ Attributes attrsWithCategory =
+ Attributes.builder().putAll(attributes).put("category",
getCategory().toString()).build();
// Metrics
- numErrors = this.solrMetricsContext.meter("errors",
getCategory().toString(), scope);
- requests = this.solrMetricsContext.counter("requests",
getCategory().toString(), scope);
+ numErrors =
+ new AttributedLongCounter(
+ this.solrMetricsContext.longCounter(
+ "solr_core_authentication_plugin_errors", "Count of errors
during authentication"),
+ attrsWithCategory);
+ requests =
+ new AttributedLongCounter(
+ this.solrMetricsContext.longCounter(
+ "solr_core_authentication_plugin_requests", "Count of requests
for authentication"),
+ attrsWithCategory);
numAuthenticated =
- this.solrMetricsContext.counter("authenticated",
getCategory().toString(), scope);
+ new AttributedLongCounter(
+ this.solrMetricsContext.longCounter(
+ "solr_core_authentication_plugin_num_authenticated",
+ "Count of successful authentication requests"),
+ attrsWithCategory);
numPassThrough =
- this.solrMetricsContext.counter("passThrough",
getCategory().toString(), scope);
+ new AttributedLongCounter(
+ this.solrMetricsContext.longCounter(
+ "solr_core_authentication_plugin_num_pass_through",
+ "Count of skipped authentication requests"),
+ attrsWithCategory);
numWrongCredentials =
- this.solrMetricsContext.counter("failWrongCredentials",
getCategory().toString(), scope);
+ new AttributedLongCounter(
+ this.solrMetricsContext.longCounter(
+ "solr_core_authentication_plugin_fail_wrong_credentials",
+ "Count of authentication failures due to incorrect
credentials"),
+ attrsWithCategory);
numMissingCredentials =
- this.solrMetricsContext.counter("failMissingCredentials",
getCategory().toString(), scope);
- requestTimes = this.solrMetricsContext.timer("requestTimes",
getCategory().toString(), scope);
- totalTime = this.solrMetricsContext.counter("totalTime",
getCategory().toString(), scope);
+ new AttributedLongCounter(
+ this.solrMetricsContext.longCounter(
+ "solr_core_authentication_plugin_fail_missing_credentials",
+ "Count of authentication failures due to missing credentials"),
+ attrsWithCategory);
Review Comment:
I think these 2 can be merged together as one metric name that is something
like "authentication_failure" and differentiate with the attribute being the
auth failure type (Incorrect creds vs missing creds). You can add the 2 to get
generic auth failures or see failure by type.
##########
solr/core/src/java/org/apache/solr/security/MultiAuthPlugin.java:
##########
@@ -204,6 +204,7 @@ public void initializeMetrics(
// TODO SOLR-17458: Add Otel
plugin.initializeMetrics(parentContext, Attributes.empty(), scope);
Review Comment:
This class looks to accept multiple authentication plugins. Because of that,
I think we should have the authentication plugin name as an attribute on the
metrics so you can differentiate which plugin had authentication passes and
failures.
##########
solr/core/src/java/org/apache/solr/security/AuthenticationPlugin.java:
##########
@@ -163,24 +163,59 @@ public SolrMetricsContext getSolrMetricsContext() {
return solrMetricsContext;
}
- // TODO SOLR-17458: Migrate to Otel
@Override
public void initializeMetrics(
SolrMetricsContext parentContext, Attributes attributes, String scope) {
this.solrMetricsContext = parentContext.getChildContext(this);
+ Attributes attrsWithCategory =
+ Attributes.builder().putAll(attributes).put("category",
getCategory().toString()).build();
// Metrics
- numErrors = this.solrMetricsContext.meter("errors",
getCategory().toString(), scope);
- requests = this.solrMetricsContext.counter("requests",
getCategory().toString(), scope);
+ numErrors =
+ new AttributedLongCounter(
+ this.solrMetricsContext.longCounter(
+ "solr_core_authentication_plugin_errors", "Count of errors
during authentication"),
+ attrsWithCategory);
+ requests =
+ new AttributedLongCounter(
+ this.solrMetricsContext.longCounter(
+ "solr_core_authentication_plugin_requests", "Count of requests
for authentication"),
+ attrsWithCategory);
numAuthenticated =
- this.solrMetricsContext.counter("authenticated",
getCategory().toString(), scope);
+ new AttributedLongCounter(
+ this.solrMetricsContext.longCounter(
+ "solr_core_authentication_plugin_num_authenticated",
+ "Count of successful authentication requests"),
+ attrsWithCategory);
numPassThrough =
- this.solrMetricsContext.counter("passThrough",
getCategory().toString(), scope);
+ new AttributedLongCounter(
+ this.solrMetricsContext.longCounter(
+ "solr_core_authentication_plugin_num_pass_through",
+ "Count of skipped authentication requests"),
+ attrsWithCategory);
numWrongCredentials =
- this.solrMetricsContext.counter("failWrongCredentials",
getCategory().toString(), scope);
+ new AttributedLongCounter(
+ this.solrMetricsContext.longCounter(
+ "solr_core_authentication_plugin_fail_wrong_credentials",
+ "Count of authentication failures due to incorrect
credentials"),
+ attrsWithCategory);
numMissingCredentials =
- this.solrMetricsContext.counter("failMissingCredentials",
getCategory().toString(), scope);
- requestTimes = this.solrMetricsContext.timer("requestTimes",
getCategory().toString(), scope);
- totalTime = this.solrMetricsContext.counter("totalTime",
getCategory().toString(), scope);
+ new AttributedLongCounter(
+ this.solrMetricsContext.longCounter(
+ "solr_core_authentication_plugin_fail_missing_credentials",
+ "Count of authentication failures due to missing credentials"),
+ attrsWithCategory);
+ requestTimes =
+ new AttributedLongTimer(
+ this.solrMetricsContext.longHistogram(
+ "solr_core_authentication_plugin_request_times",
+ "Distribution of authentication request durations"),
+ attrsWithCategory);
+ totalTime =
Review Comment:
+1. You can drop this because AttributedLongTimer is a histogram under the
hood which gives you a timeseries with the total sum of time. Also make sure to
add the `OtelUnit` of "ms"
##########
solr/core/src/java/org/apache/solr/security/AuthenticationPlugin.java:
##########
@@ -163,24 +163,59 @@ public SolrMetricsContext getSolrMetricsContext() {
return solrMetricsContext;
}
- // TODO SOLR-17458: Migrate to Otel
@Override
public void initializeMetrics(
SolrMetricsContext parentContext, Attributes attributes, String scope) {
this.solrMetricsContext = parentContext.getChildContext(this);
+ Attributes attrsWithCategory =
+ Attributes.builder().putAll(attributes).put("category",
getCategory().toString()).build();
// Metrics
- numErrors = this.solrMetricsContext.meter("errors",
getCategory().toString(), scope);
- requests = this.solrMetricsContext.counter("requests",
getCategory().toString(), scope);
+ numErrors =
Review Comment:
I think it's ok to keep it separate names in this case. The error type
differentiation didn't have anything granular like `RequestHandlerBase` did
with client/server errors unless we want to actually differentiate that here as
well. Also I don't think `core` or `plugin` in the name is necessary.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]