From e7a8c7dd13ae779085fcc27b28dd17d0d9c3e3d4 Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Wed, 18 Sep 2024 11:19:19 -0600 Subject: [PATCH 1/2] Add pipeline module --- .chloggen/add-pipeline-module.yaml | 25 +++++ Makefile | 4 + internal/globalsignal/Makefile | 1 + internal/globalsignal/go.mod | 11 +++ internal/globalsignal/go.sum | 10 ++ internal/globalsignal/signal.go | 50 ++++++++++ internal/globalsignal/signal_test.go | 41 +++++++++ pipeline/Makefile | 1 + pipeline/go.mod | 16 ++++ pipeline/go.sum | 10 ++ pipeline/pipeline.go | 131 ++++++++++++++++++++++++++ pipeline/pipeline_test.go | 132 +++++++++++++++++++++++++++ pipeline/signal.go | 18 ++++ pipeline/signal_test.go | 30 ++++++ versions.yaml | 2 + 15 files changed, 482 insertions(+) create mode 100644 .chloggen/add-pipeline-module.yaml create mode 100644 internal/globalsignal/Makefile create mode 100644 internal/globalsignal/go.mod create mode 100644 internal/globalsignal/go.sum create mode 100644 internal/globalsignal/signal.go create mode 100644 internal/globalsignal/signal_test.go create mode 100644 pipeline/Makefile create mode 100644 pipeline/go.mod create mode 100644 pipeline/go.sum create mode 100644 pipeline/pipeline.go create mode 100644 pipeline/pipeline_test.go create mode 100644 pipeline/signal.go create mode 100644 pipeline/signal_test.go diff --git a/.chloggen/add-pipeline-module.yaml b/.chloggen/add-pipeline-module.yaml new file mode 100644 index 00000000000..60819a20673 --- /dev/null +++ b/.chloggen/add-pipeline-module.yaml @@ -0,0 +1,25 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: new_component + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: pipeline + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Adds new `pipeline` module to house the concept of pipeline ID and Signal. + +# One or more tracking issues or pull requests related to the change +issues: [11209] + +# (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: + +# 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: [api] diff --git a/Makefile b/Makefile index d27740260b1..58b0335e895 100644 --- a/Makefile +++ b/Makefile @@ -303,11 +303,13 @@ check-contrib: -replace go.opentelemetry.io/collector/extension/zpagesextension=$(CURDIR)/extension/zpagesextension \ -replace go.opentelemetry.io/collector/featuregate=$(CURDIR)/featuregate \ -replace go.opentelemetry.io/collector/internal/globalgates=$(CURDIR)/internal/globalgates \ + -replace go.opentelemetry.io/collector/internal/globalsignal=$(CURDIR)/internal/globalsignal \ -replace go.opentelemetry.io/collector/otelcol=$(CURDIR)/otelcol \ -replace go.opentelemetry.io/collector/otelcol/otelcoltest=$(CURDIR)/otelcol/otelcoltest \ -replace go.opentelemetry.io/collector/pdata=$(CURDIR)/pdata \ -replace go.opentelemetry.io/collector/pdata/testdata=$(CURDIR)/pdata/testdata \ -replace go.opentelemetry.io/collector/pdata/pprofile=$(CURDIR)/pdata/pprofile \ + -replace go.opentelemetry.io/collector/pipeline=$(CURDIR)/pipeline \ -replace go.opentelemetry.io/collector/processor=$(CURDIR)/processor \ -replace go.opentelemetry.io/collector/processor/batchprocessor=$(CURDIR)/processor/batchprocessor \ -replace go.opentelemetry.io/collector/processor/memorylimiterprocessor=$(CURDIR)/processor/memorylimiterprocessor \ @@ -369,11 +371,13 @@ restore-contrib: -dropreplace go.opentelemetry.io/collector/extension/zpagesextension \ -dropreplace go.opentelemetry.io/collector/featuregate \ -dropreplace go.opentelemetry.io/collector/internal/globalgates \ + -dropreplace go.opentelemetry.io/collector/internal/globalsignal \ -dropreplace go.opentelemetry.io/collector/otelcol \ -dropreplace go.opentelemetry.io/collector/otelcol/otelcoltest \ -dropreplace go.opentelemetry.io/collector/pdata \ -dropreplace go.opentelemetry.io/collector/pdata/testdata \ -dropreplace go.opentelemetry.io/collector/pdata/pprofile \ + -dropreplace go.opentelemetry.io/collector/pipeline \ -dropreplace go.opentelemetry.io/collector/processor \ -dropreplace go.opentelemetry.io/collector/processor/batchprocessor \ -dropreplace go.opentelemetry.io/collector/processor/memorylimiterprocessor \ diff --git a/internal/globalsignal/Makefile b/internal/globalsignal/Makefile new file mode 100644 index 00000000000..ded7a36092d --- /dev/null +++ b/internal/globalsignal/Makefile @@ -0,0 +1 @@ +include ../../Makefile.Common diff --git a/internal/globalsignal/go.mod b/internal/globalsignal/go.mod new file mode 100644 index 00000000000..8ee5f5ddf1e --- /dev/null +++ b/internal/globalsignal/go.mod @@ -0,0 +1,11 @@ +module go.opentelemetry.io/collector/internal/globalsignal + +go 1.22.0 + +require github.com/stretchr/testify v1.9.0 + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/internal/globalsignal/go.sum b/internal/globalsignal/go.sum new file mode 100644 index 00000000000..60ce688a041 --- /dev/null +++ b/internal/globalsignal/go.sum @@ -0,0 +1,10 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/globalsignal/signal.go b/internal/globalsignal/signal.go new file mode 100644 index 00000000000..a10431743b0 --- /dev/null +++ b/internal/globalsignal/signal.go @@ -0,0 +1,50 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package globalsignal // import "go.opentelemetry.io/collector/internal/globalsignal" + +import ( + "fmt" + "regexp" +) + +// Signal represents the signals supported by the collector. +type Signal struct { + name string +} + +// String returns the string representation of the signal. +func (s Signal) String() string { + return s.name +} + +// MarshalText marshals the Signal. +func (s Signal) MarshalText() (text []byte, err error) { + return []byte(s.name), nil +} + +// signalRegex is used to validate the signal. +// A signal must consist of 1 to 62 lowercase ASCII alphabetic characters. +var signalRegex = regexp.MustCompile(`^[a-z]{1,62}$`) + +// NewSignal creates a Signal. It returns an error if the Signal is invalid. +// A Signal must consist of 1 to 62 lowercase ASCII alphabetic characters. +func NewSignal(signal string) (Signal, error) { + if len(signal) == 0 { + return Signal{}, fmt.Errorf("signal must not be empty") + } + if !signalRegex.MatchString(signal) { + return Signal{}, fmt.Errorf("invalid character(s) in type %q", signal) + } + return Signal{name: signal}, nil +} + +// MustNewSignal creates a Signal. It panics if the Signal is invalid. +// A signal must consist of 1 to 62 lowercase ASCII alphabetic characters. +func MustNewSignal(signal string) Signal { + s, err := NewSignal(signal) + if err != nil { + panic(err) + } + return s +} diff --git a/internal/globalsignal/signal_test.go b/internal/globalsignal/signal_test.go new file mode 100644 index 00000000000..0729c62c0b5 --- /dev/null +++ b/internal/globalsignal/signal_test.go @@ -0,0 +1,41 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package globalsignal + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func Test_NewSignal(t *testing.T) { + s, err := NewSignal("traces") + require.NoError(t, err) + assert.Equal(t, Signal{name: "traces"}, s) +} + +func Test_NewSignal_Invalid(t *testing.T) { + _, err := NewSignal("") + require.Error(t, err) + _, err = NewSignal("TRACES") + require.Error(t, err) +} + +func Test_MustNewSignal(t *testing.T) { + s := MustNewSignal("traces") + assert.Equal(t, Signal{name: "traces"}, s) +} + +func Test_Signal_String(t *testing.T) { + s := MustNewSignal("traces") + assert.Equal(t, "traces", s.String()) +} + +func Test_Signal_MarshalText(t *testing.T) { + s := MustNewSignal("traces") + b, err := s.MarshalText() + require.NoError(t, err) + assert.Equal(t, []byte("traces"), b) +} diff --git a/pipeline/Makefile b/pipeline/Makefile new file mode 100644 index 00000000000..39734bfaebb --- /dev/null +++ b/pipeline/Makefile @@ -0,0 +1 @@ +include ../Makefile.Common diff --git a/pipeline/go.mod b/pipeline/go.mod new file mode 100644 index 00000000000..d033db037c3 --- /dev/null +++ b/pipeline/go.mod @@ -0,0 +1,16 @@ +module go.opentelemetry.io/collector/pipeline + +go 1.22.0 + +require ( + github.com/stretchr/testify v1.9.0 + go.opentelemetry.io/collector/internal/globalsignal v0.109.0 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +replace go.opentelemetry.io/collector/internal/globalsignal => ../internal/globalsignal diff --git a/pipeline/go.sum b/pipeline/go.sum new file mode 100644 index 00000000000..60ce688a041 --- /dev/null +++ b/pipeline/go.sum @@ -0,0 +1,10 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pipeline/pipeline.go b/pipeline/pipeline.go new file mode 100644 index 00000000000..ae8ac833cc5 --- /dev/null +++ b/pipeline/pipeline.go @@ -0,0 +1,131 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package pipeline // import "go.opentelemetry.io/collector/pipeline" +import ( + "errors" + "fmt" + "regexp" + "strings" + + "go.opentelemetry.io/collector/internal/globalsignal" +) + +// typeAndNameSeparator is the separator that is used between type and name in type/name composite keys. +const typeAndNameSeparator = "/" + +// ID represents the identity for a pipeline. It combines two values: +// * signal - the Signal of the pipeline. +// * name - the name of that pipeline. +type ID struct { + signal Signal `mapstructure:"-"` + name string `mapstructure:"-"` +} + +// NewID returns a new ID with the given Signal and empty name. +func NewID(signal Signal) ID { + return ID{signal: signal} +} + +// MustNewID builds a Signal and returns a new ID with the given Signal and empty name. +// It panics if the Signal is invalid. +// A signal must consist of 1 to 62 lowercase ASCII alphabetic characters. +func MustNewID(signal string) ID { + return ID{signal: globalsignal.MustNewSignal(signal)} +} + +// NewIDWithName returns a new ID with the given Signal and name. +func NewIDWithName(signal Signal, name string) ID { + return ID{signal: signal, name: name} +} + +// MustNewIDWithName builds a Signal and returns a new ID with the given Signal and name. +// It panics if the Signal is invalid or name is invalid. +// A signal must consist of 1 to 62 lowercase ASCII alphabetic characters. +// A name must consist of 1 to 1024 unicode characters excluding whitespace, control characters, and symbols. +func MustNewIDWithName(signal string, name string) ID { + id := ID{signal: globalsignal.MustNewSignal(signal)} + err := validateName(name) + if err != nil { + panic(err) + } + id.name = name + return id +} + +// Signal returns the Signal of the ID. +func (i ID) Signal() Signal { + return i.signal +} + +// Name returns the name of the ID. +func (i ID) Name() string { + return i.name +} + +// MarshalText implements the encoding.TextMarshaler interface. +// This marshals the Signal and name as one string in the config. +func (i ID) MarshalText() (text []byte, err error) { + return []byte(i.String()), nil +} + +// UnmarshalText implements the encoding.TextUnmarshaler interface. +func (i *ID) UnmarshalText(text []byte) error { + idStr := string(text) + items := strings.SplitN(idStr, typeAndNameSeparator, 2) + var signalStr, nameStr string + if len(items) >= 1 { + signalStr = strings.TrimSpace(items[0]) + } + + if len(items) == 1 && signalStr == "" { + return errors.New("id must not be empty") + } + + if signalStr == "" { + return fmt.Errorf("in %q id: the part before %s should not be empty", idStr, typeAndNameSeparator) + } + + if len(items) > 1 { + // "name" part is present. + nameStr = strings.TrimSpace(items[1]) + if nameStr == "" { + return fmt.Errorf("in %q id: the part after %s should not be empty", idStr, typeAndNameSeparator) + } + if err := validateName(nameStr); err != nil { + return fmt.Errorf("in %q id: %w", nameStr, err) + } + } + + var err error + if i.signal, err = globalsignal.NewSignal(signalStr); err != nil { + return fmt.Errorf("in %q id: %w", idStr, err) + } + i.name = nameStr + + return nil +} + +// String returns the ID string representation as "signal[/name]" format. +func (i ID) String() string { + if i.name == "" { + return i.signal.String() + } + + return i.signal.String() + typeAndNameSeparator + i.name +} + +// nameRegexp is used to validate the name of an ID. A name can consist of +// 1 to 1024 unicode characters excluding whitespace, control characters, and +// symbols. +var nameRegexp = regexp.MustCompile(`^[^\pZ\pC\pS]+$`) + +func validateName(nameStr string) error { + if len(nameStr) > 1024 { + return fmt.Errorf("name %q is longer than 1024 characters (%d characters)", nameStr, len(nameStr)) + } + if !nameRegexp.MatchString(nameStr) { + return fmt.Errorf("invalid character(s) in name %q", nameStr) + } + return nil +} diff --git a/pipeline/pipeline_test.go b/pipeline/pipeline_test.go new file mode 100644 index 00000000000..1f96c89a949 --- /dev/null +++ b/pipeline/pipeline_test.go @@ -0,0 +1,132 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package pipeline + +import ( + "strings" + "testing" + + "github.com/stretchr/testify/assert" + + "go.opentelemetry.io/collector/internal/globalsignal" +) + +func Test_NewID(t *testing.T) { + id := NewID(SignalTraces) + assert.Equal(t, ID{signal: SignalTraces}, id) +} + +func Test_MustNewID(t *testing.T) { + id := MustNewID("traces") + assert.Equal(t, ID{signal: SignalTraces}, id) +} + +func Test_NewIDWithName(t *testing.T) { + id := NewIDWithName(SignalTraces, "test") + assert.Equal(t, ID{signal: SignalTraces, name: "test"}, id) +} + +func Test_MustNewIDWithName(t *testing.T) { + id := MustNewIDWithName("traces", "test") + assert.Equal(t, ID{signal: SignalTraces, name: "test"}, id) +} + +func TestMarshalText(t *testing.T) { + id := NewIDWithName(SignalTraces, "name") + got, err := id.MarshalText() + assert.NoError(t, err) + assert.Equal(t, id.String(), string(got)) +} + +func TestUnmarshalText(t *testing.T) { + validSignal := globalsignal.MustNewSignal("valid") + var testCases = []struct { + idStr string + expectedErr bool + expectedID ID + }{ + { + idStr: "valid", + expectedID: ID{signal: validSignal, name: ""}, + }, + { + idStr: "valid/valid_name", + expectedID: ID{signal: validSignal, name: "valid_name"}, + }, + { + idStr: " valid / valid_name ", + expectedID: ID{signal: validSignal, name: "valid_name"}, + }, + { + idStr: "valid/中文好", + expectedID: ID{signal: validSignal, name: "中文好"}, + }, + { + idStr: "valid/name-with-dashes", + expectedID: ID{signal: validSignal, name: "name-with-dashes"}, + }, + // issue 10816 + { + idStr: "valid/Linux-Messages-File_01J49HCH3SWFXRVASWFZFRT3J2__processor0__logs", + expectedID: ID{signal: validSignal, name: "Linux-Messages-File_01J49HCH3SWFXRVASWFZFRT3J2__processor0__logs"}, + }, + { + idStr: "valid/1", + expectedID: ID{signal: validSignal, name: "1"}, + }, + { + idStr: "/valid_name", + expectedErr: true, + }, + { + idStr: " /valid_name", + expectedErr: true, + }, + { + idStr: "valid/", + expectedErr: true, + }, + { + idStr: "valid/ ", + expectedErr: true, + }, + { + idStr: " ", + expectedErr: true, + }, + { + idStr: "valid/invalid name", + expectedErr: true, + }, + { + idStr: "valid/" + strings.Repeat("a", 1025), + expectedErr: true, + }, + { + idStr: "INVALID", + expectedErr: true, + }, + { + idStr: "INVALID/name", + expectedErr: true, + }, + } + + for _, test := range testCases { + t.Run(test.idStr, func(t *testing.T) { + id := ID{} + err := id.UnmarshalText([]byte(test.idStr)) + if test.expectedErr { + assert.Error(t, err) + return + } + + assert.NoError(t, err) + assert.Equal(t, test.expectedID, id) + assert.Equal(t, test.expectedID.Signal(), id.Signal()) + assert.Equal(t, test.expectedID.Name(), id.Name()) + assert.Equal(t, test.expectedID.String(), id.String()) + }) + } +} diff --git a/pipeline/signal.go b/pipeline/signal.go new file mode 100644 index 00000000000..eaa2c75b331 --- /dev/null +++ b/pipeline/signal.go @@ -0,0 +1,18 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package pipeline // import "go.opentelemetry.io/collector/pipeline" + +import ( + "go.opentelemetry.io/collector/internal/globalsignal" +) + +// Signal represents the signals supported by the collector. We currently support +// collecting metrics, traces and logs, this can expand in the future. +type Signal = globalsignal.Signal + +var ( + SignalTraces = globalsignal.MustNewSignal("traces") + SignalMetrics = globalsignal.MustNewSignal("metrics") + SignalLogs = globalsignal.MustNewSignal("logs") +) diff --git a/pipeline/signal_test.go b/pipeline/signal_test.go new file mode 100644 index 00000000000..a1609f98a1b --- /dev/null +++ b/pipeline/signal_test.go @@ -0,0 +1,30 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package pipeline + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_Signal_String(t *testing.T) { + assert.Equal(t, "traces", SignalTraces.String()) + assert.Equal(t, "metrics", SignalMetrics.String()) + assert.Equal(t, "logs", SignalLogs.String()) +} + +func Test_Signal_MarshalText(t *testing.T) { + val, err := SignalTraces.MarshalText() + assert.NoError(t, err) + assert.Equal(t, []byte("traces"), val) + + val, err = SignalMetrics.MarshalText() + assert.NoError(t, err) + assert.Equal(t, []byte("metrics"), val) + + val, err = SignalLogs.MarshalText() + assert.NoError(t, err) + assert.Equal(t, []byte("logs"), val) +} diff --git a/versions.yaml b/versions.yaml index 2d1969ae6dd..4f0b4a31e69 100644 --- a/versions.yaml +++ b/versions.yaml @@ -21,6 +21,7 @@ module-sets: modules: - go.opentelemetry.io/collector - go.opentelemetry.io/collector/internal/globalgates + - go.opentelemetry.io/collector/internal/globalsignal - go.opentelemetry.io/collector/cmd/builder - go.opentelemetry.io/collector/cmd/mdatagen - go.opentelemetry.io/collector/component @@ -58,6 +59,7 @@ module-sets: - go.opentelemetry.io/collector/otelcol/otelcoltest - go.opentelemetry.io/collector/pdata/pprofile - go.opentelemetry.io/collector/pdata/testdata + - go.opentelemetry.io/collector/pipeline - go.opentelemetry.io/collector/processor - go.opentelemetry.io/collector/processor/batchprocessor - go.opentelemetry.io/collector/processor/memorylimiterprocessor From f75f5113f1ccb1291295a1d166bc3c3445d43813 Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:30:55 -0600 Subject: [PATCH 2/2] fix lint --- pipeline/pipeline_test.go | 5 +++-- pipeline/signal_test.go | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pipeline/pipeline_test.go b/pipeline/pipeline_test.go index 1f96c89a949..91727381092 100644 --- a/pipeline/pipeline_test.go +++ b/pipeline/pipeline_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/internal/globalsignal" ) @@ -35,7 +36,7 @@ func Test_MustNewIDWithName(t *testing.T) { func TestMarshalText(t *testing.T) { id := NewIDWithName(SignalTraces, "name") got, err := id.MarshalText() - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, id.String(), string(got)) } @@ -122,7 +123,7 @@ func TestUnmarshalText(t *testing.T) { return } - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, test.expectedID, id) assert.Equal(t, test.expectedID.Signal(), id.Signal()) assert.Equal(t, test.expectedID.Name(), id.Name()) diff --git a/pipeline/signal_test.go b/pipeline/signal_test.go index a1609f98a1b..4e6d17bbcc2 100644 --- a/pipeline/signal_test.go +++ b/pipeline/signal_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func Test_Signal_String(t *testing.T) { @@ -17,14 +18,14 @@ func Test_Signal_String(t *testing.T) { func Test_Signal_MarshalText(t *testing.T) { val, err := SignalTraces.MarshalText() - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, []byte("traces"), val) val, err = SignalMetrics.MarshalText() - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, []byte("metrics"), val) val, err = SignalLogs.MarshalText() - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, []byte("logs"), val) }