-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SOLR-17587: Prometheus Writer duplicate TYPE information in exposition format #2902
Changes from 8 commits
f27803e
5e07534
8abef07
286911b
cf3b2e0
b553839
ed482ab
3ae9106
b700157
fc86708
b288537
3596c90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,12 +25,11 @@ | |
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.lang.invoke.MethodHandles; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.Consumer; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Collectors; | ||
import org.apache.solr.common.SolrException; | ||
import org.apache.solr.common.util.NamedList; | ||
import org.apache.solr.metrics.AggregateMetric; | ||
import org.apache.solr.metrics.prometheus.SolrPrometheusFormatter; | ||
|
@@ -115,30 +114,22 @@ public static void toPrometheus( | |
Metric dropwizardMetric = dropwizardMetrics.get(metricName); | ||
formatter.exportDropwizardMetric(dropwizardMetric, metricName); | ||
} catch (Exception e) { | ||
// Do not fail entirely for metrics exporting. Log and try to export next metric | ||
log.warn("Error occurred exporting Dropwizard Metric to Prometheus", e); | ||
throw new SolrException( | ||
SolrException.ErrorCode.SERVER_ERROR, | ||
"Error occurred exporting Dropwizard Metric to Prometheus", | ||
e); | ||
Comment on lines
+117
to
+120
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also wanted to mention this. I was thinking to just remove the |
||
} | ||
}); | ||
|
||
consumer.accept(formatter); | ||
} | ||
|
||
public static SolrPrometheusFormatter getFormatterType(String registryName) { | ||
String coreName; | ||
boolean cloudMode = false; | ||
String[] parsedRegistry = registryName.split("\\."); | ||
|
||
switch (parsedRegistry[1]) { | ||
case "core": | ||
if (parsedRegistry.length == 3) { | ||
coreName = parsedRegistry[2]; | ||
} else if (parsedRegistry.length == 5) { | ||
coreName = Arrays.stream(parsedRegistry).skip(1).collect(Collectors.joining("_")); | ||
cloudMode = true; | ||
} else { | ||
coreName = registryName; | ||
} | ||
return new SolrPrometheusCoreFormatter(coreName, cloudMode); | ||
return new SolrPrometheusCoreFormatter(); | ||
case "jvm": | ||
return new SolrPrometheusJvmFormatter(); | ||
case "jetty": | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for single char find & replace, just use
replace
. You'll see by code inspection it's much faster.