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

Add a resource detector for Azure VMs #5422

Open
wants to merge 29 commits into
base: main
Choose a base branch
from

Conversation

pyohannes
Copy link

Fixes #5421

This PR adds a resource detector for Azure VMs which sets values according to to semantic conventions for host, cloud, and os resources:

  • cloud.provider
  • cloud.platform
  • host.id
  • host.name
  • host.type
  • os.type
  • os.version

@pyohannes pyohannes requested a review from a team as a code owner April 23, 2024 12:29
Copy link

codecov bot commented Apr 23, 2024

Codecov Report

Attention: Patch coverage is 91.30435% with 4 lines in your changes missing coverage. Please review.

Project coverage is 63.7%. Comparing base (fbbdb68) to head (4d45d2a).

Current head 4d45d2a differs from pull request most recent head a507369

Please upload reports for the commit a507369 to get more accurate results.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #5422     +/-   ##
=======================================
+ Coverage   63.6%   63.7%   +0.1%     
=======================================
  Files        194     195      +1     
  Lines      12092   12126     +34     
=======================================
+ Hits        7699    7736     +37     
+ Misses      4174    4172      -2     
+ Partials     219     218      -1     
Files Coverage Δ
detectors/azure/azurevm/vm.go 91.3% <91.3%> (ø)

... and 1 file with indirect coverage changes

@MrAlias
Copy link
Contributor

MrAlias commented May 23, 2024

@pyohannes we will want to add you as an owner for this.

@MrAlias
Copy link
Contributor

MrAlias commented May 23, 2024

@pyohannes we will want to add you as an owner for this.

@pyohannes please go ahead and add this module here with yourself and the go-approvers as the code owners.

@pyohannes
Copy link
Author

@pyohannes please go ahead and add this module here with yourself and the go-approvers as the code owners.

@MrAlias Done, I added myself as a code owner.

CHANGELOG.md Outdated Show resolved Hide resolved

type azureInstanceMetadataClient struct{}

func (c *azureInstanceMetadataClient) GetJSONMetadata() ([]byte, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Since this method is mocked in the Detect test, could we test it anyway? (if we move the IP/port for the metadata endpoint into private variables, we can change them to an httptest endpoint in tests).

Copy link
Author

Choose a reason for hiding this comment

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

Yes, if so desired we can do that. We don't need to mock the method then, but just make the endpoint configurable.

Copy link
Author

Choose a reason for hiding this comment

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

I removed the mockable client object, and instead made the endpoint URL configurable.

Please have another look @dmathieu and @MrAlias.

detectors/azure/vm/README.md Outdated Show resolved Hide resolved
detectors/azure/vm/vm.go Outdated Show resolved Hide resolved
detectors/azure/vm/vm.go Outdated Show resolved Hide resolved
detectors/azure/vm/vm.go Outdated Show resolved Hide resolved
detectors/azure/vm/vm.go Outdated Show resolved Hide resolved
detectors/azure/vm/vm.go Outdated Show resolved Hide resolved
@pyohannes pyohannes force-pushed the resource-detector-azure branch 3 times, most recently from ef19296 to d4e48d3 Compare May 30, 2024 09:08
detectors/azure/azurevm/README.md Outdated Show resolved Hide resolved
detectors/azure/azurevm/README.md Show resolved Hide resolved
detectors/azure/azurevm/vm.go Show resolved Hide resolved
@pyohannes
Copy link
Author

@dmathieu @dashpole @MrAlias I hope I addressed all open comments, please have another look.

detectors/azure/azurevm/vm.go Outdated Show resolved Hide resolved
detectors/azure/azurevm/vm.go Outdated Show resolved Hide resolved
detectors/azure/azurevm/vm_test.go Outdated Show resolved Hide resolved
detectors/azure/azurevm/vm.go Outdated Show resolved Hide resolved
detectors/azure/azurevm/vm.go Outdated Show resolved Hide resolved
detectors/azure/azurevm/vm.go Outdated Show resolved Hide resolved
versions.yaml Outdated Show resolved Hide resolved
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
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.

Add a resource detector for Azure VMs
5 participants