-
Notifications
You must be signed in to change notification settings - Fork 966
Refactor Log SDK to implement OTEP-0150 #3759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
41ee190
Add log processors to the builder so LogSinkSdkProvider is immutable
jack-berg b4950f6
Add api diff
jack-berg 8f66d07
Rename to SdkLogSinkProvider
jack-berg baa8013
Rework log sdk
jack-berg 7c60e38
Refactor logging sdk to implement OTEP-0150
jack-berg 66a0f3b
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
jack-berg d7208c3
Fix typo
jack-berg 95274e7
Add unit tests
jack-berg 56072d2
Reorganize to facilitate potential future API
jack-berg 291254e
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
jack-berg 52aa806
Rename ReadableLog* to SdkLog*, make SdkLog* package private
jack-berg 21a98e3
Add LogEmitterProvider interface, tidy up some javadoc
jack-berg f9e31ac
Respond to PR feedback
jack-berg 8d4785c
Make SdkLogEmitterBuilder final
jack-berg ca91bec
Switch to LogEmitter.logBuilder().emit() pattern
jack-berg a80ddb8
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
jack-berg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 6 additions & 1 deletion
7
docs/apidiffs/current_vs_latest/opentelemetry-exporter-logging-otlp.txt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,2 +1,7 @@ | ||
| Comparing source compatibility of against | ||
| No changes. | ||
| +++ NEW CLASS: PUBLIC(+) FINAL(+) io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingLogExporter (not serializable) | ||
| +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
| +++ NEW SUPERCLASS: java.lang.Object | ||
| +++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.logs.export.LogExporter create() | ||
| +++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.common.CompletableResultCode export(java.util.Collection) | ||
| +++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.common.CompletableResultCode shutdown() |
This file contains hidden or 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
This file contains hidden or 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
73 changes: 0 additions & 73 deletions
73
sdk/logs/src/main/java/io/opentelemetry/sdk/logs/LogSinkSdkProvider.java
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
45 changes: 45 additions & 0 deletions
45
sdk/logs/src/main/java/io/opentelemetry/sdk/logs/LogSinkSharedState.java
This file contains hidden or 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,45 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.sdk.logs; | ||
|
|
||
| import io.opentelemetry.sdk.common.CompletableResultCode; | ||
| import io.opentelemetry.sdk.resources.Resource; | ||
| import java.util.List; | ||
| import javax.annotation.Nullable; | ||
|
|
||
| final class LogSinkSharedState { | ||
| private final Object lock = new Object(); | ||
| private final Resource resource; | ||
| private final LogProcessor activeLogProcessor; | ||
| @Nullable private volatile CompletableResultCode shutdownResult = null; | ||
|
|
||
| LogSinkSharedState(Resource resource, List<LogProcessor> logProcessors) { | ||
| this.resource = resource; | ||
| this.activeLogProcessor = LogProcessor.composite(logProcessors); | ||
| } | ||
|
|
||
| Resource getResource() { | ||
| return resource; | ||
| } | ||
|
|
||
| LogProcessor getActiveLogProcessor() { | ||
| return activeLogProcessor; | ||
| } | ||
|
|
||
| boolean hasBeenShutdown() { | ||
| return shutdownResult != null; | ||
| } | ||
|
|
||
| CompletableResultCode shutdown() { | ||
| synchronized (lock) { | ||
| if (shutdownResult != null) { | ||
| return shutdownResult; | ||
| } | ||
| shutdownResult = activeLogProcessor.shutdown(); | ||
| return shutdownResult; | ||
| } | ||
| } | ||
| } |
56 changes: 56 additions & 0 deletions
56
sdk/logs/src/main/java/io/opentelemetry/sdk/logs/MultiLogProcessor.java
This file contains hidden or 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,56 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.sdk.logs; | ||
|
|
||
| import io.opentelemetry.sdk.common.CompletableResultCode; | ||
| import io.opentelemetry.sdk.logs.data.LogData; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Objects; | ||
| import java.util.concurrent.atomic.AtomicBoolean; | ||
|
|
||
| final class MultiLogProcessor implements LogProcessor { | ||
|
|
||
| private final List<LogProcessor> logProcessors; | ||
| private final AtomicBoolean isShutdown = new AtomicBoolean(false); | ||
|
|
||
| static LogProcessor create(List<LogProcessor> logProcessorsList) { | ||
| return new MultiLogProcessor( | ||
| new ArrayList<>(Objects.requireNonNull(logProcessorsList, "logProcessorsList"))); | ||
| } | ||
|
|
||
| @Override | ||
| public void process(LogData logData) { | ||
| for (LogProcessor logProcessor : logProcessors) { | ||
| logProcessor.process(logData); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableResultCode shutdown() { | ||
| if (isShutdown.getAndSet(true)) { | ||
| return CompletableResultCode.ofSuccess(); | ||
| } | ||
| List<CompletableResultCode> results = new ArrayList<>(logProcessors.size()); | ||
| for (LogProcessor logProcessor : logProcessors) { | ||
| results.add(logProcessor.shutdown()); | ||
| } | ||
| return CompletableResultCode.ofAll(results); | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableResultCode forceFlush() { | ||
| List<CompletableResultCode> results = new ArrayList<>(logProcessors.size()); | ||
| for (LogProcessor logProcessor : logProcessors) { | ||
| results.add(logProcessor.forceFlush()); | ||
| } | ||
| return CompletableResultCode.ofAll(results); | ||
| } | ||
|
|
||
| private MultiLogProcessor(List<LogProcessor> logProcessorsList) { | ||
| this.logProcessors = logProcessorsList; | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
sdk/logs/src/main/java/io/opentelemetry/sdk/logs/NoopLogProcessor.java
This file contains hidden or 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,21 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.sdk.logs; | ||
|
|
||
| import io.opentelemetry.sdk.logs.data.LogData; | ||
|
|
||
| final class NoopLogProcessor implements LogProcessor { | ||
| private static final NoopLogProcessor INSTANCE = new NoopLogProcessor(); | ||
|
|
||
| static LogProcessor getInstance() { | ||
| return INSTANCE; | ||
| } | ||
|
|
||
| private NoopLogProcessor() {} | ||
|
|
||
| @Override | ||
| public void process(LogData logData) {} | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.