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

[resourcedetectionprocessor] Azure detector #2372

Merged
merged 11 commits into from
Mar 3, 2021

Conversation

mx-psi
Copy link
Member

@mx-psi mx-psi commented Feb 18, 2021

Description:

Create Azure resource detector for gathering metadata from the Azure IMDS.

Due to Azure/azure-sdk-for-go#982 we have to query the endpoint manually.

Link to tracking Issue: Fixes #2326

Testing: Added unit tests. Tested end to end with provided sample configuration on an Azure VM.

Documentation: Documented detector on README

@codecov
Copy link

codecov bot commented Feb 18, 2021

Codecov Report

Merging #2372 (e75ddd0) into main (944622e) will decrease coverage by 0.01%.
The diff coverage is 84.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2372      +/-   ##
==========================================
- Coverage   91.20%   91.18%   -0.02%     
==========================================
  Files         417      419       +2     
  Lines       20935    20981      +46     
==========================================
+ Hits        19093    19132      +39     
- Misses       1379     1382       +3     
- Partials      463      467       +4     
Flag Coverage Δ
integration 69.22% <ø> (ø)
unit 90.06% <84.78%> (-0.02%) ⬇️

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

Impacted Files Coverage Δ
...ourcedetectionprocessor/internal/azure/metadata.go 77.41% <77.41%> (ø)
processor/resourcedetectionprocessor/factory.go 98.70% <100.00%> (+0.01%) ⬆️
...resourcedetectionprocessor/internal/azure/azure.go 100.00% <100.00%> (ø)

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 944622e...e75ddd0. Read the comment docs.

}

// computeMetadata is the Azure IMDS compute metadata response format
type computeMetadata struct {
Copy link
Member Author

Choose a reason for hiding this comment

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

The struct does not contain every field returned by Azure, the rest of the fields are ignored since we use the default JSON decoder.

@mx-psi mx-psi marked this pull request as ready for review February 18, 2021 15:15
@mx-psi mx-psi requested a review from a team February 18, 2021 15:15
@mx-psi
Copy link
Member Author

mx-psi commented Feb 24, 2021

@anuraaga @jrcamp Could you take a look whenever you find the time? Thanks!

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.

Sorry for the delay - lgtm

@tigrannajaryan
Copy link
Member

@mx-psi can you take ownership of Azure detector? If yes please add yourself as codeowner for processor/resourcedetectionprocessor/internal/azure directory.

processor/k8sprocessor/ @open-telemetry/collector-contrib-approvers @owais @dmitryax @pmm-sumo
processor/metricstransformprocessor/ @open-telemetry/collector-contrib-approvers @james-bebbington
processor/resourcedetectionprocessor/ @open-telemetry/collector-contrib-approvers @jrcamp @pmm-sumo @anuraaga @dashpole
processor/resourcedetectionprocessor/internal/azure @open-telemetry/collector-contrib-approvers @mx-psi
Copy link
Member Author

@mx-psi mx-psi Feb 24, 2021

Choose a reason for hiding this comment

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

Added myself to CODEOWNERS here (I would recommend looking at the diff hiding whitespace changes)

@mx-psi
Copy link
Member Author

mx-psi commented Feb 24, 2021

@tigrannajaryan I am happy to do so, I added myself to the CODEOWNERS file :)

I am not sure if I will be pinged for reviews though since I don't have write access to the repository and that is a requirement according to Github docs. I will do my best to check PRs/issues manually in any case.

@tigrannajaryan
Copy link
Member

@tigrannajaryan I am happy to do so, I added myself to the CODEOWNERS file :)

I am not sure if I will be pinged for reviews though since I don't have write access to the repository and that is a requirement according to Github docs. I will do my best to check PRs/issues manually in any case.

I am not sure either, but it is good to at least have you listed in the file so that we know who to ask questions. :-)

Thank you.

@tigrannajaryan
Copy link
Member

@jrcamp do you plan to review or good to merge?

Copy link
Contributor

@jrcamp jrcamp left a comment

Choose a reason for hiding this comment

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

LGTM, just one question about the azure.* attributes.

attrs.InsertString(conventions.AttributeCloudRegion, compute.Location)
attrs.InsertString(conventions.AttributeHostID, compute.VMID)
attrs.InsertString(conventions.AttributeCloudAccount, compute.SubscriptionID)
attrs.InsertString("azure.vm.size", compute.VMSize)
Copy link
Contributor

Choose a reason for hiding this comment

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

@tigrannajaryan thoughts on these? Do we have any policy about using things that aren't in semantic conventions?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we do. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/attribute-and-label-naming.md#recommendations-for-opentelemetry-authors and https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/attribute-and-label-naming.md#recommendations-for-application-developers

This seems applicable:

The name may be generally applicable to applications in the industry. In that case consider submitting a proposal to this specification to add a new name to the semantic conventions, and if necessary also to add a new namespace.

Or perhaps this:

The name is specific to your company and may be possibly used outside the company as well. To avoid clashes with names introduced by other companies (in a distributed system that uses applications from multiple vendors) it is recommended to prefix the new name by your company's reverse domain name, e.g. com.acme.shopname

Copy link
Member Author

Choose a reason for hiding this comment

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

Note that the Amazon ECS detector also uses attribute names that are not in the semantic conventions and they prefix them by aws.ecs.

I think the resource group one is fairly specific to how Azure works and has no equivalents on other cloud providers so it should have some Azure prefix (if azure is not okay, which one should be used?) . I thought about using host.type instead of azure.vm.size but it feels like a stretch.

Copy link
Member

Choose a reason for hiding this comment

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

You can keep it for now, but think about Azure attribute name conventions and if you can please make a proposal in spec repo.

@tigrannajaryan
Copy link
Member

Please resolve merge conflicts.

@mx-psi
Copy link
Member Author

mx-psi commented Feb 25, 2021

@tigrannajaryan Done

@mx-psi
Copy link
Member Author

mx-psi commented Mar 3, 2021

@tigrannajaryan Could this be merged?

@tigrannajaryan tigrannajaryan merged commit fa60029 into open-telemetry:main Mar 3, 2021
@mx-psi mx-psi deleted the mx-psi/azure-detector branch March 4, 2021 07:54
This was referenced Mar 15, 2021
kisieland referenced this pull request in kisieland/opentelemetry-collector-contrib Mar 16, 2021
…#2372)

Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.6.1 to 1.7.0.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](stretchr/testify@v1.6.1...v1.7.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
pmatyjasek-sumo referenced this pull request in pmatyjasek-sumo/opentelemetry-collector-contrib Apr 28, 2021
Create Azure resource detector for gathering metadata from the [Azure IMDS](https://aka.ms/azureimds).

Due to Azure/azure-sdk-for-go#982 we have to query the endpoint manually.

**Link to tracking Issue:** Fixes #2326

**Testing:** Added unit tests. Tested end to end with provided sample configuration on an Azure VM.
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.

[resourcedetectionprocessor] Azure resource detector
5 participants