Deprecate log name field (#4160)
* Deprecate log name field * Add deprecation description to javadoc
This commit is contained in:
parent
34273f43ca
commit
19b0fec813
|
|
@ -36,6 +36,7 @@ class OtlpJsonLoggingLogExporterTest {
|
|||
private static final Resource RESOURCE =
|
||||
Resource.create(Attributes.builder().put("key", "value").build());
|
||||
|
||||
@SuppressWarnings("deprecation") // test deprecated setName method
|
||||
private static final LogData LOG1 =
|
||||
LogDataBuilder.create(RESOURCE, InstrumentationLibraryInfo.create("instrumentation", "1"))
|
||||
.setName("testLog1")
|
||||
|
|
@ -52,6 +53,7 @@ class OtlpJsonLoggingLogExporterTest {
|
|||
TraceState.getDefault()))
|
||||
.build();
|
||||
|
||||
@SuppressWarnings("deprecation") // test deprecated setName method
|
||||
private static final LogData LOG2 =
|
||||
LogDataBuilder.create(RESOURCE, InstrumentationLibraryInfo.create("instrumentation2", "2"))
|
||||
.setName("testLog2")
|
||||
|
|
|
|||
|
|
@ -330,6 +330,7 @@ class OtlpHttpLogExporterTest {
|
|||
return HttpResponse.of(httpStatus, APPLICATION_PROTOBUF, message.toByteArray());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation") // test deprecated setName method
|
||||
private static LogData generateFakeLog() {
|
||||
return LogDataBuilder.create(
|
||||
Resource.getDefault(),
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ final class LogMarshaler extends MarshalerWithSize {
|
|||
@Nullable private final String traceId;
|
||||
@Nullable private final String spanId;
|
||||
|
||||
@SuppressWarnings("deprecation") // name field to be removed
|
||||
static LogMarshaler create(io.opentelemetry.sdk.logs.data.LogData logData) {
|
||||
KeyValueMarshaler[] attributeMarshalers =
|
||||
KeyValueMarshaler.createRepeated(logData.getAttributes());
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ class LogsRequestMarshalerTest {
|
|||
private static final String BODY = "Hello world from this log...";
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation") // test deprecated setName method
|
||||
void toProtoResourceLogs() {
|
||||
ResourceLogsMarshaler[] resourceLogsMarshalers =
|
||||
ResourceLogsMarshaler.create(
|
||||
|
|
@ -83,6 +84,7 @@ class LogsRequestMarshalerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation") // test deprecated setName method
|
||||
void toProtoLogRecord() {
|
||||
LogRecord logRecord =
|
||||
parse(
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ class OtlpGrpcLogExporterTest extends AbstractGrpcTelemetryExporterTest<LogData,
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation") // test deprecated setName method
|
||||
protected LogData generateFakeTelemetry() {
|
||||
return LogDataBuilder.create(
|
||||
Resource.create(Attributes.builder().put("testKey", "testValue").build()),
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ class OtlpGrpcNettyLogExporterTest
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation") // test deprecated setName method
|
||||
protected LogData generateFakeTelemetry() {
|
||||
return LogDataBuilder.create(
|
||||
Resource.create(Attributes.builder().put("testKey", "testValue").build()),
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ class OtlpGrpcNettyShadedLogExporterTest
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation") // test deprecated setName method
|
||||
protected LogData generateFakeTelemetry() {
|
||||
return LogDataBuilder.create(
|
||||
Resource.create(Attributes.builder().put("testKey", "testValue").build()),
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ class OtlpGrpcNettyOkHttpLogExporterTest
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation") // test deprecated setName method
|
||||
protected LogData generateFakeTelemetry() {
|
||||
return LogDataBuilder.create(
|
||||
Resource.create(Attributes.builder().put("testKey", "testValue").build()),
|
||||
|
|
|
|||
|
|
@ -373,6 +373,7 @@ abstract class OtlpExporterIntegrationTest {
|
|||
testLogExporter(otlpHttpLogExporter);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation") // test deprecated setName method
|
||||
private static void testLogExporter(LogExporter logExporter) {
|
||||
LogData logData =
|
||||
LogDataBuilder.create(
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ public class LogDataAssert extends AbstractAssert<LogDataAssert, LogData> {
|
|||
}
|
||||
|
||||
/** Asserts the log has the given name. */
|
||||
@Deprecated
|
||||
public LogDataAssert hasName(String name) {
|
||||
isNotNull();
|
||||
if (!name.equals(actual.getName())) {
|
||||
|
|
@ -149,7 +150,6 @@ public class LogDataAssert extends AbstractAssert<LogDataAssert, LogData> {
|
|||
actual.getAttributes(),
|
||||
attributes,
|
||||
"Expected log to have attributes <%s> but was <%s>",
|
||||
actual.getName(),
|
||||
attributes,
|
||||
actual.getAttributes());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ public class LogAssertionsTest {
|
|||
.put("coins", 0.01, 0.05, 0.1)
|
||||
.build();
|
||||
|
||||
@SuppressWarnings("deprecation") // test deprecated setName method
|
||||
private static final LogData LOG_DATA =
|
||||
LogDataBuilder.create(RESOURCE, INSTRUMENTATION_LIBRARY_INFO)
|
||||
.setEpoch(100, TimeUnit.NANOSECONDS)
|
||||
|
|
@ -57,6 +58,7 @@ public class LogAssertionsTest {
|
|||
.build();
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation") // test deprecated hasName method
|
||||
void passing() {
|
||||
assertThat(LOG_DATA)
|
||||
.hasResource(RESOURCE)
|
||||
|
|
@ -113,6 +115,7 @@ public class LogAssertionsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation") // test deprecated hasName method
|
||||
void failure() {
|
||||
assertThatThrownBy(() -> assertThat(LOG_DATA).hasResource(Resource.empty()));
|
||||
assertThatThrownBy(
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ final class SdkLogBuilder implements LogBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public LogBuilder setName(String name) {
|
||||
logDataBuilder.setName(name);
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,12 @@ public interface LogData {
|
|||
@Nullable
|
||||
String getSeverityText();
|
||||
|
||||
/** Returns the name for this log, or null if unset. */
|
||||
/**
|
||||
* Returns the name for this log, or null if unset.
|
||||
*
|
||||
* @deprecated will be removed without replacement.
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
String getName();
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,12 @@ public final class LogDataBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
/** Set the name. */
|
||||
/**
|
||||
* Set the name.
|
||||
*
|
||||
* @deprecated will be removed without replacement.
|
||||
*/
|
||||
@Deprecated
|
||||
public LogDataBuilder setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ import javax.annotation.Nullable;
|
|||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@AutoValue
|
||||
@AutoValue.CopyAnnotations
|
||||
@Immutable
|
||||
@SuppressWarnings("deprecation") // name field to be removed
|
||||
abstract class LogDataImpl implements LogData {
|
||||
|
||||
LogDataImpl() {}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test;
|
|||
class SdkLogBuilderTest {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation") // test deprecated setName method
|
||||
void buildAndEmit() {
|
||||
Instant now = Instant.now();
|
||||
String name = "skippy";
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ public final class TestUtil {
|
|||
.setEpoch(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
|
||||
.setSeverity(severity)
|
||||
.setSeverityText("really severe")
|
||||
.setName("log1")
|
||||
.setBody(message)
|
||||
.setAttributes(Attributes.builder().put("animal", "cat").build())
|
||||
.build();
|
||||
|
|
|
|||
Loading…
Reference in New Issue