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

[pkg/ottl] Set method should allow dynamically setting map values to attributes #14946

Open
rupeshnemade opened this issue Oct 14, 2022 · 4 comments
Labels
enhancement New feature or request never stale Issues marked with this label will be never staled and automatically removed pkg/ottl priority:p2 Medium processor/transform Transform processor

Comments

@rupeshnemade
Copy link

Is your feature request related to a problem? Please describe.

While using transform processor, we tried setting set kubernetes labels to a single attribute 'labels' in a body as below.

image

But Set method doesn't iterate through the map of values & instead needs all keys in array to be explicitly mentioned like below-
set(attributes["kubernetes.labels"], resource.attributes["pod_labels_app"])

Kubernetes labels is something dynamic things & we can't explicitly mention label name in OTEL processor rules.

Describe the solution you'd like

Set method in here should allow iterate through the map & fetch all values so that we can perform something like this-

set(attributes["kubernetes.labels"], resource.attributes["pod_labels_*"])

Describe alternatives you've considered

No response

Additional context

No response

@rupeshnemade rupeshnemade added enhancement New feature or request needs triage New item requiring triage labels Oct 14, 2022
@TylerHelmuth TylerHelmuth added processor/transform Transform processor pkg/ottl priority:p2 Medium and removed needs triage New item requiring triage labels Oct 15, 2022
@TylerHelmuth
Copy link
Member

I can think of two ways to handle this situation:

  1. Update all contexts used by the transform processor to understand that wildcard (*) in a key means "all fields in a map that match that key".
  2. Create a new Factory Function that knows how to take a map and a string pattern and returns a map that contains all the fields from the input map that match the pattern. It would behave similarly to replace_all_patterns.

I would opt for the second because I like the flexibility that Factory Functions provide. I prefer putting business logic in the function vs the contexts.

@bogdandrutu @kentquirk @evan-bradley what do you think?

@TylerHelmuth TylerHelmuth changed the title Set method should allow dynamically setting map values to attributes [pkg/ottl] Set method should allow dynamically setting map values to attributes Oct 15, 2022
@evan-bradley
Copy link
Contributor

I agree, I think a function would be better for this sort of operation. In addition to keeping business logic out of the contexts I think it also provides a good pattern for doing other types of matching (regex, filtering, etc.), and makes it more explicit what is going on.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2023

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2023

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions github-actions bot added the Stale label Mar 7, 2023
@TylerHelmuth TylerHelmuth added never stale Issues marked with this label will be never staled and automatically removed and removed Stale labels Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request never stale Issues marked with this label will be never staled and automatically removed pkg/ottl priority:p2 Medium processor/transform Transform processor
Projects
None yet
Development

No branches or pull requests

3 participants