Prefers the word event when adding to a Span's timeline
Span.logs are really timestamped events. This clarifies the naming and documentation around that.
This commit is contained in:
@@ -25,12 +25,25 @@ import lombok.RequiredArgsConstructor;
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class Log {
|
||||
private final long time;
|
||||
private final String msg;
|
||||
/**
|
||||
* The epoch timestamp of the log record; often set via {@link System#currentTimeMillis()}.
|
||||
*/
|
||||
private final long timestamp;
|
||||
|
||||
/**
|
||||
* Event (if not null) should be the stable name of some notable moment in the lifetime of a Span.
|
||||
* For instance, a Span representing a browser page load might add an Event for each of the
|
||||
* Performance.timing moments here: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceTiming
|
||||
*
|
||||
* <p>While it is not a formal requirement, Event strings will be most useful if they are *not*
|
||||
* unique; rather, tracing systems should be able to use them to understand how two similar Spans
|
||||
* relate from an internal timing perspective.
|
||||
*/
|
||||
private final String event;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private Log() {
|
||||
this.time = 0;
|
||||
this.msg = null;
|
||||
this.timestamp = 0;
|
||||
this.event = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,11 +170,10 @@ public class Span {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a log or timeline annotation associated with this span
|
||||
* Add an {@link Log#event event} to the timeline associated with this span.
|
||||
*/
|
||||
public void log(String msg) {
|
||||
this.logs.add(new Log(System.currentTimeMillis(),
|
||||
msg));
|
||||
public void logEvent(String event) {
|
||||
this.logs.add(new Log(System.currentTimeMillis(), event));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,7 +187,7 @@ public class Span {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get any logs or annotations (read only)
|
||||
* Get any timestamped events (read only)
|
||||
* <p/>
|
||||
* <p/>
|
||||
* Will never be null.
|
||||
|
||||
@@ -48,7 +48,7 @@ public class JsonLogSpanListenerTests {
|
||||
.end(10)
|
||||
.build();
|
||||
span.tag("myKey", "myVal");
|
||||
span.log("myTimelineAnnotation");
|
||||
span.logEvent("myTimelineAnnotation");
|
||||
listener.stop(new SpanReleasedEvent(this, span));
|
||||
|
||||
String output = this.output.toString().trim();
|
||||
|
||||
Reference in New Issue
Block a user