Skip to content

Commit

Permalink
add defaulting behavior for addEvent overload
Browse files Browse the repository at this point in the history
  • Loading branch information
samvaity committed Jun 23, 2021
1 parent c46413e commit 5402c76
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public Context getSharedSpanBuilder(String spanName, Context context) {
*/
@Override
public void addEvent(String eventName, Map<String, Object> traceEventAttributes, OffsetDateTime timestamp) {
addEvent(eventName, traceEventAttributes, timestamp, Context.NONE);
addEvent(eventName, traceEventAttributes, timestamp, new Context(PARENT_SPAN_KEY, Span.current()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ public void addEventWithChildSpan() {
}

@Test
public void addEventWithoutContext() {
public void addEventWithoutEventSpanContext() {
// Arrange
final String eventName = "event-0";
OffsetDateTime eventTime = OffsetDateTime.parse("2021-01-01T18:35:24.00Z");
Expand All @@ -608,7 +608,7 @@ public void addEventWithoutContext() {
assertEquals(PARENT_SPAN_KEY, recordEventsSpan.getName());
List<EventData> eventData = recordEventsSpan.toSpanData().getEvents();
assertNotNull(eventData);
assertEquals(0, eventData.size());
assertEquals(1, eventData.size());
}

private static void assertSpanWithExplicitParent(Context updatedContext, String parentSpanId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ default void addEvent(String name, Map<String, Object> attributes, OffsetDateTim
}

/**
* Adds an event to the current span with the provided {@code timestamp} and {@code attributes}.
* Adds an event to the span present in the {@code Context} with the provided {@code timestamp}
* and {@code attributes}.
* <p>This API does not provide any normalization if provided timestamps are out of range of the current
* span timeline</p>
* <p>Supported attribute values include String, double, boolean, long, String [], double [], long [].
Expand Down

0 comments on commit 5402c76

Please sign in to comment.