From 647ed91c151c2a84bb2fff028bd892f4f6cfdac7 Mon Sep 17 00:00:00 2001 From: jack-berg <34418638+jack-berg@users.noreply.github.com> Date: Mon, 26 Sep 2022 10:30:59 -0500 Subject: [PATCH] Rename LogData to LogRecordData (#4774) * Rename LogData to LogRecordData * spotless --- .../OtlpJsonLoggingLogRecordExporter.java | 8 +-- .../OtlpJsonLoggingLogRecordExporterTest.java | 12 ++-- .../logging/SystemOutLogRecordExporter.java | 8 +-- .../SystemOutLogRecordExporterTest.java | 10 +-- .../internal/otlp/logs/LogMarshaler.java | 17 ++--- .../otlp/logs/LogsRequestMarshaler.java | 6 +- .../otlp/logs/ResourceLogsMarshaler.java | 10 +-- .../otlp/logs/LogsRequestMarshalerTest.java | 8 +-- .../http/logs/OtlpHttpLogRecordExporter.java | 4 +- .../otlp/logs/OtlpGrpcLogRecordExporter.java | 4 +- .../logs/OtlpHttpLogRecordExporterTest.java | 10 +-- .../logs/OtlpGrpcLogRecordExporterTest.java | 14 ++-- .../OtlpGrpcNettyLogRecordExporterTest.java | 14 ++-- ...pGrpcNettyShadedLogRecordExporterTest.java | 14 ++-- ...pGrpcNettyOkHttpLogRecordExporterTest.java | 14 ++-- .../GrpcLogRecordExporterBuilderWrapper.java | 24 +++---- .../testing/internal/TelemetryExporter.java | 8 +-- .../internal/TelemetryExporterBuilder.java | 4 +- .../LogRecordExporterCustomizer.java | 6 +- ...ConfigurableLogRecordExporterProvider.java | 4 +- .../sdk/autoconfigure/OtlpGrpcConfigTest.java | 8 +-- .../sdk/autoconfigure/OtlpGrpcRetryTest.java | 11 +-- .../OtlpGrpcServerExtension.java | 8 +-- .../sdk/autoconfigure/OtlpHttpRetryTest.java | 11 +-- .../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 +-- .../export/InMemoryLogRecordExporter.java | 8 +-- .../sdk/logs/export/LogRecordExporter.java | 14 ++-- .../logs/export/MultiLogRecordExporter.java | 4 +- .../logs/export/NoopLogRecordExporter.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 | 68 ++++++++++--------- .../export/InMemoryLogRecordExporterTest.java | 19 +++--- .../export/MultiLogRecordExporterTest.java | 8 +-- .../logs/export/SimpleLogProcessorTest.java | 14 ++-- 49 files changed, 272 insertions(+), 262 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/OtlpJsonLoggingLogRecordExporter.java b/exporters/logging-otlp/src/main/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingLogRecordExporter.java index a886c77b887..ed5b810f954 100644 --- a/exporters/logging-otlp/src/main/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingLogRecordExporter.java +++ b/exporters/logging-otlp/src/main/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingLogRecordExporter.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.LogRecordExporter; import java.io.IOException; import java.util.Collection; @@ -19,8 +19,8 @@ import java.util.logging.Logger; /** - * A {@link LogRecordExporter} which writes {@linkplain LogData logs} to a {@link Logger} in OTLP - * JSON format. Each log line will include a single {@code ResourceLogs}. + * A {@link LogRecordExporter} 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 OtlpJsonLoggingLogRecordExporter implements LogRecordExporter { @@ -35,7 +35,7 @@ public static LogRecordExporter create() { private OtlpJsonLoggingLogRecordExporter() {} @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/OtlpJsonLoggingLogRecordExporterTest.java b/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingLogRecordExporterTest.java index f7fa58e5933..876f13a7143 100644 --- a/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingLogRecordExporterTest.java +++ b/exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingLogRecordExporterTest.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.LogRecordExporter; 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 OtlpJsonLoggingLogRecordExporterTest { 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 OtlpJsonLoggingLogRecordExporterTest { 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/SystemOutLogRecordExporter.java b/exporters/logging/src/main/java/io/opentelemetry/exporter/logging/SystemOutLogRecordExporter.java index 2976fbd1e7e..bbd4839b59f 100644 --- a/exporters/logging/src/main/java/io/opentelemetry/exporter/logging/SystemOutLogRecordExporter.java +++ b/exporters/logging/src/main/java/io/opentelemetry/exporter/logging/SystemOutLogRecordExporter.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.LogRecordExporter; import java.time.Instant; import java.time.ZoneOffset; @@ -35,10 +35,10 @@ public static SystemOutLogRecordExporter create() { private SystemOutLogRecordExporter() {} @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); @@ -52,7 +52,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/SystemOutLogRecordExporterTest.java b/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/SystemOutLogRecordExporterTest.java index 454c997d9dc..b0351cc94af 100644 --- a/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/SystemOutLogRecordExporterTest.java +++ b/exporters/logging/src/test/java/io/opentelemetry/exporter/logging/SystemOutLogRecordExporterTest.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(); SystemOutLogRecordExporter.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/OtlpHttpLogRecordExporter.java b/exporters/otlp/logs/src/main/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogRecordExporter.java index 572302e8f90..752fbcad99a 100644 --- a/exporters/otlp/logs/src/main/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogRecordExporter.java +++ b/exporters/otlp/logs/src/main/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogRecordExporter.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.LogRecordExporter; import java.util.Collection; import javax.annotation.concurrent.ThreadSafe; @@ -48,7 +48,7 @@ public static OtlpHttpLogRecordExporterBuilder 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/OtlpGrpcLogRecordExporter.java b/exporters/otlp/logs/src/main/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcLogRecordExporter.java index e22d26fec2b..20873341d8d 100644 --- a/exporters/otlp/logs/src/main/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcLogRecordExporter.java +++ b/exporters/otlp/logs/src/main/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcLogRecordExporter.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.LogRecordExporter; import java.util.Collection; import javax.annotation.concurrent.ThreadSafe; @@ -50,7 +50,7 @@ public static OtlpGrpcLogRecordExporterBuilder 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/OtlpHttpLogRecordExporterTest.java b/exporters/otlp/logs/src/test/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogRecordExporterTest.java index 846baee5c21..050fcdde658 100644 --- a/exporters/otlp/logs/src/test/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogRecordExporterTest.java +++ b/exporters/otlp/logs/src/test/java/io/opentelemetry/exporter/otlp/http/logs/OtlpHttpLogRecordExporterTest.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; @@ -317,7 +317,7 @@ void testServerErrorParseError() { private static ExportLogsServiceRequest exportAndAssertResult( OtlpHttpLogRecordExporter otlpHttpLogRecordExporter, boolean expectedResult) { - List logs = Collections.singletonList(generateFakeLog()); + List logs = Collections.singletonList(generateFakeLog()); CompletableResultCode resultCode = otlpHttpLogRecordExporter.export(logs); resultCode.join(10, TimeUnit.SECONDS); assertThat(resultCode.isSuccess()).isEqualTo(expectedResult); @@ -347,8 +347,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/OtlpGrpcLogRecordExporterTest.java b/exporters/otlp/logs/src/test/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcLogRecordExporterTest.java index 0db0a45039f..acf485b243d 100644 --- a/exporters/otlp/logs/src/test/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcLogRecordExporterTest.java +++ b/exporters/otlp/logs/src/test/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcLogRecordExporterTest.java @@ -19,16 +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 OtlpGrpcLogRecordExporterTest - extends AbstractGrpcTelemetryExporterTest { + extends AbstractGrpcTelemetryExporterTest { OtlpGrpcLogRecordExporterTest() { super("log", ResourceLogs.getDefaultInstance()); @@ -51,13 +51,13 @@ void usingOkHttp() throws Exception { } @Override - protected TelemetryExporterBuilder exporterBuilder() { + protected TelemetryExporterBuilder exporterBuilder() { return TelemetryExporterBuilder.wrap(OtlpGrpcLogRecordExporter.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()) @@ -70,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/OtlpGrpcNettyLogRecordExporterTest.java b/exporters/otlp/logs/src/testGrpcNetty/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyLogRecordExporterTest.java index 510710edb31..00ae6db3e00 100644 --- a/exporters/otlp/logs/src/testGrpcNetty/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyLogRecordExporterTest.java +++ b/exporters/otlp/logs/src/testGrpcNetty/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyLogRecordExporterTest.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 OtlpGrpcNettyLogRecordExporterTest - extends AbstractGrpcTelemetryExporterTest { + extends AbstractGrpcTelemetryExporterTest { OtlpGrpcNettyLogRecordExporterTest() { super("log", ResourceLogs.getDefaultInstance()); @@ -57,14 +57,14 @@ void usingGrpc() throws Exception { } @Override - protected TelemetryExporterBuilder exporterBuilder() { + protected TelemetryExporterBuilder exporterBuilder() { return ManagedChannelTelemetryExporterBuilder.wrap( TelemetryExporterBuilder.wrap(OtlpGrpcLogRecordExporter.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/OtlpGrpcNettyShadedLogRecordExporterTest.java b/exporters/otlp/logs/src/testGrpcNettyShaded/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyShadedLogRecordExporterTest.java index 35c76cd3007..0bb1300a87e 100644 --- a/exporters/otlp/logs/src/testGrpcNettyShaded/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyShadedLogRecordExporterTest.java +++ b/exporters/otlp/logs/src/testGrpcNettyShaded/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyShadedLogRecordExporterTest.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 OtlpGrpcNettyShadedLogRecordExporterTest - extends AbstractGrpcTelemetryExporterTest { + extends AbstractGrpcTelemetryExporterTest { OtlpGrpcNettyShadedLogRecordExporterTest() { super("log", ResourceLogs.getDefaultInstance()); @@ -45,14 +45,14 @@ void usingGrpc() throws Exception { } @Override - protected TelemetryExporterBuilder exporterBuilder() { + protected TelemetryExporterBuilder exporterBuilder() { return ManagedChannelTelemetryExporterBuilder.wrap( TelemetryExporterBuilder.wrap(OtlpGrpcLogRecordExporter.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/OtlpGrpcNettyOkHttpLogRecordExporterTest.java b/exporters/otlp/logs/src/testGrpcOkhttp/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyOkHttpLogRecordExporterTest.java index 06c2da96953..01a73674286 100644 --- a/exporters/otlp/logs/src/testGrpcOkhttp/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyOkHttpLogRecordExporterTest.java +++ b/exporters/otlp/logs/src/testGrpcOkhttp/java/io/opentelemetry/exporter/otlp/logs/OtlpGrpcNettyOkHttpLogRecordExporterTest.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 OtlpGrpcNettyOkHttpLogRecordExporterTest - extends AbstractGrpcTelemetryExporterTest { + extends AbstractGrpcTelemetryExporterTest { OtlpGrpcNettyOkHttpLogRecordExporterTest() { super("log", ResourceLogs.getDefaultInstance()); @@ -45,14 +45,14 @@ void usingGrpc() throws Exception { } @Override - protected TelemetryExporterBuilder exporterBuilder() { + protected TelemetryExporterBuilder exporterBuilder() { return ManagedChannelTelemetryExporterBuilder.wrap( TelemetryExporterBuilder.wrap(OtlpGrpcLogRecordExporter.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/GrpcLogRecordExporterBuilderWrapper.java b/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/GrpcLogRecordExporterBuilderWrapper.java index c0cdcb1414d..6f5baf6c1c8 100644 --- a/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/GrpcLogRecordExporterBuilderWrapper.java +++ b/exporters/otlp/testing-internal/src/main/java/io/opentelemetry/exporter/otlp/testing/internal/GrpcLogRecordExporterBuilderWrapper.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.OtlpGrpcLogRecordExporterBuilder; -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 GrpcLogRecordExporterBuilderWrapper implements TelemetryExporterBuilder { +final class GrpcLogRecordExporterBuilderWrapper implements TelemetryExporterBuilder { private final OtlpGrpcLogRecordExporterBuilder builder; GrpcLogRecordExporterBuilderWrapper(OtlpGrpcLogRecordExporterBuilder builder) { @@ -21,63 +21,63 @@ final class GrpcLogRecordExporterBuilderWrapper implements TelemetryExporterBuil } @Override - public 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 59039c8ff1c..a44ec5dd036 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.LogRecordExporter; import io.opentelemetry.sdk.metrics.data.MetricData; import io.opentelemetry.sdk.metrics.export.MetricExporter; @@ -47,10 +47,10 @@ public CompletableResultCode shutdown() { } /** Wraps a LogRecordExporter. */ - static TelemetryExporter wrap(LogRecordExporter exporter) { - return new TelemetryExporter() { + static TelemetryExporter wrap(LogRecordExporter 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 d084e531144..b1a9f3b0bdf 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.OtlpGrpcLogRecordExporterBuilder; 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(OtlpGrpcLogRecordExporterBuilder builder) { + static TelemetryExporterBuilder wrap(OtlpGrpcLogRecordExporterBuilder builder) { return new GrpcLogRecordExporterBuilderWrapper(builder); } diff --git a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterCustomizer.java b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterCustomizer.java index 8b5b341e54f..89f5bb66380 100644 --- a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterCustomizer.java +++ b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterCustomizer.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.LogRecordExporter; import java.util.Collection; import java.util.stream.Collectors; @@ -21,8 +21,8 @@ public void customize(AutoConfigurationCustomizer autoConfiguration) { (delegate, config) -> new LogRecordExporter() { @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/TestConfigurableLogRecordExporterProvider.java b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/TestConfigurableLogRecordExporterProvider.java index 5da73b27bd9..df4df0e9f74 100644 --- a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/TestConfigurableLogRecordExporterProvider.java +++ b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/TestConfigurableLogRecordExporterProvider.java @@ -8,7 +8,7 @@ import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; import io.opentelemetry.sdk.autoconfigure.spi.logs.ConfigurableLogRecordExporterProvider; 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.LogRecordExporter; import java.util.Collection; @@ -33,7 +33,7 @@ public TestLogRecordExporter(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 a349dec426a..5fc3bb73b02 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.LogRecordExporter; 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(logRecordExporter) .extracting("delegate.client.callTimeoutMillis", INTEGER) .isEqualTo(TimeUnit.SECONDS.toMillis(15)); - assertThat(logRecordExporter.export(LOG_DATA).join(15, TimeUnit.SECONDS).isSuccess()) + assertThat(logRecordExporter.export(LOG_RECORD_DATA).join(15, TimeUnit.SECONDS).isSuccess()) .isTrue(); assertThat(server.logRequests).hasSize(1); assertThat(server.requestHeaders) @@ -228,7 +228,7 @@ public void configureLogRecordExporter() { assertThat(logRecordExporter) .extracting("delegate.client.callTimeoutMillis", INTEGER) .isEqualTo(TimeUnit.SECONDS.toMillis(15)); - assertThat(logRecordExporter.export(LOG_DATA).join(15, TimeUnit.SECONDS).isSuccess()) + assertThat(logRecordExporter.export(LOG_RECORD_DATA).join(15, TimeUnit.SECONDS).isSuccess()) .isTrue(); assertThat(server.logRequests).hasSize(1); assertThat(server.requestHeaders) 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 1daf36919f8..7b080a74a15 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.LogRecordExporter; 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) @@ -101,9 +101,10 @@ void configureLogRecordExporterRetryPolicy() { try (LogRecordExporter logRecordExporter = LogRecordExporterConfiguration.configureOtlpLogs( DefaultConfigProperties.createForTest(props), MeterProvider.noop())) { - - testRetryableStatusCodes(() -> LOG_DATA, logRecordExporter::export, server.logRequests::size); - testDefaultRetryPolicy(() -> LOG_DATA, logRecordExporter::export, server.logRequests::size); + testRetryableStatusCodes( + () -> LOG_RECORD_DATA, logRecordExporter::export, server.logRequests::size); + testDefaultRetryPolicy( + () -> LOG_RECORD_DATA, logRecordExporter::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 2030029fd1b..dc81a25e374 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.LogRecordExporter; 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(); @@ -107,9 +107,10 @@ void configureLogRecordExporterRetryPolicy() { try (LogRecordExporter logRecordExporter = LogRecordExporterConfiguration.configureOtlpLogs( DefaultConfigProperties.createForTest(props), MeterProvider.noop())) { - - testRetryableStatusCodes(() -> LOG_DATA, logRecordExporter::export, server.logRequests::size); - testDefaultRetryPolicy(() -> LOG_DATA, logRecordExporter::export, server.logRequests::size); + testRetryableStatusCodes( + () -> LOG_RECORD_DATA, logRecordExporter::export, server.logRequests::size); + testDefaultRetryPolicy( + () -> LOG_RECORD_DATA, logRecordExporter::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 8388d034fa5..dd3faf0f28d 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; } @@ -134,7 +134,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( LogRecordExporter logRecordExporter, @@ -203,7 +203,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(); @@ -230,7 +230,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/InMemoryLogRecordExporter.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/InMemoryLogRecordExporter.java index 6377a27e84f..81cea4cfd10 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/InMemoryLogRecordExporter.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/InMemoryLogRecordExporter.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; @@ -18,7 +18,7 @@ * A {@link LogRecordExporter} implementation that can be used to test OpenTelemetry integration. */ public final class InMemoryLogRecordExporter implements LogRecordExporter { - private final Queue finishedLogItems = new ConcurrentLinkedQueue<>(); + private final Queue finishedLogItems = new ConcurrentLinkedQueue<>(); private boolean isStopped = false; private InMemoryLogRecordExporter() {} @@ -37,7 +37,7 @@ public static InMemoryLogRecordExporter create() { * * @return a {@code List} of the finished {@code Log}s. */ - public List getFinishedLogItems() { + public List getFinishedLogItems() { return Collections.unmodifiableList(new ArrayList<>(finishedLogItems)); } @@ -56,7 +56,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/LogRecordExporter.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/LogRecordExporter.java index 5ce3495dbb2..44d3e021033 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/LogRecordExporter.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/LogRecordExporter.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 LogRecordExporter extends Closeable { @@ -55,15 +55,15 @@ static LogRecordExporter 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/MultiLogRecordExporter.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/MultiLogRecordExporter.java index 3cf2dce14e0..ff358794494 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/MultiLogRecordExporter.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/MultiLogRecordExporter.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 LogRecordExporter create(List logRecordExporters) { } @Override - public CompletableResultCode export(Collection logs) { + public CompletableResultCode export(Collection logs) { List results = new ArrayList<>(logRecordExporters.length); for (LogRecordExporter logRecordExporter : logRecordExporters) { CompletableResultCode exportResult; diff --git a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/NoopLogRecordExporter.java b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/NoopLogRecordExporter.java index 607e180ccfe..8c0018826f4 100644 --- a/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/NoopLogRecordExporter.java +++ b/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/export/NoopLogRecordExporter.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 NoopLogRecordExporter implements LogRecordExporter { @@ -18,7 +18,7 @@ static LogRecordExporter 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 67dc939954a..b3dfe0b155a 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(LogRecordExporter exporter) { @Override public void onEmit(ReadWriteLogRecord logRecord) { try { - List logs = Collections.singletonList(logRecord.toLogData()); + List logs = Collections.singletonList(logRecord.toLogRecordData()); CompletableResultCode result = logRecordExporter.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 a0417f70e8d..4495e254f82 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; @@ -124,11 +124,11 @@ void emitMultipleLogs() { emitLog(loggerProvider, LOG_MESSAGE_1); emitLog(loggerProvider, LOG_MESSAGE_2); - List exported = waitingLogRecordExporter.waitForExport(); + List exported = waitingLogRecordExporter.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 @@ -159,7 +159,7 @@ void emitMoreLogsThanBufferSize() { () -> assertThat(logRecordExporter.getExported()) .hasSize(6) - .allSatisfy(logData -> assertThat(logData).hasBody(LOG_MESSAGE_1))); + .allSatisfy(logRecordData -> assertThat(logRecordData).hasBody(LOG_MESSAGE_1))); } @Test @@ -180,7 +180,7 @@ void forceEmit() { for (int i = 0; i < 50; i++) { emitLog(sdkLoggerProvider, "notExported"); } - List exported = waitingLogRecordExporter.waitForExport(); + List exported = waitingLogRecordExporter.waitForExport(); assertThat(exported).isNotNull(); assertThat(exported.size()).isEqualTo(49); @@ -215,18 +215,18 @@ void emitLogsToMultipleExporters() { emitLog(sdkLoggerProvider, LOG_MESSAGE_1); emitLog(sdkLoggerProvider, LOG_MESSAGE_2); - List exported1 = waitingLogRecordExporter1.waitForExport(); - List exported2 = waitingLogRecordExporter2.waitForExport(); + List exported1 = waitingLogRecordExporter1.waitForExport(); + List exported2 = waitingLogRecordExporter2.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 @@ -267,7 +267,7 @@ void emitMoreLogsThanTheMaximumLimit() { blockingLogRecordExporter.unblock(); // While we wait for maxQueuedLogs we ensure that the queue is also empty after this. - List exported = waitingLogRecordExporter.waitForExport(); + List exported = waitingLogRecordExporter.waitForExport(); assertThat(exported).isNotNull(); assertThat(exported).hasSize(maxQueuedLogs + 1); @@ -312,13 +312,16 @@ void exporterThrowsException() { .build(); emitLog(sdkLoggerProvider, LOG_MESSAGE_1); - List exported = waitingLogRecordExporter.waitForExport(); - assertThat(exported).satisfiesExactly(logData -> assertThat(logData).hasBody(LOG_MESSAGE_1)); + + List exported = waitingLogRecordExporter.waitForExport(); + assertThat(exported) + .satisfiesExactly(logRecordData -> assertThat(logRecordData).hasBody(LOG_MESSAGE_1)); waitingLogRecordExporter.reset(); // Continue to export after the exception was received. emitLog(sdkLoggerProvider, LOG_MESSAGE_2); exported = waitingLogRecordExporter.waitForExport(); - assertThat(exported).satisfiesExactly(logData -> assertThat(logData).hasBody(LOG_MESSAGE_2)); + assertThat(exported) + .satisfiesExactly(logRecordData -> assertThat(logRecordData).hasBody(LOG_MESSAGE_2)); } @Test @@ -387,8 +390,9 @@ void shutdownFlushes() { // Force a shutdown, which forces processing of all remaining logs. sdkLoggerProvider.shutdown().join(10, TimeUnit.SECONDS); - List exported = waitingLogRecordExporter.getExported(); - assertThat(exported).satisfiesExactly(logData -> assertThat(logData).hasBody(LOG_MESSAGE_2)); + List exported = waitingLogRecordExporter.getExported(); + assertThat(exported) + .satisfiesExactly(logRecordData -> assertThat(logRecordData).hasBody(LOG_MESSAGE_2)); assertThat(waitingLogRecordExporter.shutDownCalled.get()).isTrue(); } @@ -423,7 +427,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 { @@ -474,11 +478,11 @@ private static class CompletableLogRecordExporter implements LogRecordExporter { 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; } @@ -488,7 +492,7 @@ void succeed() { } @Override - public CompletableResultCode export(Collection logs) { + public CompletableResultCode export(Collection logs) { exported.addAll(logs); if (succeeded) { return CompletableResultCode.ofSuccess(); @@ -515,7 +519,7 @@ public CompletableResultCode shutdown() { static class WaitingLogRecordExporter implements LogRecordExporter { - private final List logDataList = new ArrayList<>(); + private final List logRecordDataList = new ArrayList<>(); private final int numberToWaitFor; private final CompletableResultCode exportResultCode; private CountDownLatch countDownLatch; @@ -534,21 +538,21 @@ static class WaitingLogRecordExporter implements LogRecordExporter { 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) { @@ -560,8 +564,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/InMemoryLogRecordExporterTest.java b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/InMemoryLogRecordExporterTest.java index d188241f172..d868534089d 100644 --- a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/InMemoryLogRecordExporterTest.java +++ b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/InMemoryLogRecordExporterTest.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/MultiLogRecordExporterTest.java b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/MultiLogRecordExporterTest.java index f8800d59c24..1f970d6bf40 100644 --- a/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/MultiLogRecordExporterTest.java +++ b/sdk/logs/src/test/java/io/opentelemetry/sdk/logs/export/MultiLogRecordExporterTest.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 MultiLogRecordExporterTest { @Mock private LogRecordExporter logRecordExporter1; @Mock private LogRecordExporter logRecordExporter2; - 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 fbc166d5397..a6cd227be89 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 LogRecordExporter logRecordExporter; @Mock private ReadWriteLogRecord readWriteLogRecord; @@ -46,7 +46,7 @@ void setUp() { logProcessor = SimpleLogProcessor.create(logRecordExporter); when(logRecordExporter.export(anyCollection())).thenReturn(CompletableResultCode.ofSuccess()); when(logRecordExporter.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(logRecordExporter).export(Collections.singletonList(LOG_DATA)); + verify(logRecordExporter).export(Collections.singletonList(LOG_RECORD_DATA)); } @Test @@ -81,7 +81,7 @@ void forceFlush() { logProcessor.onEmit(readWriteLogRecord); logProcessor.onEmit(readWriteLogRecord); - verify(logRecordExporter, times(2)).export(Collections.singletonList(LOG_DATA)); + verify(logRecordExporter, 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(logRecordExporter, times(2)).export(Collections.singletonList(LOG_DATA)); + verify(logRecordExporter, times(2)).export(Collections.singletonList(LOG_RECORD_DATA)); CompletableResultCode shutdown = logProcessor.shutdown(); assertThat(shutdown.isDone()).isFalse();