From ba4072f84888749a00f5748cca9f2a7fc2e42fc9 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Tue, 2 Apr 2024 15:39:50 +0200 Subject: [PATCH] [pkg/inframetadata] Improve warning when host-identifying attributes are missing (#314) * [pkg/inframetadata] Improve warning when host-identifying attributes are missing * Update mx-psi_improve-warning.yaml --- .chloggen/mx-psi_improve-warning.yaml | 16 ++++++++++++++++ pkg/inframetadata/reporter.go | 5 ++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100755 .chloggen/mx-psi_improve-warning.yaml diff --git a/.chloggen/mx-psi_improve-warning.yaml b/.chloggen/mx-psi_improve-warning.yaml new file mode 100755 index 00000000..5dbfef98 --- /dev/null +++ b/.chloggen/mx-psi_improve-warning.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component (e.g. pkg/quantile) +component: pkg/inframetadata + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Fixes warning log where resource attributes were not correctly logged + +# The PR related to this change +issues: [314] + +# (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: diff --git a/pkg/inframetadata/reporter.go b/pkg/inframetadata/reporter.go index 26107990..1561ac8e 100644 --- a/pkg/inframetadata/reporter.go +++ b/pkg/inframetadata/reporter.go @@ -109,7 +109,10 @@ func (r *Reporter) pushAndLog(ctx context.Context, hm payload.HostMetadata) { func (r *Reporter) hostname(res pcommon.Resource) (string, bool) { src, ok := attributes.SourceFromAttrs(res.Attributes()) if !ok { - r.logger.Warn("resource does not have host-identifying attributes", zap.Any("attributes", res.Attributes())) + r.logger.Warn("resource does not have host-identifying attributes", + zap.Any("attributes", res.Attributes().AsRaw()), + zap.String("further info", "https://docs.datadoghq.com/opentelemetry/schema_semantics/hostname/?tab=datadogexporter"), + ) return "", false } if src.Kind != source.HostnameKind {