-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename EventEmitter and related classes to EventLogger (#6316)
- Loading branch information
Showing
23 changed files
with
341 additions
and
338 deletions.
There are no files selected for viewing
42 changes: 0 additions & 42 deletions
42
...ator/src/main/java/io/opentelemetry/api/incubator/events/DefaultEventEmitterProvider.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...bator/src/main/java/io/opentelemetry/api/incubator/events/DefaultEventLoggerProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} | ||
} |
52 changes: 0 additions & 52 deletions
52
api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventEmitter.java
This file was deleted.
Oops, something went wrong.
41 changes: 0 additions & 41 deletions
41
api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventEmitterBuilder.java
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
* | ||
* <p>Example usage emitting events: | ||
* | ||
* <pre>{@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 | ||
* } | ||
* } | ||
* }</pre> | ||
*/ | ||
@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 <a | ||
* href="https://opentelemetry.io/docs/specs/semconv/general/events/">event.name semantic | ||
* conventions</a> 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 <a | ||
* href="https://opentelemetry.io/docs/specs/semconv/general/events/">event.name semantic | ||
* conventions</a> for more details. | ||
* @param attributes attributes associated with the event | ||
*/ | ||
EventBuilder builder(String eventName, Attributes attributes); | ||
} |
41 changes: 41 additions & 0 deletions
41
api/incubator/src/main/java/io/opentelemetry/api/incubator/events/EventLoggerBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
* | ||
* <p>{@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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.