-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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] Send host metadata on change, refactor main host metadata sending #25145
Merged
mx-psi
merged 10 commits into
open-telemetry:main
from
mx-psi:mx-psi/inframetadata-base-reporter
Sep 5, 2023
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5e6c041
[*/datadog] Bump opentelemetry-mapping-go/* to v0.7.1
mx-psi 51f8206
[exporter/datadog] Use reporter for exporter host as well
mx-psi e04d63d
Merge branch 'main' into mx-psi/inframetadata-base-reporter
mx-psi f9ef662
Add changelog
mx-psi 5563234
Merge remote-tracking branch 'origin/main' into mx-psi/inframetadata-…
mx-psi 04c11cb
Fix test and send on startup
mx-psi 689e2de
Merge branch 'main' into mx-psi/inframetadata-base-reporter
mx-psi cf84ded
make gotidy
mx-psi 18127cc
Address lint failure
mx-psi 2f14ce2
Merge remote-tracking branch 'origin/main' into mx-psi/inframetadata-…
mx-psi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: enhancement | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: datadogexporter | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Host metadata for remote hosts is now reported on first sight or on change | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [25145] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: | | ||
Host metadata for remote hosts will only be sent for payloads with the datadog.host.use_as_metadata resource attribute. | ||
|
||
# If your change doesn't affect end users or the exported elements of any package, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [user] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,12 +150,11 @@ func NewPusher(params exporter.CreateSettings, pcfg PusherConfig) inframetadata. | |
|
||
// RunPusher to push host metadata payloads from the host where the Collector is running periodically to Datadog intake. | ||
// This function is blocking and it is meant to be run on a goroutine. | ||
func RunPusher(ctx context.Context, params exporter.CreateSettings, pcfg PusherConfig, p source.Provider, attrs pcommon.Map) { | ||
func RunPusher(ctx context.Context, params exporter.CreateSettings, pcfg PusherConfig, p source.Provider, attrs pcommon.Map, reporter *inframetadata.Reporter) { | ||
// Push metadata every 30 minutes | ||
ticker := time.NewTicker(30 * time.Minute) | ||
defer ticker.Stop() | ||
defer params.Logger.Debug("Shut down host metadata routine") | ||
pusher := NewPusher(params, pcfg) | ||
|
||
// Get host metadata from resources and fill missing info using our exporter. | ||
// Currently we only retrieve it once but still send the same payload | ||
|
@@ -169,23 +168,18 @@ func RunPusher(ctx context.Context, params exporter.CreateSettings, pcfg PusherC | |
hostMetadata = metadataFromAttributes(attrs) | ||
} | ||
fillHostMetadata(params, pcfg, p, &hostMetadata) | ||
|
||
// Run one first time at startup | ||
if err := pusher.Push(ctx, hostMetadata); err != nil { | ||
params.Logger.Warn("Initial host metadata failed", zap.Error(err)) | ||
} else { | ||
params.Logger.Info("Sent initial host metadata") | ||
// Consume one first time | ||
if err := reporter.ConsumeHostMetadata(hostMetadata); err != nil { | ||
params.Logger.Warn("Failed to consume host metadata", zap.Any("payload", hostMetadata)) | ||
} | ||
|
||
for { | ||
select { | ||
case <-ctx.Done(): | ||
return | ||
case <-ticker.C: // Send host metadata | ||
if err := pusher.Push(ctx, hostMetadata); err != nil { | ||
params.Logger.Warn("Sending host metadata failed", zap.Error(err)) | ||
} else { | ||
params.Logger.Info("Sent host metadata") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
case <-ticker.C: | ||
if err := reporter.ConsumeHostMetadata(hostMetadata); err != nil { | ||
params.Logger.Warn("Failed to consume host metadata", zap.Any("payload", hostMetadata)) | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to keep this log?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now have a log each time we push here: https://github.com/DataDog/opentelemetry-mapping-go/blob/8cccaf6f3cfb6e4ad31da562517c3a656f1692d7/pkg/inframetadata/reporter.go#L129-L132