Add support for generating Standard(OTEL) conformant events in DataPrepper#5524
Conversation
…epper Signed-off-by: Krishna Kondaka <krishkdk@amazon.com>
|
@dlvenable @KarstenSchnitter Please review. |
|
Hi @kkondaka, I do not know the internals of Data-prepper, just trying to understand few things on this change. Will This new |
|
|
||
| public enum OTelLogsFormatOption { | ||
| JSON("json"), | ||
| STANDARD_JSON("standard_json"), |
There was a problem hiding this comment.
I understand that the current format option is instructing the input format into the codec. That is, how do we decode.
But, in the difference between "standard" and "opensearch" we are directing the output from the codec.
I tend to think we should make this a new option instead of overloading this.
|
|
||
| protected static final String NAME_KEY = "name"; | ||
| protected static final String SCOPE_KEY = "scope"; | ||
| protected static final String SCOPE_KEY = "instrumentationScope"; |
There was a problem hiding this comment.
This affects both standard and OpenSearch. Is this what we want?
There was a problem hiding this comment.
It is not used in Opensearch mode. It already has other keys defined like this
static final String INSTRUMENTATION_SCOPE_NAME = "instrumentationScope.name";
static final String INSTRUMENTATION_SCOPE_VERSION = "instrumentationScope.version";
static final String INSTRUMENTATION_SCOPE_ATTRIBUTES = "instrumentationScope.attributes";
The new SCOPE_KEY with instrumentationScope is only used in the standard mode.
| @JsonProperty(value = "otel_format", defaultValue = "opensearch") | ||
| @JsonPropertyDescription("Specifies the format of the OTel Output.") | ||
| @NotNull | ||
| private OTelOutputFormat otelFormat = OTelOutputFormat.OPENSEARCH; |
There was a problem hiding this comment.
This makes sense.
But, why do you change the enum above? See my other comment.
There was a problem hiding this comment.
As I clarified above. That was not needed. Removed it.
Signed-off-by: Krishna Kondaka <krishkdk@amazon.com>
|
@ps48 I have not verified the |
KarstenSchnitter
left a comment
There was a problem hiding this comment.
I only did a partial review, but I wanted to give some timely feedback. I searched for some of the issues I commented on specifically. There might be more just around them.
| return Instant.ofEpochSecond(0L, unixNano).toString(); | ||
| } | ||
|
|
||
| public static long timeISO8601ToNanos(final String timeISO08601) { |
There was a problem hiding this comment.
Just for symmetry with the other names:
| public static long timeISO8601ToNanos(final String timeISO08601) { | |
| public static long convertISO8601ToNanos(final String timeISO08601) { |
There was a problem hiding this comment.
Will address in my next PR.
| .flatMap(rs -> parseResourceLogs(rs, timeReceived).stream()).collect(Collectors.toList()); | ||
| } | ||
|
|
||
| protected Collection<OpenTelemetryLog> parseResourceLogs(ResourceLogs rs, final Instant timeReceived) { |
There was a problem hiding this comment.
I do not know, if this is the right time for changing the method signature. But how about returning a Stream>OpenTelemetryLog> here? This would avoid the creation of a collection at the end of the method just to stream it again at the caller.
There was a problem hiding this comment.
Will investigate and address in the next PR.
| } | ||
| if (!instrumentationScope.getAttributesList().isEmpty()) { | ||
| for (Map.Entry<String, Object> entry: OTelProtoOpensearchCodec.unpackKeyValueList(instrumentationScope.getAttributesList()).entrySet()) { | ||
| instrumentationScopeAttr.put(INSTRUMENTATION_SCOPE_ATTRIBUTES+entry.getKey(), entry.getValue()); |
There was a problem hiding this comment.
Isn't there a DOT missing in this concatenation similar to all the other attributes. For resource, logs, metrics, and span attributes there is a function being called to generate the attribute name.
There was a problem hiding this comment.
Not required. The "unpackKeyValueList" is returning the attributes with "." as prefix!
| .map(sls -> | ||
| processLogsList(sls.getLogRecordsList(), | ||
| serviceName, | ||
| OTelProtoOpensearchCodec.getInstrumentationScopeAttributes(sls.getScope()), |
There was a problem hiding this comment.
Isn't this method located in this very class? Why is there an explicit class reference?
There was a problem hiding this comment.
Will address in my next PR.
| .withStartTime(OTelProtoStandardCodec.getStartTimeISO8601(dp)) | ||
| .withTime(OTelProtoStandardCodec.getTimeISO8601(dp)) | ||
| .withServiceName(serviceName) | ||
| .withValue(OTelProtoStandardCodec.getValueAsDouble(dp)) |
There was a problem hiding this comment.
I am not sure, that the standard gauge/sum/histogram data point should always use a double value. Maybe there should be a distinction between value.int and value.double as documented here: https://github.com/opensearch-project/opensearch-catalog/blob/main/docs/schema/observability/metrics/metrics.md
There was a problem hiding this comment.
Will investigate and address in next PR. If you know, definitive answer, please let me know.
|
@KarstenSchnitter Please complete your review and let me know any other comments you may have. I have another PR coming up and I will address all your comments in that. |
…epper (opensearch-project#5524) * Add support for generating Standard(OTEL) conformant events in DataPrepper Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> * Addressed review comments Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> --------- Signed-off-by: Krishna Kondaka <krishkdk@amazon.com>
…epper (opensearch-project#5524) * Add support for generating Standard(OTEL) conformant events in DataPrepper Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> * Addressed review comments Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> --------- Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> Signed-off-by: George Chen <qchea@amazon.com>
…epper (opensearch-project#5524) * Add support for generating Standard(OTEL) conformant events in DataPrepper Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> * Addressed review comments Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> --------- Signed-off-by: Krishna Kondaka <krishkdk@amazon.com>
…epper (opensearch-project#5524) * Add support for generating Standard(OTEL) conformant events in DataPrepper Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> * Addressed review comments Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> --------- Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> # Conflicts: # data-prepper-plugins/otel-logs-source/src/main/java/org/opensearch/dataprepper/plugins/source/otellogs/OTelLogsSource.java # data-prepper-plugins/otel-logs-source/src/main/java/org/opensearch/dataprepper/plugins/source/otellogs/OTelLogsSourceConfig.java # data-prepper-plugins/otel-metrics-source/src/main/java/org/opensearch/dataprepper/plugins/source/otelmetrics/OTelMetricsSource.java # data-prepper-plugins/otel-trace-source/src/main/java/org/opensearch/dataprepper/plugins/source/oteltrace/OTelTraceSource.java # data-prepper-plugins/otel-trace-source/src/main/java/org/opensearch/dataprepper/plugins/source/oteltrace/OTelTraceSourceConfig.java
…epper (opensearch-project#5524) * Add support for generating Standard(OTEL) conformant events in DataPrepper Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> * Addressed review comments Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> --------- Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> # Conflicts: # data-prepper-plugins/otel-logs-source/src/main/java/org/opensearch/dataprepper/plugins/source/otellogs/OTelLogsSource.java # data-prepper-plugins/otel-logs-source/src/main/java/org/opensearch/dataprepper/plugins/source/otellogs/OTelLogsSourceConfig.java # data-prepper-plugins/otel-metrics-source/src/main/java/org/opensearch/dataprepper/plugins/source/otelmetrics/OTelMetricsSource.java # data-prepper-plugins/otel-trace-source/src/main/java/org/opensearch/dataprepper/plugins/source/oteltrace/OTelTraceSource.java # data-prepper-plugins/otel-trace-source/src/main/java/org/opensearch/dataprepper/plugins/source/oteltrace/OTelTraceSourceConfig.java
…epper (opensearch-project#5524) * Add support for generating Standard(OTEL) conformant events in DataPrepper Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> * Addressed review comments Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> --------- Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> Signed-off-by: mamol27 <mamol27@yandex.ru>
Description
Add support for generating Standard(OTEL) conformant events in DataPrepper.
Added option to
otel-logs-source,otel-metrics-sourceandotel-trace-sourceto generate Standard/OTEL conformant events usingoutput_format: oteloptionIssues Resolved
Resolves #5259
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.