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

[chore] [processor/k8sattributes] improve documentation for the k8sattributes processor #33800

Conversation

bacherfl
Copy link
Contributor

Description: This PR attempts to improve the documentation of the k8sattributes processor. Being relatively new to this component I tried to make the documentation a bit easier to understand for new users, and highlight some limitations I found while going through the implementation.

Link to tracking Issue: #32104

Testing: Trying out different configurations and association rules to get a better understanding

Documentation: Extended the readme of this component

In order to get an association applied, all the sources specified need to match.

Each sources rule is specified as a pair of `from` (representing the rule type) and `name` (representing the attribute name if `from` is set to `resource_attribute`).
The following rule types are available:

- `connection`: Takes the IP attribute from connection context (if available). In this case the processor must appear before any batching or tail sampling, which remove this information.
- `resource_attribute`: Allows specifying the attribute name to lookup in the list of attributes of the received Resource. Semantic convention should be used for naming.

Pod association configuration.
Available attribute names for association sources are the following:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

please let me know if this list is incomplete or wrong, but I thought it might be worth having this explicit list to avoid confusion regarding which attributes can be used for these rules (e.g. the limitation of container level attributes not working here)

@bacherfl bacherfl changed the title chore: improve documentation for the k8sattributes processor [processor/k8sattributes] improve documentation for the k8sattributes processor Jun 28, 2024
@bacherfl bacherfl changed the title [processor/k8sattributes] improve documentation for the k8sattributes processor [chore] [processor/k8sattributes] improve documentation for the k8sattributes processor Jun 28, 2024
@bacherfl bacherfl marked this pull request as ready for review June 28, 2024 05:51
@bacherfl bacherfl requested a review from a team June 28, 2024 05:51
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.

Thank's for working on this!

I also think that the list at https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/33800/files#diff-57b0d6448d516c0c80b326a7f7f95c3256b2b774e496870dc1dd35dcf8bfc256R101 is a bit hard to interpret and leaves some parts as assumptions?
Could we also revisit this as well?
I'm particularly interested about if the container.id is populated when only the k8s.container.name is provided. If that's the case, then the documentation needs to be fixed. If not, then I think this should be fixed in the implementation since I guess it should be doable to get the container.id as well (at extractPodContainersAttributes) (filing a different issue to track this should be fine).

processor/k8sattributesprocessor/README.md Show resolved Hide resolved
- k8s.pod.ip
- k8s.pod.start_time
- k8s.pod.uid
- k8s.replicaset.uid
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't these be either enabled by default or explicitly set by the metadata rules in order to be available in the association? If so, I think it makes sense to mention 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.

good point, I have moved the list to the section about extending the metadata and added a remark that they need to be set there to be available in the association

@crobert-1 crobert-1 added the documentation Improvements or additions to documentation label Jun 28, 2024
@bacherfl
Copy link
Contributor Author

bacherfl commented Jul 1, 2024

Thank's for working on this!

I also think that the list at https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/33800/files#diff-57b0d6448d516c0c80b326a7f7f95c3256b2b774e496870dc1dd35dcf8bfc256R101 is a bit hard to interpret and leaves some parts as assumptions? Could we also revisit this as well? I'm particularly interested about if the container.id is populated when only the k8s.container.name is provided. If that's the case, then the documentation needs to be fixed. If not, then I think this should be fixed in the implementation since I guess it should be doable to get the container.id as well (at extractPodContainersAttributes) (filing a different issue to track this should be fine).

Thanks for your feedback, @ChrsMark! You're right - I was not 100% sure if I should also revisit this section - After trying out some configurations and debugging I verified that those additional container attributes are indeed only added if the k8s.container.name is present in the resource attributes, so it is technically correct. But maybe the requirement of having this attribute in the resource attributes should be highlighted more explicitly since this might be overlooked otherwise. I will try to also reword this section a little

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Jul 16, 2024
@bacherfl
Copy link
Contributor Author

@ChrsMark when you have some time, can you give this one another review please?

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.

The added content looks good to me.

My only concern is if we actually covered the following:

After trying out some configurations and debugging I verified that those additional container attributes are indeed only added if the k8s.container.name is present in the resource attributes, so it is technically correct.

I still think it's a tricky part which either needs to be clearly documented and/or be fixed within the implementation so as to provide the same set of metadata in all cases (if possible).

@bacherfl
Copy link
Contributor Author

The added content looks good to me.

My only concern is if we actually covered the following:

After trying out some configurations and debugging I verified that those additional container attributes are indeed only added if the k8s.container.name is present in the resource attributes, so it is technically correct.

I still think it's a tricky part which either needs to be clearly documented and/or be fixed within the implementation so as to provide the same set of metadata in all cases (if possible).

Thank you for the feedback @ChrsMark! When working on this it seemed to me that this particular point was actually already covered in the original readme in this section: https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/33800/files#diff-57b0d6448d516c0c80b326a7f7f95c3256b2b774e496870dc1dd35dcf8bfc256R97-R106

I hope the additional example added in this PR helps to make this a bit clearer, but I agree that this is a bit of a confusing requirement to begin with, so having a closer look at the implementation to see if this can be improved might be a good idea (at least for pods running a single container it should be possible to automatically attach container level attributes)

@github-actions github-actions bot removed the Stale label Jul 17, 2024
@bacherfl
Copy link
Contributor Author

FYI - I have created an issue to discuss the possibility of falling back to the only container in a single-container pod to relax the requirement of having to provide the k8s.container.name/container.id attributes here: #34189

Copy link
Contributor

@evan-bradley evan-bradley left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@evan-bradley
Copy link
Contributor

@dmitryax @fatsheep9146 @rmfitzpatrick @TylerHelmuth could one of you please take a look?

Copy link
Contributor

@tiffany76 tiffany76 left a comment

Choose a reason for hiding this comment

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

Docs approver here. Just a few small copy edits. Thanks!

processor/k8sattributesprocessor/README.md Outdated Show resolved Hide resolved
processor/k8sattributesprocessor/README.md Outdated Show resolved Hide resolved
processor/k8sattributesprocessor/README.md Outdated Show resolved Hide resolved
@bacherfl
Copy link
Contributor Author

bacherfl commented Aug 6, 2024

Docs approver here. Just a few small copy edits. Thanks!

Thanks for the suggestions, @tiffany76! I have included them into the PR

@TylerHelmuth TylerHelmuth merged commit f4442aa into open-telemetry:main Aug 7, 2024
138 checks passed
@github-actions github-actions bot added this to the next release milestone Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation processor/k8sattributes k8s Attributes processor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants