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

[processor/k8sattributes] allow metadata extractions to be empty list #27185

Merged

Conversation

fatsheep9146
Copy link
Contributor

@fatsheep9146 fatsheep9146 commented Sep 26, 2023

Description:
Allow metadata extractions to be null

After this is merged, user is allow to specify the metadata to be null like following

    processors:
      k8sattributes:
        extract:
          annotations:
          - from: pod
            key: workload
            tag_name: k8s.annotations.workload
          labels:
          - from: pod
            key: app
            tag_name: k8s.labels.app
          metadata: []

and the trace is like
image

Link to tracking Issue:

fix #14452

Testing:

Documentation:

@fatsheep9146 fatsheep9146 requested a review from a team September 26, 2023 01:42
@github-actions github-actions bot added the processor/k8sattributes k8s Attributes processor label Sep 26, 2023
Comment on lines 131 to 133
if len(fields) == 0 {
fields = enabledAttributes()
}
Copy link
Member

@dmitryax dmitryax Sep 26, 2023

Choose a reason for hiding this comment

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

@fatsheep9146 given that your fix in core is merged, we can move this part to createDefaultConfig and don't do anything else. Users will be able to set metadata: [] which I believe is more correct way than setting null

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That make senses, I will modify like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After modify like this, user should set [], null is not supported, since the null should override the default values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I test this locally and make sure, for now only setting metadata to [] works, setting to null will keep the default values

Copy link
Member

Choose a reason for hiding this comment

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

I test this locally and make sure, for now only setting metadata to [] works, setting to null will keep the default values

This behavior makes total sense. We don't need to support null additionally for this

Signed-off-by: Ziqi Zhao <[email protected]>
Signed-off-by: Ziqi Zhao <[email protected]>
@dmitryax dmitryax changed the title [processor/k8sattributes] allow metadata extractions to be null [processor/k8sattributes] allow metadata extractions to be empty list Sep 26, 2023
@dmitryax dmitryax merged commit 0882eee into open-telemetry:main Sep 26, 2023
@github-actions github-actions bot added this to the next release milestone Sep 26, 2023
jmsnll pushed a commit to jmsnll/opentelemetry-collector-contrib that referenced this pull request Nov 12, 2023
…open-telemetry#27185)

**Description:** 
Allow metadata extractions to be empty list

After this is merged, user is allow to specify the metadata to be empty list
like following

```
    processors:
      k8sattributes:
        extract:
          annotations:
          - from: pod
            key: workload
            tag_name: k8s.annotations.workload
          labels:
          - from: pod
            key: app
            tag_name: k8s.labels.app
          metadata: []
```

**Link to tracking Issue:** fix open-telemetry#14452 

---------

Signed-off-by: Ziqi Zhao <[email protected]>
Co-authored-by: Dmitrii Anoshin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
processor/k8sattributes k8s Attributes processor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

k8sattributes processor - Allow metadata extractions to be null
3 participants