Skip to content

Commit

Permalink
Add get{Signal}Exporter methods to Simple{Signal}Processor, Batch{Sig…
Browse files Browse the repository at this point in the history
…nal}Processor (#6078)
  • Loading branch information
jack-berg authored Mar 22, 2024
1 parent 434609a commit b897510
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 2 deletions.
7 changes: 6 additions & 1 deletion docs/apidiffs/current_vs_latest/opentelemetry-sdk-logs.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
Comparing source compatibility of against
No changes.
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.logs.export.BatchLogRecordProcessor (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.logs.export.LogRecordExporter getLogRecordExporter()
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.logs.export.SimpleLogRecordProcessor (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.logs.export.LogRecordExporter getLogRecordExporter()
7 changes: 6 additions & 1 deletion docs/apidiffs/current_vs_latest/opentelemetry-sdk-trace.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
Comparing source compatibility of against
No changes.
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.trace.export.BatchSpanProcessor (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.trace.export.SpanExporter getSpanExporter()
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.trace.export.SimpleSpanProcessor (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.trace.export.SpanExporter getSpanExporter()
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ public CompletableResultCode forceFlush() {
return worker.forceFlush();
}

/** Return the processor's configured {@link LogRecordExporter}. */
public LogRecordExporter getLogRecordExporter() {
return worker.logRecordExporter;
}

// Visible for testing
List<LogRecordData> getBatch() {
return worker.batch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ public CompletableResultCode forceFlush() {
return CompletableResultCode.ofAll(pendingExports);
}

/** Return the processor's configured {@link LogRecordExporter}. */
public LogRecordExporter getLogRecordExporter() {
return logRecordExporter;
}

@Override
public String toString() {
return "SimpleLogRecordProcessor{" + "logRecordExporter=" + logRecordExporter + '}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package io.opentelemetry.sdk.logs.export;

import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatCode;
import static org.awaitility.Awaitility.await;
Expand Down Expand Up @@ -417,6 +418,13 @@ void shutdownPropagatesFailure() {
assertThat(result.isSuccess()).isFalse();
}

@Test
void getLogRecordExporter() {
assertThat(
BatchLogRecordProcessor.builder(mockLogRecordExporter).build().getLogRecordExporter())
.isSameAs(mockLogRecordExporter);
}

@Test
void toString_Valid() {
when(mockLogRecordExporter.toString()).thenReturn("MockLogRecordExporter");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ void shutdown() {
verify(logRecordExporter).shutdown();
}

@Test
void getLogRecordExporter() {
assertThat(
((SimpleLogRecordProcessor) SimpleLogRecordProcessor.create(logRecordExporter))
.getLogRecordExporter())
.isSameAs(logRecordExporter);
}

@Test
void toString_Valid() {
when(logRecordExporter.toString()).thenReturn("MockLogRecordExporter");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ public CompletableResultCode forceFlush() {
return worker.forceFlush();
}

/** Return the processor's configured {@link SpanExporter}. */
public SpanExporter getSpanExporter() {
return worker.spanExporter;
}

// Visible for testing
List<SpanData> getBatch() {
return worker.batch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ public CompletableResultCode forceFlush() {
return CompletableResultCode.ofAll(pendingExports);
}

/** Return the processor's configured {@link SpanExporter}. */
public SpanExporter getSpanExporter() {
return spanExporter;
}

@Override
public String toString() {
return "SimpleSpanProcessor{"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,12 @@ void shutdownPropagatesFailure() {
assertThat(result.isSuccess()).isFalse();
}

@Test
void getSpanExporter() {
assertThat(BatchSpanProcessor.builder(mockSpanExporter).build().getSpanExporter())
.isSameAs(mockSpanExporter);
}

@Test
void stringRepresentation() {
BatchSpanProcessor processor = BatchSpanProcessor.builder(mockSpanExporter).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,10 @@ void close() {
simpleSampledSpansProcessor.close();
verify(spanExporter).shutdown();
}

@Test
void getSpanExporter() {
assertThat(((SimpleSpanProcessor) SimpleSpanProcessor.create(spanExporter)).getSpanExporter())
.isSameAs(spanExporter);
}
}

0 comments on commit b897510

Please sign in to comment.