differentiate dimension and instance labels

This commit is contained in:
Jonathan Shook 2023-08-28 16:15:10 -05:00
parent 59a6544e68
commit 6c4833d48d
7 changed files with 22 additions and 9 deletions

View File

@ -71,13 +71,13 @@ public class NamingFolio {
* by name, type, table, keyspace. For now it just returns everything in fully qualified form. * by name, type, table, keyspace. For now it just returns everything in fully qualified form.
*/ */
public String nameFor(NBLabeledElement labeled, String... fields) { public String nameFor(NBLabeledElement labeled, String... fields) {
NBLabels labelsPlus = labeled.getLabels().and(fields); NBLabels labelsPlus = labeled.getLabels().andTypes(fields);
String name = namer.apply(labelsPlus.asMap()); String name = namer.apply(labelsPlus.asMap());
return name; return name;
} }
public String nameFor(NBLabeledElement labeled, Map<String,String> fields) { public String nameFor(NBLabeledElement labeled, Map<String,String> fields) {
NBLabels labelsPlus = labeled.getLabels().and(fields); NBLabels labelsPlus = labeled.getLabels().andTypes(fields);
String name = namer.apply(labelsPlus.asMap()); String name = namer.apply(labelsPlus.asMap());
return name; return name;

View File

@ -42,6 +42,6 @@ public class CqlTableColumn extends CqlColumnBase {
@Override @Override
public NBLabels getLabels() { public NBLabels getLabels() {
return super.getLabels().and("table", table.getName()); return super.getLabels().andTypes("table", table.getName());
} }
} }

View File

@ -42,6 +42,6 @@ public class CqlTypeColumn extends CqlColumnBase {
@Override @Override
public NBLabels getLabels() { public NBLabels getLabels() {
return super.getLabels().and("name", this.type.getName()); return super.getLabels().andTypes("name", this.type.getName());
} }
} }

View File

@ -171,6 +171,6 @@ public class DiagTask_gauge extends BaseDiagTask implements Gauge<Double> {
@Override @Override
public NBLabels getLabels() { public NBLabels getLabels() {
return super.getLabels().and("stat",this.stat.toString()); return super.getLabels().andTypes("stat",this.stat.toString());
} }
} }

View File

@ -51,7 +51,7 @@ public class KafkaAdapterMetrics {
public KafkaAdapterMetrics(final KafkaBaseOpDispenser kafkaBaseOpDispenser, final NBLabeledElement labeledParent) { public KafkaAdapterMetrics(final KafkaBaseOpDispenser kafkaBaseOpDispenser, final NBLabeledElement labeledParent) {
this.kafkaBaseOpDispenser = kafkaBaseOpDispenser; this.kafkaBaseOpDispenser = kafkaBaseOpDispenser;
labels=labeledParent.getLabels().and("name",KafkaAdapterMetrics.class.getSimpleName()); labels=labeledParent.getLabels().andTypes("name",KafkaAdapterMetrics.class.getSimpleName());
} }
public void initS4JAdapterInstrumentation() { public void initS4JAdapterInstrumentation() {

View File

@ -83,7 +83,7 @@ public class Scenario implements Callable<ExecutionMetricsResult>, NBLabeledElem
@Override @Override
public NBLabels getLabels() { public NBLabels getLabels() {
return this.parentComponent.getLabels().and("scenario", this.scenarioName); return this.parentComponent.getLabels().andTypes("scenario", this.scenarioName);
} }
public enum State { public enum State {

View File

@ -142,8 +142,9 @@ public interface NBLabels {
* Keys and values in "key1", "value1", "key2", "value2", ... form * Keys and values in "key1", "value1", "key2", "value2", ... form
* @return A new NBLabels instance * @return A new NBLabels instance
*/ */
NBLabels and(String... labelsAndValues); NBLabels andTypes(String... typeLabelsAndValues);
NBLabels and(NBLabels labels);
/** /**
* Create a new NBLabels value with the additional keys and values appended. * Create a new NBLabels value with the additional keys and values appended.
* *
@ -151,7 +152,10 @@ public interface NBLabels {
* a map of keys and values * a map of keys and values
* @return A new NBLabels instance * @return A new NBLabels instance
*/ */
NBLabels and(Map<String, String> labels); NBLabels andTypes(Map<String, String> typeLabelsAndValues);
NBLabels andInstances(String... instanceLabelsAndValues);
NBLabels andInstances(Map<String,String> instanceLabelsAndValues);
/** /**
* Return the value of the specified label key. * Return the value of the specified label key.
@ -170,4 +174,13 @@ public interface NBLabels {
* @return a {@link Map} of keys and values, in deterministic order * @return a {@link Map} of keys and values, in deterministic order
*/ */
Map<String, String> asMap(); Map<String, String> asMap();
/**
* @return a new set of labels which includes only those which are not using per-instance semantics.
*/
NBLabels onlyTypes();
NBLabels onlyInstances();
String[] getInstanceFields();
} }