Rename EventImpl to ImmutableEvent (#1738)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
This commit is contained in:
parent
9c6f1ff031
commit
a706fb3350
|
|
@ -24,7 +24,7 @@ import io.opentelemetry.exporters.jaeger.proto.api_v2.Model;
|
|||
import io.opentelemetry.sdk.extensions.otproto.TraceProtoUtils;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import io.opentelemetry.sdk.trace.TestSpanData;
|
||||
import io.opentelemetry.sdk.trace.data.EventImpl;
|
||||
import io.opentelemetry.sdk.trace.data.ImmutableEvent;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData.Event;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData.Link;
|
||||
|
|
@ -123,7 +123,7 @@ class AdapterTest {
|
|||
@Test
|
||||
void testJaegerLog() {
|
||||
// prepare
|
||||
EventImpl event = getTimedEvent();
|
||||
ImmutableEvent event = getTimedEvent();
|
||||
|
||||
// test
|
||||
Model.Log log = Adapter.toJaegerLog(event);
|
||||
|
|
@ -261,10 +261,10 @@ class AdapterTest {
|
|||
assertTrue(error.getVBool());
|
||||
}
|
||||
|
||||
private static EventImpl getTimedEvent() {
|
||||
private static ImmutableEvent getTimedEvent() {
|
||||
long epochNanos = TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis());
|
||||
Attributes attributes = Attributes.of(stringKey("foo"), "bar");
|
||||
return EventImpl.create(epochNanos, "the log message", attributes);
|
||||
return ImmutableEvent.create(epochNanos, "the log message", attributes);
|
||||
}
|
||||
|
||||
private static SpanData getSpanData(long startMs, long endMs) {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
import io.opentelemetry.common.Attributes;
|
||||
import io.opentelemetry.sdk.common.CompletableResultCode;
|
||||
import io.opentelemetry.sdk.trace.TestSpanData;
|
||||
import io.opentelemetry.sdk.trace.data.EventImpl;
|
||||
import io.opentelemetry.sdk.trace.data.ImmutableEvent;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import io.opentelemetry.trace.Span.Kind;
|
||||
import io.opentelemetry.trace.SpanId;
|
||||
|
|
@ -58,7 +58,7 @@ class LoggingSpanExporterTest {
|
|||
.setKind(Kind.INTERNAL)
|
||||
.setEvents(
|
||||
Collections.singletonList(
|
||||
EventImpl.create(
|
||||
ImmutableEvent.create(
|
||||
epochNanos + 500,
|
||||
"somethingHappenedHere",
|
||||
Attributes.of(booleanKey("important"), true))))
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import io.opentelemetry.proto.common.v1.KeyValue;
|
|||
import io.opentelemetry.proto.trace.v1.Span;
|
||||
import io.opentelemetry.proto.trace.v1.Status;
|
||||
import io.opentelemetry.sdk.trace.TestSpanData;
|
||||
import io.opentelemetry.sdk.trace.data.EventImpl;
|
||||
import io.opentelemetry.sdk.trace.data.ImmutableEvent;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData.Link;
|
||||
import io.opentelemetry.trace.Span.Kind;
|
||||
import io.opentelemetry.trace.SpanContext;
|
||||
|
|
@ -63,7 +63,7 @@ class SpanAdapterTest {
|
|||
.setTotalAttributeCount(2)
|
||||
.setEvents(
|
||||
Collections.singletonList(
|
||||
EventImpl.create(12347, "my_event", Attributes.empty())))
|
||||
ImmutableEvent.create(12347, "my_event", Attributes.empty())))
|
||||
.setTotalRecordedEvents(3)
|
||||
.setLinks(Collections.singletonList(Link.create(SPAN_CONTEXT)))
|
||||
.setTotalRecordedLinks(2)
|
||||
|
|
@ -130,7 +130,7 @@ class SpanAdapterTest {
|
|||
void toProtoSpanEvent_WithoutAttributes() {
|
||||
assertThat(
|
||||
SpanAdapter.toProtoSpanEvent(
|
||||
EventImpl.create(12345, "test_without_attributes", Attributes.empty())))
|
||||
ImmutableEvent.create(12345, "test_without_attributes", Attributes.empty())))
|
||||
.isEqualTo(
|
||||
Span.Event.newBuilder()
|
||||
.setTimeUnixNano(12345)
|
||||
|
|
@ -142,7 +142,7 @@ class SpanAdapterTest {
|
|||
void toProtoSpanEvent_WithAttributes() {
|
||||
assertThat(
|
||||
SpanAdapter.toProtoSpanEvent(
|
||||
EventImpl.create(
|
||||
ImmutableEvent.create(
|
||||
12345,
|
||||
"test_with_attributes",
|
||||
Attributes.of(stringKey("key_string"), "string"),
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import com.google.common.collect.ImmutableList;
|
|||
import io.opentelemetry.common.Attributes;
|
||||
import io.opentelemetry.sdk.common.CompletableResultCode;
|
||||
import io.opentelemetry.sdk.trace.TestSpanData;
|
||||
import io.opentelemetry.sdk.trace.data.EventImpl;
|
||||
import io.opentelemetry.sdk.trace.data.ImmutableEvent;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData.Event;
|
||||
import io.opentelemetry.trace.Span.Kind;
|
||||
|
|
@ -45,8 +45,8 @@ public class ZipkinSpanExporterEndToEndHttpTest {
|
|||
private static final Attributes attributes = Attributes.empty();
|
||||
private static final List<Event> annotations =
|
||||
ImmutableList.of(
|
||||
EventImpl.create(RECEIVED_TIMESTAMP_NANOS, "RECEIVED", Attributes.empty()),
|
||||
EventImpl.create(SENT_TIMESTAMP_NANOS, "SENT", Attributes.empty()));
|
||||
ImmutableEvent.create(RECEIVED_TIMESTAMP_NANOS, "RECEIVED", Attributes.empty()),
|
||||
ImmutableEvent.create(SENT_TIMESTAMP_NANOS, "SENT", Attributes.empty()));
|
||||
|
||||
private static final String ENDPOINT_V1_SPANS = "/api/v1/spans";
|
||||
private static final String ENDPOINT_V2_SPANS = "/api/v2/spans";
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import io.opentelemetry.sdk.common.export.ConfigBuilder;
|
|||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import io.opentelemetry.sdk.resources.ResourceAttributes;
|
||||
import io.opentelemetry.sdk.trace.TestSpanData;
|
||||
import io.opentelemetry.sdk.trace.data.EventImpl;
|
||||
import io.opentelemetry.sdk.trace.data.ImmutableEvent;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData.Event;
|
||||
import io.opentelemetry.trace.Span.Kind;
|
||||
|
|
@ -66,8 +66,8 @@ class ZipkinSpanExporterTest {
|
|||
private static final Attributes attributes = Attributes.empty();
|
||||
private static final List<Event> annotations =
|
||||
ImmutableList.of(
|
||||
EventImpl.create(1505855799_433901068L, "RECEIVED", Attributes.empty()),
|
||||
EventImpl.create(1505855799_459486280L, "SENT", Attributes.empty()));
|
||||
ImmutableEvent.create(1505855799_433901068L, "RECEIVED", Attributes.empty()),
|
||||
ImmutableEvent.create(1505855799_459486280L, "SENT", Attributes.empty()));
|
||||
|
||||
@Test
|
||||
void generateSpan_remoteParent() {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import io.opentelemetry.sdk.common.Clock;
|
|||
import io.opentelemetry.sdk.common.InstrumentationLibraryInfo;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import io.opentelemetry.sdk.trace.config.TraceConfig;
|
||||
import io.opentelemetry.sdk.trace.data.EventImpl;
|
||||
import io.opentelemetry.sdk.trace.data.ImmutableEvent;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData.Event;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData.Link;
|
||||
|
|
@ -84,7 +84,7 @@ final class RecordEventsReadableSpan implements ReadWriteSpan {
|
|||
private AttributesMap attributes;
|
||||
// List of recorded events.
|
||||
@GuardedBy("lock")
|
||||
private final EvictingQueue<EventImpl> events;
|
||||
private final EvictingQueue<ImmutableEvent> events;
|
||||
// Number of events recorded.
|
||||
@GuardedBy("lock")
|
||||
private int totalRecordedEvents = 0;
|
||||
|
|
@ -322,7 +322,7 @@ final class RecordEventsReadableSpan implements ReadWriteSpan {
|
|||
if (name == null) {
|
||||
return;
|
||||
}
|
||||
addTimedEvent(EventImpl.create(clock.now(), name, Attributes.empty(), 0));
|
||||
addTimedEvent(ImmutableEvent.create(clock.now(), name, Attributes.empty(), 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -330,7 +330,7 @@ final class RecordEventsReadableSpan implements ReadWriteSpan {
|
|||
if (name == null) {
|
||||
return;
|
||||
}
|
||||
addTimedEvent(EventImpl.create(timestamp, name, Attributes.empty(), 0));
|
||||
addTimedEvent(ImmutableEvent.create(timestamp, name, Attributes.empty(), 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -340,7 +340,7 @@ final class RecordEventsReadableSpan implements ReadWriteSpan {
|
|||
}
|
||||
int totalAttributeCount = attributes.size();
|
||||
addTimedEvent(
|
||||
EventImpl.create(
|
||||
ImmutableEvent.create(
|
||||
clock.now(),
|
||||
name,
|
||||
copyAndLimitAttributes(attributes, traceConfig.getMaxNumberOfAttributesPerEvent()),
|
||||
|
|
@ -354,7 +354,7 @@ final class RecordEventsReadableSpan implements ReadWriteSpan {
|
|||
}
|
||||
int totalAttributeCount = attributes.size();
|
||||
addTimedEvent(
|
||||
EventImpl.create(
|
||||
ImmutableEvent.create(
|
||||
timestamp,
|
||||
name,
|
||||
copyAndLimitAttributes(attributes, traceConfig.getMaxNumberOfAttributesPerEvent()),
|
||||
|
|
@ -371,7 +371,7 @@ final class RecordEventsReadableSpan implements ReadWriteSpan {
|
|||
return result.build();
|
||||
}
|
||||
|
||||
private void addTimedEvent(EventImpl timedEvent) {
|
||||
private void addTimedEvent(ImmutableEvent timedEvent) {
|
||||
synchronized (lock) {
|
||||
if (hasEnded) {
|
||||
logger.log(Level.FINE, "Calling addEvent() on an ended Span.");
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import javax.annotation.concurrent.Immutable;
|
|||
/** An immutable implementation of the {@link SpanData.Event}. */
|
||||
@Immutable
|
||||
@AutoValue
|
||||
public abstract class EventImpl implements SpanData.Event {
|
||||
public abstract class ImmutableEvent implements SpanData.Event {
|
||||
|
||||
/**
|
||||
* Returns a new immutable {@code Event}.
|
||||
|
|
@ -22,8 +22,8 @@ public abstract class EventImpl implements SpanData.Event {
|
|||
* @param attributes the attributes of the {@code Event}.
|
||||
* @return a new immutable {@code Event<T>}
|
||||
*/
|
||||
public static EventImpl create(long epochNanos, String name, Attributes attributes) {
|
||||
return new AutoValue_EventImpl(name, attributes, epochNanos, attributes.size());
|
||||
public static ImmutableEvent create(long epochNanos, String name, Attributes attributes) {
|
||||
return new AutoValue_ImmutableEvent(name, attributes, epochNanos, attributes.size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -35,10 +35,10 @@ public abstract class EventImpl implements SpanData.Event {
|
|||
* @param totalAttributeCount the total number of attributes for this {@code} Event.
|
||||
* @return a new immutable {@code Event<T>}
|
||||
*/
|
||||
public static EventImpl create(
|
||||
public static ImmutableEvent create(
|
||||
long epochNanos, String name, Attributes attributes, int totalAttributeCount) {
|
||||
return new AutoValue_EventImpl(name, attributes, epochNanos, totalAttributeCount);
|
||||
return new AutoValue_ImmutableEvent(name, attributes, epochNanos, totalAttributeCount);
|
||||
}
|
||||
|
||||
EventImpl() {}
|
||||
ImmutableEvent() {}
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ import io.opentelemetry.sdk.common.InstrumentationLibraryInfo;
|
|||
import io.opentelemetry.sdk.internal.TestClock;
|
||||
import io.opentelemetry.sdk.resources.Resource;
|
||||
import io.opentelemetry.sdk.trace.config.TraceConfig;
|
||||
import io.opentelemetry.sdk.trace.data.EventImpl;
|
||||
import io.opentelemetry.sdk.trace.data.ImmutableEvent;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData.Event;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData.Link;
|
||||
|
|
@ -133,7 +133,8 @@ class RecordEventsReadableSpanTest {
|
|||
spanDoWork(span, null);
|
||||
SpanData spanData = span.toSpanData();
|
||||
Event event =
|
||||
EventImpl.create(START_EPOCH_NANOS + NANOS_PER_SECOND, "event2", Attributes.empty(), 0);
|
||||
ImmutableEvent.create(
|
||||
START_EPOCH_NANOS + NANOS_PER_SECOND, "event2", Attributes.empty(), 0);
|
||||
verifySpanData(
|
||||
spanData,
|
||||
expectedAttributes,
|
||||
|
|
@ -162,7 +163,8 @@ class RecordEventsReadableSpanTest {
|
|||
Mockito.verify(spanProcessor, Mockito.times(1)).onEnd(span);
|
||||
SpanData spanData = span.toSpanData();
|
||||
Event event =
|
||||
EventImpl.create(START_EPOCH_NANOS + NANOS_PER_SECOND, "event2", Attributes.empty(), 0);
|
||||
ImmutableEvent.create(
|
||||
START_EPOCH_NANOS + NANOS_PER_SECOND, "event2", Attributes.empty(), 0);
|
||||
verifySpanData(
|
||||
spanData,
|
||||
expectedAttributes,
|
||||
|
|
@ -192,7 +194,7 @@ class RecordEventsReadableSpanTest {
|
|||
|
||||
assertThrows(
|
||||
UnsupportedOperationException.class,
|
||||
() -> spanData.getEvents().add(EventImpl.create(1000, "test", Attributes.empty())));
|
||||
() -> spanData.getEvents().add(ImmutableEvent.create(1000, "test", Attributes.empty())));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -563,7 +565,7 @@ class RecordEventsReadableSpanTest {
|
|||
assertThat(spanData.getEvents().size()).isEqualTo(maxNumberOfEvents);
|
||||
for (int i = 0; i < maxNumberOfEvents; i++) {
|
||||
Event expectedEvent =
|
||||
EventImpl.create(
|
||||
ImmutableEvent.create(
|
||||
START_EPOCH_NANOS + (maxNumberOfEvents + i) * NANOS_PER_SECOND,
|
||||
"event2",
|
||||
Attributes.empty(),
|
||||
|
|
@ -578,7 +580,7 @@ class RecordEventsReadableSpanTest {
|
|||
assertThat(spanData.getEvents().size()).isEqualTo(maxNumberOfEvents);
|
||||
for (int i = 0; i < maxNumberOfEvents; i++) {
|
||||
Event expectedEvent =
|
||||
EventImpl.create(
|
||||
ImmutableEvent.create(
|
||||
START_EPOCH_NANOS + (maxNumberOfEvents + i) * NANOS_PER_SECOND,
|
||||
"event2",
|
||||
Attributes.empty(),
|
||||
|
|
@ -859,9 +861,9 @@ class RecordEventsReadableSpanTest {
|
|||
|
||||
List<Event> events =
|
||||
Arrays.asList(
|
||||
EventImpl.create(
|
||||
ImmutableEvent.create(
|
||||
firstEventEpochNanos, "event1", event1Attributes, event1Attributes.size()),
|
||||
EventImpl.create(
|
||||
ImmutableEvent.create(
|
||||
secondEventTimeNanos, "event2", event2Attributes, event2Attributes.size()));
|
||||
|
||||
SpanData result = readableSpan.toSpanData();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
|||
|
||||
import io.opentelemetry.common.Attributes;
|
||||
import io.opentelemetry.sdk.common.InstrumentationLibraryInfo;
|
||||
import io.opentelemetry.sdk.trace.data.EventImpl;
|
||||
import io.opentelemetry.sdk.trace.data.ImmutableEvent;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData.Link;
|
||||
import io.opentelemetry.trace.Span.Kind;
|
||||
|
|
@ -54,7 +54,7 @@ class TestSpanDataTest {
|
|||
|
||||
assertThrows(
|
||||
UnsupportedOperationException.class,
|
||||
() -> spanData.getEvents().add(EventImpl.create(1234, "foo", Attributes.empty())));
|
||||
() -> spanData.getEvents().add(ImmutableEvent.create(1234, "foo", Attributes.empty())));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -83,13 +83,13 @@ class TestSpanDataTest {
|
|||
|
||||
@Test
|
||||
void timedEvent_defaultTotalAttributeCountIsZero() {
|
||||
EventImpl event = EventImpl.create(START_EPOCH_NANOS, "foo", Attributes.empty());
|
||||
ImmutableEvent event = ImmutableEvent.create(START_EPOCH_NANOS, "foo", Attributes.empty());
|
||||
assertThat(event.getTotalAttributeCount()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void timedEvent_canSetTotalAttributeCount() {
|
||||
EventImpl event = EventImpl.create(START_EPOCH_NANOS, "foo", Attributes.empty(), 123);
|
||||
ImmutableEvent event = ImmutableEvent.create(START_EPOCH_NANOS, "foo", Attributes.empty(), 123);
|
||||
assertThat(event.getTotalAttributeCount()).isEqualTo(123);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue