Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate log name field #4160

Merged
merged 2 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ private static <T extends Message> HttpResponse buildResponse(HttpStatus httpSta
return HttpResponse.of(httpStatus, APPLICATION_PROTOBUF, message.toByteArray());
}

@SuppressWarnings("deprecation") // test deprecated setName method
private static LogData generateFakeLog() {
return LogDataBuilder.create(
Resource.getDefault(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -83,6 +84,7 @@ void toProtoResourceLogs() {
}

@Test
@SuppressWarnings("deprecation") // test deprecated setName method
void toProtoLogRecord() {
LogRecord logRecord =
parse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public TelemetryExporter<LogData> build() {
}

@Override
@SuppressWarnings("deprecation") // test deprecated setName method
protected LogData generateFakeTelemetry() {
return LogDataBuilder.create(
Resource.create(Attributes.builder().put("testKey", "testValue").build()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public TelemetryExporter<LogData> build() {
}

@Override
@SuppressWarnings("deprecation") // test deprecated setName method
protected LogData generateFakeTelemetry() {
return LogDataBuilder.create(
Resource.create(Attributes.builder().put("testKey", "testValue").build()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public TelemetryExporter<LogData> build() {
}

@Override
@SuppressWarnings("deprecation") // test deprecated setName method
protected LogData generateFakeTelemetry() {
return LogDataBuilder.create(
Resource.create(Attributes.builder().put("testKey", "testValue").build()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public TelemetryExporter<LogData> build() {
}

@Override
@SuppressWarnings("deprecation") // test deprecated setName method
protected LogData generateFakeTelemetry() {
return LogDataBuilder.create(
Resource.create(Attributes.builder().put("testKey", "testValue").build()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ void testOtlpHttpLogExport(String compression) {
testLogExporter(otlpHttpLogExporter);
}

@SuppressWarnings("deprecation") // test deprecated setName method
private static void testLogExporter(LogExporter logExporter) {
LogData logData =
LogDataBuilder.create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public LogDataAssert hasSeverityText(String severityText) {
}

/** Asserts the log has the given name. */
@Deprecated
public LogDataAssert hasName(String name) {
isNotNull();
if (!name.equals(actual.getName())) {
Expand Down Expand Up @@ -149,7 +150,6 @@ public LogDataAssert hasAttributes(Attributes attributes) {
actual.getAttributes(),
attributes,
"Expected log to have attributes <%s> but was <%s>",
actual.getName(),
attributes,
actual.getAttributes());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -57,6 +58,7 @@ public class LogAssertionsTest {
.build();

@Test
@SuppressWarnings("deprecation") // test deprecated hasName method
void passing() {
assertThat(LOG_DATA)
.hasResource(RESOURCE)
Expand Down Expand Up @@ -113,6 +115,7 @@ void passing() {
}

@Test
@SuppressWarnings("deprecation") // test deprecated hasName method
void failure() {
assertThatThrownBy(() -> assertThat(LOG_DATA).hasResource(Resource.empty()));
assertThatThrownBy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public LogBuilder setSeverityText(String severityText) {
}

@Override
@Deprecated
public LogBuilder setName(String name) {
logDataBuilder.setName(name);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ public LogDataBuilder setSeverityText(String severityText) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
import javax.annotation.concurrent.Immutable;

@AutoValue
@AutoValue.CopyAnnotations
@Immutable
@SuppressWarnings("deprecation") // name field to be removed
abstract class LogDataImpl implements LogData {

LogDataImpl() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
class SdkLogBuilderTest {

@Test
@SuppressWarnings("deprecation") // test deprecated setName method
void buildAndEmit() {
Instant now = Instant.now();
String name = "skippy";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public static LogData createLogData(Severity severity, String message) {
.setEpoch(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
.setSeverity(severity)
.setSeverityText("really severe")
.setName("log1")
.setBody(message)
.setAttributes(Attributes.builder().put("animal", "cat").build())
.build();
Expand Down