mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-16 17:34:52 -06:00
improve method names on annotations
This commit is contained in:
parent
5e52ff2031
commit
e4a566cedd
@ -407,7 +407,7 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
|
|||||||
.element(this)
|
.element(this)
|
||||||
.now()
|
.now()
|
||||||
.layer(Layer.Session)
|
.layer(Layer.Session)
|
||||||
.detail("cli", String.join("\n", args))
|
.addDetail("cli", String.join("\n", args))
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -58,8 +58,8 @@ public class GrafanaMetricsAnnotator implements Annotator, NBConfigurable {
|
|||||||
try {
|
try {
|
||||||
GAnnotation ga = new GAnnotation();
|
GAnnotation ga = new GAnnotation();
|
||||||
|
|
||||||
ga.setTime(annotation.getStart());
|
ga.setTime(annotation.getStartMillis());
|
||||||
ga.setTimeEnd(annotation.getEnd());
|
ga.setTimeEnd(annotation.getEndMillis());
|
||||||
|
|
||||||
annotation.getLabels().asMap().forEach((k, v) -> {
|
annotation.getLabels().asMap().forEach((k, v) -> {
|
||||||
ga.getTags().add(k + ":" + v);
|
ga.getTags().add(k + ":" + v);
|
||||||
@ -69,7 +69,7 @@ public class GrafanaMetricsAnnotator implements Annotator, NBConfigurable {
|
|||||||
});
|
});
|
||||||
ga.getTags().add("layer:" + annotation.getLayer().toString());
|
ga.getTags().add("layer:" + annotation.getLayer().toString());
|
||||||
|
|
||||||
if (annotation.getStart() == annotation.getEnd()) {
|
if (annotation.getStartMillis() == annotation.getEndMillis()) {
|
||||||
ga.getTags().add("span:instant");
|
ga.getTags().add("span:instant");
|
||||||
} else {
|
} else {
|
||||||
ga.getTags().add("span:interval");
|
ga.getTags().add("span:interval");
|
||||||
|
@ -107,7 +107,7 @@ public class ActivityExecutor implements NBLabeledElement, ActivityController, P
|
|||||||
.element(this)
|
.element(this)
|
||||||
.interval(this.startedAt, this.stoppedAt)
|
.interval(this.startedAt, this.stoppedAt)
|
||||||
.layer(Layer.Activity)
|
.layer(Layer.Activity)
|
||||||
.detail("params", getActivityDef().toString())
|
.addDetail("params", getActivityDef().toString())
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ public class ActivityExecutor implements NBLabeledElement, ActivityController, P
|
|||||||
.element(this)
|
.element(this)
|
||||||
.interval(this.startedAt, this.stoppedAt)
|
.interval(this.startedAt, this.stoppedAt)
|
||||||
.layer(Layer.Activity)
|
.layer(Layer.Activity)
|
||||||
.detail("params", getActivityDef().toString())
|
.addDetail("params", getActivityDef().toString())
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -400,8 +400,8 @@ public class ActivityExecutor implements NBLabeledElement, ActivityController, P
|
|||||||
.element(this)
|
.element(this)
|
||||||
.now()
|
.now()
|
||||||
.layer(Layer.Activity)
|
.layer(Layer.Activity)
|
||||||
.detail("event", "start-activity")
|
.addDetail("event", "start-activity")
|
||||||
.detail("params", activityDef.toString())
|
.addDetail("params", activityDef.toString())
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -520,7 +520,7 @@ public class ActivityExecutor implements NBLabeledElement, ActivityController, P
|
|||||||
.element(this)
|
.element(this)
|
||||||
.now()
|
.now()
|
||||||
.layer(Layer.Activity)
|
.layer(Layer.Activity)
|
||||||
.detail("params", getActivityDef().toString())
|
.addDetail("params", getActivityDef().toString())
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -562,8 +562,8 @@ public class ActivityExecutor implements NBLabeledElement, ActivityController, P
|
|||||||
.element(this)
|
.element(this)
|
||||||
.interval(startedAt, stoppedAt)
|
.interval(startedAt, stoppedAt)
|
||||||
.layer(Layer.Activity)
|
.layer(Layer.Activity)
|
||||||
.detail("event", "stop-activity")
|
.addDetail("event", "stop-activity")
|
||||||
.detail("params", activityDef.toString())
|
.addDetail("params", activityDef.toString())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ public class Scenario implements Callable<ExecutionMetricsResult>, NBLabeledElem
|
|||||||
.element(this)
|
.element(this)
|
||||||
.now()
|
.now()
|
||||||
.layer(Layer.Scenario)
|
.layer(Layer.Scenario)
|
||||||
.detail("engine", engine.toString())
|
.addDetail("engine", engine.toString())
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -351,7 +351,7 @@ public class Scenario implements Callable<ExecutionMetricsResult>, NBLabeledElem
|
|||||||
.element(this)
|
.element(this)
|
||||||
.interval(startedAtMillis, this.endedAtMillis)
|
.interval(startedAtMillis, this.endedAtMillis)
|
||||||
.layer(Layer.Scenario)
|
.layer(Layer.Scenario)
|
||||||
.detail("event","stop-scenario")
|
.addDetail("event","stop-scenario")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Annotators.recordAnnotation(annotation);
|
Annotators.recordAnnotation(annotation);
|
||||||
|
@ -37,20 +37,20 @@ import java.util.function.Function;
|
|||||||
public interface Annotation extends NBLabeledElement {
|
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.
|
* for an instant in time.
|
||||||
*
|
*
|
||||||
* @return The beginning of the interval of time that the annotation describes
|
* @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.
|
* is for an instant in time.
|
||||||
*
|
*
|
||||||
* @return The end of the interval of time that the annotation describes
|
* @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.
|
* Annotations must be associated with a processing layer in NoSQLBench.
|
||||||
|
@ -71,7 +71,7 @@ public class AnnotationBuilder implements AnnotationBuilderFacets.All {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AnnotationBuilderFacets.WantsMoreDetailsOrBuild detail(String name, String value) {
|
public AnnotationBuilderFacets.WantsMoreDetailsOrBuild addDetail(String name, String value) {
|
||||||
this.details.put(name, value);
|
this.details.put(name, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public interface AnnotationBuilderFacets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface WantsMoreDetailsOrBuild {
|
interface WantsMoreDetailsOrBuild {
|
||||||
WantsMoreDetailsOrBuild detail(String name, String value);
|
WantsMoreDetailsOrBuild addDetail(String name, String value);
|
||||||
Annotation build();
|
Annotation build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +68,8 @@ public class MutableAnnotation implements Annotation {
|
|||||||
setElement(element);
|
setElement(element);
|
||||||
setSession(session);
|
setSession(session);
|
||||||
setLayer(layer);
|
setLayer(layer);
|
||||||
setStart(start);
|
setStartMillis(start);
|
||||||
setEnd(end);
|
setEndMillis(end);
|
||||||
setDetails(details);
|
setDetails(details);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,11 +82,11 @@ public class MutableAnnotation implements Annotation {
|
|||||||
this.session = sessionName;
|
this.session = sessionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStart(long intervalStart) {
|
public void setStartMillis(long intervalStart) {
|
||||||
this.start = intervalStart;
|
this.start = intervalStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnd(long intervalEnd) {
|
public void setEndMillis(long intervalEnd) {
|
||||||
this.end = intervalEnd;
|
this.end = intervalEnd;
|
||||||
this.details.put("duration",String.valueOf(getDurationMillis()));
|
this.details.put("duration",String.valueOf(getDurationMillis()));
|
||||||
}
|
}
|
||||||
@ -100,12 +100,12 @@ public class MutableAnnotation implements Annotation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getStart() {
|
public long getStartMillis() {
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getEnd() {
|
public long getEndMillis() {
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,10 +141,10 @@ public class MutableAnnotation implements Annotation {
|
|||||||
ZonedDateTime endTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(getStartMillis()), zoneid);
|
ZonedDateTime endTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(getStartMillis()), zoneid);
|
||||||
|
|
||||||
sb.append("[");
|
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));
|
sb.append(zonedStartTime.format(DateTimeFormatter.ISO_INSTANT));
|
||||||
if (getStart() != getEnd()) {
|
if (getStartMillis() != getEndMillis()) {
|
||||||
ZonedDateTime zonedEndTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(getEnd()), zoneid);
|
ZonedDateTime zonedEndTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(getEndMillis()), zoneid);
|
||||||
sb.append(" - ").append(zonedEndTime.format(DateTimeFormatter.ISO_INSTANT));
|
sb.append(" - ").append(zonedEndTime.format(DateTimeFormatter.ISO_INSTANT));
|
||||||
}
|
}
|
||||||
sb.append("]\n");
|
sb.append("]\n");
|
||||||
@ -179,7 +179,7 @@ public class MutableAnnotation implements Annotation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Temporal getTemporal() {
|
public Temporal getTemporal() {
|
||||||
return (getStart() == getEnd()) ? Temporal.instant : Temporal.interval;
|
return (getStartMillis() == getEndMillis()) ? Temporal.instant : Temporal.interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String asJson() {
|
public String asJson() {
|
||||||
|
@ -34,9 +34,9 @@ public class AnnotationBuilderTest {
|
|||||||
.element(NBLabeledElement.forKV("test_element","value"))
|
.element(NBLabeledElement.forKV("test_element","value"))
|
||||||
.at(time)
|
.at(time)
|
||||||
.layer(Layer.Scenario)
|
.layer(Layer.Scenario)
|
||||||
.detail("detailk1", "detailv1")
|
.addDetail("detailk1", "detailv1")
|
||||||
.detail("detailk2", "detailv21\ndetailv22")
|
.addDetail("detailk2", "detailv21\ndetailv22")
|
||||||
.detail("detailk3", "v1\nv2\nv3\n")
|
.addDetail("detailk3", "v1\nv2\nv3\n")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
String represented = an1.toString();
|
String represented = an1.toString();
|
||||||
|
Loading…
Reference in New Issue
Block a user