Skip to content

Commit 0f3bc18

Browse files
committed
simplify
Signed-off-by: Hilmar Falkenberg <[email protected]>
1 parent f0d84c7 commit 0f3bc18

File tree

3 files changed

+9
-69
lines changed

3 files changed

+9
-69
lines changed

sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/AuditException.java

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,60 +7,31 @@
77

88
import io.opentelemetry.context.Context;
99
import io.opentelemetry.sdk.logs.data.LogRecordData;
10-
import java.util.ArrayList;
1110
import java.util.Collection;
11+
import java.util.Collections;
1212
import javax.annotation.Nullable;
1313

1414
public class AuditException extends RuntimeException {
1515

1616
private static final long serialVersionUID = 5791873097754062413L;
1717

18-
@Nullable public Throwable cause;
19-
2018
@Nullable public Context context;
2119

22-
@Nullable public Collection<LogRecordData> logRecords;
20+
public Collection<LogRecordData> logRecords;
2321

24-
public AuditException(
25-
Throwable cause, Context context, @Nullable Collection<LogRecordData> logs) {
26-
super(cause);
27-
this.logRecords = logs;
28-
this.context = context;
29-
}
30-
31-
public AuditException(@Nullable String message, @Nullable Throwable cause) {
22+
private AuditException(@Nullable String message, @Nullable Throwable cause) {
3223
super(message, cause);
24+
logRecords = Collections.emptyList();
3325
}
3426

35-
public AuditException(
36-
@Nullable String message,
37-
@Nullable Throwable cause,
38-
@Nullable Collection<LogRecordData> logs) {
27+
AuditException(String message, @Nullable Throwable cause, Collection<LogRecordData> logs) {
3928
this(message, cause);
4029
this.logRecords = logs;
4130
}
4231

43-
public void add(@Nullable Collection<LogRecordData> data) {
44-
if (data == null || data.isEmpty()) {
45-
return;
46-
}
47-
if (logRecords == null) {
48-
logRecords = new ArrayList<>(data);
49-
} else {
50-
logRecords.addAll(data);
51-
}
52-
}
53-
54-
public void because(@Nullable Throwable exception) {
55-
cause = exception;
56-
}
57-
58-
@Override
59-
@Nullable
60-
public synchronized Throwable getCause() {
61-
if (cause != null) {
62-
return cause;
63-
}
64-
return super.getCause();
32+
AuditException(Throwable cause, Context context, Collection<LogRecordData> logs) {
33+
super(cause);
34+
this.logRecords = logs;
35+
this.context = context;
6536
}
6637
}

sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/AuditLogRecordProcessorBuilder.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import static io.opentelemetry.api.internal.Utils.checkArgument;
99
import static java.util.Objects.requireNonNull;
1010

11-
import java.time.Duration;
1211
import java.util.concurrent.TimeUnit;
1312
import javax.annotation.Nonnull;
1413
import javax.annotation.Nullable;
@@ -139,15 +138,6 @@ public AuditLogRecordProcessorBuilder setExceptionHandler(
139138
return this;
140139
}
141140

142-
/**
143-
* Sets the maximum time an export will be allowed to run before being cancelled. If unset,
144-
* defaults to {@value DEFAULT_EXPORT_TIMEOUT_MILLIS}ms.
145-
*/
146-
public AuditLogRecordProcessorBuilder setExporterTimeout(@Nonnull Duration timeout) {
147-
requireNonNull(timeout, "timeout");
148-
return setExporterTimeout(timeout.toNanos(), TimeUnit.NANOSECONDS);
149-
}
150-
151141
/**
152142
* Sets the maximum time an export will be allowed to run before being cancelled. If unset,
153143
* defaults to {@value DEFAULT_EXPORT_TIMEOUT_MILLIS}ms.
@@ -218,15 +208,6 @@ public AuditLogRecordProcessorBuilder setRetryMultiplier(double retryMultiplier)
218208
return this;
219209
}
220210

221-
/**
222-
* Sets the delay interval between two consecutive exports. If unset, defaults to {@value
223-
* DEFAULT_SCHEDULE_DELAY_MILLIS}ms.
224-
*/
225-
public AuditLogRecordProcessorBuilder setScheduleDelay(@Nonnull Duration delay) {
226-
requireNonNull(delay, "delay");
227-
return setScheduleDelay(delay.toNanos(), TimeUnit.NANOSECONDS);
228-
}
229-
230211
/**
231212
* Sets the delay interval between two consecutive exports. If unset, defaults to {@value
232213
* DEFAULT_SCHEDULE_DELAY_MILLIS}ms.

sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/AuditLogRecordProcessorTest.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,6 @@ void builderInvalidConfig() {
103103
.setScheduleDelay(1, null))
104104
.isInstanceOf(NullPointerException.class)
105105
.hasMessage("unit");
106-
assertThatThrownBy(
107-
() ->
108-
AuditLogRecordProcessor.builder(mockLogRecordExporter, mockLogStore)
109-
.setScheduleDelay(null))
110-
.isInstanceOf(NullPointerException.class)
111-
.hasMessage("delay");
112106
assertThatThrownBy(
113107
() ->
114108
AuditLogRecordProcessor.builder(mockLogRecordExporter, mockLogStore)
@@ -121,12 +115,6 @@ void builderInvalidConfig() {
121115
.setExporterTimeout(1, null))
122116
.isInstanceOf(NullPointerException.class)
123117
.hasMessage("unit");
124-
assertThatThrownBy(
125-
() ->
126-
AuditLogRecordProcessor.builder(mockLogRecordExporter, mockLogStore)
127-
.setExporterTimeout(null))
128-
.isInstanceOf(NullPointerException.class)
129-
.hasMessage("timeout");
130118
assertThatThrownBy(
131119
() ->
132120
AuditLogRecordProcessor.builder(mockLogRecordExporter, mockLogStore)

0 commit comments

Comments
 (0)