Skip to content

Commit f7c52e1

Browse files
author
John Watson
authored
Update OTLP protobufs to v0.13.0-alpha (open-telemetry#4170)
and add documentation on how to update that dependency.
1 parent 34d75aa commit f7c52e1

10 files changed

Lines changed: 135 additions & 137 deletions

File tree

CONTRIBUTING.md

Lines changed: 111 additions & 84 deletions
Large diffs are not rendered by default.

dependencyManagement/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ val DEPENDENCIES = listOf(
8787
"eu.rekawek.toxiproxy:toxiproxy-java:2.1.5",
8888
"io.github.netmikey.logunit:logunit-jul:1.1.3",
8989
"io.jaegertracing:jaeger-client:1.8.0",
90-
"io.opentelemetry.proto:opentelemetry-proto:0.11.0-alpha",
90+
"io.opentelemetry.proto:opentelemetry-proto:0.13.0-alpha",
9191
"io.opentracing:opentracing-api:0.33.0",
9292
"junit:junit:4.13.2",
9393
"nl.jqno.equalsverifier:equalsverifier:3.9",

exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingLogExporterTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ void log() throws Exception {
8787
assertThat(logs.getEvents())
8888
.hasSize(1)
8989
.allSatisfy(log -> assertThat(log.getLevel()).isEqualTo(Level.INFO));
90+
String message = logs.getEvents().get(0).getMessage();
9091
JSONAssert.assertEquals(
9192
"{\n"
9293
+ " \"resource\":{\n"
@@ -105,7 +106,7 @@ void log() throws Exception {
105106
+ " \"name\":\"instrumentation2\",\n"
106107
+ " \"version\":\"2\"\n"
107108
+ " },\n"
108-
+ " \"logs\":[\n"
109+
+ " \"logRecords\":[\n"
109110
+ " {\n"
110111
+ " \"timeUnixNano\":\"1631533710000000\",\n"
111112
+ " \"severityNumber\":\"SEVERITY_NUMBER_INFO\",\n"
@@ -132,7 +133,7 @@ void log() throws Exception {
132133
+ " \"name\":\"instrumentation\",\n"
133134
+ " \"version\":\"1\"\n"
134135
+ " },\n"
135-
+ " \"logs\":[\n"
136+
+ " \"logRecords\":[\n"
136137
+ " {\n"
137138
+ " \"timeUnixNano\":\"1631533710000000\",\n"
138139
+ " \"severityNumber\":\"SEVERITY_NUMBER_INFO\",\n"
@@ -162,9 +163,9 @@ void log() throws Exception {
162163
+ " }\n"
163164
+ " ]\n"
164165
+ "}",
165-
logs.getEvents().get(0).getMessage(),
166+
message,
166167
/* strict= */ false);
167-
assertThat(logs.getEvents().get(0).getMessage()).doesNotContain("\n");
168+
assertThat(message).doesNotContain("\n");
168169
}
169170

170171
@Test

exporters/logging-otlp/src/test/java/io/opentelemetry/exporter/logging/otlp/OtlpJsonLoggingSpanExporterTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ void log() throws Exception {
101101
assertThat(logs.getEvents())
102102
.hasSize(1)
103103
.allSatisfy(log -> assertThat(log.getLevel()).isEqualTo(Level.INFO));
104+
String message = logs.getEvents().get(0).getMessage();
104105
JSONAssert.assertEquals(
105106
"{"
106107
+ " \"resource\": {"
@@ -124,7 +125,6 @@ void log() throws Exception {
124125
+ " \"startTimeUnixNano\": \"500\","
125126
+ " \"endTimeUnixNano\": \"1501\","
126127
+ " \"status\": {"
127-
+ " \"deprecatedCode\": \"DEPRECATED_STATUS_CODE_UNKNOWN_ERROR\","
128128
+ " \"code\": \"STATUS_CODE_ERROR\""
129129
+ " }"
130130
+ " }]"
@@ -167,9 +167,9 @@ void log() throws Exception {
167167
+ " }]"
168168
+ " }]"
169169
+ "}",
170-
logs.getEvents().get(0).getMessage(),
170+
message,
171171
/* strict= */ false);
172-
assertThat(logs.getEvents().get(0).getMessage()).doesNotContain("\n");
172+
assertThat(message).doesNotContain("\n");
173173
}
174174

175175
@Test

exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/logs/InstrumentationLibraryLogsMarshaler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final class InstrumentationLibraryLogsMarshaler extends MarshalerWithSize {
3333
public void writeTo(Serializer output) throws IOException {
3434
output.serializeMessage(
3535
InstrumentationLibraryLogs.INSTRUMENTATION_LIBRARY, instrumentationLibrary);
36-
output.serializeRepeatedMessage(InstrumentationLibraryLogs.LOGS, logMarshalers);
36+
output.serializeRepeatedMessage(InstrumentationLibraryLogs.LOG_RECORDS, logMarshalers);
3737
output.serializeString(InstrumentationLibraryLogs.SCHEMA_URL, schemaUrlUtf8);
3838
}
3939

@@ -46,7 +46,8 @@ private static int calculateSize(
4646
MarshalerUtil.sizeMessage(
4747
InstrumentationLibraryLogs.INSTRUMENTATION_LIBRARY, instrumentationLibrary);
4848
size += MarshalerUtil.sizeBytes(InstrumentationLibraryLogs.SCHEMA_URL, schemaUrlUtf8);
49-
size += MarshalerUtil.sizeRepeatedMessage(InstrumentationLibraryLogs.LOGS, logMarshalers);
49+
size +=
50+
MarshalerUtil.sizeRepeatedMessage(InstrumentationLibraryLogs.LOG_RECORDS, logMarshalers);
5051
return size;
5152
}
5253
}

exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/traces/SpanStatusMarshaler.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,33 @@
1616

1717
final class SpanStatusMarshaler extends MarshalerWithSize {
1818
private final ProtoEnumInfo protoStatusCode;
19-
private final ProtoEnumInfo deprecatedStatusCode;
2019
private final byte[] descriptionUtf8;
2120

2221
static SpanStatusMarshaler create(StatusData status) {
2322
ProtoEnumInfo protoStatusCode = Status.StatusCode.STATUS_CODE_UNSET;
24-
ProtoEnumInfo deprecatedStatusCode = Status.DeprecatedStatusCode.DEPRECATED_STATUS_CODE_OK;
2523
if (status.getStatusCode() == StatusCode.OK) {
2624
protoStatusCode = Status.StatusCode.STATUS_CODE_OK;
2725
} else if (status.getStatusCode() == StatusCode.ERROR) {
2826
protoStatusCode = Status.StatusCode.STATUS_CODE_ERROR;
29-
deprecatedStatusCode = Status.DeprecatedStatusCode.DEPRECATED_STATUS_CODE_UNKNOWN_ERROR;
3027
}
3128
byte[] description = MarshalerUtil.toBytes(status.getDescription());
32-
return new SpanStatusMarshaler(protoStatusCode, deprecatedStatusCode, description);
29+
return new SpanStatusMarshaler(protoStatusCode, description);
3330
}
3431

35-
private SpanStatusMarshaler(
36-
ProtoEnumInfo protoStatusCode, ProtoEnumInfo deprecatedStatusCode, byte[] descriptionUtf8) {
37-
super(computeSize(protoStatusCode, deprecatedStatusCode, descriptionUtf8));
32+
private SpanStatusMarshaler(ProtoEnumInfo protoStatusCode, byte[] descriptionUtf8) {
33+
super(computeSize(protoStatusCode, descriptionUtf8));
3834
this.protoStatusCode = protoStatusCode;
39-
this.deprecatedStatusCode = deprecatedStatusCode;
4035
this.descriptionUtf8 = descriptionUtf8;
4136
}
4237

4338
@Override
4439
public void writeTo(Serializer output) throws IOException {
45-
output.serializeEnum(Status.DEPRECATED_CODE, deprecatedStatusCode);
4640
output.serializeString(Status.MESSAGE, descriptionUtf8);
4741
output.serializeEnum(Status.CODE, protoStatusCode);
4842
}
4943

50-
private static int computeSize(
51-
ProtoEnumInfo protoStatusCode, ProtoEnumInfo deprecatedStatusCode, byte[] descriptionUtf8) {
44+
private static int computeSize(ProtoEnumInfo protoStatusCode, byte[] descriptionUtf8) {
5245
int size = 0;
53-
size += MarshalerUtil.sizeEnum(Status.DEPRECATED_CODE, deprecatedStatusCode);
5446
size += MarshalerUtil.sizeBytes(Status.MESSAGE, descriptionUtf8);
5547
size += MarshalerUtil.sizeEnum(Status.CODE, protoStatusCode);
5648
return size;

exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/otlp/logs/LogsRequestMarshalerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private static <T extends Message> T parse(T prototype, Marshaler marshaler) {
178178
ResourceLogs.Builder fixed = (ResourceLogs.Builder) builder;
179179
for (InstrumentationLibraryLogs.Builder ill :
180180
fixed.getInstrumentationLibraryLogsBuilderList()) {
181-
for (LogRecord.Builder span : ill.getLogsBuilderList()) {
181+
for (LogRecord.Builder span : ill.getLogRecordsBuilderList()) {
182182
fixSpanJsonIds(span);
183183
}
184184
}

exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/otlp/traces/TraceRequestMarshalerTest.java

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
import static io.opentelemetry.api.common.AttributeKey.stringKey;
99
import static io.opentelemetry.proto.trace.v1.Span.SpanKind.SPAN_KIND_SERVER;
10-
import static io.opentelemetry.proto.trace.v1.Status.DeprecatedStatusCode.DEPRECATED_STATUS_CODE_OK;
11-
import static io.opentelemetry.proto.trace.v1.Status.DeprecatedStatusCode.DEPRECATED_STATUS_CODE_UNKNOWN_ERROR;
1210
import static io.opentelemetry.proto.trace.v1.Status.StatusCode.STATUS_CODE_ERROR;
1311
import static io.opentelemetry.proto.trace.v1.Status.StatusCode.STATUS_CODE_OK;
1412
import static io.opentelemetry.proto.trace.v1.Status.StatusCode.STATUS_CODE_UNSET;
@@ -229,45 +227,24 @@ void toProtoSpanKind() {
229227
}
230228

231229
@Test
232-
@SuppressWarnings("deprecation")
233-
// setDeprecatedCode is deprecated.
234230
void toProtoStatus() {
235231
assertThat(parse(Status.getDefaultInstance(), SpanStatusMarshaler.create(StatusData.unset())))
236-
.isEqualTo(
237-
Status.newBuilder()
238-
.setCode(STATUS_CODE_UNSET)
239-
.setDeprecatedCode(DEPRECATED_STATUS_CODE_OK)
240-
.build());
232+
.isEqualTo(Status.newBuilder().setCode(STATUS_CODE_UNSET).build());
241233
assertThat(
242234
parse(
243235
Status.getDefaultInstance(),
244236
SpanStatusMarshaler.create(StatusData.create(StatusCode.ERROR, "ERROR"))))
245-
.isEqualTo(
246-
Status.newBuilder()
247-
.setCode(STATUS_CODE_ERROR)
248-
.setDeprecatedCode(DEPRECATED_STATUS_CODE_UNKNOWN_ERROR)
249-
.setMessage("ERROR")
250-
.build());
237+
.isEqualTo(Status.newBuilder().setCode(STATUS_CODE_ERROR).setMessage("ERROR").build());
251238
assertThat(
252239
parse(
253240
Status.getDefaultInstance(),
254241
SpanStatusMarshaler.create(StatusData.create(StatusCode.ERROR, "UNKNOWN"))))
255-
.isEqualTo(
256-
Status.newBuilder()
257-
.setCode(STATUS_CODE_ERROR)
258-
.setDeprecatedCode(DEPRECATED_STATUS_CODE_UNKNOWN_ERROR)
259-
.setMessage("UNKNOWN")
260-
.build());
242+
.isEqualTo(Status.newBuilder().setCode(STATUS_CODE_ERROR).setMessage("UNKNOWN").build());
261243
assertThat(
262244
parse(
263245
Status.getDefaultInstance(),
264246
SpanStatusMarshaler.create(StatusData.create(StatusCode.OK, "OK_OVERRIDE"))))
265-
.isEqualTo(
266-
Status.newBuilder()
267-
.setCode(STATUS_CODE_OK)
268-
.setDeprecatedCode(DEPRECATED_STATUS_CODE_OK)
269-
.setMessage("OK_OVERRIDE")
270-
.build());
247+
.isEqualTo(Status.newBuilder().setCode(STATUS_CODE_OK).setMessage("OK_OVERRIDE").build());
271248
}
272249

273250
@Test

integration-tests/otlp/src/main/java/io/opentelemetry/integrationtest/OtlpExporterIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,9 @@ private static void testLogExporter(LogExporter logExporter) {
415415
InstrumentationLibraryLogs ilLogs = resourceLogs.getInstrumentationLibraryLogs(0);
416416
assertThat(ilLogs.getInstrumentationLibrary().getName())
417417
.isEqualTo(OtlpExporterIntegrationTest.class.getName());
418-
assertThat(ilLogs.getLogsCount()).isEqualTo(1);
418+
assertThat(ilLogs.getLogRecordsCount()).isEqualTo(1);
419419

420-
io.opentelemetry.proto.logs.v1.LogRecord protoLog = ilLogs.getLogs(0);
420+
io.opentelemetry.proto.logs.v1.LogRecord protoLog = ilLogs.getLogRecords(0);
421421
assertThat(protoLog.getName()).isEqualTo("log-name");
422422
assertThat(protoLog.getBody().getStringValue()).isEqualTo("log body");
423423
assertThat(protoLog.getAttributesList())

sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/FullConfigTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ void configures() throws Exception {
281281
.setValue(AnyValue.newBuilder().setStringValue("meow").build())
282282
.build());
283283
// MetricExporterCustomizer filters logs not whose level is less than Severity.INFO
284-
LogRecord log = logRequest.getResourceLogs(0).getInstrumentationLibraryLogs(0).getLogs(0);
284+
LogRecord log = logRequest.getResourceLogs(0).getInstrumentationLibraryLogs(0).getLogRecords(0);
285285
assertThat(log.getBody().getStringValue()).isEqualTo("info log message");
286286
assertThat(log.getSeverityNumberValue()).isEqualTo(Severity.INFO.getSeverityNumber());
287287
}

0 commit comments

Comments
 (0)