Encode enums as numbers in logging OTLP exporters (#4783)

This commit is contained in:
jack-berg 2022-10-17 16:56:23 -05:00 committed by GitHub
parent 250a2f0849
commit 5be58c5913
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 9 deletions

View File

@ -43,7 +43,7 @@ final class JsonSerializer extends Serializer {
@Override
protected void writeEnum(ProtoFieldInfo field, ProtoEnumInfo enumValue) throws IOException {
generator.writeStringField(field.getJsonName(), enumValue.getJsonName());
generator.writeNumberField(field.getJsonName(), enumValue.getEnumNumber());
}
@Override

View File

@ -110,7 +110,7 @@ class OtlpJsonLoggingLogRecordExporterTest {
+ " },"
+ " \"logRecords\": [{"
+ " \"timeUnixNano\":\"1631533710000000\","
+ " \"severityNumber\":\"SEVERITY_NUMBER_INFO\","
+ " \"severityNumber\":9,"
+ " \"severityText\":\"INFO\","
+ " \"body\": {"
+ " \"stringValue\":\"body2\""
@ -137,7 +137,7 @@ class OtlpJsonLoggingLogRecordExporterTest {
+ " },"
+ " \"logRecords\": [{"
+ " \"timeUnixNano\":\"1631533710000000\","
+ " \"severityNumber\":\"SEVERITY_NUMBER_INFO\","
+ " \"severityNumber\":9,"
+ " \"severityText\":\"INFO\","
+ " \"body\": {"
+ " \"stringValue\":\"body1\""

View File

@ -122,7 +122,7 @@ class OtlpJsonLoggingMetricExporterTest {
+ " \"timeUnixNano\": \"2\","
+ " \"asDouble\": 4.0"
+ " }],"
+ " \"aggregationTemporality\": \"AGGREGATION_TEMPORALITY_CUMULATIVE\","
+ " \"aggregationTemporality\": 2,"
+ " \"isMonotonic\": true"
+ " }"
+ " }]"
@ -151,7 +151,7 @@ class OtlpJsonLoggingMetricExporterTest {
+ " \"timeUnixNano\": \"2\","
+ " \"asDouble\": 4.0"
+ " }],"
+ " \"aggregationTemporality\": \"AGGREGATION_TEMPORALITY_CUMULATIVE\","
+ " \"aggregationTemporality\": 2,"
+ " \"isMonotonic\": true"
+ " }"
+ " }]"

View File

@ -126,11 +126,11 @@ class OtlpJsonLoggingSpanExporterTest {
+ " \"traceId\": \"12340000000043211234000000004321\","
+ " \"spanId\": \"8765000000005678\","
+ " \"name\": \"testSpan2\","
+ " \"kind\": \"SPAN_KIND_CLIENT\","
+ " \"kind\": 3,"
+ " \"startTimeUnixNano\": \"500\","
+ " \"endTimeUnixNano\": \"1501\","
+ " \"status\": {"
+ " \"code\": \"STATUS_CODE_ERROR\""
+ " \"code\": 2"
+ " }"
+ " }]"
+ " }, {"
@ -148,7 +148,7 @@ class OtlpJsonLoggingSpanExporterTest {
+ " \"traceId\": \"12345678876543211234567887654321\","
+ " \"spanId\": \"8765432112345678\","
+ " \"name\": \"testSpan1\","
+ " \"kind\": \"SPAN_KIND_INTERNAL\","
+ " \"kind\": 1,"
+ " \"startTimeUnixNano\": \"100\","
+ " \"endTimeUnixNano\": \"1100\","
+ " \"attributes\": [{"
@ -173,7 +173,7 @@ class OtlpJsonLoggingSpanExporterTest {
+ " }]"
+ " }],"
+ " \"status\": {"
+ " \"code\": \"STATUS_CODE_OK\""
+ " \"code\": 1"
+ " }"
+ " }]"
+ " }]"