improve method names on annotations

This commit is contained in:
Jonathan Shook 2023-09-15 16:48:43 -05:00
parent 5e52ff2031
commit e4a566cedd
9 changed files with 32 additions and 32 deletions

View File

@ -407,7 +407,7 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
.element(this)
.now()
.layer(Layer.Session)
.detail("cli", String.join("\n", args))
.addDetail("cli", String.join("\n", args))
.build()
);

View File

@ -58,8 +58,8 @@ public class GrafanaMetricsAnnotator implements Annotator, NBConfigurable {
try {
GAnnotation ga = new GAnnotation();
ga.setTime(annotation.getStart());
ga.setTimeEnd(annotation.getEnd());
ga.setTime(annotation.getStartMillis());
ga.setTimeEnd(annotation.getEndMillis());
annotation.getLabels().asMap().forEach((k, v) -> {
ga.getTags().add(k + ":" + v);
@ -69,7 +69,7 @@ public class GrafanaMetricsAnnotator implements Annotator, NBConfigurable {
});
ga.getTags().add("layer:" + annotation.getLayer().toString());
if (annotation.getStart() == annotation.getEnd()) {
if (annotation.getStartMillis() == annotation.getEndMillis()) {
ga.getTags().add("span:instant");
} else {
ga.getTags().add("span:interval");

View File

@ -107,7 +107,7 @@ public class ActivityExecutor implements NBLabeledElement, ActivityController, P
.element(this)
.interval(this.startedAt, this.stoppedAt)
.layer(Layer.Activity)
.detail("params", getActivityDef().toString())
.addDetail("params", getActivityDef().toString())
.build()
);
}
@ -131,7 +131,7 @@ public class ActivityExecutor implements NBLabeledElement, ActivityController, P
.element(this)
.interval(this.startedAt, this.stoppedAt)
.layer(Layer.Activity)
.detail("params", getActivityDef().toString())
.addDetail("params", getActivityDef().toString())
.build()
);
}
@ -400,8 +400,8 @@ public class ActivityExecutor implements NBLabeledElement, ActivityController, P
.element(this)
.now()
.layer(Layer.Activity)
.detail("event", "start-activity")
.detail("params", activityDef.toString())
.addDetail("event", "start-activity")
.addDetail("params", activityDef.toString())
.build());
try {
@ -520,7 +520,7 @@ public class ActivityExecutor implements NBLabeledElement, ActivityController, P
.element(this)
.now()
.layer(Layer.Activity)
.detail("params", getActivityDef().toString())
.addDetail("params", getActivityDef().toString())
.build()
);
@ -562,8 +562,8 @@ public class ActivityExecutor implements NBLabeledElement, ActivityController, P
.element(this)
.interval(startedAt, stoppedAt)
.layer(Layer.Activity)
.detail("event", "stop-activity")
.detail("params", activityDef.toString())
.addDetail("event", "stop-activity")
.addDetail("params", activityDef.toString())
.build());
}

View File

@ -252,7 +252,7 @@ public class Scenario implements Callable<ExecutionMetricsResult>, NBLabeledElem
.element(this)
.now()
.layer(Layer.Scenario)
.detail("engine", engine.toString())
.addDetail("engine", engine.toString())
.build()
);
@ -351,7 +351,7 @@ public class Scenario implements Callable<ExecutionMetricsResult>, NBLabeledElem
.element(this)
.interval(startedAtMillis, this.endedAtMillis)
.layer(Layer.Scenario)
.detail("event","stop-scenario")
.addDetail("event","stop-scenario")
.build();
Annotators.recordAnnotation(annotation);

View File

@ -37,20 +37,20 @@ import java.util.function.Function;
public interface Annotation extends NBLabeledElement {
/**
* If this is the same as {@link #getEnd()}, then the annotation is
* If this is the same as {@link #getEndMillis()}, then the annotation is
* for an instant in time.
*
* @return The beginning of the interval of time that the annotation describes
*/
long getStart();
long getStartMillis();
/**
* If this is the same as {@link #getStart()}, then the annotation
* If this is the same as {@link #getStartMillis()}, then the annotation
* is for an instant in time.
*
* @return The end of the interval of time that the annotation describes
*/
long getEnd();
long getEndMillis();
/**
* Annotations must be associated with a processing layer in NoSQLBench.

View File

@ -71,7 +71,7 @@ public class AnnotationBuilder implements AnnotationBuilderFacets.All {
@Override
public AnnotationBuilderFacets.WantsMoreDetailsOrBuild detail(String name, String value) {
public AnnotationBuilderFacets.WantsMoreDetailsOrBuild addDetail(String name, String value) {
this.details.put(name, value);
return this;
}

View File

@ -56,7 +56,7 @@ public interface AnnotationBuilderFacets {
}
interface WantsMoreDetailsOrBuild {
WantsMoreDetailsOrBuild detail(String name, String value);
WantsMoreDetailsOrBuild addDetail(String name, String value);
Annotation build();
}

View File

@ -68,8 +68,8 @@ public class MutableAnnotation implements Annotation {
setElement(element);
setSession(session);
setLayer(layer);
setStart(start);
setEnd(end);
setStartMillis(start);
setEndMillis(end);
setDetails(details);
}
@ -82,11 +82,11 @@ public class MutableAnnotation implements Annotation {
this.session = sessionName;
}
public void setStart(long intervalStart) {
public void setStartMillis(long intervalStart) {
this.start = intervalStart;
}
public void setEnd(long intervalEnd) {
public void setEndMillis(long intervalEnd) {
this.end = intervalEnd;
this.details.put("duration",String.valueOf(getDurationMillis()));
}
@ -100,12 +100,12 @@ public class MutableAnnotation implements Annotation {
}
@Override
public long getStart() {
public long getStartMillis() {
return start;
}
@Override
public long getEnd() {
public long getEndMillis() {
return end;
}
@ -141,10 +141,10 @@ public class MutableAnnotation implements Annotation {
ZonedDateTime endTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(getStartMillis()), zoneid);
sb.append("[");
ZonedDateTime zonedStartTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(getStart()), zoneid);
ZonedDateTime zonedStartTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(getStartMillis()), zoneid);
sb.append(zonedStartTime.format(DateTimeFormatter.ISO_INSTANT));
if (getStart() != getEnd()) {
ZonedDateTime zonedEndTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(getEnd()), zoneid);
if (getStartMillis() != getEndMillis()) {
ZonedDateTime zonedEndTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(getEndMillis()), zoneid);
sb.append(" - ").append(zonedEndTime.format(DateTimeFormatter.ISO_INSTANT));
}
sb.append("]\n");
@ -179,7 +179,7 @@ public class MutableAnnotation implements Annotation {
}
public Temporal getTemporal() {
return (getStart() == getEnd()) ? Temporal.instant : Temporal.interval;
return (getStartMillis() == getEndMillis()) ? Temporal.instant : Temporal.interval;
}
public String asJson() {

View File

@ -34,9 +34,9 @@ public class AnnotationBuilderTest {
.element(NBLabeledElement.forKV("test_element","value"))
.at(time)
.layer(Layer.Scenario)
.detail("detailk1", "detailv1")
.detail("detailk2", "detailv21\ndetailv22")
.detail("detailk3", "v1\nv2\nv3\n")
.addDetail("detailk1", "detailv1")
.addDetail("detailk2", "detailv21\ndetailv22")
.addDetail("detailk3", "v1\nv2\nv3\n")
.build();
String represented = an1.toString();