in data-prepper-plugins/otel-trace-raw-prepper/src/main/java/com/amazon/dataprepper/plugins/prepper/oteltrace/model/OTelProtoHelper.java [48:82]
public static Object convertAnyValue(final AnyValue value) {
switch (value.getValueCase()) {
case VALUE_NOT_SET:
case STRING_VALUE:
return value.getStringValue();
case BOOL_VALUE:
return value.getBoolValue();
case INT_VALUE:
return value.getIntValue();
case DOUBLE_VALUE:
return value.getDoubleValue();
/**
* Both {@link AnyValue.ARRAY_VALUE_FIELD_NUMBER} and {@link AnyValue.KVLIST_VALUE_FIELD_NUMBER} are
* nested objects. Storing them in flatten structure is not OpenSearch friendly. So they are stored
* as Json string.
*/
case ARRAY_VALUE:
try {
return OBJECT_MAPPER.writeValueAsString(value.getArrayValue().getValuesList().stream()
.map(OTelProtoHelper::convertAnyValue).collect(Collectors.toList()));
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
case KVLIST_VALUE:
try {
return OBJECT_MAPPER.writeValueAsString(value.getKvlistValue().getValuesList().stream()
.collect(Collectors.toMap(i -> REPLACE_DOT_WITH_AT.apply(i.getKey()),
i ->convertAnyValue(i.getValue()))));
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
default:
throw new RuntimeException("Unknown case");
}
}