Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default value of flattenAttributes to true in Otel metrics source #4190

Merged
merged 3 commits into from
Feb 27, 2024

Conversation

kkondaka
Copy link
Collaborator

@kkondaka kkondaka commented Feb 27, 2024

Description

Set default value of flattenAttributes to true in Otel metrics source.
Modify the OTEL metrics source to create events/records with flatten attributes set to true.
If OTEL processor config changes the flatten attributes to flase, then change it false in the processor.

OTEL metrics always have been implemented with flattening the attributes(ie fields inside "attributes" field are moved to the root). We have added option to not flatten some time back. But that's not used by anyone (that I know of). When the previous PR which moved the creation of OTEL metrics records to OTEL source (instead of otel processor) I picked the default to false and it is changed to true in the processor. But that was unnecessary also hit a bug due to valid characters in a key. This new approach will avoid it.

Issues Resolved

Resolves #[Issue number to be closed when this PR is merged]

Check List

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

@@ -85,7 +81,7 @@ public Collection<Record<? extends Metric>> doExecute(Collection<Record<?>> reco
for (Record<?> rec : records) {
if ((rec.getData() instanceof Event)) {
Record<? extends Metric> newRecord = (Record<? extends Metric>)rec;
if (otelMetricsRawProcessorConfig.getFlattenAttributesFlag() ||
if (!otelMetricsRawProcessorConfig.getFlattenAttributesFlag() ||
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain why this is being negated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's true by default. Only when it is set to false in the config, we call JacksonMetric.setFlattenAttributes(false)

Signed-off-by: Krishna Kondaka <[email protected]>
Copy link
Member

@dlvenable dlvenable left a comment

Choose a reason for hiding this comment

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

Aren't these changes going to break existing pipelines? This makes the data fundamentally different.

@kkondaka
Copy link
Collaborator Author

@dlvenable. No It doesn't change existing setup

@kkondaka kkondaka merged commit 2787fce into opensearch-project:main Feb 27, 2024
41 of 47 checks passed
kkondaka pushed a commit to kkondaka/kk-data-prepper-f2 that referenced this pull request Feb 27, 2024
kkondaka pushed a commit to kkondaka/kk-data-prepper-f2 that referenced this pull request Feb 27, 2024
kkondaka added a commit that referenced this pull request Feb 27, 2024
Signed-off-by: Krishna Kondaka <[email protected]>
Co-authored-by: Krishna Kondaka <[email protected]>
@kkondaka kkondaka deleted the otel-metrics-src-fix branch May 13, 2024 05:52
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.

3 participants