Skip to content

Add support for generating Standard(OTEL) conformant events in DataPrepper#5524

Merged
kkondaka merged 2 commits intoopensearch-project:mainfrom
kkondaka:otel-sources-standard
Mar 20, 2025
Merged

Add support for generating Standard(OTEL) conformant events in DataPrepper#5524
kkondaka merged 2 commits intoopensearch-project:mainfrom
kkondaka:otel-sources-standard

Conversation

@kkondaka
Copy link
Copy Markdown
Collaborator

Description

Add support for generating Standard(OTEL) conformant events in DataPrepper.
Added option to otel-logs-source, otel-metrics-source and otel-trace-source to generate Standard/OTEL conformant events using output_format: otel option

Issues Resolved

Resolves #5259

Check List

  • [ X] New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • [X ] Commits are signed with a real name per the DCO

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.

…epper

Signed-off-by: Krishna Kondaka <krishkdk@amazon.com>
@kkondaka
Copy link
Copy Markdown
Collaborator Author

@dlvenable @KarstenSchnitter Please review.

@ps48
Copy link
Copy Markdown
Member

ps48 commented Mar 17, 2025

Hi @kkondaka, I do not know the internals of Data-prepper, just trying to understand few things on this change. Will This new output_format: otel still work with otel_traces_raw processor and when ingesting this to opensearch is the index_type still trace-analytics-raw ?
Thanks!


public enum OTelLogsFormatOption {
JSON("json"),
STANDARD_JSON("standard_json"),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This affects both standard and OpenSearch. Is this what we want?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense.

But, why do you change the enum above? See my other comment.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I clarified above. That was not needed. Removed it.

Signed-off-by: Krishna Kondaka <krishkdk@amazon.com>
@kkondaka
Copy link
Copy Markdown
Collaborator Author

@ps48 I have not verified the otel_traces_raw behavior with the new Standard mode. Will do that in my next PR.

Copy link
Copy Markdown
Collaborator

@KarstenSchnitter KarstenSchnitter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for symmetry with the other names:

Suggested change
public static long timeISO8601ToNanos(final String timeISO08601) {
public static long convertISO8601ToNanos(final String timeISO08601) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will address in my next PR.

.flatMap(rs -> parseResourceLogs(rs, timeReceived).stream()).collect(Collectors.toList());
}

protected Collection<OpenTelemetryLog> parseResourceLogs(ResourceLogs rs, final Instant timeReceived) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required. The "unpackKeyValueList" is returning the attributes with "." as prefix!

.map(sls ->
processLogsList(sls.getLogRecordsList(),
serviceName,
OTelProtoOpensearchCodec.getInstrumentationScopeAttributes(sls.getScope()),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this method located in this very class? Why is there an explicit class reference?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will address in my next PR.

.withStartTime(OTelProtoStandardCodec.getStartTimeISO8601(dp))
.withTime(OTelProtoStandardCodec.getTimeISO8601(dp))
.withServiceName(serviceName)
.withValue(OTelProtoStandardCodec.getValueAsDouble(dp))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will investigate and address in next PR. If you know, definitive answer, please let me know.

@kkondaka
Copy link
Copy Markdown
Collaborator Author

@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.

@kkondaka kkondaka merged commit f136f48 into opensearch-project:main Mar 20, 2025
46 of 50 checks passed
chenqi0805 pushed a commit to chenqi0805/data-prepper that referenced this pull request Apr 2, 2025
…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>
chenqi0805 pushed a commit to chenqi0805/data-prepper that referenced this pull request Apr 2, 2025
…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>
amdhing pushed a commit to amdhing/data-prepper that referenced this pull request Apr 16, 2025
…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>
Davidding4718 pushed a commit to Davidding4718/data-prepper that referenced this pull request Apr 25, 2025
…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
Davidding4718 pushed a commit to Davidding4718/data-prepper that referenced this pull request Apr 25, 2025
…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
Mamol27 pushed a commit to Mamol27/data-prepper that referenced this pull request May 6, 2025
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OTEL sources should create events without any transformations

5 participants