diff --git a/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/DefaultEventEmitterProvider.java b/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/DefaultEventEmitterProvider.java deleted file mode 100644 index e69a9a3745f..00000000000 --- a/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/DefaultEventEmitterProvider.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.api.incubator.events; - -class DefaultEventEmitterProvider implements EventEmitterProvider { - - private static final EventEmitterProvider INSTANCE = new DefaultEventEmitterProvider(); - private static final EventEmitterBuilder NOOP_EVENT_EMITTER_BUILDER = - new NoopEventEmitterBuilder(); - - private DefaultEventEmitterProvider() {} - - static EventEmitterProvider getInstance() { - return INSTANCE; - } - - @Override - public EventEmitterBuilder eventEmitterBuilder(String instrumentationScopeName) { - return NOOP_EVENT_EMITTER_BUILDER; - } - - private static class NoopEventEmitterBuilder implements EventEmitterBuilder { - - @Override - public EventEmitterBuilder setSchemaUrl(String schemaUrl) { - return this; - } - - @Override - public EventEmitterBuilder setInstrumentationVersion(String instrumentationVersion) { - return this; - } - - @Override - public EventEmitter build() { - return DefaultEventEmitter.getInstance(); - } - } -} diff --git a/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/DefaultEventEmitter.java b/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/DefaultEventLogger.java similarity index 81% rename from api/incubator/src/main/java/io/opentelemetry/api/incubator/events/DefaultEventEmitter.java rename to api/incubator/src/main/java/io/opentelemetry/api/incubator/events/DefaultEventLogger.java index 1c914a74d9d..9a9450b009c 100644 --- a/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/DefaultEventEmitter.java +++ b/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/DefaultEventLogger.java @@ -9,13 +9,13 @@ import java.time.Instant; import java.util.concurrent.TimeUnit; -class DefaultEventEmitter implements EventEmitter { +class DefaultEventLogger implements EventLogger { - private static final EventEmitter INSTANCE = new DefaultEventEmitter(); + private static final EventLogger INSTANCE = new DefaultEventLogger(); - private DefaultEventEmitter() {} + private DefaultEventLogger() {} - static EventEmitter getInstance() { + static EventLogger getInstance() { return INSTANCE; } diff --git a/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/DefaultEventLoggerProvider.java b/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/DefaultEventLoggerProvider.java new file mode 100644 index 00000000000..d365e2bbd4d --- /dev/null +++ b/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/DefaultEventLoggerProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.api.incubator.events; + +class DefaultEventLoggerProvider implements EventLoggerProvider { + + private static final EventLoggerProvider INSTANCE = new DefaultEventLoggerProvider(); + private static final EventLoggerBuilder NOOP_EVENT_LOGGER_BUILDER = new NoopEventLoggerBuilder(); + + private DefaultEventLoggerProvider() {} + + static EventLoggerProvider getInstance() { + return INSTANCE; + } + + @Override + public EventLoggerBuilder eventLoggerBuilder(String instrumentationScopeName) { + return NOOP_EVENT_LOGGER_BUILDER; + } + + private static class NoopEventLoggerBuilder implements EventLoggerBuilder { + + @Override + public EventLoggerBuilder setSchemaUrl(String schemaUrl) { + return this; + } + + @Override + public EventLoggerBuilder setInstrumentationVersion(String instrumentationVersion) { + return this; + } + + @Override + public EventLogger build() { + return DefaultEventLogger.getInstance(); + } + } +} diff --git a/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventEmitter.java b/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventEmitter.java deleted file mode 100644 index ba588f7ec79..00000000000 --- a/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventEmitter.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.api.incubator.events; - -import io.opentelemetry.api.common.Attributes; -import javax.annotation.concurrent.ThreadSafe; - -/** - * A {@link EventEmitter} is the entry point into an event pipeline. - * - *

Example usage emitting events: - * - *

{@code
- * class MyClass {
- *   private final EventEmitter eventEmitter = openTelemetryEventEmitterProvider
- *         .eventEmitterBuilder("scope-name")
- *         .build();
- *
- *   void doWork() {
- *     eventEmitter.emit("my-event", Attributes.builder()
- *         .put("key1", "value1")
- *         .put("key2", "value2")
- *         .build())
- *     // do work
- *   }
- * }
- * }
- */ -@ThreadSafe -public interface EventEmitter { - - /** - * Emit an event. - * - * @param eventName the event name, which acts as a classifier for events. Within a particular - * event domain, event name defines a particular class or type of event. - * @param attributes attributes associated with the event - */ - void emit(String eventName, Attributes attributes); - - /** - * Return a {@link EventBuilder} to emit an event. - * - * @param eventName the event name, which acts as a classifier for events. Within a particular - * event domain, event name defines a particular class or type of event. - * @param attributes attributes associated with the event - */ - EventBuilder builder(String eventName, Attributes attributes); -} diff --git a/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventEmitterBuilder.java b/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventEmitterBuilder.java deleted file mode 100644 index 5fa04658652..00000000000 --- a/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventEmitterBuilder.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.api.incubator.events; - -/** - * Builder class for creating {@link EventEmitter} instances. - * - *

{@link EventEmitter}s are identified by their scope name, version, and schema URL. These - * identifying fields, along with attributes, combine to form the instrumentation scope, which is - * attached to all events produced by the {@link EventEmitter}. - */ -public interface EventEmitterBuilder { - - /** - * Set the scope schema URL of the resulting {@link EventEmitter}. Schema URL is part of {@link - * EventEmitter} identity. - * - * @param schemaUrl The schema URL. - * @return this - */ - EventEmitterBuilder setSchemaUrl(String schemaUrl); - - /** - * Sets the instrumentation scope version of the resulting {@link EventEmitter}. Version is part - * of {@link EventEmitter} identity. - * - * @param instrumentationScopeVersion The instrumentation scope version. - * @return this - */ - EventEmitterBuilder setInstrumentationVersion(String instrumentationScopeVersion); - - /** - * Gets or creates a {@link EventEmitter} instance. - * - * @return a {@link EventEmitter} instance configured with the provided options. - */ - EventEmitter build(); -} diff --git a/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventLogger.java b/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventLogger.java new file mode 100644 index 00000000000..785d8e000ca --- /dev/null +++ b/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventLogger.java @@ -0,0 +1,58 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.api.incubator.events; + +import io.opentelemetry.api.common.Attributes; +import javax.annotation.concurrent.ThreadSafe; + +/** + * A {@link EventLogger} is the entry point into an event pipeline. + * + *

Example usage emitting events: + * + *

{@code
+ * class MyClass {
+ *   private final EventLogger eventLogger = eventLoggerProvider
+ *         .eventLoggerBuilder("scope-name")
+ *         .build();
+ *
+ *   void doWork() {
+ *     eventLogger.emit("my-namespace.my-event", Attributes.builder()
+ *         .put("key1", "value1")
+ *         .put("key2", "value2")
+ *         .build())
+ *     // do work
+ *   }
+ * }
+ * }
+ */ +@ThreadSafe +public interface EventLogger { + + /** + * Emit an event. + * + * @param eventName the event name, which identifies the class or type of event. Event with the + * same name are structurally similar to one another. Event names are subject to the same + * naming rules as attribute names. Notably, they are namespaced to avoid collisions. See event.name semantic + * conventions for more details. + * @param attributes attributes associated with the event + */ + void emit(String eventName, Attributes attributes); + + /** + * Return a {@link EventBuilder} to emit an event. + * + * @param eventName the event name, which identifies the class or type of event. Event with the + * same name are structurally similar to one another. Event names are subject to the same + * naming rules as attribute names. Notably, they are namespaced to avoid collisions. See event.name semantic + * conventions for more details. + * @param attributes attributes associated with the event + */ + EventBuilder builder(String eventName, Attributes attributes); +} diff --git a/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventLoggerBuilder.java b/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventLoggerBuilder.java new file mode 100644 index 00000000000..d3105cac6c7 --- /dev/null +++ b/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventLoggerBuilder.java @@ -0,0 +1,41 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.api.incubator.events; + +/** + * Builder class for creating {@link EventLogger} instances. + * + *

{@link EventLogger}s are identified by their scope name, version, and schema URL. These + * identifying fields, along with attributes, combine to form the instrumentation scope, which is + * attached to all events produced by the {@link EventLogger}. + */ +public interface EventLoggerBuilder { + + /** + * Set the scope schema URL of the resulting {@link EventLogger}. Schema URL is part of {@link + * EventLogger} identity. + * + * @param schemaUrl The schema URL. + * @return this + */ + EventLoggerBuilder setSchemaUrl(String schemaUrl); + + /** + * Sets the instrumentation scope version of the resulting {@link EventLogger}. Version is part of + * {@link EventLogger} identity. + * + * @param instrumentationScopeVersion The instrumentation scope version. + * @return this + */ + EventLoggerBuilder setInstrumentationVersion(String instrumentationScopeVersion); + + /** + * Gets or creates a {@link EventLogger} instance. + * + * @return a {@link EventLogger} instance configured with the provided options. + */ + EventLogger build(); +} diff --git a/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventEmitterProvider.java b/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventLoggerProvider.java similarity index 52% rename from api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventEmitterProvider.java rename to api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventLoggerProvider.java index d5eb035e3f8..cfef2a0622d 100644 --- a/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventEmitterProvider.java +++ b/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventLoggerProvider.java @@ -8,39 +8,38 @@ import javax.annotation.concurrent.ThreadSafe; /** - * A registry for creating scoped {@link EventEmitter}s. The name Provider is for consistency + * A registry for creating scoped {@link EventLogger}s. The name Provider is for consistency * with other languages and it is NOT loaded using reflection. * - * @see EventEmitter + * @see EventLogger */ @ThreadSafe -public interface EventEmitterProvider { +public interface EventLoggerProvider { /** - * Gets or creates a named EventEmitter instance which emits events to the {@code eventDomain}. + * Gets or creates a named {@link EventLogger} instance. * * @param instrumentationScopeName A name uniquely identifying the instrumentation scope, such as * the instrumentation library, package, or fully qualified class name. Must not be null. * @return a Logger instance. */ - default EventEmitter get(String instrumentationScopeName) { - return eventEmitterBuilder(instrumentationScopeName).build(); + default EventLogger get(String instrumentationScopeName) { + return eventLoggerBuilder(instrumentationScopeName).build(); } /** - * Creates a LoggerBuilder for a named EventEmitter instance. + * Creates a LoggerBuilder for a named {@link EventLogger} instance. * * @param instrumentationScopeName A name uniquely identifying the instrumentation scope, such as * the instrumentation library, package, or fully qualified class name. Must not be null. * @return a LoggerBuilder instance. */ - EventEmitterBuilder eventEmitterBuilder(String instrumentationScopeName); + EventLoggerBuilder eventLoggerBuilder(String instrumentationScopeName); /** - * Returns a no-op {@link EventEmitterProvider} which provides Loggers which do not record or - * emit. + * Returns a no-op {@link EventLoggerProvider} which provides Loggers which do not record or emit. */ - static EventEmitterProvider noop() { - return DefaultEventEmitterProvider.getInstance(); + static EventLoggerProvider noop() { + return DefaultEventLoggerProvider.getInstance(); } } diff --git a/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/GlobalEventEmitterProvider.java b/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/GlobalEventEmitterProvider.java deleted file mode 100644 index bf0e8353d52..00000000000 --- a/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/GlobalEventEmitterProvider.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.api.incubator.events; - -import io.opentelemetry.api.GlobalOpenTelemetry; -import java.util.concurrent.atomic.AtomicReference; -import javax.annotation.Nullable; - -/** - * This class provides a temporary global accessor for {@link EventEmitterProvider} until the event - * API is marked stable. It will eventually be merged into {@link GlobalOpenTelemetry}. - */ -// We intentionally assign to be used for error reporting. -@SuppressWarnings("StaticAssignmentOfThrowable") -public final class GlobalEventEmitterProvider { - - private static final AtomicReference instance = - new AtomicReference<>(EventEmitterProvider.noop()); - - @SuppressWarnings("NonFinalStaticField") - @Nullable - private static volatile Throwable setInstanceCaller; - - private GlobalEventEmitterProvider() {} - - /** Returns the globally registered {@link EventEmitterProvider}. */ - // instance cannot be set to null - @SuppressWarnings("NullAway") - public static EventEmitterProvider get() { - return instance.get(); - } - - /** - * Sets the global {@link EventEmitterProvider}. Future calls to {@link #get()} will return the - * provided {@link EventEmitterProvider} instance. This should be called once as early as possible - * in your application initialization logic. - */ - public static void set(EventEmitterProvider eventEmitterProvider) { - boolean changed = instance.compareAndSet(EventEmitterProvider.noop(), eventEmitterProvider); - if (!changed && (eventEmitterProvider != EventEmitterProvider.noop())) { - throw new IllegalStateException( - "GlobalEventEmitterProvider.set has already been called. GlobalEventEmitterProvider.set " - + "must be called only once before any calls to GlobalEventEmitterProvider.get. " - + "Previous invocation set to cause of this exception.", - setInstanceCaller); - } - setInstanceCaller = new Throwable(); - } - - /** - * Unsets the global {@link EventEmitterProvider}. This is only meant to be used from tests which - * need to reconfigure {@link EventEmitterProvider}. - */ - public static void resetForTest() { - instance.set(EventEmitterProvider.noop()); - } -} diff --git a/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/GlobalEventLoggerProvider.java b/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/GlobalEventLoggerProvider.java new file mode 100644 index 00000000000..68664f08b56 --- /dev/null +++ b/api/incubator/src/main/java/io/opentelemetry/api/incubator/events/GlobalEventLoggerProvider.java @@ -0,0 +1,60 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.api.incubator.events; + +import io.opentelemetry.api.GlobalOpenTelemetry; +import java.util.concurrent.atomic.AtomicReference; +import javax.annotation.Nullable; + +/** + * This class provides a temporary global accessor for {@link EventLoggerProvider} until the event + * API is marked stable. It will eventually be merged into {@link GlobalOpenTelemetry}. + */ +// We intentionally assign to be used for error reporting. +@SuppressWarnings("StaticAssignmentOfThrowable") +public final class GlobalEventLoggerProvider { + + private static final AtomicReference instance = + new AtomicReference<>(EventLoggerProvider.noop()); + + @SuppressWarnings("NonFinalStaticField") + @Nullable + private static volatile Throwable setInstanceCaller; + + private GlobalEventLoggerProvider() {} + + /** Returns the globally registered {@link EventLoggerProvider}. */ + // instance cannot be set to null + @SuppressWarnings("NullAway") + public static EventLoggerProvider get() { + return instance.get(); + } + + /** + * Sets the global {@link EventLoggerProvider}. Future calls to {@link #get()} will return the + * provided {@link EventLoggerProvider} instance. This should be called once as early as possible + * in your application initialization logic. + */ + public static void set(EventLoggerProvider eventLoggerProvider) { + boolean changed = instance.compareAndSet(EventLoggerProvider.noop(), eventLoggerProvider); + if (!changed && (eventLoggerProvider != EventLoggerProvider.noop())) { + throw new IllegalStateException( + "GlobalEventLoggerProvider.set has already been called. GlobalEventLoggerProvider.set " + + "must be called only once before any calls to GlobalEventLoggerProvider.get. " + + "Previous invocation set to cause of this exception.", + setInstanceCaller); + } + setInstanceCaller = new Throwable(); + } + + /** + * Unsets the global {@link EventLoggerProvider}. This is only meant to be used from tests which + * need to reconfigure {@link EventLoggerProvider}. + */ + public static void resetForTest() { + instance.set(EventLoggerProvider.noop()); + } +} diff --git a/api/incubator/src/test/java/io/opentelemetry/api/incubator/events/DefaultEventEmitterProviderTest.java b/api/incubator/src/test/java/io/opentelemetry/api/incubator/events/DefaultEventLoggerProviderTest.java similarity index 71% rename from api/incubator/src/test/java/io/opentelemetry/api/incubator/events/DefaultEventEmitterProviderTest.java rename to api/incubator/src/test/java/io/opentelemetry/api/incubator/events/DefaultEventLoggerProviderTest.java index 52e23c5b44d..431130045cc 100644 --- a/api/incubator/src/test/java/io/opentelemetry/api/incubator/events/DefaultEventEmitterProviderTest.java +++ b/api/incubator/src/test/java/io/opentelemetry/api/incubator/events/DefaultEventLoggerProviderTest.java @@ -11,18 +11,18 @@ import io.opentelemetry.api.common.Attributes; import org.junit.jupiter.api.Test; -class DefaultEventEmitterProviderTest { +class DefaultEventLoggerProviderTest { @Test - void noopEventEmitterProvider_doesNotThrow() { - EventEmitterProvider provider = EventEmitterProvider.noop(); + void noopEventLoggerProvider_doesNotThrow() { + EventLoggerProvider provider = EventLoggerProvider.noop(); - assertThat(provider).isSameAs(DefaultEventEmitterProvider.getInstance()); + assertThat(provider).isSameAs(DefaultEventLoggerProvider.getInstance()); assertThatCode(() -> provider.get("scope-name")).doesNotThrowAnyException(); assertThatCode( () -> provider - .eventEmitterBuilder("scope-name") + .eventLoggerBuilder("scope-name") .setInstrumentationVersion("1.0") .setSchemaUrl("http://schema.com") .build()) @@ -31,7 +31,7 @@ void noopEventEmitterProvider_doesNotThrow() { assertThatCode( () -> provider - .eventEmitterBuilder("scope-name") + .eventLoggerBuilder("scope-name") .build() .emit("event-name", Attributes.empty())) .doesNotThrowAnyException(); diff --git a/api/incubator/src/test/java/io/opentelemetry/api/incubator/events/DefaultEventEmitterTest.java b/api/incubator/src/test/java/io/opentelemetry/api/incubator/events/DefaultEventLoggerTest.java similarity index 79% rename from api/incubator/src/test/java/io/opentelemetry/api/incubator/events/DefaultEventEmitterTest.java rename to api/incubator/src/test/java/io/opentelemetry/api/incubator/events/DefaultEventLoggerTest.java index a8d70533f47..9d14ef63c48 100644 --- a/api/incubator/src/test/java/io/opentelemetry/api/incubator/events/DefaultEventEmitterTest.java +++ b/api/incubator/src/test/java/io/opentelemetry/api/incubator/events/DefaultEventLoggerTest.java @@ -12,15 +12,15 @@ import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.Test; -class DefaultEventEmitterTest { +class DefaultEventLoggerTest { @Test void emit() { - assertThatCode(() -> DefaultEventEmitter.getInstance().emit("event-name", Attributes.empty())) + assertThatCode(() -> DefaultEventLogger.getInstance().emit("event-name", Attributes.empty())) .doesNotThrowAnyException(); assertThatCode( () -> - DefaultEventEmitter.getInstance() + DefaultEventLogger.getInstance() .emit( "event-domain.event-name", Attributes.builder().put("key1", "value1").build())) @@ -30,10 +30,10 @@ void emit() { @Test void builder() { Attributes attributes = Attributes.builder().put("key1", "value1").build(); - EventEmitter emitter = DefaultEventEmitter.getInstance(); + EventLogger eventLogger = DefaultEventLogger.getInstance(); assertThatCode( () -> - emitter + eventLogger .builder("com.example.MyEvent", attributes) .setTimestamp(123456L, TimeUnit.NANOSECONDS) .setTimestamp(Instant.now()) diff --git a/api/incubator/src/test/java/io/opentelemetry/api/incubator/events/GlobalEventEmitterProviderTest.java b/api/incubator/src/test/java/io/opentelemetry/api/incubator/events/GlobalEventEmitterProviderTest.java deleted file mode 100644 index 8f48c17bc5b..00000000000 --- a/api/incubator/src/test/java/io/opentelemetry/api/incubator/events/GlobalEventEmitterProviderTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.api.incubator.events; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -class GlobalEventEmitterProviderTest { - - @BeforeAll - static void beforeClass() { - GlobalEventEmitterProvider.resetForTest(); - } - - @AfterEach - void after() { - GlobalEventEmitterProvider.resetForTest(); - } - - @Test - void setAndGet() { - assertThat(GlobalEventEmitterProvider.get()).isEqualTo(EventEmitterProvider.noop()); - EventEmitterProvider eventEmitterProvider = - instrumentationScopeName -> - EventEmitterProvider.noop().eventEmitterBuilder(instrumentationScopeName); - GlobalEventEmitterProvider.set(eventEmitterProvider); - assertThat(GlobalEventEmitterProvider.get()).isEqualTo(eventEmitterProvider); - } - - @Test - void setThenSet() { - GlobalEventEmitterProvider.set( - instrumentationScopeName -> - EventEmitterProvider.noop().eventEmitterBuilder(instrumentationScopeName)); - assertThatThrownBy( - () -> - GlobalEventEmitterProvider.set( - instrumentationScopeName -> - EventEmitterProvider.noop().eventEmitterBuilder(instrumentationScopeName))) - .isInstanceOf(IllegalStateException.class) - .hasMessageContaining("GlobalEventEmitterProvider.set has already been called") - .hasStackTraceContaining("setThenSet"); - } -} diff --git a/api/incubator/src/test/java/io/opentelemetry/api/incubator/events/GlobalEventLoggerProviderTest.java b/api/incubator/src/test/java/io/opentelemetry/api/incubator/events/GlobalEventLoggerProviderTest.java new file mode 100644 index 00000000000..d3392d59838 --- /dev/null +++ b/api/incubator/src/test/java/io/opentelemetry/api/incubator/events/GlobalEventLoggerProviderTest.java @@ -0,0 +1,51 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.api.incubator.events; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +class GlobalEventLoggerProviderTest { + + @BeforeAll + static void beforeClass() { + GlobalEventLoggerProvider.resetForTest(); + } + + @AfterEach + void after() { + GlobalEventLoggerProvider.resetForTest(); + } + + @Test + void setAndGet() { + assertThat(GlobalEventLoggerProvider.get()).isEqualTo(EventLoggerProvider.noop()); + EventLoggerProvider eventLoggerProvider = + instrumentationScopeName -> + EventLoggerProvider.noop().eventLoggerBuilder(instrumentationScopeName); + GlobalEventLoggerProvider.set(eventLoggerProvider); + assertThat(GlobalEventLoggerProvider.get()).isEqualTo(eventLoggerProvider); + } + + @Test + void setThenSet() { + GlobalEventLoggerProvider.set( + instrumentationScopeName -> + EventLoggerProvider.noop().eventLoggerBuilder(instrumentationScopeName)); + assertThatThrownBy( + () -> + GlobalEventLoggerProvider.set( + instrumentationScopeName -> + EventLoggerProvider.noop().eventLoggerBuilder(instrumentationScopeName))) + .isInstanceOf(IllegalStateException.class) + .hasMessageContaining("GlobalEventLoggerProvider.set has already been called") + .hasStackTraceContaining("setThenSet"); + } +} diff --git a/integration-tests/otlp/src/main/java/io/opentelemetry/integrationtest/OtlpExporterIntegrationTest.java b/integration-tests/otlp/src/main/java/io/opentelemetry/integrationtest/OtlpExporterIntegrationTest.java index 544b9a94794..810b51f5131 100644 --- a/integration-tests/otlp/src/main/java/io/opentelemetry/integrationtest/OtlpExporterIntegrationTest.java +++ b/integration-tests/otlp/src/main/java/io/opentelemetry/integrationtest/OtlpExporterIntegrationTest.java @@ -21,7 +21,7 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.Attributes; -import io.opentelemetry.api.incubator.events.EventEmitter; +import io.opentelemetry.api.incubator.events.EventLogger; import io.opentelemetry.api.incubator.logs.ExtendedLogRecordBuilder; import io.opentelemetry.api.incubator.logs.KeyAnyValue; import io.opentelemetry.api.logs.Logger; @@ -66,7 +66,7 @@ import io.opentelemetry.sdk.logs.SdkLoggerProvider; import io.opentelemetry.sdk.logs.export.BatchLogRecordProcessor; import io.opentelemetry.sdk.logs.export.LogRecordExporter; -import io.opentelemetry.sdk.logs.internal.SdkEventEmitterProvider; +import io.opentelemetry.sdk.logs.internal.SdkEventLoggerProvider; import io.opentelemetry.sdk.metrics.SdkMeterProvider; import io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder; import io.opentelemetry.sdk.metrics.export.MetricExporter; @@ -533,9 +533,9 @@ private static void testLogRecordExporter(LogRecordExporter logRecordExporter) { .build(); Logger logger = loggerProvider.get(OtlpExporterIntegrationTest.class.getName()); - EventEmitter eventEmitter = - SdkEventEmitterProvider.create(loggerProvider) - .eventEmitterBuilder(OtlpExporterIntegrationTest.class.getName()) + EventLogger eventLogger = + SdkEventLoggerProvider.create(loggerProvider) + .eventLoggerBuilder(OtlpExporterIntegrationTest.class.getName()) .build(); SpanContext spanContext = @@ -568,7 +568,7 @@ private static void testLogRecordExporter(LogRecordExporter logRecordExporter) { .setSeverityText("DEBUG") .setContext(Context.current()) .emit(); - eventEmitter.emit("event-name", Attributes.builder().put("key", "value").build()); + eventLogger.emit("event-name", Attributes.builder().put("key", "value").build()); } // Closing triggers flush of processor @@ -706,7 +706,7 @@ private static void testLogRecordExporter(LogRecordExporter logRecordExporter) { .isEqualTo(spanContext.getTraceFlags()); assertThat(protoLog1.getTimeUnixNano()).isEqualTo(100); - // LogRecord via EventEmitter.emit(String, Attributes) + // LogRecord via EventLogger.emit(String, Attributes) io.opentelemetry.proto.logs.v1.LogRecord protoLog2 = ilLogs.getLogRecords(1); assertThat(protoLog2.getBody().getStringValue()).isEmpty(); assertThat(protoLog2.getAttributesList()) diff --git a/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/AutoConfiguredOpenTelemetrySdkBuilder.java b/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/AutoConfiguredOpenTelemetrySdkBuilder.java index 08bb093939e..3e9a315a737 100644 --- a/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/AutoConfiguredOpenTelemetrySdkBuilder.java +++ b/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/AutoConfiguredOpenTelemetrySdkBuilder.java @@ -8,7 +8,7 @@ import static java.util.Objects.requireNonNull; import io.opentelemetry.api.GlobalOpenTelemetry; -import io.opentelemetry.api.incubator.events.GlobalEventEmitterProvider; +import io.opentelemetry.api.incubator.events.GlobalEventLoggerProvider; import io.opentelemetry.context.propagation.ContextPropagators; import io.opentelemetry.context.propagation.TextMapPropagator; import io.opentelemetry.sdk.OpenTelemetrySdk; @@ -25,7 +25,7 @@ import io.opentelemetry.sdk.logs.SdkLoggerProvider; import io.opentelemetry.sdk.logs.SdkLoggerProviderBuilder; import io.opentelemetry.sdk.logs.export.LogRecordExporter; -import io.opentelemetry.sdk.logs.internal.SdkEventEmitterProvider; +import io.opentelemetry.sdk.logs.internal.SdkEventLoggerProvider; import io.opentelemetry.sdk.metrics.SdkMeterProvider; import io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder; import io.opentelemetry.sdk.metrics.export.MetricExporter; @@ -571,8 +571,8 @@ private void maybeSetAsGlobal(OpenTelemetrySdk openTelemetrySdk) { return; } GlobalOpenTelemetry.set(openTelemetrySdk); - GlobalEventEmitterProvider.set( - SdkEventEmitterProvider.create(openTelemetrySdk.getSdkLoggerProvider())); + GlobalEventLoggerProvider.set( + SdkEventLoggerProvider.create(openTelemetrySdk.getSdkLoggerProvider())); logger.log( Level.FINE, "Global OpenTelemetry set to {0} by autoconfiguration", openTelemetrySdk); } diff --git a/sdk-extensions/autoconfigure/src/test/java/io/opentelemetry/sdk/autoconfigure/AutoConfiguredOpenTelemetrySdkTest.java b/sdk-extensions/autoconfigure/src/test/java/io/opentelemetry/sdk/autoconfigure/AutoConfiguredOpenTelemetrySdkTest.java index 57b8eb011fb..37cafb9bdfa 100644 --- a/sdk-extensions/autoconfigure/src/test/java/io/opentelemetry/sdk/autoconfigure/AutoConfiguredOpenTelemetrySdkTest.java +++ b/sdk-extensions/autoconfigure/src/test/java/io/opentelemetry/sdk/autoconfigure/AutoConfiguredOpenTelemetrySdkTest.java @@ -26,7 +26,7 @@ import io.github.netmikey.logunit.api.LogCapturer; import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.api.OpenTelemetry; -import io.opentelemetry.api.incubator.events.GlobalEventEmitterProvider; +import io.opentelemetry.api.incubator.events.GlobalEventLoggerProvider; import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.SpanId; import io.opentelemetry.api.trace.TraceId; @@ -49,7 +49,7 @@ import io.opentelemetry.sdk.logs.LogRecordProcessor; import io.opentelemetry.sdk.logs.SdkLoggerProvider; import io.opentelemetry.sdk.logs.SdkLoggerProviderBuilder; -import io.opentelemetry.sdk.logs.internal.SdkEventEmitterProvider; +import io.opentelemetry.sdk.logs.internal.SdkEventLoggerProvider; import io.opentelemetry.sdk.metrics.SdkMeterProvider; import io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder; import io.opentelemetry.sdk.metrics.export.MetricReader; @@ -156,7 +156,7 @@ public SdkLoggerProviderBuilder apply( @BeforeEach void resetGlobal() { GlobalOpenTelemetry.resetForTest(); - GlobalEventEmitterProvider.resetForTest(); + GlobalEventLoggerProvider.resetForTest(); builder = AutoConfiguredOpenTelemetrySdk.builder() .addPropertiesSupplier(disableExportPropertySupplier()); @@ -456,7 +456,7 @@ void builder_setResultAsGlobalFalse() { OpenTelemetrySdk openTelemetry = builder.build().getOpenTelemetrySdk(); assertThat(GlobalOpenTelemetry.get()).extracting("delegate").isNotSameAs(openTelemetry); - assertThat(GlobalEventEmitterProvider.get()).isNotSameAs(openTelemetry.getSdkLoggerProvider()); + assertThat(GlobalEventLoggerProvider.get()).isNotSameAs(openTelemetry.getSdkLoggerProvider()); } @Test @@ -464,8 +464,8 @@ void builder_setResultAsGlobalTrue() { OpenTelemetrySdk openTelemetry = builder.setResultAsGlobal().build().getOpenTelemetrySdk(); assertThat(GlobalOpenTelemetry.get()).extracting("delegate").isSameAs(openTelemetry); - assertThat(GlobalEventEmitterProvider.get()) - .isInstanceOf(SdkEventEmitterProvider.class) + assertThat(GlobalEventLoggerProvider.get()) + .isInstanceOf(SdkEventLoggerProvider.class) .extracting("delegateLoggerProvider") .isSameAs(openTelemetry.getSdkLoggerProvider()); } diff --git a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/AutoConfiguredOpenTelemetrySdkTest.java b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/AutoConfiguredOpenTelemetrySdkTest.java index 2c85ae02507..4fc7dce0c35 100644 --- a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/AutoConfiguredOpenTelemetrySdkTest.java +++ b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/AutoConfiguredOpenTelemetrySdkTest.java @@ -13,7 +13,7 @@ import io.github.netmikey.logunit.api.LogCapturer; import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.api.OpenTelemetry; -import io.opentelemetry.api.incubator.events.GlobalEventEmitterProvider; +import io.opentelemetry.api.incubator.events.GlobalEventLoggerProvider; import io.opentelemetry.exporter.prometheus.PrometheusHttpServer; import io.opentelemetry.sdk.OpenTelemetrySdk; import java.lang.reflect.Field; @@ -32,7 +32,7 @@ class AutoConfiguredOpenTelemetrySdkTest { @BeforeEach void setUp() { GlobalOpenTelemetry.resetForTest(); - GlobalEventEmitterProvider.resetForTest(); + GlobalEventLoggerProvider.resetForTest(); } @SuppressWarnings("ResultOfMethodCallIgnored") diff --git a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/FileConfigurationTest.java b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/FileConfigurationTest.java index 058b6ed91d3..7ce59ad321a 100644 --- a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/FileConfigurationTest.java +++ b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/FileConfigurationTest.java @@ -19,7 +19,7 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.api.baggage.propagation.W3CBaggagePropagator; -import io.opentelemetry.api.incubator.events.GlobalEventEmitterProvider; +import io.opentelemetry.api.incubator.events.GlobalEventLoggerProvider; import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator; import io.opentelemetry.context.propagation.ContextPropagators; import io.opentelemetry.context.propagation.TextMapPropagator; @@ -29,7 +29,7 @@ import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException; import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties; -import io.opentelemetry.sdk.logs.internal.SdkEventEmitterProvider; +import io.opentelemetry.sdk.logs.internal.SdkEventLoggerProvider; import io.opentelemetry.sdk.resources.Resource; import io.opentelemetry.sdk.trace.SdkTracerProvider; import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor; @@ -71,7 +71,7 @@ void setup() throws IOException { configFilePath = tempDir.resolve("otel-config.yaml"); Files.write(configFilePath, yaml.getBytes(StandardCharsets.UTF_8)); GlobalOpenTelemetry.resetForTest(); - GlobalEventEmitterProvider.resetForTest(); + GlobalEventLoggerProvider.resetForTest(); } @Test @@ -139,7 +139,7 @@ void configFile_setResultAsGlobalFalse() { cleanup.addCloseable(openTelemetrySdk); assertThat(GlobalOpenTelemetry.get()).extracting("delegate").isNotSameAs(openTelemetrySdk); - assertThat(GlobalEventEmitterProvider.get()) + assertThat(GlobalEventLoggerProvider.get()) .isNotSameAs(openTelemetrySdk.getSdkLoggerProvider()); } @@ -155,8 +155,8 @@ void configFile_setResultAsGlobalTrue() { cleanup.addCloseable(openTelemetrySdk); assertThat(GlobalOpenTelemetry.get()).extracting("delegate").isSameAs(openTelemetrySdk); - assertThat(GlobalEventEmitterProvider.get()) - .isInstanceOf(SdkEventEmitterProvider.class) + assertThat(GlobalEventLoggerProvider.get()) + .isInstanceOf(SdkEventLoggerProvider.class) .extracting("delegateLoggerProvider") .isSameAs(openTelemetrySdk.getSdkLoggerProvider()); } diff --git a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/FullConfigTest.java b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/FullConfigTest.java index a5c5fc2fe24..2097af7945c 100644 --- a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/FullConfigTest.java +++ b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/FullConfigTest.java @@ -18,8 +18,8 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.api.baggage.propagation.W3CBaggagePropagator; import io.opentelemetry.api.common.Attributes; -import io.opentelemetry.api.incubator.events.EventEmitter; -import io.opentelemetry.api.incubator.events.GlobalEventEmitterProvider; +import io.opentelemetry.api.incubator.events.EventLogger; +import io.opentelemetry.api.incubator.events.GlobalEventLoggerProvider; import io.opentelemetry.api.logs.Logger; import io.opentelemetry.api.logs.Severity; import io.opentelemetry.api.metrics.Meter; @@ -159,7 +159,7 @@ void setUp() { // Initialize here so we can shutdown when done GlobalOpenTelemetry.resetForTest(); - GlobalEventEmitterProvider.resetForTest(); + GlobalEventLoggerProvider.resetForTest(); openTelemetrySdk = AutoConfiguredOpenTelemetrySdk.initialize().getOpenTelemetrySdk(); } @@ -167,7 +167,7 @@ void setUp() { void afterEach() { openTelemetrySdk.close(); GlobalOpenTelemetry.resetForTest(); - GlobalEventEmitterProvider.resetForTest(); + GlobalEventLoggerProvider.resetForTest(); } @Test @@ -206,9 +206,8 @@ void configures() throws Exception { logger.logRecordBuilder().setBody("debug log message").setSeverity(Severity.DEBUG).emit(); logger.logRecordBuilder().setBody("info log message").setSeverity(Severity.INFO).emit(); - EventEmitter eventEmitter = - GlobalEventEmitterProvider.get().eventEmitterBuilder("test").build(); - eventEmitter.emit("test-name", Attributes.builder().put("cow", "moo").build()); + EventLogger eventLogger = GlobalEventLoggerProvider.get().eventLoggerBuilder("test").build(); + eventLogger.emit("test-name", Attributes.builder().put("cow", "moo").build()); openTelemetrySdk.getSdkTracerProvider().forceFlush().join(10, TimeUnit.SECONDS); openTelemetrySdk.getSdkLoggerProvider().forceFlush().join(10, TimeUnit.SECONDS); diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/internal/SdkEventBuilder.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/internal/SdkEventBuilder.java index d817edad529..ce4f5d69623 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/internal/SdkEventBuilder.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/internal/SdkEventBuilder.java @@ -33,7 +33,7 @@ public EventBuilder setTimestamp(Instant instant) { @Override public void emit() { - SdkEventEmitterProvider.addEventName(logRecordBuilder, eventName); + SdkEventLoggerProvider.addEventName(logRecordBuilder, eventName); logRecordBuilder.emit(); } } diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/internal/SdkEventEmitterProvider.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/internal/SdkEventLoggerProvider.java similarity index 58% rename from sdk/logs/src/main/java/io/opentelemetry/sdk/logs/internal/SdkEventEmitterProvider.java rename to sdk/logs/src/main/java/io/opentelemetry/sdk/logs/internal/SdkEventLoggerProvider.java index 0fdaa6f05ad..3eb6bb708ab 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/internal/SdkEventEmitterProvider.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/internal/SdkEventLoggerProvider.java @@ -8,9 +8,9 @@ import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.incubator.events.EventBuilder; -import io.opentelemetry.api.incubator.events.EventEmitter; -import io.opentelemetry.api.incubator.events.EventEmitterBuilder; -import io.opentelemetry.api.incubator.events.EventEmitterProvider; +import io.opentelemetry.api.incubator.events.EventLogger; +import io.opentelemetry.api.incubator.events.EventLoggerBuilder; +import io.opentelemetry.api.incubator.events.EventLoggerProvider; import io.opentelemetry.api.logs.LogRecordBuilder; import io.opentelemetry.api.logs.Logger; import io.opentelemetry.api.logs.LoggerBuilder; @@ -19,82 +19,82 @@ import java.util.concurrent.TimeUnit; /** - * SDK implementation for {@link EventEmitterProvider}. + * SDK implementation for {@link EventLoggerProvider}. * *

Delegates all calls to the configured {@link LoggerProvider}, and its {@link LoggerBuilder}s, * {@link Logger}s. */ -public final class SdkEventEmitterProvider implements EventEmitterProvider { +public final class SdkEventLoggerProvider implements EventLoggerProvider { static final AttributeKey EVENT_NAME = AttributeKey.stringKey("event.name"); private final LoggerProvider delegateLoggerProvider; private final Clock clock; - private SdkEventEmitterProvider(LoggerProvider delegateLoggerProvider, Clock clock) { + private SdkEventLoggerProvider(LoggerProvider delegateLoggerProvider, Clock clock) { this.delegateLoggerProvider = delegateLoggerProvider; this.clock = clock; } /** - * Create a {@link SdkEventEmitterProvider} which delegates to the {@code delegateLoggerProvider}. + * Create a {@link SdkEventLoggerProvider} which delegates to the {@code delegateLoggerProvider}. */ - public static SdkEventEmitterProvider create(LoggerProvider delegateLoggerProvider) { - return new SdkEventEmitterProvider(delegateLoggerProvider, Clock.getDefault()); + public static SdkEventLoggerProvider create(LoggerProvider delegateLoggerProvider) { + return new SdkEventLoggerProvider(delegateLoggerProvider, Clock.getDefault()); } /** - * Create a {@link SdkEventEmitterProvider} which delegates to the {@code delegateLoggerProvider}. + * Create a {@link SdkEventLoggerProvider} which delegates to the {@code delegateLoggerProvider}. */ - public static SdkEventEmitterProvider create(LoggerProvider delegateLoggerProvider, Clock clock) { - return new SdkEventEmitterProvider(delegateLoggerProvider, clock); + public static SdkEventLoggerProvider create(LoggerProvider delegateLoggerProvider, Clock clock) { + return new SdkEventLoggerProvider(delegateLoggerProvider, clock); } @Override - public EventEmitter get(String instrumentationScopeName) { - return eventEmitterBuilder(instrumentationScopeName).build(); + public EventLogger get(String instrumentationScopeName) { + return eventLoggerBuilder(instrumentationScopeName).build(); } @Override - public EventEmitterBuilder eventEmitterBuilder(String instrumentationScopeName) { - return new SdkEventEmitterBuilder( + public EventLoggerBuilder eventLoggerBuilder(String instrumentationScopeName) { + return new SdkEventLoggerBuilder( clock, delegateLoggerProvider.loggerBuilder(instrumentationScopeName)); } - private static class SdkEventEmitterBuilder implements EventEmitterBuilder { + private static class SdkEventLoggerBuilder implements EventLoggerBuilder { private final Clock clock; private final LoggerBuilder delegateLoggerBuilder; - private SdkEventEmitterBuilder(Clock clock, LoggerBuilder delegateLoggerBuilder) { + private SdkEventLoggerBuilder(Clock clock, LoggerBuilder delegateLoggerBuilder) { this.clock = clock; this.delegateLoggerBuilder = delegateLoggerBuilder; } @Override - public EventEmitterBuilder setSchemaUrl(String schemaUrl) { + public EventLoggerBuilder setSchemaUrl(String schemaUrl) { delegateLoggerBuilder.setSchemaUrl(schemaUrl); return this; } @Override - public EventEmitterBuilder setInstrumentationVersion(String instrumentationScopeVersion) { + public EventLoggerBuilder setInstrumentationVersion(String instrumentationScopeVersion) { delegateLoggerBuilder.setInstrumentationVersion(instrumentationScopeVersion); return this; } @Override - public EventEmitter build() { - return new SdkEventEmitter(clock, delegateLoggerBuilder.build()); + public EventLogger build() { + return new SdkEventLogger(clock, delegateLoggerBuilder.build()); } } - private static class SdkEventEmitter implements EventEmitter { + private static class SdkEventLogger implements EventLogger { private final Clock clock; private final Logger delegateLogger; - private SdkEventEmitter(Clock clock, Logger delegateLogger) { + private SdkEventLogger(Clock clock, Logger delegateLogger) { this.clock = clock; this.delegateLogger = delegateLogger; } diff --git a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/internal/SdkEventEmitterProviderTest.java b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/internal/SdkEventLoggerProviderTest.java similarity index 84% rename from sdk/logs/src/test/java/io/opentelemetry/sdk/logs/internal/SdkEventEmitterProviderTest.java rename to sdk/logs/src/test/java/io/opentelemetry/sdk/logs/internal/SdkEventLoggerProviderTest.java index 73db07cce57..847d3142e40 100644 --- a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/internal/SdkEventEmitterProviderTest.java +++ b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/internal/SdkEventLoggerProviderTest.java @@ -11,7 +11,7 @@ import static org.mockito.Mockito.when; import io.opentelemetry.api.common.Attributes; -import io.opentelemetry.api.incubator.events.EventEmitter; +import io.opentelemetry.api.incubator.events.EventLogger; import io.opentelemetry.sdk.common.Clock; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; import io.opentelemetry.sdk.logs.ReadWriteLogRecord; @@ -21,15 +21,15 @@ import java.util.concurrent.atomic.AtomicReference; import org.junit.jupiter.api.Test; -class SdkEventEmitterProviderTest { +class SdkEventLoggerProviderTest { private static final Resource RESOURCE = Resource.builder().put("resource-key", "resource-value").build(); private final Clock clock = mock(Clock.class); private final AtomicReference seenLog = new AtomicReference<>(); - private final SdkEventEmitterProvider eventEmitterProvider = - SdkEventEmitterProvider.create( + private final SdkEventLoggerProvider eventLoggerProvider = + SdkEventLoggerProvider.create( SdkLoggerProvider.builder() .setResource(RESOURCE) .addLogRecordProcessor((context, logRecord) -> seenLog.set(logRecord)) @@ -40,8 +40,8 @@ class SdkEventEmitterProviderTest { void emit() { when(clock.now()).thenReturn(10L); - eventEmitterProvider - .eventEmitterBuilder("test-scope") + eventLoggerProvider + .eventLoggerBuilder("test-scope") .build() .emit( "event-name", @@ -64,9 +64,9 @@ void builder() { long yesterday = System.nanoTime() - TimeUnit.DAYS.toNanos(1); Attributes attributes = Attributes.of(stringKey("foo"), "bar"); - EventEmitter emitter = eventEmitterProvider.eventEmitterBuilder("test-scope").build(); + EventLogger eventLogger = eventLoggerProvider.eventLoggerBuilder("test-scope").build(); - emitter.builder("testing", attributes).setTimestamp(yesterday, TimeUnit.NANOSECONDS).emit(); + eventLogger.builder("testing", attributes).setTimestamp(yesterday, TimeUnit.NANOSECONDS).emit(); verifySeen(yesterday, attributes); }