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

[exporter/datadog] Fix host alias field in metadata payload & fix GCP host alias. #9748

Merged
merged 7 commits into from
May 24, 2022

Conversation

KSerrania
Copy link
Contributor

@KSerrania KSerrania commented May 5, 2022

Description:

Fixes the metadata payload field name used to send host aliases to the Datadog backend (the correct field is host_aliases, not host-aliases, see this datadog-agent code for comparison).

Also fixes the GCP host alias resolution to match what is done in the datadog-agent. Since we weren't sending this host alias correctly at all before, we consider this not to be a breaking change.

Link to tracking Issue: #9122

Testing: Amended the unit test for the GCP host alias. Manually checked that host aliases are now properly seen in the Datadog backend when the Meta.HostAliases field is not empty.

Documentation: n/a

@mx-psi mx-psi linked an issue May 5, 2022 that may be closed by this pull request
Comment on lines 46 to 49
// Add host id as a host alias to preserve backwards compatibility
// The Datadog Agent does not do this
hostInfo.HostAliases = append(hostInfo.HostAliases, hostID.StringVal())
if cloudAccount, ok := attrs.Get(conventions.AttributeCloudAccountID); ok {
alias := fmt.Sprintf("%s.%s", hostID.StringVal(), cloudAccount.StringVal())
hostInfo.HostAliases = append(hostInfo.HostAliases, alias)
}
Copy link
Member

Choose a reason for hiding this comment

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

Note for future git history spelunkers: this is not a breaking change since we were not sending host aliases at all to the backend.

@mx-psi
Copy link
Member

mx-psi commented May 5, 2022

🤔 Could you do an empty commit? Github Actions is not running for some reason on your last commit (or alternatively, fix the conflict with the changelog)

@mx-psi
Copy link
Member

mx-psi commented May 5, 2022

2022-05-05T09:28:13.2773192Z === RUN   TestMetadataFromAttributes
2022-05-05T09:28:13.2773553Z     metadata_test.go:129: 
2022-05-05T09:28:13.2773968Z         	Error Trace:	metadata_test.go:129
2022-05-05T09:28:13.2774343Z         	Error:      	elements differ
2022-05-05T09:28:13.2774669Z         	            	
2022-05-05T09:28:13.2775136Z         	            	extra elements in list A:
2022-05-05T09:28:13.2775792Z         	            	([]interface {}) (len=1) {
2022-05-05T09:28:13.2776519Z         	            	 (string) (len=18) "project:project-id"
2022-05-05T09:28:13.2776890Z         	            	}
2022-05-05T09:28:13.2777202Z         	            	
2022-05-05T09:28:13.2871981Z         	            	
2022-05-05T09:28:13.2872628Z         	            	listA:
2022-05-05T09:28:13.2873129Z         	            	([]string) (len=4) {
2022-05-05T09:28:13.2874196Z         	            	 (string) (len=19) "instance-id:host-id",
2022-05-05T09:28:13.2874941Z         	            	 (string) (len=15) "zone:cloud-zone",
2022-05-05T09:28:13.2875924Z         	            	 (string) (len=23) "instance-type:host-type",
2022-05-05T09:28:13.2876715Z         	            	 (string) (len=18) "project:project-id"
2022-05-05T09:28:13.2877109Z         	            	}
2022-05-05T09:28:13.2877472Z         	            	
2022-05-05T09:28:13.2877812Z         	            	
2022-05-05T09:28:13.2878209Z         	            	listB:
2022-05-05T09:28:13.2878848Z         	            	([]string) (len=3) {
2022-05-05T09:28:13.2879598Z         	            	 (string) (len=19) "instance-id:host-id",
2022-05-05T09:28:13.2880331Z         	            	 (string) (len=15) "zone:cloud-zone",
2022-05-05T09:28:13.2881107Z         	            	 (string) (len=23) "instance-type:host-type"
2022-05-05T09:28:13.2881493Z         	            	}
2022-05-05T09:28:13.2881920Z         	Test:       	TestMetadataFromAttributes
2022-05-05T09:28:13.2882372Z --- FAIL: TestMetadataFromAttributes (0.00s)

@github-actions
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 May 21, 2022
@mx-psi mx-psi removed the Stale label May 23, 2022
@KSerrania KSerrania marked this pull request as ready for review May 23, 2022 18:03
@KSerrania KSerrania requested review from a team and djaglowski May 23, 2022 18:03
@djaglowski djaglowski merged commit f75ced7 into open-telemetry:main May 24, 2022
@mx-psi mx-psi deleted the kserrania/host-aliases branch May 24, 2022 13:10
kentquirk pushed a commit to McSick/opentelemetry-collector-contrib that referenced this pull request Jun 14, 2022
… host alias. (open-telemetry#9748)

* [exporter/datadog] Fix host_alias json field

* Update GCP host alias computation

* Add release note

* Fix tests

* Fix GCP host alias resolution
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.

[exporter/datadog] Possibly incorrect json identifier for host aliases
3 participants