From df5ba72b5089c787226931f53ccdd52104d28546 Mon Sep 17 00:00:00 2001 From: kaiyan-sheng Date: Fri, 25 Oct 2024 02:43:16 -0600 Subject: [PATCH] [receiver/awsfirehosereceiver] make otlp_v1 a valid record type (#35750) #### Description This PR is to add `otlp_v1` into the list of valid `record_type` input. Otherwise when `record_type` sets to `otlp_v1`, we get error: ``` 2024-10-23T16:53:09.823Z info service@v0.112.0/service.go:135 Setting up own telemetry... 2024-10-23T16:53:09.824Z info telemetry/metrics.go:70 Serving metrics {"address": "localhost:8888", "metrics level": "Normal"} Error: failed to build pipelines: failed to create "awsfirehose" receiver for data type "metrics": unrecognized record type ``` --------- Co-authored-by: Matthew Wear --- .chloggen/add_otlp.yaml | 25 ++++++++++++++++++++ receiver/awsfirehosereceiver/factory.go | 6 +++-- receiver/awsfirehosereceiver/factory_test.go | 3 +++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 .chloggen/add_otlp.yaml diff --git a/.chloggen/add_otlp.yaml b/.chloggen/add_otlp.yaml new file mode 100644 index 000000000000..dbea16c5a93d --- /dev/null +++ b/.chloggen/add_otlp.yaml @@ -0,0 +1,25 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: awsfirehosereceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: make otlp_v1 a valid record type + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [35750] + +# (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: [user] diff --git a/receiver/awsfirehosereceiver/factory.go b/receiver/awsfirehosereceiver/factory.go index 7ba2149539c2..1d918f85ac54 100644 --- a/receiver/awsfirehosereceiver/factory.go +++ b/receiver/awsfirehosereceiver/factory.go @@ -18,6 +18,7 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsfirehosereceiver/internal/unmarshaler" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsfirehosereceiver/internal/unmarshaler/cwlog" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsfirehosereceiver/internal/unmarshaler/cwmetricstream" + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsfirehosereceiver/internal/unmarshaler/otlpmetricstream" ) const ( @@ -28,8 +29,9 @@ const ( var ( errUnrecognizedRecordType = errors.New("unrecognized record type") availableRecordTypes = map[string]bool{ - cwmetricstream.TypeStr: true, - cwlog.TypeStr: true, + cwmetricstream.TypeStr: true, + cwlog.TypeStr: true, + otlpmetricstream.TypeStr: true, } ) diff --git a/receiver/awsfirehosereceiver/factory_test.go b/receiver/awsfirehosereceiver/factory_test.go index 4beca7a7eeec..c42417511f32 100644 --- a/receiver/awsfirehosereceiver/factory_test.go +++ b/receiver/awsfirehosereceiver/factory_test.go @@ -11,6 +11,8 @@ import ( "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/receiver/receivertest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsfirehosereceiver/internal/unmarshaler/otlpmetricstream" ) func TestValidConfig(t *testing.T) { @@ -43,5 +45,6 @@ func TestCreateLogsReceiver(t *testing.T) { func TestValidateRecordType(t *testing.T) { require.NoError(t, validateRecordType(defaultMetricsRecordType)) require.NoError(t, validateRecordType(defaultLogsRecordType)) + require.NoError(t, validateRecordType(otlpmetricstream.TypeStr)) require.Error(t, validateRecordType("nop")) }