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/resourcedetection] Add Amazon EKS detector #2820

Merged
merged 5 commits into from
Mar 25, 2021

Conversation

jrcamp
Copy link
Contributor

@jrcamp jrcamp commented Mar 22, 2021

This adds an eks detector for Amazon EKS. It sets cloud.provider,
cloud.infrastructure_service, and k8s.cluster.name.

It's intended to be used in conjunction with ec2 detector. The eks detector
should come first so that the more specific cloud.infrastructure_service value
wins (see README.md).

Note that this code is taken from
https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/detectors/aws/eks.
There is a goal to prevent duplication with go-contrib in #1590 and I started
down that path but it will require more time than currently available as it
needs to transform from different data models, deal with any differences in
metadata between existing detectors, etc.

This adds an eks detector for Amazon EKS. It sets cloud.provider,
cloud.infrastructure_service, and k8s.cluster.name.

It's intended to be used in conjunction with ec2 detector. The eks detector
should come first so that the more specific cloud.infrastructure_service value
wins (see README.md).

Note that this code is taken from
https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/detectors/aws/eks.
There is a goal to prevent duplication with go-contrib in #1590 and I started
down that path but it will require more time than currently available as it
needs to transform from different data models, deal with any differences in
metadata between existing detectors, etc.
@jrcamp jrcamp requested a review from anuraaga as a code owner March 22, 2021 17:38
@jrcamp jrcamp requested a review from a team March 22, 2021 17:38
@jrcamp jrcamp assigned anuraaga and unassigned owais Mar 22, 2021
@codecov
Copy link

codecov bot commented Mar 22, 2021

Codecov Report

Merging #2820 (172066c) into main (716e0a0) will decrease coverage by 0.14%.
The diff coverage is 37.31%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2820      +/-   ##
==========================================
- Coverage   91.58%   91.44%   -0.15%     
==========================================
  Files         452      453       +1     
  Lines       22222    22289      +67     
==========================================
+ Hits        20353    20383      +30     
- Misses       1397     1430      +33     
- Partials      472      476       +4     
Flag Coverage Δ
integration 69.09% <ø> (ø)
unit 90.39% <37.31%> (-0.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...rcedetectionprocessor/internal/aws/eks/detector.go 36.36% <36.36%> (ø)
processor/resourcedetectionprocessor/factory.go 98.73% <100.00%> (+0.01%) ⬆️
exporter/elasticexporter/exporter.go 88.50% <0.00%> (+1.72%) ⬆️
receiver/k8sclusterreceiver/watcher.go 97.64% <0.00%> (+2.35%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 716e0a0...172066c. Read the comment docs.


* cloud.provider ("aws")
* cloud.infrastructure_service ("aws_eks")
* k8s.cluster.name (name of the EKS cluster)
Copy link
Contributor

Choose a reason for hiding this comment

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

For some reason I thought k8s doesn't have the concept of a cluster name but I see it in the spec, nice

Is now a good time to add arn? If not no worries

https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/cloud_provider/aws/eks.md

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would rather do separately.

}

// Detect returns a Resource describing the Amazon EKS environment being run in.
func (detector *Detector) Detect(ctx context.Context) (pdata.Resource, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This code looks familiar, maybe ported from Java? I think for the collector since we already use the k8s client library elsewhere, we can just use it here instead of writing all this fetch logic.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah reread PR description and see it's copied from the Go SDK - but yeah in the collector I would probably expect this to just use the client library. Otherwise if the code can be deduped that sounds good too though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you clarify your plan here? I think it could be easier to just use the k8s client library to fix all of @tigrannajaryan's comments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I'm assuming go-contrib didn't use k8s API to avoid dragging in all of k8s dependencies. I'm reluctant to add it since it will add more friction if we try to upstream it. However, I don't think it's completely unreasonable to say go-contrib and our use cases are different enough that they will just have separate implementations and each does the best for their particular case.

Unless you have strong objections I say let's go with a minimally fixed up version in the hopes of consolidating with go-contrib.

Copy link
Contributor

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

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

See some codecov replies that seem like they should be tested but if you can double-check possibility of checking the error cases will be nice

@tigrannajaryan tigrannajaryan merged commit 2a747fc into open-telemetry:main Mar 25, 2021
pmatyjasek-sumo referenced this pull request in pmatyjasek-sumo/opentelemetry-collector-contrib Apr 28, 2021
This adds an eks detector for Amazon EKS. It sets cloud.provider,
cloud.infrastructure_service, and k8s.cluster.name.

It's intended to be used in conjunction with ec2 detector. The eks detector
should come first so that the more specific cloud.infrastructure_service value
wins (see README.md).

Note that this code is taken from
https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/detectors/aws/eks.
There is a goal to prevent duplication with go-contrib in #1590 and I started
down that path but it will require more time than currently available as it
needs to transform from different data models, deal with any differences in
metadata between existing detectors, etc.
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.

4 participants