more metrics sanitization

This commit is contained in:
Jonathan Shook
2023-08-30 00:57:46 -05:00
parent b1e95ab330
commit f0d0f20898
3 changed files with 7 additions and 6 deletions

View File

@@ -180,7 +180,7 @@ public abstract class BaseOpDispenser<T extends Op, S> implements OpDispenser<T>
final int hdrDigits = pop.getStaticConfigOr("hdr_digits", 4).intValue(); final int hdrDigits = pop.getStaticConfigOr("hdr_digits", 4).intValue();
successTimer = ActivityMetrics.timer(pop, "success", hdrDigits); successTimer = ActivityMetrics.timer(pop, "success", hdrDigits);
errorTimer = ActivityMetrics.timer(pop, "error", hdrDigits); errorTimer = ActivityMetrics.timer(pop, "error", hdrDigits);
resultSizeHistogram = ActivityMetrics.histogram(pop, "resultset-size", hdrDigits); resultSizeHistogram = ActivityMetrics.histogram(pop, "resultset_size", hdrDigits);
} }
} }

View File

@@ -39,7 +39,7 @@ public class ExceptionHistoMetrics {
public ExceptionHistoMetrics(final NBLabeledElement parentLabels, final ActivityDef activityDef) { public ExceptionHistoMetrics(final NBLabeledElement parentLabels, final ActivityDef activityDef) {
this.parentLabels = parentLabels; this.parentLabels = parentLabels;
this.activityDef = activityDef; this.activityDef = activityDef;
this.allerrors = ActivityMetrics.histogram(parentLabels, "errorhistos.ALL", activityDef.getParams().getOptionalInteger("hdr_digits").orElse(4)); this.allerrors = ActivityMetrics.histogram(parentLabels, "errorhistos_ALL", activityDef.getParams().getOptionalInteger("hdr_digits").orElse(4));
} }
public void update(final String name, final long magnitude) { public void update(final String name, final long magnitude) {
@@ -47,7 +47,7 @@ public class ExceptionHistoMetrics {
if (null == h) synchronized (this.histos) { if (null == h) synchronized (this.histos) {
h = this.histos.computeIfAbsent( h = this.histos.computeIfAbsent(
name, name,
k -> ActivityMetrics.histogram(this.parentLabels, "errorhistos." + name, this.activityDef.getParams().getOptionalInteger("hdr_digits").orElse(4)) errName -> ActivityMetrics.histogram(this.parentLabels, "errorhistos_"+errName, this.activityDef.getParams().getOptionalInteger("hdr_digits").orElse(4))
); );
} }
h.update(magnitude); h.update(magnitude);

View File

@@ -207,7 +207,7 @@ public class NBCLIScenarioParser {
alias = alias.replaceAll("STEP", sanitize(stepName)); alias = alias.replaceAll("STEP", sanitize(stepName));
alias = (alias.startsWith("alias=") ? alias : "alias=" + alias); alias = (alias.startsWith("alias=") ? alias : "alias=" + alias);
buildingCmd.put("alias", alias); buildingCmd.put("alias", alias);
buildingCmd.put("labels","labels=workload:"+sanitize(workloadToken)); buildingCmd.put("labels","labels=workload:$"+sanitize(workloadToken));
logger.debug(() -> "rebuilt command: " + String.join(" ", buildingCmd.values())); logger.debug(() -> "rebuilt command: " + String.join(" ", buildingCmd.values()));
buildCmdBuffer.addAll(buildingCmd.values()); buildCmdBuffer.addAll(buildingCmd.values());
@@ -221,11 +221,12 @@ public class NBCLIScenarioParser {
public static String sanitize(String word) { public static String sanitize(String word) {
String sanitized = word; String sanitized = word;
sanitized = sanitized.replaceAll("\\..+$", ""); sanitized = sanitized.replaceAll("\\..+$", "");
String shortened = sanitized;
sanitized = sanitized.replaceAll("-","_"); sanitized = sanitized.replaceAll("-","_");
sanitized = sanitized.replaceAll("[^a-zA-Z0-9_]+", ""); sanitized = sanitized.replaceAll("[^a-zA-Z0-9_]+", "");
if (!word.equals(sanitized)) { if (!shortened.equals(sanitized)) {
logger.warn("The identifier or value '" + word + "' was sanitized to '" + sanitized + "' to be compatible with monitoring systems. You should probably change this to make diagnostics easier."); logger.warn("The identifier or value '" + shortened + "' was sanitized to '" + sanitized + "' to be compatible with monitoring systems. You should probably change this to make diagnostics easier.");
} }
return sanitized; return sanitized;
} }