Skip to content
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

Add get{Signal}Exporter methods to Simple{Signal}Processor, Batch{Signal}Processor #6078

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
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 @@ -120,6 +120,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 @@ -126,6 +126,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{" + "spanExporter=" + spanExporter + '}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,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 @@ -252,4 +252,10 @@ void close() {
simpleSampledSpansProcessor.close();
verify(spanExporter).shutdown();
}

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