From 2e8fc49d31a995f19c308dcdfab613f5e8668f8a Mon Sep 17 00:00:00 2001 From: Alex Boten <223565+codeboten@users.noreply.github.com> Date: Mon, 12 Aug 2024 10:20:28 -0700 Subject: [PATCH] [receiver/cloudflare] update scope name for consistency (#34613) Update the scope name for telemetry produced by the cloudflarereceiver from otelcol/cloudflare to github.com/open-telemetry/opentelemetry-collector-contrib/receiver/cloudflarereceiver Part of open-telemetry/opentelemetry-collector#9494 --------- Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com> --- .chloggen/codeboten_more-scope-7.yaml | 27 +++++++++++++++++++ receiver/cloudflarereceiver/logs.go | 4 +-- receiver/cloudflarereceiver/logs_test.go | 4 +-- .../testdata/processed/all_fields.yaml | 2 +- .../processed/multiple_log_payload.yaml | 6 ++--- 5 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 .chloggen/codeboten_more-scope-7.yaml diff --git a/.chloggen/codeboten_more-scope-7.yaml b/.chloggen/codeboten_more-scope-7.yaml new file mode 100644 index 000000000000..bb0842db8cf1 --- /dev/null +++ b/.chloggen/codeboten_more-scope-7.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: cloudflarereceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "Update the scope name for telemetry produced by the cloudflarereceiver from `otelcol/cloudflare` to `github.com/open-telemetry/opentelemetry-collector-contrib/receiver/cloudflarereceiver`" + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [34613] + +# (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: + +# 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: [] diff --git a/receiver/cloudflarereceiver/logs.go b/receiver/cloudflarereceiver/logs.go index 051acbcfb903..3c690dd5ec98 100644 --- a/receiver/cloudflarereceiver/logs.go +++ b/receiver/cloudflarereceiver/logs.go @@ -39,8 +39,6 @@ type logsReceiver struct { const secretHeaderName = "X-CF-Secret" -var receiverScopeName = "otelcol/" + metadata.Type.String() - func newLogsReceiver(params rcvr.Settings, cfg *Config, consumer consumer.Logs) (*logsReceiver, error) { recv := &logsReceiver{ cfg: &cfg.Logs, @@ -233,7 +231,7 @@ func (l *logsReceiver) processLogs(now pcommon.Timestamp, logs []map[string]any) resource.Attributes().PutStr("cloudflare.zone", zone) } scopeLogs := resourceLogs.ScopeLogs().AppendEmpty() - scopeLogs.Scope().SetName(receiverScopeName) + scopeLogs.Scope().SetName(metadata.ScopeName) for _, log := range logGroup { logRecord := scopeLogs.LogRecords().AppendEmpty() diff --git a/receiver/cloudflarereceiver/logs_test.go b/receiver/cloudflarereceiver/logs_test.go index b1c759f760e0..696a6b5f645b 100644 --- a/receiver/cloudflarereceiver/logs_test.go +++ b/receiver/cloudflarereceiver/logs_test.go @@ -48,7 +48,7 @@ func TestPayloadToLogRecord(t *testing.T) { logs := plog.NewLogs() rl := logs.ResourceLogs().AppendEmpty() sl := rl.ScopeLogs().AppendEmpty() - sl.Scope().SetName(receiverScopeName) + sl.Scope().SetName("github.com/open-telemetry/opentelemetry-collector-contrib/receiver/cloudflarereceiver") for idx, line := range strings.Split(payload, "\n") { lr := sl.LogRecords().AppendEmpty() @@ -86,7 +86,7 @@ func TestPayloadToLogRecord(t *testing.T) { })) sl := rl.ScopeLogs().AppendEmpty() - sl.Scope().SetName(receiverScopeName) + sl.Scope().SetName("github.com/open-telemetry/opentelemetry-collector-contrib/receiver/cloudflarereceiver") lr := sl.LogRecords().AppendEmpty() require.NoError(t, lr.Attributes().FromRaw(map[string]any{ diff --git a/receiver/cloudflarereceiver/testdata/processed/all_fields.yaml b/receiver/cloudflarereceiver/testdata/processed/all_fields.yaml index dea4d0d1e3c7..8b0701a92a5e 100644 --- a/receiver/cloudflarereceiver/testdata/processed/all_fields.yaml +++ b/receiver/cloudflarereceiver/testdata/processed/all_fields.yaml @@ -284,4 +284,4 @@ resourceLogs: timeUnixNano: "1677821346000000000" traceId: "" scope: - name: otelcol/cloudflare + name: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/cloudflarereceiver diff --git a/receiver/cloudflarereceiver/testdata/processed/multiple_log_payload.yaml b/receiver/cloudflarereceiver/testdata/processed/multiple_log_payload.yaml index 25014da16909..94f14c7b9862 100644 --- a/receiver/cloudflarereceiver/testdata/processed/multiple_log_payload.yaml +++ b/receiver/cloudflarereceiver/testdata/processed/multiple_log_payload.yaml @@ -83,7 +83,7 @@ resourceLogs: timeUnixNano: "1677821345000000000" traceId: "" scope: - name: otelcol/cloudflare + name: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/cloudflarereceiver - resource: attributes: - key: cloudflare.zone @@ -178,7 +178,7 @@ resourceLogs: timeUnixNano: "1677821345000000000" traceId: "" scope: - name: otelcol/cloudflare + name: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/cloudflarereceiver - resource: attributes: - key: cloudflare.zone @@ -230,4 +230,4 @@ resourceLogs: timeUnixNano: "1677821345000000000" traceId: "" scope: - name: otelcol/cloudflare + name: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/cloudflarereceiver