Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Apply the builder pattern to the Span.log(..) methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsembwever committed Mar 2, 2016
1 parent fd5564d commit 097c9e8
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions opentracing/src/main/java/opentracing/Span.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,28 @@ public interface Span {
/** Get a Baggage item by key. */
String getBaggageItem(String key);

/** *
* Add a new log event to the Span, accepting an event name string and an optional structured payload argument.
* If specified, the payload argument may be of any type and arbitrary size,
* though implementations are not required to retain all payload arguments
* (or even all parts of all payload arguments).
*
* The timestamp of this log event is the current time.
**/
Span log(String eventName, /* @Nullable */ Object payload);

/**
* Add a new log event to the Span, accepting an event name string and an optional structured payload argument.
* If specified, the payload argument may be of any type and arbitrary size,
* though implementations are not required to retain all payload arguments
* (or even all parts of all payload arguments).
* Create an event builder, specifying the mandatory event name string.
*
* The timestamp is specified manually here to represent a past log event.
* The timestamp in microseconds in UTC time.
* The timestamp of this log event is by default the time the EventBuilder is constructed.
**/
Span log(long instantMicroseconds, String eventName, /* @Nullable */ Object payload);
EventBuilder buildEvent(String eventName);

interface EventBuilder {
/**
* Add the optional structured payload argument.
* If specified, the payload argument may be of any type and arbitrary size,
* though implementations are not required to retain all payload arguments
* (or even all parts of all payload arguments).
**/
EventBuilder withPayload(Object payload);

/**
* Add a specific timestamp, in microseconds in UTC time.
**/
EventBuilder withTimestamp(long microseconds);

/** Build the log event, adding it to the Span, then return the Span. */
Span log();
}
}

0 comments on commit 097c9e8

Please sign in to comment.