Skip to content

[processor/k8sattributes] Automatic resource attributes - annotation prefix #38825

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

Merged

Conversation

zeitlinger
Copy link
Member

This is the first part of #37114 - the ability to use an annotation prefix to define a resource attribute

@zeitlinger
Copy link
Member Author

@dmitryax as discussed, this is the first PR for automatic resource attributes

Copy link
Contributor

@mattsains mattsains left a comment

Choose a reason for hiding this comment

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

I am not an approver unfortunately, but I looked through this PR and it looks good to me

@mattsains
Copy link
Contributor

perhaps @andrzej-stencel could take a look?

Copy link
Member

@dmitryax dmitryax left a comment

Choose a reason for hiding this comment

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

@zeitlinger
Copy link
Member Author

zeitlinger commented Apr 3, 2025

@dmitryax answering here:

Can we just move well known attributes from this section to where all the other pre-defined resource attributes are configured extract.metadata, and disabled by default?

Then this section would be responsible for taking resource attributes from annotations only. Instead of calling it automatic_attributes, it can be something like

extract:
  otel_annotations: <bool> // false by default

will do

Then, if we want to provide flexibility for annotations extraction, we could add extract.annotations with the same syntax as we currently have for extract.labels. That is not really needed right now.

will remove

Providing such interface would be consistent with the existing one and easier to understand by the end users. Please let me know WDYT.

sounds good 😄

@zeitlinger zeitlinger force-pushed the automatic-attributes-from-annotations branch 2 times, most recently from 8de94f4 to 5ec4a2d Compare April 3, 2025 10:49
@zeitlinger
Copy link
Member Author

@dmitryax done - the test failures seem unrelated to this PR

@dmitryax
Copy link
Member

dmitryax commented Apr 9, 2025

I actually missed that we already have extract::annotations config option. What if instead of adding another boolean flag otel_annotations, we just add this rule by default in extract::annotations. Users who don't want it, can disable it by setting it to an empty slice. The prefix is very specific, I don't think it's being used extensively, so it shouldn't surprise the users. WDYT?

If that sounds good, we should clearly describe it in the changelog and how to disable it.

@zeitlinger
Copy link
Member Author

I actually missed that we already have extract::annotations config option. What if instead of adding another boolean flag otel_annotations, we just add this rule by default in extract::annotations. Users who don't want it, can disable it by setting it to an empty slice. The prefix is very specific, I don't think it's being used extensively, so it shouldn't surprise the users. WDYT?

If that sounds good, we should clearly describe it in the changelog and how to disable it.

I like that 😄

@zeitlinger
Copy link
Member Author

zeitlinger commented Apr 9, 2025

I actually missed that we already have extract::annotations config option. What if instead of adding another boolean flag otel_annotations, we just add this rule by default in extract::annotations. Users who don't want it, can disable it by setting it to an empty slice. The prefix is very specific, I don't think it's being used extensively, so it shouldn't surprise the users. WDYT?
If that sounds good, we should clearly describe it in the changelog and how to disable it.

I like that 😄

@dmitryax on second thought - what about users who do have their own attribute rules?

They would have to add a rule with the exact prefix - I would like to avoid that users have to know those details.

@zeitlinger zeitlinger force-pushed the automatic-attributes-from-annotations branch from 5ec4a2d to 496c904 Compare April 9, 2025 10:01
Copy link
Member

@ChrsMark ChrsMark left a comment

Choose a reason for hiding this comment

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

I like the idea of keeping the extract:otel_annotations setting different from the extract::annotations. Changing the behaviour of extract::annotations now to include the logic of this PR would affect users as a breaking change and disabling this or just overriding the rules would require extra manual work for the users. In addition, it's not a bad design to group this rulings under a specific setting as a shortcut, right?

Based on this I'd lean towards going with the separate one.

key: app.kubernetes.io/component
from: pod
# Apply the operator rules - see https://github.com/open-telemetry/semantic-conventions/blob/main/docs/non-normative/k8s-attributes.md
otel_annotations: true # default is false - use true to enable
Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with the addition of this specific one. However, I wonder how this will be combined with the rest of the settings as described at #37114 (comment). Sorry if I miss any context here but that'd help clarifying this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we'll need to have another 2 flag to cover this

Copy link
Member

Choose a reason for hiding this comment

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

Should we decide on those at a high level before adding this specific one? My preference would be to have alignment on the high level config schema before starting any partial implementations. Would that make sense?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@ChrsMark ChrsMark Apr 10, 2025

Choose a reason for hiding this comment

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

Hmm, extract::metadata is a map string array so I'm not sure how we could add extra options without breaking it, right?
Also in this PR we extract the annotation through the extract::otel_annotations setting so I assume the equivalent would be extract::well_known_labels, @zeitlinger could you confirm if that's the direction you had in mind?

Copy link
Member

Choose a reason for hiding this comment

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

From my perspective I'm coverd with the current state and the future plans. @dmitryax feel free to resolve this comment if we are on agreement.

Copy link
Member

@dmitryax dmitryax left a comment

Choose a reason for hiding this comment

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

LGTM

@dmitryax
Copy link
Member

dmitryax commented Apr 9, 2025

They would have to add a rule with the exact prefix - I would like to avoid that users have to know those details.

I was thinking of avoiding complicating the configuration interface which is already big and complex, but this is a valid concern. So I agree with keeping another option.

@zeitlinger zeitlinger force-pushed the automatic-attributes-from-annotations branch from 952cd90 to 0e8a3c9 Compare April 10, 2025 13:17
@ChrsMark
Copy link
Member

We will need a third one for the service attributes

I see, my only concern would be that the service attributes group will have an overlap with the other 2 but we can discuss it then (probably that should be fine though).

I'm going to approve this PR as is since this top level otel_annotations setting makes sense on its own and the path forward seems to be clear.

@dmitryax dmitryax merged commit 6682df5 into open-telemetry:main Apr 11, 2025
171 checks passed
@github-actions github-actions bot added this to the next release milestone Apr 11, 2025
@zeitlinger zeitlinger deleted the automatic-attributes-from-annotations branch April 11, 2025 08:34
akshays-19 pushed a commit to akshays-19/opentelemetry-collector-contrib that referenced this pull request Apr 23, 2025
…prefix (open-telemetry#38825)

This is the first part of
open-telemetry#37114
- the ability to use an annotation prefix to define a resource attribute

---------

Co-authored-by: Christos Markou <[email protected]>
Fiery-Fenix pushed a commit to Fiery-Fenix/opentelemetry-collector-contrib that referenced this pull request Apr 24, 2025
…prefix (open-telemetry#38825)

This is the first part of
open-telemetry#37114
- the ability to use an annotation prefix to define a resource attribute

---------

Co-authored-by: Christos Markou <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants