From 3ea38103cd5ec13fb70ea79d412a1f5d963e6ef0 Mon Sep 17 00:00:00 2001 From: Jack Berg Date: Thu, 22 Sep 2022 15:23:23 -0500 Subject: [PATCH 1/2] Rename LogData to LogRecordData --- .../otlp/OtlpJsonLoggingLogExporter.java | 8 +-- .../otlp/OtlpJsonLoggingLogExporterTest.java | 12 ++-- .../logging/SystemOutLogExporter.java | 8 +-- .../logging/SystemOutLogExporterTest.java | 10 +-- .../internal/otlp/logs/LogMarshaler.java | 17 ++--- .../otlp/logs/LogsRequestMarshaler.java | 6 +- .../otlp/logs/ResourceLogsMarshaler.java | 10 +-- .../otlp/logs/LogsRequestMarshalerTest.java | 8 +-- .../otlp/http/logs/OtlpHttpLogExporter.java | 4 +- .../otlp/logs/OtlpGrpcLogExporter.java | 4 +- .../http/logs/OtlpHttpLogExporterTest.java | 10 +-- .../otlp/logs/OtlpGrpcLogExporterTest.java | 15 +++-- .../logs/OtlpGrpcNettyLogExporterTest.java | 14 ++-- .../OtlpGrpcNettyShadedLogExporterTest.java | 14 ++-- .../OtlpGrpcNettyOkHttpLogExporterTest.java | 14 ++-- .../GrpcLogExporterBuilderWrapper.java | 24 +++---- .../testing/internal/TelemetryExporter.java | 8 +-- .../internal/TelemetryExporterBuilder.java | 4 +- .../autoconfigure/LogExporterCustomizer.java | 6 +- .../TestConfigurableLogExporterProvider.java | 4 +- .../sdk/autoconfigure/OtlpGrpcConfigTest.java | 8 +-- .../sdk/autoconfigure/OtlpGrpcRetryTest.java | 8 +-- .../OtlpGrpcServerExtension.java | 8 +-- .../sdk/autoconfigure/OtlpHttpRetryTest.java | 8 +-- .../OtlpHttpServerExtension.java | 8 +-- .../sdk/testing/assertj/LogAssertions.java | 8 +-- ...taAssert.java => LogRecordDataAssert.java} | 34 +++++----- ...estLogData.java => TestLogRecordData.java} | 20 +++--- .../testing/assertj/LogAssertionsTest.java | 8 +-- .../io/opentelemetry/sdk/logs/LogLimits.java | 6 +- .../sdk/logs/LogLimitsBuilder.java | 6 +- .../sdk/logs/ReadWriteLogRecord.java | 8 +-- ...{SdkLogData.java => SdkLogRecordData.java} | 10 +-- .../sdk/logs/SdkLoggerProviderBuilder.java | 6 +- .../sdk/logs/SdkReadWriteLogRecord.java | 6 +- .../data/{LogData.java => LogRecordData.java} | 2 +- .../sdk/logs/export/BatchLogProcessor.java | 10 +-- .../sdk/logs/export/InMemoryLogExporter.java | 8 +-- .../sdk/logs/export/LogExporter.java | 14 ++-- .../sdk/logs/export/MultiLogExporter.java | 4 +- .../sdk/logs/export/NoopLogExporter.java | 4 +- .../sdk/logs/export/SimpleLogProcessor.java | 6 +- .../sdk/logs/SdkLogRecordBuilderTest.java | 4 +- .../sdk/logs/SdkLoggerProviderTest.java | 10 +-- .../opentelemetry/sdk/logs/SdkLoggerTest.java | 6 +- .../logs/export/BatchLogProcessorTest.java | 67 ++++++++++--------- .../logs/export/InMemoryLogExporterTest.java | 19 +++--- .../sdk/logs/export/MultiLogExporterTest.java | 8 +-- .../logs/export/SimpleLogProcessorTest.java | 14 ++-- 49 files changed, 268 insertions(+), 260 deletions(-) rename sdk/logs-testing/src/main/java/io/opentelemetry/sdk/testing/assertj/{LogDataAssert.java => LogRecordDataAssert.java} (81%) rename sdk/logs-testing/src/main/java/io/opentelemetry/sdk/testing/logs/{TestLogData.java => TestLogRecordData.java} (81%) rename sdk/logs/src/main/java/io/opentelemetry/sdk/logs/{SdkLogData.java => SdkLogRecordData.java} (83%) rename sdk/logs/src/main/java/io/opentelemetry/sdk/logs/data/{LogData.java => LogRecordData.java} (98%) diff --git a/exporters/logging-otlp/src/main/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingLogExporter.java b/exporters/logging-otlp/src/main/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingLogExporter.java index 2f13c1a5078..f388e8fbb17 100644 --- a/exporters/logging-otlp/src/main/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingLogExporter.java +++ b/exporters/logging-otlp/src/main/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingLogExporter.java @@ -11,7 +11,7 @@ import com.fasterxml.jackson.core.io.SegmentedStringWriter; import io.opentelemetry.exporter.internal.otlp.logs.ResourceLogsMarshaler; import io.opentelemetry.sdk.common.CompletableResultCode; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.logs.export.LogExporter; import java.io.IOException; import java.util.Collection; @@ -19,8 +19,8 @@ import java.util.logging.Logger; /** - * A {@link LogExporter} which writes {@linkplain LogData logs} to a {@link Logger} in OTLP JSON - * format. Each log line will include a single {@code ResourceLogs}. + * A {@link LogExporter} which writes {@linkplain LogRecordData logs} to a {@link Logger} in OTLP + * JSON format. Each log line will include a single {@code ResourceLogs}. */ public final class OtlpJsonLoggingLogExporter implements LogExporter { @@ -34,7 +34,7 @@ public static LogExporter create() { private OtlpJsonLoggingLogExporter() {} @Override - public CompletableResultCode export(Collection logs) { + public CompletableResultCode export(Collection logs) { ResourceLogsMarshaler[] allResourceLogs = ResourceLogsMarshaler.create(logs); for (ResourceLogsMarshaler resourceLogs : allResourceLogs) { SegmentedStringWriter sw = new SegmentedStringWriter(JSON_FACTORY._getBufferRecycler()); diff --git a/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingLogExporterTest.java b/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingLogExporterTest.java index 75df9c0f5a9..cb5634e4221 100644 --- a/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingLogExporterTest.java +++ b/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingLogExporterTest.java @@ -18,10 +18,10 @@ import io.opentelemetry.api.trace.TraceState; import io.opentelemetry.internal.testing.slf4j.SuppressLogger; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.logs.export.LogExporter; import io.opentelemetry.sdk.resources.Resource; -import io.opentelemetry.sdk.testing.logs.TestLogData; +import io.opentelemetry.sdk.testing.logs.TestLogRecordData; import java.util.Arrays; import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.BeforeEach; @@ -36,8 +36,8 @@ class OtlpJsonLoggingLogExporterTest { private static final Resource RESOURCE = Resource.create(Attributes.builder().put("key", "value").build()); - private static final LogData LOG1 = - TestLogData.builder() + private static final LogRecordData LOG1 = + TestLogRecordData.builder() .setResource(RESOURCE) .setInstrumentationScopeInfo( InstrumentationScopeInfo.builder("instrumentation") @@ -57,8 +57,8 @@ class OtlpJsonLoggingLogExporterTest { TraceState.getDefault())) .build(); - private static final LogData LOG2 = - TestLogData.builder() + private static final LogRecordData LOG2 = + TestLogRecordData.builder() .setResource(RESOURCE) .setInstrumentationScopeInfo( InstrumentationScopeInfo.builder("instrumentation2").setVersion("2").build()) diff --git a/exporters/logging/src/main/java/io/opentelemetry/exporter/logging/SystemOutLogExporter.java b/exporters/logging/src/main/java/io/opentelemetry/exporter/logging/SystemOutLogExporter.java index 597cf97bd21..b662c4e5576 100644 --- a/exporters/logging/src/main/java/io/opentelemetry/exporter/logging/SystemOutLogExporter.java +++ b/exporters/logging/src/main/java/io/opentelemetry/exporter/logging/SystemOutLogExporter.java @@ -9,7 +9,7 @@ import io.opentelemetry.sdk.common.CompletableResultCode; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.logs.export.LogExporter; import java.time.Instant; import java.time.ZoneOffset; @@ -41,10 +41,10 @@ public static SystemOutLogExporter create() { public SystemOutLogExporter() {} @Override - public CompletableResultCode export(Collection logs) { + public CompletableResultCode export(Collection logs) { StringBuilder stringBuilder = new StringBuilder(60); - for (LogData log : logs) { + for (LogRecordData log : logs) { stringBuilder.setLength(0); formatLog(stringBuilder, log); System.out.println(stringBuilder); @@ -58,7 +58,7 @@ public CompletableResultCode flush() { } // VisibleForTesting - static void formatLog(StringBuilder stringBuilder, LogData log) { + static void formatLog(StringBuilder stringBuilder, LogRecordData log) { InstrumentationScopeInfo instrumentationScopeInfo = log.getInstrumentationScopeInfo(); stringBuilder .append( diff --git a/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/SystemOutLogExporterTest.java b/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/SystemOutLogExporterTest.java index 4df86a61e8c..6e00b318214 100644 --- a/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/SystemOutLogExporterTest.java +++ b/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/SystemOutLogExporterTest.java @@ -17,9 +17,9 @@ import io.opentelemetry.api.trace.TraceState; import io.opentelemetry.sdk.common.CompletableResultCode; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.resources.Resource; -import io.opentelemetry.sdk.testing.logs.TestLogData; +import io.opentelemetry.sdk.testing.logs.TestLogRecordData; import java.time.LocalDateTime; import java.time.Month; import java.time.ZoneOffset; @@ -41,7 +41,7 @@ void returnCodes() { void format() { long timestamp = LocalDateTime.of(1970, Month.AUGUST, 7, 10, 0).toInstant(ZoneOffset.UTC).toEpochMilli(); - LogData log = sampleLog(timestamp); + LogRecordData log = sampleLog(timestamp); StringBuilder output = new StringBuilder(); SystemOutLogExporter.formatLog(output, log); assertThat(output.toString()) @@ -50,8 +50,8 @@ void format() { + "[scopeInfo: logTest:1.0] {amount=1, cheese=\"cheddar\"}"); } - private static LogData sampleLog(long timestamp) { - return TestLogData.builder() + private static LogRecordData sampleLog(long timestamp) { + return TestLogRecordData.builder() .setResource(Resource.empty()) .setInstrumentationScopeInfo( InstrumentationScopeInfo.builder("logTest").setVersion("1.0").build()) diff --git a/exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/logs/LogMarshaler.java b/exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/logs/LogMarshaler.java index 212059d3a72..b8efcda7f81 100644 --- a/exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/logs/LogMarshaler.java +++ b/exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/logs/LogMarshaler.java @@ -18,6 +18,7 @@ import io.opentelemetry.exporter.internal.otlp.StringAnyValueMarshaler; import io.opentelemetry.proto.logs.v1.internal.LogRecord; import io.opentelemetry.proto.logs.v1.internal.SeverityNumber; +import io.opentelemetry.sdk.logs.data.LogRecordData; import java.io.IOException; import javax.annotation.Nullable; @@ -35,22 +36,22 @@ final class LogMarshaler extends MarshalerWithSize { @Nullable private final String traceId; @Nullable private final String spanId; - static LogMarshaler create(io.opentelemetry.sdk.logs.data.LogData logData) { + static LogMarshaler create(LogRecordData logRecordData) { KeyValueMarshaler[] attributeMarshalers = - KeyValueMarshaler.createRepeated(logData.getAttributes()); + KeyValueMarshaler.createRepeated(logRecordData.getAttributes()); // For now, map all the bodies to String AnyValue. StringAnyValueMarshaler anyValueMarshaler = - new StringAnyValueMarshaler(MarshalerUtil.toBytes(logData.getBody().asString())); + new StringAnyValueMarshaler(MarshalerUtil.toBytes(logRecordData.getBody().asString())); - SpanContext spanContext = logData.getSpanContext(); + SpanContext spanContext = logRecordData.getSpanContext(); return new LogMarshaler( - logData.getEpochNanos(), - toProtoSeverityNumber(logData.getSeverity()), - MarshalerUtil.toBytes(logData.getSeverityText()), + logRecordData.getEpochNanos(), + toProtoSeverityNumber(logRecordData.getSeverity()), + MarshalerUtil.toBytes(logRecordData.getSeverityText()), anyValueMarshaler, attributeMarshalers, - logData.getTotalAttributeCount() - logData.getAttributes().size(), + logRecordData.getTotalAttributeCount() - logRecordData.getAttributes().size(), spanContext.getTraceFlags(), spanContext.getTraceId().equals(INVALID_TRACE_ID) ? null : spanContext.getTraceId(), spanContext.getSpanId().equals(INVALID_SPAN_ID) ? null : spanContext.getSpanId()); diff --git a/exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/logs/LogsRequestMarshaler.java b/exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/logs/LogsRequestMarshaler.java index d02bc1f2c31..b1f4b5cd36d 100644 --- a/exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/logs/LogsRequestMarshaler.java +++ b/exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/logs/LogsRequestMarshaler.java @@ -10,13 +10,13 @@ import io.opentelemetry.exporter.internal.marshal.MarshalerWithSize; import io.opentelemetry.exporter.internal.marshal.Serializer; import io.opentelemetry.proto.collector.logs.v1.internal.ExportLogsServiceRequest; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.trace.data.SpanData; import java.io.IOException; import java.util.Collection; /** - * {@link Marshaler} to convert SDK {@link LogData} to OTLP ExportLogsServiceRequest. + * {@link Marshaler} to convert SDK {@link LogRecordData} to OTLP ExportLogsServiceRequest. * *

This class is internal and is hence not for public use. Its APIs are unstable and can change * at any time. @@ -29,7 +29,7 @@ public final class LogsRequestMarshaler extends MarshalerWithSize { * Returns a {@link LogsRequestMarshaler} that can be used to convert the provided {@link * SpanData} into a serialized OTLP ExportLogsServiceRequest. */ - public static LogsRequestMarshaler create(Collection logs) { + public static LogsRequestMarshaler create(Collection logs) { return new LogsRequestMarshaler(ResourceLogsMarshaler.create(logs)); } diff --git a/exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/logs/ResourceLogsMarshaler.java b/exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/logs/ResourceLogsMarshaler.java index 66ff689f6a2..4e2ee16e7e1 100644 --- a/exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/logs/ResourceLogsMarshaler.java +++ b/exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/logs/ResourceLogsMarshaler.java @@ -13,7 +13,7 @@ import io.opentelemetry.exporter.internal.otlp.ResourceMarshaler; import io.opentelemetry.proto.logs.v1.internal.ResourceLogs; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.resources.Resource; import java.io.IOException; import java.util.Collection; @@ -32,7 +32,7 @@ public final class ResourceLogsMarshaler extends MarshalerWithSize { private final InstrumentationScopeLogsMarshaler[] instrumentationScopeLogsMarshalers; /** Returns Marshalers of ResourceLogs created by grouping the provided logRecords. */ - public static ResourceLogsMarshaler[] create(Collection logs) { + public static ResourceLogsMarshaler[] create(Collection logs) { Map>> resourceAndScopeMap = groupByResourceAndScope(logs); @@ -93,13 +93,13 @@ private static int calculateSize( } private static Map>> - groupByResourceAndScope(Collection logs) { + groupByResourceAndScope(Collection logs) { return MarshalerUtil.groupByResourceAndScope( logs, // TODO(anuraaga): Replace with an internal SdkData type of interface that exposes these // two. - LogData::getResource, - LogData::getInstrumentationScopeInfo, + LogRecordData::getResource, + LogRecordData::getInstrumentationScopeInfo, LogMarshaler::create); } } diff --git a/exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/otlp/logs/LogsRequestMarshalerTest.java b/exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/otlp/logs/LogsRequestMarshalerTest.java index b42d8cbc81d..e6aab7daace 100644 --- a/exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/otlp/logs/LogsRequestMarshalerTest.java +++ b/exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/otlp/logs/LogsRequestMarshalerTest.java @@ -29,7 +29,7 @@ import io.opentelemetry.proto.logs.v1.ScopeLogs; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; import io.opentelemetry.sdk.resources.Resource; -import io.opentelemetry.sdk.testing.logs.TestLogData; +import io.opentelemetry.sdk.testing.logs.TestLogRecordData; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.UncheckedIOException; @@ -53,7 +53,7 @@ void toProtoResourceLogs() { ResourceLogsMarshaler[] resourceLogsMarshalers = ResourceLogsMarshaler.create( Collections.singleton( - TestLogData.builder() + TestLogRecordData.builder() .setResource( Resource.builder().put("one", 1).setSchemaUrl("http://url").build()) .setInstrumentationScopeInfo( @@ -100,7 +100,7 @@ void toProtoLogRecord() { parse( LogRecord.getDefaultInstance(), LogMarshaler.create( - TestLogData.builder() + TestLogRecordData.builder() .setResource( Resource.create(Attributes.builder().put("testKey", "testValue").build())) .setInstrumentationScopeInfo( @@ -136,7 +136,7 @@ void toProtoLogRecord_MinimalFields() { parse( LogRecord.getDefaultInstance(), LogMarshaler.create( - TestLogData.builder() + TestLogRecordData.builder() .setResource( Resource.create(Attributes.builder().put("testKey", "testValue").build())) .setInstrumentationScopeInfo( diff --git a/exporters/otlp/logs/src/main/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporter.java b/exporters/otlp/logs/src/main/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporter.java index dd05f5789ab..1e4fcc567bc 100644 --- a/exporters/otlp/logs/src/main/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporter.java +++ b/exporters/otlp/logs/src/main/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporter.java @@ -8,7 +8,7 @@ import io.opentelemetry.exporter.internal.okhttp.OkHttpExporter; import io.opentelemetry.exporter.internal.otlp.logs.LogsRequestMarshaler; import io.opentelemetry.sdk.common.CompletableResultCode; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.logs.export.LogExporter; import java.util.Collection; import javax.annotation.concurrent.ThreadSafe; @@ -48,7 +48,7 @@ public static OtlpHttpLogExporterBuilder builder() { * @return the result of the operation */ @Override - public CompletableResultCode export(Collection logs) { + public CompletableResultCode export(Collection logs) { LogsRequestMarshaler exportRequest = LogsRequestMarshaler.create(logs); return delegate.export(exportRequest, logs.size()); } diff --git a/exporters/otlp/logs/src/main/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcLogExporter.java b/exporters/otlp/logs/src/main/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcLogExporter.java index 089bdb80c21..5682de6aaf7 100644 --- a/exporters/otlp/logs/src/main/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcLogExporter.java +++ b/exporters/otlp/logs/src/main/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcLogExporter.java @@ -8,7 +8,7 @@ import io.opentelemetry.exporter.internal.grpc.GrpcExporter; import io.opentelemetry.exporter.internal.otlp.logs.LogsRequestMarshaler; import io.opentelemetry.sdk.common.CompletableResultCode; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.logs.export.LogExporter; import java.util.Collection; import javax.annotation.concurrent.ThreadSafe; @@ -50,7 +50,7 @@ public static OtlpGrpcLogExporterBuilder builder() { * @return the result of the operation */ @Override - public CompletableResultCode export(Collection logs) { + public CompletableResultCode export(Collection logs) { LogsRequestMarshaler request = LogsRequestMarshaler.create(logs); return delegate.export(request, logs.size()); } diff --git a/exporters/otlp/logs/src/test/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporterTest.java b/exporters/otlp/logs/src/test/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporterTest.java index 924d7c704be..179a0dc656b 100644 --- a/exporters/otlp/logs/src/test/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporterTest.java +++ b/exporters/otlp/logs/src/test/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogExporterTest.java @@ -33,9 +33,9 @@ import io.opentelemetry.proto.logs.v1.ResourceLogs; import io.opentelemetry.sdk.common.CompletableResultCode; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.resources.Resource; -import io.opentelemetry.sdk.testing.logs.TestLogData; +import io.opentelemetry.sdk.testing.logs.TestLogRecordData; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.UncheckedIOException; @@ -308,7 +308,7 @@ void testServerErrorParseError() { private static ExportLogsServiceRequest exportAndAssertResult( OtlpHttpLogExporter otlpHttpLogExporter, boolean expectedResult) { - List logs = Collections.singletonList(generateFakeLog()); + List logs = Collections.singletonList(generateFakeLog()); CompletableResultCode resultCode = otlpHttpLogExporter.export(logs); resultCode.join(10, TimeUnit.SECONDS); assertThat(resultCode.isSuccess()).isEqualTo(expectedResult); @@ -338,8 +338,8 @@ private static HttpResponse buildResponse(HttpStatus httpSta return HttpResponse.of(httpStatus, APPLICATION_PROTOBUF, message.toByteArray()); } - private static LogData generateFakeLog() { - return TestLogData.builder() + private static LogRecordData generateFakeLog() { + return TestLogRecordData.builder() .setResource(Resource.getDefault()) .setInstrumentationScopeInfo( InstrumentationScopeInfo.builder("testLib") diff --git a/exporters/otlp/logs/src/test/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcLogExporterTest.java b/exporters/otlp/logs/src/test/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcLogExporterTest.java index 6138584ec88..8ad60b0fe8e 100644 --- a/exporters/otlp/logs/src/test/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcLogExporterTest.java +++ b/exporters/otlp/logs/src/test/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcLogExporterTest.java @@ -19,15 +19,16 @@ import io.opentelemetry.exporter.otlp.testing.internal.TelemetryExporterBuilder; import io.opentelemetry.proto.logs.v1.ResourceLogs; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.resources.Resource; -import io.opentelemetry.sdk.testing.logs.TestLogData; +import io.opentelemetry.sdk.testing.logs.TestLogRecordData; import java.io.Closeable; import java.time.Instant; import java.util.List; import org.junit.jupiter.api.Test; -class OtlpGrpcLogExporterTest extends AbstractGrpcTelemetryExporterTest { +class OtlpGrpcLogExporterTest + extends AbstractGrpcTelemetryExporterTest { OtlpGrpcLogExporterTest() { super("log", ResourceLogs.getDefaultInstance()); @@ -50,13 +51,13 @@ void usingOkHttp() throws Exception { } @Override - protected TelemetryExporterBuilder exporterBuilder() { + protected TelemetryExporterBuilder exporterBuilder() { return TelemetryExporterBuilder.wrap(OtlpGrpcLogExporter.builder()); } @Override - protected LogData generateFakeTelemetry() { - return TestLogData.builder() + protected LogRecordData generateFakeTelemetry() { + return TestLogRecordData.builder() .setResource(Resource.create(Attributes.builder().put("testKey", "testValue").build())) .setInstrumentationScopeInfo( InstrumentationScopeInfo.builder("instrumentation").setVersion("1").build()) @@ -69,7 +70,7 @@ protected LogData generateFakeTelemetry() { } @Override - protected Marshaler[] toMarshalers(List telemetry) { + protected Marshaler[] toMarshalers(List telemetry) { return ResourceLogsMarshaler.create(telemetry); } } diff --git a/exporters/otlp/logs/src/testGrpcNetty/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyLogExporterTest.java b/exporters/otlp/logs/src/testGrpcNetty/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyLogExporterTest.java index 3683d80848e..e9f0f7158b1 100644 --- a/exporters/otlp/logs/src/testGrpcNetty/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyLogExporterTest.java +++ b/exporters/otlp/logs/src/testGrpcNetty/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyLogExporterTest.java @@ -21,16 +21,16 @@ import io.opentelemetry.exporter.otlp.testing.internal.TelemetryExporterBuilder; import io.opentelemetry.proto.logs.v1.ResourceLogs; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.resources.Resource; -import io.opentelemetry.sdk.testing.logs.TestLogData; +import io.opentelemetry.sdk.testing.logs.TestLogRecordData; import java.io.Closeable; import java.time.Instant; import java.util.List; import org.junit.jupiter.api.Test; class OtlpGrpcNettyLogExporterTest - extends AbstractGrpcTelemetryExporterTest { + extends AbstractGrpcTelemetryExporterTest { OtlpGrpcNettyLogExporterTest() { super("log", ResourceLogs.getDefaultInstance()); @@ -57,14 +57,14 @@ void usingGrpc() throws Exception { } @Override - protected TelemetryExporterBuilder exporterBuilder() { + protected TelemetryExporterBuilder exporterBuilder() { return ManagedChannelTelemetryExporterBuilder.wrap( TelemetryExporterBuilder.wrap(OtlpGrpcLogExporter.builder())); } @Override - protected LogData generateFakeTelemetry() { - return TestLogData.builder() + protected LogRecordData generateFakeTelemetry() { + return TestLogRecordData.builder() .setResource(Resource.create(Attributes.builder().put("testKey", "testValue").build())) .setInstrumentationScopeInfo( InstrumentationScopeInfo.builder("instrumentation").setVersion("1").build()) @@ -77,7 +77,7 @@ protected LogData generateFakeTelemetry() { } @Override - protected Marshaler[] toMarshalers(List telemetry) { + protected Marshaler[] toMarshalers(List telemetry) { return ResourceLogsMarshaler.create(telemetry); } } diff --git a/exporters/otlp/logs/src/testGrpcNettyShaded/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyShadedLogExporterTest.java b/exporters/otlp/logs/src/testGrpcNettyShaded/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyShadedLogExporterTest.java index 755bda0790b..f18d7151c47 100644 --- a/exporters/otlp/logs/src/testGrpcNettyShaded/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyShadedLogExporterTest.java +++ b/exporters/otlp/logs/src/testGrpcNettyShaded/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyShadedLogExporterTest.java @@ -18,16 +18,16 @@ import io.opentelemetry.exporter.otlp.testing.internal.TelemetryExporterBuilder; import io.opentelemetry.proto.logs.v1.ResourceLogs; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.resources.Resource; -import io.opentelemetry.sdk.testing.logs.TestLogData; +import io.opentelemetry.sdk.testing.logs.TestLogRecordData; import java.io.Closeable; import java.time.Instant; import java.util.List; import org.junit.jupiter.api.Test; class OtlpGrpcNettyShadedLogExporterTest - extends AbstractGrpcTelemetryExporterTest { + extends AbstractGrpcTelemetryExporterTest { OtlpGrpcNettyShadedLogExporterTest() { super("log", ResourceLogs.getDefaultInstance()); @@ -45,14 +45,14 @@ void usingGrpc() throws Exception { } @Override - protected TelemetryExporterBuilder exporterBuilder() { + protected TelemetryExporterBuilder exporterBuilder() { return ManagedChannelTelemetryExporterBuilder.wrap( TelemetryExporterBuilder.wrap(OtlpGrpcLogExporter.builder())); } @Override - protected LogData generateFakeTelemetry() { - return TestLogData.builder() + protected LogRecordData generateFakeTelemetry() { + return TestLogRecordData.builder() .setResource(Resource.create(Attributes.builder().put("testKey", "testValue").build())) .setInstrumentationScopeInfo( InstrumentationScopeInfo.builder("instrumentation").setVersion("1").build()) @@ -65,7 +65,7 @@ protected LogData generateFakeTelemetry() { } @Override - protected Marshaler[] toMarshalers(List telemetry) { + protected Marshaler[] toMarshalers(List telemetry) { return ResourceLogsMarshaler.create(telemetry); } } diff --git a/exporters/otlp/logs/src/testGrpcOkhttp/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyOkHttpLogExporterTest.java b/exporters/otlp/logs/src/testGrpcOkhttp/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyOkHttpLogExporterTest.java index b66753ca4bc..6f6794a5e00 100644 --- a/exporters/otlp/logs/src/testGrpcOkhttp/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyOkHttpLogExporterTest.java +++ b/exporters/otlp/logs/src/testGrpcOkhttp/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyOkHttpLogExporterTest.java @@ -18,16 +18,16 @@ import io.opentelemetry.exporter.otlp.testing.internal.TelemetryExporterBuilder; import io.opentelemetry.proto.logs.v1.ResourceLogs; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.resources.Resource; -import io.opentelemetry.sdk.testing.logs.TestLogData; +import io.opentelemetry.sdk.testing.logs.TestLogRecordData; import java.io.Closeable; import java.time.Instant; import java.util.List; import org.junit.jupiter.api.Test; class OtlpGrpcNettyOkHttpLogExporterTest - extends AbstractGrpcTelemetryExporterTest { + extends AbstractGrpcTelemetryExporterTest { OtlpGrpcNettyOkHttpLogExporterTest() { super("log", ResourceLogs.getDefaultInstance()); @@ -45,14 +45,14 @@ void usingGrpc() throws Exception { } @Override - protected TelemetryExporterBuilder exporterBuilder() { + protected TelemetryExporterBuilder exporterBuilder() { return ManagedChannelTelemetryExporterBuilder.wrap( TelemetryExporterBuilder.wrap(OtlpGrpcLogExporter.builder())); } @Override - protected LogData generateFakeTelemetry() { - return TestLogData.builder() + protected LogRecordData generateFakeTelemetry() { + return TestLogRecordData.builder() .setResource(Resource.create(Attributes.builder().put("testKey", "testValue").build())) .setInstrumentationScopeInfo( InstrumentationScopeInfo.builder("instrumentation").setVersion("1").build()) @@ -65,7 +65,7 @@ protected LogData generateFakeTelemetry() { } @Override - protected Marshaler[] toMarshalers(List telemetry) { + protected Marshaler[] toMarshalers(List telemetry) { return ResourceLogsMarshaler.create(telemetry); } } diff --git a/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/GrpcLogExporterBuilderWrapper.java b/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/GrpcLogExporterBuilderWrapper.java index 46fdc025da3..f070cb23181 100644 --- a/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/GrpcLogExporterBuilderWrapper.java +++ b/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/GrpcLogExporterBuilderWrapper.java @@ -9,11 +9,11 @@ import io.opentelemetry.exporter.internal.retry.RetryPolicy; import io.opentelemetry.exporter.internal.retry.RetryUtil; import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporterBuilder; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import java.time.Duration; import java.util.concurrent.TimeUnit; -final class GrpcLogExporterBuilderWrapper implements TelemetryExporterBuilder { +final class GrpcLogExporterBuilderWrapper implements TelemetryExporterBuilder { private final OtlpGrpcLogExporterBuilder builder; GrpcLogExporterBuilderWrapper(OtlpGrpcLogExporterBuilder builder) { @@ -21,63 +21,63 @@ final class GrpcLogExporterBuilderWrapper implements TelemetryExporterBuilder setEndpoint(String endpoint) { + public TelemetryExporterBuilder setEndpoint(String endpoint) { builder.setEndpoint(endpoint); return this; } @Override - public TelemetryExporterBuilder setTimeout(long timeout, TimeUnit unit) { + public TelemetryExporterBuilder setTimeout(long timeout, TimeUnit unit) { builder.setTimeout(timeout, unit); return this; } @Override - public TelemetryExporterBuilder setTimeout(Duration timeout) { + public TelemetryExporterBuilder setTimeout(Duration timeout) { builder.setTimeout(timeout); return this; } @Override - public TelemetryExporterBuilder setCompression(String compression) { + public TelemetryExporterBuilder setCompression(String compression) { builder.setCompression(compression); return this; } @Override - public TelemetryExporterBuilder addHeader(String key, String value) { + public TelemetryExporterBuilder addHeader(String key, String value) { builder.addHeader(key, value); return this; } @Override - public TelemetryExporterBuilder setTrustedCertificates(byte[] certificates) { + public TelemetryExporterBuilder setTrustedCertificates(byte[] certificates) { builder.setTrustedCertificates(certificates); return this; } @Override - public TelemetryExporterBuilder setClientTls( + public TelemetryExporterBuilder setClientTls( byte[] privateKeyPem, byte[] certificatePem) { builder.setClientTls(privateKeyPem, certificatePem); return this; } @Override - public TelemetryExporterBuilder setRetryPolicy(RetryPolicy retryPolicy) { + public TelemetryExporterBuilder setRetryPolicy(RetryPolicy retryPolicy) { RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy); return this; } @Override @SuppressWarnings("deprecation") // testing deprecated functionality - public TelemetryExporterBuilder setChannel(ManagedChannel channel) { + public TelemetryExporterBuilder setChannel(ManagedChannel channel) { builder.setChannel(channel); return this; } @Override - public TelemetryExporter build() { + public TelemetryExporter build() { return TelemetryExporter.wrap(builder.build()); } } diff --git a/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/TelemetryExporter.java b/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/TelemetryExporter.java index db6eb1c8272..2ce6825998a 100644 --- a/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/TelemetryExporter.java +++ b/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/TelemetryExporter.java @@ -6,7 +6,7 @@ package io.opentelemetry.exporter.otlp.testing.internal; import io.opentelemetry.sdk.common.CompletableResultCode; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.logs.export.LogExporter; import io.opentelemetry.sdk.metrics.data.MetricData; import io.opentelemetry.sdk.metrics.export.MetricExporter; @@ -47,10 +47,10 @@ public CompletableResultCode shutdown() { } /** Wraps a LogExporter. */ - static TelemetryExporter wrap(LogExporter exporter) { - return new TelemetryExporter() { + static TelemetryExporter wrap(LogExporter exporter) { + return new TelemetryExporter() { @Override - public CompletableResultCode export(Collection items) { + public CompletableResultCode export(Collection items) { return exporter.export(items); } diff --git a/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/TelemetryExporterBuilder.java b/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/TelemetryExporterBuilder.java index 2758c0ea7c4..b916fd9b851 100644 --- a/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/TelemetryExporterBuilder.java +++ b/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/TelemetryExporterBuilder.java @@ -10,7 +10,7 @@ import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporterBuilder; import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporterBuilder; import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.metrics.data.MetricData; import io.opentelemetry.sdk.trace.data.SpanData; import java.time.Duration; @@ -26,7 +26,7 @@ static TelemetryExporterBuilder wrap(OtlpGrpcMetricExporterBuilder b return new GrpcMetricExporterBuilderWrapper(builder); } - static TelemetryExporterBuilder wrap(OtlpGrpcLogExporterBuilder builder) { + static TelemetryExporterBuilder wrap(OtlpGrpcLogExporterBuilder builder) { return new GrpcLogExporterBuilderWrapper(builder); } diff --git a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/LogExporterCustomizer.java b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/LogExporterCustomizer.java index bf5443de77e..83bbe1caad7 100644 --- a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/LogExporterCustomizer.java +++ b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/LogExporterCustomizer.java @@ -9,7 +9,7 @@ import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer; import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider; import io.opentelemetry.sdk.common.CompletableResultCode; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.logs.export.LogExporter; import java.util.Collection; import java.util.stream.Collectors; @@ -21,8 +21,8 @@ public void customize(AutoConfigurationCustomizer autoConfiguration) { (delegate, config) -> new LogExporter() { @Override - public CompletableResultCode export(Collection logs) { - Collection filtered = + public CompletableResultCode export(Collection logs) { + Collection filtered = logs.stream() .filter( log -> diff --git a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/TestConfigurableLogExporterProvider.java b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/TestConfigurableLogExporterProvider.java index cee3e1e2837..bb280d1c0a1 100644 --- a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/TestConfigurableLogExporterProvider.java +++ b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/TestConfigurableLogExporterProvider.java @@ -8,7 +8,7 @@ import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; import io.opentelemetry.sdk.autoconfigure.spi.logs.ConfigurableLogExporterProvider; import io.opentelemetry.sdk.common.CompletableResultCode; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.logs.export.LogExporter; import java.util.Collection; @@ -32,7 +32,7 @@ public TestLogExporter(ConfigProperties config) { } @Override - public CompletableResultCode export(Collection logs) { + public CompletableResultCode export(Collection logs) { return CompletableResultCode.ofSuccess(); } diff --git a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcConfigTest.java b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcConfigTest.java index 05782769751..44676991c8a 100644 --- a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcConfigTest.java +++ b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcConfigTest.java @@ -20,7 +20,7 @@ import io.opentelemetry.sdk.OpenTelemetrySdk; import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.logs.export.LogExporter; import io.opentelemetry.sdk.metrics.InstrumentType; import io.opentelemetry.sdk.metrics.data.AggregationTemporality; @@ -44,7 +44,7 @@ class OtlpGrpcConfigTest { private static final List SPAN_DATA = Lists.newArrayList(generateFakeSpan()); private static final List METRIC_DATA = Lists.newArrayList(generateFakeMetric()); - private static final List LOG_DATA = Lists.newArrayList(generateFakeLog()); + private static final List LOG_RECORD_DATA = Lists.newArrayList(generateFakeLog()); @RegisterExtension @Order(1) @@ -114,7 +114,7 @@ void configureExportersGeneral() { assertThat(logExporter) .extracting("delegate.client.callTimeoutMillis", INTEGER) .isEqualTo(TimeUnit.SECONDS.toMillis(15)); - assertThat(logExporter.export(LOG_DATA).join(15, TimeUnit.SECONDS).isSuccess()).isTrue(); + assertThat(logExporter.export(LOG_RECORD_DATA).join(15, TimeUnit.SECONDS).isSuccess()).isTrue(); assertThat(server.logRequests).hasSize(1); assertThat(server.requestHeaders) .anyMatch( @@ -227,7 +227,7 @@ public void configureLogExporter() { assertThat(logExporter) .extracting("delegate.client.callTimeoutMillis", INTEGER) .isEqualTo(TimeUnit.SECONDS.toMillis(15)); - assertThat(logExporter.export(LOG_DATA).join(15, TimeUnit.SECONDS).isSuccess()).isTrue(); + assertThat(logExporter.export(LOG_RECORD_DATA).join(15, TimeUnit.SECONDS).isSuccess()).isTrue(); assertThat(server.logRequests).hasSize(1); assertThat(server.requestHeaders) .anyMatch( diff --git a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcRetryTest.java b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcRetryTest.java index 84e25b952ea..5c1734a6819 100644 --- a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcRetryTest.java +++ b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcRetryTest.java @@ -19,7 +19,7 @@ import io.opentelemetry.exporter.internal.retry.RetryUtil; import io.opentelemetry.internal.testing.slf4j.SuppressLogger; import io.opentelemetry.sdk.common.CompletableResultCode; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.logs.export.LogExporter; import io.opentelemetry.sdk.metrics.data.MetricData; import io.opentelemetry.sdk.metrics.export.MetricExporter; @@ -40,7 +40,7 @@ class OtlpGrpcRetryTest { private static final List SPAN_DATA = Lists.newArrayList(generateFakeSpan()); private static final List METRIC_DATA = Lists.newArrayList(generateFakeMetric()); - private static final List LOG_DATA = Lists.newArrayList(generateFakeLog()); + private static final List LOG_RECORD_DATA = Lists.newArrayList(generateFakeLog()); @RegisterExtension @Order(1) @@ -102,8 +102,8 @@ void configureLogExporterRetryPolicy() { LogExporterConfiguration.configureOtlpLogs( DefaultConfigProperties.createForTest(props), MeterProvider.noop())) { - testRetryableStatusCodes(() -> LOG_DATA, logExporter::export, server.logRequests::size); - testDefaultRetryPolicy(() -> LOG_DATA, logExporter::export, server.logRequests::size); + testRetryableStatusCodes(() -> LOG_RECORD_DATA, logExporter::export, server.logRequests::size); + testDefaultRetryPolicy(() -> LOG_RECORD_DATA, logExporter::export, server.logRequests::size); } } diff --git a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcServerExtension.java b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcServerExtension.java index 6f452c2e1b6..5becf18380d 100644 --- a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcServerExtension.java +++ b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcServerExtension.java @@ -27,14 +27,14 @@ import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceResponse; import io.opentelemetry.proto.collector.trace.v1.TraceServiceGrpc; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.metrics.data.AggregationTemporality; import io.opentelemetry.sdk.metrics.data.MetricData; import io.opentelemetry.sdk.metrics.internal.data.ImmutableLongPointData; import io.opentelemetry.sdk.metrics.internal.data.ImmutableMetricData; import io.opentelemetry.sdk.metrics.internal.data.ImmutableSumData; import io.opentelemetry.sdk.resources.Resource; -import io.opentelemetry.sdk.testing.logs.TestLogData; +import io.opentelemetry.sdk.testing.logs.TestLogRecordData; import io.opentelemetry.sdk.testing.trace.TestSpanData; import io.opentelemetry.sdk.trace.data.SpanData; import io.opentelemetry.sdk.trace.data.StatusData; @@ -163,8 +163,8 @@ static MetricData generateFakeMetric() { 10)))); } - static LogData generateFakeLog() { - return TestLogData.builder() + static LogRecordData generateFakeLog() { + return TestLogRecordData.builder() .setResource(Resource.empty()) .setInstrumentationScopeInfo(InstrumentationScopeInfo.empty()) .setEpoch(Instant.now()) diff --git a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpRetryTest.java b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpRetryTest.java index 8fb520d7db3..5dde94b4610 100644 --- a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpRetryTest.java +++ b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpRetryTest.java @@ -20,7 +20,7 @@ import io.opentelemetry.exporter.internal.retry.RetryUtil; import io.opentelemetry.internal.testing.slf4j.SuppressLogger; import io.opentelemetry.sdk.common.CompletableResultCode; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.logs.export.LogExporter; import io.opentelemetry.sdk.metrics.data.MetricData; import io.opentelemetry.sdk.metrics.export.MetricExporter; @@ -41,7 +41,7 @@ class OtlpHttpRetryTest { private static final List SPAN_DATA = Lists.newArrayList(generateFakeSpan()); private static final List METRIC_DATA = Lists.newArrayList(generateFakeMetric()); - private static final List LOG_DATA = Lists.newArrayList(generateFakeLog()); + private static final List LOG_RECORD_DATA = Lists.newArrayList(generateFakeLog()); @RegisterExtension public static final OtlpHttpServerExtension server = new OtlpHttpServerExtension(); @@ -108,8 +108,8 @@ void configureLogExporterRetryPolicy() { LogExporterConfiguration.configureOtlpLogs( DefaultConfigProperties.createForTest(props), MeterProvider.noop())) { - testRetryableStatusCodes(() -> LOG_DATA, logExporter::export, server.logRequests::size); - testDefaultRetryPolicy(() -> LOG_DATA, logExporter::export, server.logRequests::size); + testRetryableStatusCodes(() -> LOG_RECORD_DATA, logExporter::export, server.logRequests::size); + testDefaultRetryPolicy(() -> LOG_RECORD_DATA, logExporter::export, server.logRequests::size); } } diff --git a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpServerExtension.java b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpServerExtension.java index ae6b4a26e3d..3b774f313fc 100644 --- a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpServerExtension.java +++ b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpServerExtension.java @@ -22,14 +22,14 @@ import io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest; import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.metrics.data.AggregationTemporality; import io.opentelemetry.sdk.metrics.data.MetricData; import io.opentelemetry.sdk.metrics.internal.data.ImmutableLongPointData; import io.opentelemetry.sdk.metrics.internal.data.ImmutableMetricData; import io.opentelemetry.sdk.metrics.internal.data.ImmutableSumData; import io.opentelemetry.sdk.resources.Resource; -import io.opentelemetry.sdk.testing.logs.TestLogData; +import io.opentelemetry.sdk.testing.logs.TestLogRecordData; import io.opentelemetry.sdk.testing.trace.TestSpanData; import io.opentelemetry.sdk.trace.data.SpanData; import io.opentelemetry.sdk.trace.data.StatusData; @@ -146,8 +146,8 @@ static MetricData generateFakeMetric() { 10)))); } - static LogData generateFakeLog() { - return TestLogData.builder() + static LogRecordData generateFakeLog() { + return TestLogRecordData.builder() .setResource(Resource.empty()) .setInstrumentationScopeInfo(InstrumentationScopeInfo.empty()) .setEpoch(Instant.now()) diff --git a/sdk/logs-testing/src/main/java/io/opentelemetry/sdk/testing/assertj/LogAssertions.java b/sdk/logs-testing/src/main/java/io/opentelemetry/sdk/testing/assertj/LogAssertions.java index b4400ce9a68..1163cc84591 100644 --- a/sdk/logs-testing/src/main/java/io/opentelemetry/sdk/testing/assertj/LogAssertions.java +++ b/sdk/logs-testing/src/main/java/io/opentelemetry/sdk/testing/assertj/LogAssertions.java @@ -5,15 +5,15 @@ package io.opentelemetry.sdk.testing.assertj; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import org.assertj.core.api.Assertions; /** Test assertions for data heading to exporters within the Metrics SDK. */ public final class LogAssertions extends Assertions { - /** Returns an assertion for {@link io.opentelemetry.sdk.logs.data.LogData}. */ - public static LogDataAssert assertThat(LogData log) { - return new LogDataAssert(log); + /** Returns an assertion for {@link LogRecordData}. */ + public static LogRecordDataAssert assertThat(LogRecordData log) { + return new LogRecordDataAssert(log); } private LogAssertions() {} diff --git a/sdk/logs-testing/src/main/java/io/opentelemetry/sdk/testing/assertj/LogDataAssert.java b/sdk/logs-testing/src/main/java/io/opentelemetry/sdk/testing/assertj/LogRecordDataAssert.java similarity index 81% rename from sdk/logs-testing/src/main/java/io/opentelemetry/sdk/testing/assertj/LogDataAssert.java rename to sdk/logs-testing/src/main/java/io/opentelemetry/sdk/testing/assertj/LogRecordDataAssert.java index ca0be6d65b5..cb0eb83722f 100644 --- a/sdk/logs-testing/src/main/java/io/opentelemetry/sdk/testing/assertj/LogDataAssert.java +++ b/sdk/logs-testing/src/main/java/io/opentelemetry/sdk/testing/assertj/LogRecordDataAssert.java @@ -13,20 +13,20 @@ import io.opentelemetry.api.logs.Severity; import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.resources.Resource; import java.util.Map; import java.util.function.Consumer; import org.assertj.core.api.AbstractAssert; -/** Test assertions for {@link LogData}. */ -public class LogDataAssert extends AbstractAssert { - protected LogDataAssert(LogData actual) { - super(actual, LogDataAssert.class); +/** Test assertions for {@link LogRecordData}. */ +public class LogRecordDataAssert extends AbstractAssert { + protected LogRecordDataAssert(LogRecordData actual) { + super(actual, LogRecordDataAssert.class); } /** Asserts the {@link Resource} associated with a log matches the expected value. */ - public LogDataAssert hasResource(Resource resource) { + public LogRecordDataAssert hasResource(Resource resource) { isNotNull(); if (!actual.getResource().equals(resource)) { failWithActualExpectedAndMessage( @@ -42,7 +42,8 @@ public LogDataAssert hasResource(Resource resource) { /** * Asserts the {@link InstrumentationScopeInfo} associated with a log matches the expected value. */ - public LogDataAssert hasInstrumentationScope(InstrumentationScopeInfo instrumentationScopeInfo) { + public LogRecordDataAssert hasInstrumentationScope( + InstrumentationScopeInfo instrumentationScopeInfo) { isNotNull(); if (!actual.getInstrumentationScopeInfo().equals(instrumentationScopeInfo)) { failWithActualExpectedAndMessage( @@ -56,7 +57,7 @@ public LogDataAssert hasInstrumentationScope(InstrumentationScopeInfo instrument } /** Asserts the log has the given epoch timestamp. */ - public LogDataAssert hasEpochNanos(long epochNanos) { + public LogRecordDataAssert hasEpochNanos(long epochNanos) { isNotNull(); if (actual.getEpochNanos() != epochNanos) { failWithActualExpectedAndMessage( @@ -70,7 +71,7 @@ public LogDataAssert hasEpochNanos(long epochNanos) { } /** Asserts the log has the given span context. */ - public LogDataAssert hasSpanContext(SpanContext spanContext) { + public LogRecordDataAssert hasSpanContext(SpanContext spanContext) { isNotNull(); if (!actual.getSpanContext().equals(spanContext)) { failWithActualExpectedAndMessage( @@ -84,7 +85,7 @@ public LogDataAssert hasSpanContext(SpanContext spanContext) { } /** Asserts the log has the given severity. */ - public LogDataAssert hasSeverity(Severity severity) { + public LogRecordDataAssert hasSeverity(Severity severity) { isNotNull(); if (actual.getSeverity() != severity) { failWithActualExpectedAndMessage( @@ -98,7 +99,7 @@ public LogDataAssert hasSeverity(Severity severity) { } /** Asserts the log has the given severity text. */ - public LogDataAssert hasSeverityText(String severityText) { + public LogRecordDataAssert hasSeverityText(String severityText) { isNotNull(); if (!severityText.equals(actual.getSeverityText())) { failWithActualExpectedAndMessage( @@ -112,7 +113,7 @@ public LogDataAssert hasSeverityText(String severityText) { } /** Asserts the log has the given body. */ - public LogDataAssert hasBody(String body) { + public LogRecordDataAssert hasBody(String body) { isNotNull(); if (!actual.getBody().asString().equals(body)) { failWithActualExpectedAndMessage( @@ -126,7 +127,7 @@ public LogDataAssert hasBody(String body) { } /** Asserts the log has the given attributes. */ - public LogDataAssert hasAttributes(Attributes attributes) { + public LogRecordDataAssert hasAttributes(Attributes attributes) { isNotNull(); if (!attributesAreEqual(attributes)) { failWithActualExpectedAndMessage( @@ -142,7 +143,8 @@ public LogDataAssert hasAttributes(Attributes attributes) { /** Asserts the log has the given attributes. */ @SuppressWarnings({"rawtypes", "unchecked"}) @SafeVarargs - public final LogDataAssert hasAttributes(Map.Entry, ?>... entries) { + public final LogRecordDataAssert hasAttributes( + Map.Entry, ?>... entries) { AttributesBuilder attributesBuilder = Attributes.builder(); for (Map.Entry, ?> attr : entries) { attributesBuilder.put((AttributeKey) attr.getKey(), attr.getValue()); @@ -152,7 +154,7 @@ public final LogDataAssert hasAttributes(Map.Entry, ?> } /** Asserts the log has attributes satisfying the given condition. */ - public LogDataAssert hasAttributesSatisfying(Consumer attributes) { + public LogRecordDataAssert hasAttributesSatisfying(Consumer attributes) { isNotNull(); assertThat(actual.getAttributes()).as("attributes").satisfies(attributes); return this; @@ -165,7 +167,7 @@ private boolean attributesAreEqual(Attributes attributes) { } /** Asserts the log has the given total attributes. */ - public LogDataAssert hasTotalAttributeCount(int totalAttributeCount) { + public LogRecordDataAssert hasTotalAttributeCount(int totalAttributeCount) { isNotNull(); if (actual.getTotalAttributeCount() != totalAttributeCount) { failWithActualExpectedAndMessage( diff --git a/sdk/logs-testing/src/main/java/io/opentelemetry/sdk/testing/logs/TestLogData.java b/sdk/logs-testing/src/main/java/io/opentelemetry/sdk/testing/logs/TestLogRecordData.java similarity index 81% rename from sdk/logs-testing/src/main/java/io/opentelemetry/sdk/testing/logs/TestLogData.java rename to sdk/logs-testing/src/main/java/io/opentelemetry/sdk/testing/logs/TestLogRecordData.java index 878f953c8b5..5efb9005df2 100644 --- a/sdk/logs-testing/src/main/java/io/opentelemetry/sdk/testing/logs/TestLogData.java +++ b/sdk/logs-testing/src/main/java/io/opentelemetry/sdk/testing/logs/TestLogRecordData.java @@ -11,20 +11,20 @@ import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; import io.opentelemetry.sdk.logs.data.Body; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.resources.Resource; import java.time.Instant; import java.util.concurrent.TimeUnit; import javax.annotation.concurrent.Immutable; -/** Immutable representation of {@link LogData}. */ +/** Immutable representation of {@link LogRecordData}. */ @Immutable @AutoValue -public abstract class TestLogData implements LogData { +public abstract class TestLogRecordData implements LogRecordData { - /** Creates a new Builder for creating an {@link LogData} instance. */ + /** Creates a new Builder for creating an {@link LogRecordData} instance. */ public static Builder builder() { - return new AutoValue_TestLogData.Builder() + return new AutoValue_TestLogRecordData.Builder() .setResource(Resource.empty()) .setInstrumentationScopeInfo(InstrumentationScopeInfo.empty()) .setEpoch(0, TimeUnit.NANOSECONDS) @@ -35,16 +35,16 @@ public static Builder builder() { .setTotalAttributeCount(0); } - TestLogData() {} + TestLogRecordData() {} - /** A {@code Builder} class for {@link TestLogData}. */ + /** A {@code Builder} class for {@link TestLogRecordData}. */ @AutoValue.Builder public abstract static class Builder { - abstract TestLogData autoBuild(); + abstract TestLogRecordData autoBuild(); - /** Create a new {@link LogData} instance from the data in this. */ - public TestLogData build() { + /** Create a new {@link LogRecordData} instance from the data in this. */ + public TestLogRecordData build() { return autoBuild(); } diff --git a/sdk/logs-testing/src/test/java/io/opentelemetry/sdk/testing/assertj/LogAssertionsTest.java b/sdk/logs-testing/src/test/java/io/opentelemetry/sdk/testing/assertj/LogAssertionsTest.java index a55dabdd3d4..750f6e59221 100644 --- a/sdk/logs-testing/src/test/java/io/opentelemetry/sdk/testing/assertj/LogAssertionsTest.java +++ b/sdk/logs-testing/src/test/java/io/opentelemetry/sdk/testing/assertj/LogAssertionsTest.java @@ -17,9 +17,9 @@ import io.opentelemetry.api.trace.TraceFlags; import io.opentelemetry.api.trace.TraceState; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.resources.Resource; -import io.opentelemetry.sdk.testing.logs.TestLogData; +import io.opentelemetry.sdk.testing.logs.TestLogRecordData; import java.util.Arrays; import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.Test; @@ -43,8 +43,8 @@ public class LogAssertionsTest { .put("coins", 0.01, 0.05, 0.1) .build(); - private static final LogData LOG_DATA = - TestLogData.builder() + private static final LogRecordData LOG_DATA = + TestLogRecordData.builder() .setResource(RESOURCE) .setInstrumentationScopeInfo(INSTRUMENTATION_SCOPE_INFO) .setEpoch(100, TimeUnit.NANOSECONDS) diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/LogLimits.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/LogLimits.java index d25190fbfc3..97420043e77 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/LogLimits.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/LogLimits.java @@ -6,7 +6,7 @@ package io.opentelemetry.sdk.logs; import com.google.auto.value.AutoValue; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import java.util.function.Supplier; import javax.annotation.concurrent.Immutable; @@ -40,9 +40,9 @@ static LogLimits create(int maxNumAttributes, int maxAttributeLength) { LogLimits() {} /** - * Returns the max number of attributes per {@link LogData}. + * Returns the max number of attributes per {@link LogRecordData}. * - * @return the max number of attributes per {@link LogData}. + * @return the max number of attributes per {@link LogRecordData}. */ public abstract int getMaxNumberOfAttributes(); diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/LogLimitsBuilder.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/LogLimitsBuilder.java index 361f9951e8b..847829784d7 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/LogLimitsBuilder.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/LogLimitsBuilder.java @@ -6,7 +6,7 @@ package io.opentelemetry.sdk.logs; import io.opentelemetry.api.internal.Utils; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; /** Builder for {@link LogLimits}. */ public final class LogLimitsBuilder { @@ -20,9 +20,9 @@ public final class LogLimitsBuilder { LogLimitsBuilder() {} /** - * Sets the max number of attributes per {@link LogData}. + * Sets the max number of attributes per {@link LogRecordData}. * - * @param maxNumberOfAttributes the max number of attributes per {@link LogData}. Must be + * @param maxNumberOfAttributes the max number of attributes per {@link LogRecordData}. Must be * positive. * @return this. * @throws IllegalArgumentException if {@code maxNumberOfAttributes} is not positive. diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/ReadWriteLogRecord.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/ReadWriteLogRecord.java index c7f8e0b0e8f..d491b1e94e7 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/ReadWriteLogRecord.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/ReadWriteLogRecord.java @@ -6,7 +6,7 @@ package io.opentelemetry.sdk.logs; import io.opentelemetry.api.common.AttributeKey; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; /** A log record that can be read from and written to. */ public interface ReadWriteLogRecord { @@ -21,10 +21,10 @@ public interface ReadWriteLogRecord { // TODO: add additional setters - /** Return an immutable {@link LogData} instance representing this log record. */ - LogData toLogData(); + /** Return an immutable {@link LogRecordData} instance representing this log record. */ + LogRecordData toLogRecordData(); // TODO: add additional log record accessors. Currently, all fields can be accessed indirectly via - // #toLogData() with at the expense of additional allocations. + // #toLogRecordData() with at the expense of additional allocations. } diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLogData.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLogRecordData.java similarity index 83% rename from sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLogData.java rename to sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLogRecordData.java index 36d6fa8de07..c413b8bc4f4 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLogData.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLogRecordData.java @@ -11,7 +11,7 @@ import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; import io.opentelemetry.sdk.logs.data.Body; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.resources.Resource; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; @@ -19,11 +19,11 @@ @AutoValue @AutoValue.CopyAnnotations @Immutable -abstract class SdkLogData implements LogData { +abstract class SdkLogRecordData implements LogRecordData { - SdkLogData() {} + SdkLogRecordData() {} - static SdkLogData create( + static SdkLogRecordData create( Resource resource, InstrumentationScopeInfo instrumentationScopeInfo, long epochNanos, @@ -33,7 +33,7 @@ static SdkLogData create( Body body, Attributes attributes, int totalAttributeCount) { - return new AutoValue_SdkLogData( + return new AutoValue_SdkLogRecordData( resource, instrumentationScopeInfo, epochNanos, diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLoggerProviderBuilder.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLoggerProviderBuilder.java index 2c930e5826e..bb9ef134162 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLoggerProviderBuilder.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLoggerProviderBuilder.java @@ -10,7 +10,7 @@ import io.opentelemetry.api.logs.LogRecordBuilder; import io.opentelemetry.api.logs.Logger; import io.opentelemetry.sdk.common.Clock; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.resources.Resource; import java.util.ArrayList; import java.util.List; @@ -27,8 +27,8 @@ public final class SdkLoggerProviderBuilder { SdkLoggerProviderBuilder() {} /** - * Assign a {@link Resource} to be attached to all {@link LogData} created by {@link Logger}s - * obtained from the {@link SdkLoggerProvider}. + * Assign a {@link Resource} to be attached to all {@link LogRecordData} created by {@link + * Logger}s obtained from the {@link SdkLoggerProvider}. * * @param resource the resource * @return this diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkReadWriteLogRecord.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkReadWriteLogRecord.java index c6906d5cb2a..f7ce9d84570 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkReadWriteLogRecord.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkReadWriteLogRecord.java @@ -13,7 +13,7 @@ import io.opentelemetry.sdk.common.InstrumentationScopeInfo; import io.opentelemetry.sdk.internal.AttributesMap; import io.opentelemetry.sdk.logs.data.Body; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.resources.Resource; import javax.annotation.Nullable; import javax.annotation.concurrent.ThreadSafe; @@ -105,9 +105,9 @@ private Attributes getImmutableAttributes() { } @Override - public LogData toLogData() { + public LogRecordData toLogRecordData() { synchronized (lock) { - return SdkLogData.create( + return SdkLogRecordData.create( resource, instrumentationScopeInfo, epochNanos, diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/data/LogData.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/data/LogRecordData.java similarity index 98% rename from sdk/logs/src/main/java/io/opentelemetry/sdk/logs/data/LogData.java rename to sdk/logs/src/main/java/io/opentelemetry/sdk/logs/data/LogRecordData.java index 26890c8f64a..945c83cabf2 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/data/LogData.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/data/LogRecordData.java @@ -20,7 +20,7 @@ * Log Data Model. */ @Immutable -public interface LogData { +public interface LogRecordData { /** Returns the resource of this log. */ Resource getResource(); diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/BatchLogProcessor.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/BatchLogProcessor.java index 014eac2ebc8..c70c0b386f7 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/BatchLogProcessor.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/BatchLogProcessor.java @@ -14,7 +14,7 @@ import io.opentelemetry.sdk.internal.DaemonThreadFactory; import io.opentelemetry.sdk.logs.LogProcessor; import io.opentelemetry.sdk.logs.ReadWriteLogRecord; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import java.util.ArrayList; import java.util.Collections; import java.util.Queue; @@ -101,7 +101,7 @@ public CompletableResultCode forceFlush() { } // Visible for testing - ArrayList getBatch() { + ArrayList getBatch() { return worker.batch; } @@ -133,7 +133,7 @@ private static final class Worker implements Runnable { private final BlockingQueue signal; private final AtomicReference flushRequested = new AtomicReference<>(); private volatile boolean continueWork = true; - private final ArrayList batch; + private final ArrayList batch; private Worker( LogExporter logExporter, @@ -202,7 +202,7 @@ public void run() { flush(); } while (!queue.isEmpty() && batch.size() < maxExportBatchSize) { - batch.add(queue.poll().toLogData()); + batch.add(queue.poll().toLogRecordData()); } if (batch.size() >= maxExportBatchSize || System.nanoTime() >= nextExportTime) { exportCurrentBatch(); @@ -229,7 +229,7 @@ private void flush() { while (logsToFlush > 0) { ReadWriteLogRecord logRecord = queue.poll(); assert logRecord != null; - batch.add(logRecord.toLogData()); + batch.add(logRecord.toLogRecordData()); logsToFlush--; if (batch.size() >= maxExportBatchSize) { exportCurrentBatch(); diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/InMemoryLogExporter.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/InMemoryLogExporter.java index 3b34f27e9af..ad16d4c12fe 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/InMemoryLogExporter.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/InMemoryLogExporter.java @@ -6,7 +6,7 @@ package io.opentelemetry.sdk.logs.export; import io.opentelemetry.sdk.common.CompletableResultCode; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -16,7 +16,7 @@ /** A {@link LogExporter} implementation that can be used to test OpenTelemetry integration. */ public final class InMemoryLogExporter implements LogExporter { - private final Queue finishedLogItems = new ConcurrentLinkedQueue<>(); + private final Queue finishedLogItems = new ConcurrentLinkedQueue<>(); private boolean isStopped = false; private InMemoryLogExporter() {} @@ -35,7 +35,7 @@ public static InMemoryLogExporter create() { * * @return a {@code List} of the finished {@code Log}s. */ - public List getFinishedLogItems() { + public List getFinishedLogItems() { return Collections.unmodifiableList(new ArrayList<>(finishedLogItems)); } @@ -54,7 +54,7 @@ public void reset() { *

If this is called after {@code shutdown}, this will return {@code ResultCode.FAILURE}. */ @Override - public CompletableResultCode export(Collection logs) { + public CompletableResultCode export(Collection logs) { if (isStopped) { return CompletableResultCode.ofFailure(); } diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/LogExporter.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/LogExporter.java index 97b5c82306e..3e536298d3e 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/LogExporter.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/LogExporter.java @@ -8,7 +8,7 @@ import io.opentelemetry.sdk.common.CompletableResultCode; import io.opentelemetry.sdk.logs.LogProcessor; import io.opentelemetry.sdk.logs.SdkLoggerProvider; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import java.io.Closeable; import java.util.ArrayList; import java.util.Arrays; @@ -17,8 +17,8 @@ import java.util.concurrent.TimeUnit; /** - * An exporter is responsible for taking a collection of {@link LogData}s and transmitting them to - * their ultimate destination. + * An exporter is responsible for taking a collection of {@link LogRecordData}s and transmitting + * them to their ultimate destination. */ public interface LogExporter extends Closeable { @@ -53,15 +53,15 @@ static LogExporter composite(Iterable exporters) { } /** - * Exports the collections of given {@link LogData}. + * Exports the collections of given {@link LogRecordData}. * - * @param logs the collection of {@link LogData} to be exported + * @param logs the collection of {@link LogRecordData} to be exported * @return the result of the export, which is often an asynchronous operation */ - CompletableResultCode export(Collection logs); + CompletableResultCode export(Collection logs); /** - * Exports the collection of {@link LogData} that have not yet been exported. + * Exports the collection of {@link LogRecordData} that have not yet been exported. * * @return the result of the flush, which is often an asynchronous operation */ diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/MultiLogExporter.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/MultiLogExporter.java index 216d03f57ee..c97d4a7b23a 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/MultiLogExporter.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/MultiLogExporter.java @@ -6,7 +6,7 @@ package io.opentelemetry.sdk.logs.export; import io.opentelemetry.sdk.common.CompletableResultCode; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -35,7 +35,7 @@ static LogExporter create(List logExporters) { } @Override - public CompletableResultCode export(Collection logs) { + public CompletableResultCode export(Collection logs) { List results = new ArrayList<>(logExporters.length); for (LogExporter logExporter : logExporters) { CompletableResultCode exportResult; diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/NoopLogExporter.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/NoopLogExporter.java index fe11b98c4b4..48762e606f8 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/NoopLogExporter.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/NoopLogExporter.java @@ -6,7 +6,7 @@ package io.opentelemetry.sdk.logs.export; import io.opentelemetry.sdk.common.CompletableResultCode; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import java.util.Collection; final class NoopLogExporter implements LogExporter { @@ -18,7 +18,7 @@ static LogExporter getInstance() { } @Override - public CompletableResultCode export(Collection logs) { + public CompletableResultCode export(Collection logs) { return CompletableResultCode.ofSuccess(); } diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/SimpleLogProcessor.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/SimpleLogProcessor.java index 70745e3f3de..9e85ab71113 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/SimpleLogProcessor.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/SimpleLogProcessor.java @@ -10,7 +10,7 @@ import io.opentelemetry.sdk.common.CompletableResultCode; import io.opentelemetry.sdk.logs.LogProcessor; import io.opentelemetry.sdk.logs.ReadWriteLogRecord; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import java.util.Collections; import java.util.List; import java.util.Set; @@ -20,7 +20,7 @@ import java.util.logging.Logger; /** - * An implementation of the {@link LogProcessor} that passes {@link LogData} directly to the + * An implementation of the {@link LogProcessor} that passes {@link LogRecordData} directly to the * configured exporter. * *

This processor will cause all logs to be exported directly as they finish, meaning each export @@ -60,7 +60,7 @@ public static LogProcessor create(LogExporter exporter) { @Override public void onEmit(ReadWriteLogRecord logRecord) { try { - List logs = Collections.singletonList(logRecord.toLogData()); + List logs = Collections.singletonList(logRecord.toLogRecordData()); CompletableResultCode result = logExporter.export(logs); pendingExports.add(result); result.whenComplete( diff --git a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLogRecordBuilderTest.java b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLogRecordBuilderTest.java index 5fc609f5c4e..a31275d62df 100644 --- a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLogRecordBuilderTest.java +++ b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLogRecordBuilderTest.java @@ -77,7 +77,7 @@ void emit_AllFields() { builder.setSeverity(severity); builder.setSeverityText(sevText); builder.emit(); - assertThat(emittedLog.get().toLogData()) + assertThat(emittedLog.get().toLogRecordData()) .hasResource(RESOURCE) .hasInstrumentationScope(SCOPE_INFO) .hasBody(bodyStr) @@ -96,7 +96,7 @@ void emit_NoFields() { builder.emit(); - assertThat(emittedLog.get().toLogData()) + assertThat(emittedLog.get().toLogRecordData()) .hasResource(RESOURCE) .hasInstrumentationScope(SCOPE_INFO) .hasBody(Body.empty().asString()) diff --git a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLoggerProviderTest.java b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLoggerProviderTest.java index 17edd615bd8..be9d97a5bbd 100644 --- a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLoggerProviderTest.java +++ b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLoggerProviderTest.java @@ -25,7 +25,7 @@ import io.opentelemetry.sdk.common.Clock; import io.opentelemetry.sdk.common.CompletableResultCode; import io.opentelemetry.sdk.common.InstrumentationScopeInfo; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.resources.Resource; import java.util.ArrayList; import java.util.List; @@ -215,7 +215,7 @@ void loggerBuilder_NoProcessor_UsesNoop() { @Test void loggerBuilder_WithLogProcessor() { Resource resource = Resource.builder().put("r1", "v1").build(); - AtomicReference logData = new AtomicReference<>(); + AtomicReference logRecordData = new AtomicReference<>(); sdkLoggerProvider = SdkLoggerProvider.builder() .setResource(resource) @@ -226,7 +226,7 @@ void loggerBuilder_WithLogProcessor() { logRecord.setAttribute(AttributeKey.stringKey("k1"), "new-v1"); // Add new attribute k3 logRecord.setAttribute(AttributeKey.stringKey("k3"), "v3"); - logData.set(logRecord.toLogData()); + logRecordData.set(logRecord.toLogRecordData()); }) .build(); @@ -248,7 +248,7 @@ void loggerBuilder_WithLogProcessor() { .setAttribute(AttributeKey.stringKey("k2"), "v2") .emit(); - assertThat(logData.get()) + assertThat(logRecordData.get()) .hasResource(resource) .hasInstrumentationScope(InstrumentationScopeInfo.create("test")) .hasEpochNanos(100) @@ -291,6 +291,6 @@ void canSetClock() { SdkLoggerProvider.builder().setClock(clock).addLogProcessor(logProcessor).build(); sdkLoggerProvider.loggerBuilder(null).build().logRecordBuilder().emit(); assertThat(seenLogs.size()).isEqualTo(1); - assertThat(seenLogs.get(0).toLogData().getEpochNanos()).isEqualTo(now); + assertThat(seenLogs.get(0).toLogRecordData().getEpochNanos()).isEqualTo(now); } } diff --git a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLoggerTest.java b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLoggerTest.java index 4e71e25975e..2d8f05ecdbe 100644 --- a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLoggerTest.java +++ b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/SdkLoggerTest.java @@ -52,7 +52,7 @@ void logRecordBuilder() { // Have to test through the builder logRecordBuilder.emit(); - assertThat(seenLog.get().toLogData()).hasBody("foo").hasEpochNanos(5); + assertThat(seenLog.get().toLogRecordData()).hasBody("foo").hasEpochNanos(5); } @Test @@ -82,7 +82,7 @@ void logRecordBuilder_maxAttributeLength() { .build()) .emit(); - Attributes attributes = seenLog.get().toLogData().getAttributes(); + Attributes attributes = seenLog.get().toLogRecordData().getAttributes(); assertThat(attributes) .containsEntry("string", strVal) @@ -117,7 +117,7 @@ void logRecordBuilder_maxAttributes() { } builder.emit(); - assertThat(seenLog.get().toLogData()) + assertThat(seenLog.get().toLogRecordData()) .hasAttributes(expectedAttributes.build()) .hasTotalAttributeCount(maxNumberOfAttrs * 2); } diff --git a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/BatchLogProcessorTest.java b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/BatchLogProcessorTest.java index bb3f9445093..15307987da4 100644 --- a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/BatchLogProcessorTest.java +++ b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/BatchLogProcessorTest.java @@ -19,7 +19,7 @@ import io.opentelemetry.internal.testing.slf4j.SuppressLogger; import io.opentelemetry.sdk.common.CompletableResultCode; import io.opentelemetry.sdk.logs.SdkLoggerProvider; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.testing.assertj.LogAssertions; import java.util.ArrayList; import java.util.Arrays; @@ -120,11 +120,11 @@ void emitMultipleLogs() { emitLog(loggerProvider, LOG_MESSAGE_1); emitLog(loggerProvider, LOG_MESSAGE_2); - List exported = waitingLogExporter.waitForExport(); + List exported = waitingLogExporter.waitForExport(); assertThat(exported) .satisfiesExactly( - logData -> assertThat(logData).hasBody(LOG_MESSAGE_1), - logData -> assertThat(logData).hasBody(LOG_MESSAGE_2)); + logRecordData -> assertThat(logRecordData).hasBody(LOG_MESSAGE_1), + logRecordData -> assertThat(logRecordData).hasBody(LOG_MESSAGE_2)); } @Test @@ -155,7 +155,7 @@ void emitMoreLogsThanBufferSize() { () -> assertThat(logExporter.getExported()) .hasSize(6) - .allSatisfy(logData -> assertThat(logData).hasBody(LOG_MESSAGE_1))); + .allSatisfy(logRecordData -> assertThat(logRecordData).hasBody(LOG_MESSAGE_1))); } @Test @@ -176,7 +176,7 @@ void forceEmit() { for (int i = 0; i < 50; i++) { emitLog(sdkLoggerProvider, "notExported"); } - List exported = waitingLogExporter.waitForExport(); + List exported = waitingLogExporter.waitForExport(); assertThat(exported).isNotNull(); assertThat(exported.size()).isEqualTo(49); @@ -211,18 +211,18 @@ void emitLogsToMultipleExporters() { emitLog(sdkLoggerProvider, LOG_MESSAGE_1); emitLog(sdkLoggerProvider, LOG_MESSAGE_2); - List exported1 = waitingLogExporter1.waitForExport(); - List exported2 = waitingLogExporter2.waitForExport(); + List exported1 = waitingLogExporter1.waitForExport(); + List exported2 = waitingLogExporter2.waitForExport(); assertThat(exported1) .hasSize(2) .satisfiesExactly( - logData -> assertThat(logData).hasBody(LOG_MESSAGE_1), - logData -> assertThat(logData).hasBody(LOG_MESSAGE_2)); + logRecordData -> assertThat(logRecordData).hasBody(LOG_MESSAGE_1), + logRecordData -> assertThat(logRecordData).hasBody(LOG_MESSAGE_2)); assertThat(exported2) .hasSize(2) .satisfiesExactly( - logData -> assertThat(logData).hasBody(LOG_MESSAGE_1), - logData -> assertThat(logData).hasBody(LOG_MESSAGE_2)); + logRecordData -> assertThat(logRecordData).hasBody(LOG_MESSAGE_1), + logRecordData -> assertThat(logRecordData).hasBody(LOG_MESSAGE_2)); } @Test @@ -263,7 +263,7 @@ void emitMoreLogsThanTheMaximumLimit() { blockingLogExporter.unblock(); // While we wait for maxQueuedLogs we ensure that the queue is also empty after this. - List exported = waitingLogExporter.waitForExport(); + List exported = waitingLogExporter.waitForExport(); assertThat(exported).isNotNull(); assertThat(exported).hasSize(maxQueuedLogs + 1); @@ -307,13 +307,15 @@ void exporterThrowsException() { .build(); emitLog(sdkLoggerProvider, LOG_MESSAGE_1); - List exported = waitingLogExporter.waitForExport(); - assertThat(exported).satisfiesExactly(logData -> assertThat(logData).hasBody(LOG_MESSAGE_1)); + List exported = waitingLogExporter.waitForExport(); + assertThat(exported) + .satisfiesExactly(logRecordData -> assertThat(logRecordData).hasBody(LOG_MESSAGE_1)); waitingLogExporter.reset(); // Continue to export after the exception was received. emitLog(sdkLoggerProvider, LOG_MESSAGE_2); exported = waitingLogExporter.waitForExport(); - assertThat(exported).satisfiesExactly(logData -> assertThat(logData).hasBody(LOG_MESSAGE_2)); + assertThat(exported) + .satisfiesExactly(logRecordData -> assertThat(logRecordData).hasBody(LOG_MESSAGE_2)); } @Test @@ -382,8 +384,9 @@ void shutdownFlushes() { // Force a shutdown, which forces processing of all remaining logs. sdkLoggerProvider.shutdown().join(10, TimeUnit.SECONDS); - List exported = waitingLogExporter.getExported(); - assertThat(exported).satisfiesExactly(logData -> assertThat(logData).hasBody(LOG_MESSAGE_2)); + List exported = waitingLogExporter.getExported(); + assertThat(exported) + .satisfiesExactly(logRecordData -> assertThat(logRecordData).hasBody(LOG_MESSAGE_2)); assertThat(waitingLogExporter.shutDownCalled.get()).isTrue(); } @@ -418,7 +421,7 @@ private enum State { State state = State.WAIT_TO_BLOCK; @Override - public CompletableResultCode export(Collection logs) { + public CompletableResultCode export(Collection logs) { synchronized (monitor) { while (state != State.UNBLOCKED) { try { @@ -469,11 +472,11 @@ private static class CompletableLogExporter implements LogExporter { private final List results = new ArrayList<>(); - private final List exported = new ArrayList<>(); + private final List exported = new ArrayList<>(); private volatile boolean succeeded; - List getExported() { + List getExported() { return exported; } @@ -483,7 +486,7 @@ void succeed() { } @Override - public CompletableResultCode export(Collection logs) { + public CompletableResultCode export(Collection logs) { exported.addAll(logs); if (succeeded) { return CompletableResultCode.ofSuccess(); @@ -510,7 +513,7 @@ public CompletableResultCode shutdown() { static class WaitingLogExporter implements LogExporter { - private final List logDataList = new ArrayList<>(); + private final List logRecordDataList = new ArrayList<>(); private final int numberToWaitFor; private final CompletableResultCode exportResultCode; private CountDownLatch countDownLatch; @@ -528,21 +531,21 @@ static class WaitingLogExporter implements LogExporter { this.timeout = timeout; } - List getExported() { - List result = new ArrayList<>(logDataList); - logDataList.clear(); + List getExported() { + List result = new ArrayList<>(logRecordDataList); + logRecordDataList.clear(); return result; } /** * Waits until we received {@link #numberToWaitFor} logs to export. Returns the list of exported - * {@link LogData} objects, otherwise {@code null} if the current thread is interrupted. + * {@link LogRecordData} objects, otherwise {@code null} if the current thread is interrupted. * - * @return the list of exported {@link LogData} objects, otherwise {@code null} if the current - * thread is interrupted. + * @return the list of exported {@link LogRecordData} objects, otherwise {@code null} if the + * current thread is interrupted. */ @Nullable - List waitForExport() { + List waitForExport() { try { countDownLatch.await(timeout, TimeUnit.SECONDS); } catch (InterruptedException e) { @@ -554,8 +557,8 @@ List waitForExport() { } @Override - public CompletableResultCode export(Collection logs) { - this.logDataList.addAll(logs); + public CompletableResultCode export(Collection logs) { + this.logRecordDataList.addAll(logs); for (int i = 0; i < logs.size(); i++) { countDownLatch.countDown(); } diff --git a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/InMemoryLogExporterTest.java b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/InMemoryLogExporterTest.java index c91a680c4ff..5763a730d00 100644 --- a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/InMemoryLogExporterTest.java +++ b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/InMemoryLogExporterTest.java @@ -10,9 +10,9 @@ import io.opentelemetry.api.logs.Logger; import io.opentelemetry.sdk.logs.SdkLoggerProvider; -import io.opentelemetry.sdk.logs.data.LogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; import io.opentelemetry.sdk.testing.assertj.LogAssertions; -import io.opentelemetry.sdk.testing.logs.TestLogData; +import io.opentelemetry.sdk.testing.logs.TestLogRecordData; import java.util.Collections; import java.util.List; import org.junit.jupiter.api.AfterEach; @@ -44,7 +44,7 @@ void getFinishedLogItems() { logger.logRecordBuilder().setSeverity(DEBUG).setBody("message 2").emit(); logger.logRecordBuilder().setSeverity(DEBUG).setBody("message 3").emit(); - List logItems = exporter.getFinishedLogItems(); + List logItems = exporter.getFinishedLogItems(); assertThat(logItems).isNotNull(); assertThat(logItems.size()).isEqualTo(3); LogAssertions.assertThat(logItems.get(0)).hasBody("message 1"); @@ -57,7 +57,7 @@ void reset() { logger.logRecordBuilder().setSeverity(DEBUG).setBody("message 1").emit(); logger.logRecordBuilder().setSeverity(DEBUG).setBody("message 2").emit(); logger.logRecordBuilder().setSeverity(DEBUG).setBody("message 3").emit(); - List logItems = exporter.getFinishedLogItems(); + List logItems = exporter.getFinishedLogItems(); assertThat(logItems).isNotNull(); assertThat(logItems.size()).isEqualTo(3); // Reset then expect no items in memory. @@ -70,7 +70,7 @@ void shutdown() { logger.logRecordBuilder().setSeverity(DEBUG).setBody("message 1").emit(); logger.logRecordBuilder().setSeverity(DEBUG).setBody("message 2").emit(); logger.logRecordBuilder().setSeverity(DEBUG).setBody("message 3").emit(); - List logItems = exporter.getFinishedLogItems(); + List logItems = exporter.getFinishedLogItems(); assertThat(logItems).isNotNull(); assertThat(logItems.size()).isEqualTo(3); // Shutdown then expect no items in memory. @@ -83,13 +83,14 @@ void shutdown() { @Test void export_ReturnCode() { - LogData logData = TestLogData.builder().setBody("message 1").setSeverity(DEBUG).build(); - assertThat(exporter.export(Collections.singletonList(logData)).isSuccess()).isTrue(); + LogRecordData logRecordData = + TestLogRecordData.builder().setBody("message 1").setSeverity(DEBUG).build(); + assertThat(exporter.export(Collections.singletonList(logRecordData)).isSuccess()).isTrue(); exporter.shutdown(); // After shutdown no more export. - assertThat(exporter.export(Collections.singletonList(logData)).isSuccess()).isFalse(); + assertThat(exporter.export(Collections.singletonList(logRecordData)).isSuccess()).isFalse(); exporter.reset(); // Reset does not do anything if already shutdown. - assertThat(exporter.export(Collections.singletonList(logData)).isSuccess()).isFalse(); + assertThat(exporter.export(Collections.singletonList(logRecordData)).isSuccess()).isFalse(); } } diff --git a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/MultiLogExporterTest.java b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/MultiLogExporterTest.java index 29981cb31de..c5094392687 100644 --- a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/MultiLogExporterTest.java +++ b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/MultiLogExporterTest.java @@ -13,8 +13,8 @@ import io.opentelemetry.api.logs.Severity; import io.opentelemetry.internal.testing.slf4j.SuppressLogger; import io.opentelemetry.sdk.common.CompletableResultCode; -import io.opentelemetry.sdk.logs.data.LogData; -import io.opentelemetry.sdk.testing.logs.TestLogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; +import io.opentelemetry.sdk.testing.logs.TestLogRecordData; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -29,9 +29,9 @@ class MultiLogExporterTest { @Mock private LogExporter logExporter1; @Mock private LogExporter logExporter2; - private static final List LOG_LIST = + private static final List LOG_LIST = Collections.singletonList( - TestLogData.builder().setBody("Message!").setSeverity(Severity.DEBUG).build()); + TestLogRecordData.builder().setBody("Message!").setSeverity(Severity.DEBUG).build()); @Test void empty() { diff --git a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/SimpleLogProcessorTest.java b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/SimpleLogProcessorTest.java index 8f52aabbc52..d17ade98811 100644 --- a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/SimpleLogProcessorTest.java +++ b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/SimpleLogProcessorTest.java @@ -19,8 +19,8 @@ import io.opentelemetry.sdk.common.CompletableResultCode; import io.opentelemetry.sdk.logs.LogProcessor; import io.opentelemetry.sdk.logs.ReadWriteLogRecord; -import io.opentelemetry.sdk.logs.data.LogData; -import io.opentelemetry.sdk.testing.logs.TestLogData; +import io.opentelemetry.sdk.logs.data.LogRecordData; +import io.opentelemetry.sdk.testing.logs.TestLogRecordData; import java.util.Collections; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -34,7 +34,7 @@ @MockitoSettings(strictness = Strictness.LENIENT) class SimpleLogProcessorTest { - private static final LogData LOG_DATA = TestLogData.builder().build(); + private static final LogRecordData LOG_RECORD_DATA = TestLogRecordData.builder().build(); @Mock private LogExporter logExporter; @Mock private ReadWriteLogRecord readWriteLogRecord; @@ -46,7 +46,7 @@ void setUp() { logProcessor = SimpleLogProcessor.create(logExporter); when(logExporter.export(anyCollection())).thenReturn(CompletableResultCode.ofSuccess()); when(logExporter.shutdown()).thenReturn(CompletableResultCode.ofSuccess()); - when(readWriteLogRecord.toLogData()).thenReturn(LOG_DATA); + when(readWriteLogRecord.toLogRecordData()).thenReturn(LOG_RECORD_DATA); } @Test @@ -59,7 +59,7 @@ void create_NullExporter() { @Test void onEmit() { logProcessor.onEmit(readWriteLogRecord); - verify(logExporter).export(Collections.singletonList(LOG_DATA)); + verify(logExporter).export(Collections.singletonList(LOG_RECORD_DATA)); } @Test @@ -81,7 +81,7 @@ void forceFlush() { logProcessor.onEmit(readWriteLogRecord); logProcessor.onEmit(readWriteLogRecord); - verify(logExporter, times(2)).export(Collections.singletonList(LOG_DATA)); + verify(logExporter, times(2)).export(Collections.singletonList(LOG_RECORD_DATA)); CompletableResultCode flush = logProcessor.forceFlush(); assertThat(flush.isDone()).isFalse(); @@ -104,7 +104,7 @@ void shutdown() { logProcessor.onEmit(readWriteLogRecord); logProcessor.onEmit(readWriteLogRecord); - verify(logExporter, times(2)).export(Collections.singletonList(LOG_DATA)); + verify(logExporter, times(2)).export(Collections.singletonList(LOG_RECORD_DATA)); CompletableResultCode shutdown = logProcessor.shutdown(); assertThat(shutdown.isDone()).isFalse(); From 0d381fbbbb54ad2ea9a972e3ec9614095f27a072 Mon Sep 17 00:00:00 2001 From: Jack Berg Date: Thu, 22 Sep 2022 15:34:03 -0500 Subject: [PATCH 2/2] spotless --- .../opentelemetry/sdk/autoconfigure/OtlpGrpcConfigTest.java | 6 ++++-- .../opentelemetry/sdk/autoconfigure/OtlpGrpcRetryTest.java | 3 ++- .../opentelemetry/sdk/autoconfigure/OtlpHttpRetryTest.java | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcConfigTest.java b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcConfigTest.java index 44676991c8a..d0449ab8fab 100644 --- a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcConfigTest.java +++ b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcConfigTest.java @@ -114,7 +114,8 @@ void configureExportersGeneral() { assertThat(logExporter) .extracting("delegate.client.callTimeoutMillis", INTEGER) .isEqualTo(TimeUnit.SECONDS.toMillis(15)); - assertThat(logExporter.export(LOG_RECORD_DATA).join(15, TimeUnit.SECONDS).isSuccess()).isTrue(); + assertThat(logExporter.export(LOG_RECORD_DATA).join(15, TimeUnit.SECONDS).isSuccess()) + .isTrue(); assertThat(server.logRequests).hasSize(1); assertThat(server.requestHeaders) .anyMatch( @@ -227,7 +228,8 @@ public void configureLogExporter() { assertThat(logExporter) .extracting("delegate.client.callTimeoutMillis", INTEGER) .isEqualTo(TimeUnit.SECONDS.toMillis(15)); - assertThat(logExporter.export(LOG_RECORD_DATA).join(15, TimeUnit.SECONDS).isSuccess()).isTrue(); + assertThat(logExporter.export(LOG_RECORD_DATA).join(15, TimeUnit.SECONDS).isSuccess()) + .isTrue(); assertThat(server.logRequests).hasSize(1); assertThat(server.requestHeaders) .anyMatch( diff --git a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcRetryTest.java b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcRetryTest.java index 5c1734a6819..c508f38d462 100644 --- a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcRetryTest.java +++ b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcRetryTest.java @@ -102,7 +102,8 @@ void configureLogExporterRetryPolicy() { LogExporterConfiguration.configureOtlpLogs( DefaultConfigProperties.createForTest(props), MeterProvider.noop())) { - testRetryableStatusCodes(() -> LOG_RECORD_DATA, logExporter::export, server.logRequests::size); + testRetryableStatusCodes( + () -> LOG_RECORD_DATA, logExporter::export, server.logRequests::size); testDefaultRetryPolicy(() -> LOG_RECORD_DATA, logExporter::export, server.logRequests::size); } } diff --git a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpRetryTest.java b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpRetryTest.java index 5dde94b4610..da64fffebba 100644 --- a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpRetryTest.java +++ b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpRetryTest.java @@ -108,7 +108,8 @@ void configureLogExporterRetryPolicy() { LogExporterConfiguration.configureOtlpLogs( DefaultConfigProperties.createForTest(props), MeterProvider.noop())) { - testRetryableStatusCodes(() -> LOG_RECORD_DATA, logExporter::export, server.logRequests::size); + testRetryableStatusCodes( + () -> LOG_RECORD_DATA, logExporter::export, server.logRequests::size); testDefaultRetryPolicy(() -> LOG_RECORD_DATA, logExporter::export, server.logRequests::size); } }