diff --git a/.chloggen/document_factories.yaml b/.chloggen/document_factories.yaml new file mode 100644 index 00000000000..fffb842e1b6 --- /dev/null +++ b/.chloggen/document_factories.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: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: exporter, processor, receiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Document factory functions. + +# One or more tracking issues or pull requests related to the change +issues: [9323] + +# (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/.chloggen/document_fields.yaml b/.chloggen/document_fields.yaml new file mode 100644 index 00000000000..cd2af1bcb6c --- /dev/null +++ b/.chloggen/document_fields.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: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: component + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Document status enums and New constructors + +# One or more tracking issues or pull requests related to the change +issues: [9822] + +# (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/.chloggen/experimental_include_metadata.yaml b/.chloggen/experimental_include_metadata.yaml new file mode 100644 index 00000000000..11a936f5b8d --- /dev/null +++ b/.chloggen/experimental_include_metadata.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: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: confighttp, configgrpc + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Remove the experimental comment on `IncludeMetadata` in confighttp and configgrpc + +# One or more tracking issues or pull requests related to the change +issues: [9381] + +# (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/.chloggen/profiles-consumertest.yaml b/.chloggen/profiles-consumertest.yaml new file mode 100644 index 00000000000..b211551f461 --- /dev/null +++ b/.chloggen/profiles-consumertest.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: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: consumer/consumertest + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Allow testing profiles with consumertest. + +# One or more tracking issues or pull requests related to the change +issues: [10692] + +# (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/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 94ffea52618..895006c3f3a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -30,12 +30,12 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12 + uses: github/codeql-action/init@2d790406f505036ef40ecba973cc774a50395aac # v3.25.13 with: languages: go - name: Autobuild - uses: github/codeql-action/autobuild@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12 + uses: github/codeql-action/autobuild@2d790406f505036ef40ecba973cc774a50395aac # v3.25.13 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12 + uses: github/codeql-action/analyze@2d790406f505036ef40ecba973cc774a50395aac # v3.25.13 diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index eeb02e0464c..9b418a3ec9f 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -64,6 +64,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12 + uses: github/codeql-action/upload-sarif@2d790406f505036ef40ecba973cc774a50395aac # v3.25.13 with: sarif_file: results.sarif diff --git a/Makefile b/Makefile index c098ca8e40e..2d3dcd706d4 100644 --- a/Makefile +++ b/Makefile @@ -278,6 +278,8 @@ check-contrib: -replace go.opentelemetry.io/collector/connector=$(CURDIR)/connector \ -replace go.opentelemetry.io/collector/connector/forwardconnector=$(CURDIR)/connector/forwardconnector \ -replace go.opentelemetry.io/collector/consumer=$(CURDIR)/consumer \ + -replace go.opentelemetry.io/collector/consumer/consumerprofiles=$(CURDIR)/consumer/consumerprofiles \ + -replace go.opentelemetry.io/collector/consumer/consumertest=$(CURDIR)/consumer/consumertest \ -replace go.opentelemetry.io/collector/exporter=$(CURDIR)/exporter \ -replace go.opentelemetry.io/collector/exporter/debugexporter=$(CURDIR)/exporter/debugexporter \ -replace go.opentelemetry.io/collector/exporter/loggingexporter=$(CURDIR)/exporter/loggingexporter \ @@ -337,6 +339,8 @@ restore-contrib: -dropreplace go.opentelemetry.io/collector/connector \ -dropreplace go.opentelemetry.io/collector/connector/forwardconnector \ -dropreplace go.opentelemetry.io/collector/consumer \ + -dropreplace go.opentelemetry.io/collector/consumer/consumerprofiles \ + -dropreplace go.opentelemetry.io/collector/consumer/consumertest \ -dropreplace go.opentelemetry.io/collector/exporter \ -dropreplace go.opentelemetry.io/collector/exporter/debugexporter \ -dropreplace go.opentelemetry.io/collector/exporter/loggingexporter \ diff --git a/cmd/builder/internal/builder/main_test.go b/cmd/builder/internal/builder/main_test.go index d2c06279eb1..44e1b37513e 100644 --- a/cmd/builder/internal/builder/main_test.go +++ b/cmd/builder/internal/builder/main_test.go @@ -59,6 +59,8 @@ var ( "/confmap/provider/httpsprovider", "/confmap/provider/yamlprovider", "/consumer", + "/consumer/consumerprofiles", + "/consumer/consumertest", "/connector", "/exporter", "/exporter/debugexporter", diff --git a/cmd/builder/test/core.builder.yaml b/cmd/builder/test/core.builder.yaml index 03311f9c3fe..1b2ba855916 100644 --- a/cmd/builder/test/core.builder.yaml +++ b/cmd/builder/test/core.builder.yaml @@ -38,6 +38,7 @@ replaces: - go.opentelemetry.io/collector/confmap/provider/httpsprovider => ${WORKSPACE_DIR}/confmap/provider/httpsprovider - go.opentelemetry.io/collector/confmap/provider/yamlprovider => ${WORKSPACE_DIR}/confmap/provider/yamlprovider - go.opentelemetry.io/collector/consumer => ${WORKSPACE_DIR}/consumer + - go.opentelemetry.io/collector/consumer/consumertest => ${WORKSPACE_DIR}/consumer/consumertest - go.opentelemetry.io/collector/connector => ${WORKSPACE_DIR}/connector - go.opentelemetry.io/collector/exporter => ${WORKSPACE_DIR}/exporter - go.opentelemetry.io/collector/exporter/debugexporter => ${WORKSPACE_DIR}/exporter/debugexporter diff --git a/cmd/mdatagen/go.mod b/cmd/mdatagen/go.mod index 61486b04514..f52462b4e55 100644 --- a/cmd/mdatagen/go.mod +++ b/cmd/mdatagen/go.mod @@ -10,6 +10,7 @@ require ( go.opentelemetry.io/collector/confmap v0.105.0 go.opentelemetry.io/collector/confmap/provider/fileprovider v0.105.0 go.opentelemetry.io/collector/consumer v0.105.0 + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 go.opentelemetry.io/collector/filter v0.105.0 go.opentelemetry.io/collector/pdata v1.12.0 go.opentelemetry.io/collector/receiver v0.105.0 @@ -46,8 +47,10 @@ require ( github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect go.opentelemetry.io/collector/featuregate v1.12.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect + go.opentelemetry.io/collector/pdata/pprofile v0.105.0 // indirect go.opentelemetry.io/otel v1.28.0 // indirect go.opentelemetry.io/otel/exporters/prometheus v0.50.0 // indirect go.opentelemetry.io/otel/sdk v1.28.0 // indirect @@ -93,3 +96,7 @@ retract ( replace go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile replace go.opentelemetry.io/collector/internal/globalgates => ../../internal/globalgates + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest diff --git a/cmd/otelcorecol/builder-config.yaml b/cmd/otelcorecol/builder-config.yaml index 5c9055848f0..e63f908086e 100644 --- a/cmd/otelcorecol/builder-config.yaml +++ b/cmd/otelcorecol/builder-config.yaml @@ -62,6 +62,8 @@ replaces: - go.opentelemetry.io/collector/confmap/provider/httpsprovider => ../../confmap/provider/httpsprovider - go.opentelemetry.io/collector/confmap/provider/yamlprovider => ../../confmap/provider/yamlprovider - go.opentelemetry.io/collector/consumer => ../../consumer + - go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + - go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest - go.opentelemetry.io/collector/connector => ../../connector - go.opentelemetry.io/collector/connector/forwardconnector => ../../connector/forwardconnector - go.opentelemetry.io/collector/exporter => ../../exporter diff --git a/cmd/otelcorecol/go.mod b/cmd/otelcorecol/go.mod index acda68e7df2..9eec0fe1d67 100644 --- a/cmd/otelcorecol/go.mod +++ b/cmd/otelcorecol/go.mod @@ -92,10 +92,13 @@ require ( go.opentelemetry.io/collector/config/configtls v1.12.0 // indirect go.opentelemetry.io/collector/config/internal v0.105.0 // indirect go.opentelemetry.io/collector/consumer v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 // indirect go.opentelemetry.io/collector/extension/auth v0.105.0 // indirect go.opentelemetry.io/collector/featuregate v1.12.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect go.opentelemetry.io/collector/pdata v1.12.0 // indirect + go.opentelemetry.io/collector/pdata/pprofile v0.105.0 // indirect go.opentelemetry.io/collector/semconv v0.105.0 // indirect go.opentelemetry.io/collector/service v0.105.0 // indirect go.opentelemetry.io/contrib/config v0.8.0 // indirect @@ -178,6 +181,10 @@ replace go.opentelemetry.io/collector/confmap/provider/yamlprovider => ../../con replace go.opentelemetry.io/collector/consumer => ../../consumer +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest + replace go.opentelemetry.io/collector/connector => ../../connector replace go.opentelemetry.io/collector/connector/forwardconnector => ../../connector/forwardconnector diff --git a/component/componentprofiles/go.mod b/component/componentprofiles/go.mod index 397fce1d779..7d1f8fa6103 100644 --- a/component/componentprofiles/go.mod +++ b/component/componentprofiles/go.mod @@ -2,7 +2,7 @@ module go.opentelemetry.io/collector/component/componentprofiles go 1.21.0 -require go.opentelemetry.io/collector/component v0.104.0 +require go.opentelemetry.io/collector/component v0.105.0 require ( github.com/gogo/protobuf v1.3.2 // indirect diff --git a/component/status.go b/component/status.go index 8cd4d802644..60894a217ca 100644 --- a/component/status.go +++ b/component/status.go @@ -11,13 +11,21 @@ type Status int32 // Enumeration of possible component statuses const ( + // StatusNone indicates absence of component status. StatusNone Status = iota + // StatusStarting indicates the component is starting. StatusStarting + // StatusOK indicates the component is running without issues. StatusOK + // StatusRecoverableError indicates that the component has experienced a transient error and may recover. StatusRecoverableError + // StatusPermanentError indicates that the component has detected a condition at runtime that will need human intervention to fix. The collector will continue to run in a degraded mode. StatusPermanentError + // StatusFatalError indicates that the collector has experienced a fatal runtime error and will shut down. StatusFatalError + // StatusStopping indicates that the component is in the process of shutting down. StatusStopping + // StatusStopped indicates that the component has completed shutdown. StatusStopped ) @@ -74,24 +82,26 @@ func NewStatusEvent(status Status) *StatusEvent { } } -// NewRecoverableErrorEvent creates and returns a StatusEvent with StatusRecoverableError, the -// specified error, and a timestamp set to time.Now(). +// NewRecoverableErrorEvent wraps a transient error +// passed as argument as a StatusEvent with a status StatusRecoverableError +// and a timestamp set to time.Now(). func NewRecoverableErrorEvent(err error) *StatusEvent { ev := NewStatusEvent(StatusRecoverableError) ev.err = err return ev } -// NewPermanentErrorEvent creates and returns a StatusEvent with StatusPermanentError, the -// specified error, and a timestamp set to time.Now(). +// NewPermanentErrorEvent wraps an error requiring human intervention to fix +// passed as argument as a StatusEvent with a status StatusPermanentError +// and a timestamp set to time.Now(). func NewPermanentErrorEvent(err error) *StatusEvent { ev := NewStatusEvent(StatusPermanentError) ev.err = err return ev } -// NewFatalErrorEvent creates and returns a StatusEvent with StatusFatalError, the -// specified error, and a timestamp set to time.Now(). +// NewFatalErrorEvent wraps the fatal runtime error passed as argument as a StatusEvent +// with a status StatusFatalError and a timestamp set to time.Now(). func NewFatalErrorEvent(err error) *StatusEvent { ev := NewStatusEvent(StatusFatalError) ev.err = err diff --git a/config/configgrpc/configgrpc.go b/config/configgrpc/configgrpc.go index 2bffbe4993f..f718f25913e 100644 --- a/config/configgrpc/configgrpc.go +++ b/config/configgrpc/configgrpc.go @@ -188,7 +188,6 @@ type ServerConfig struct { Auth *configauth.Authentication `mapstructure:"auth"` // Include propagates the incoming connection's metadata to downstream consumers. - // Experimental: *NOTE* this option is subject to change or removal in the future. IncludeMetadata bool `mapstructure:"include_metadata"` } diff --git a/config/configgrpc/go.mod b/config/configgrpc/go.mod index 6db35d3bebc..99db60086ae 100644 --- a/config/configgrpc/go.mod +++ b/config/configgrpc/go.mod @@ -105,3 +105,7 @@ replace go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile replace go.opentelemetry.io/collector/component => ../../component replace go.opentelemetry.io/collector/consumer => ../../consumer + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest diff --git a/config/confighttp/confighttp.go b/config/confighttp/confighttp.go index 2a1960e05fd..5421ddab708 100644 --- a/config/confighttp/confighttp.go +++ b/config/confighttp/confighttp.go @@ -297,7 +297,6 @@ type ServerConfig struct { MaxRequestBodySize int64 `mapstructure:"max_request_body_size"` // IncludeMetadata propagates the client metadata from the incoming requests to the downstream consumers - // Experimental: *NOTE* this option is subject to change or removal in the future. IncludeMetadata bool `mapstructure:"include_metadata"` // Additional headers attached to each HTTP response sent to the client. diff --git a/config/confighttp/go.mod b/config/confighttp/go.mod index f8ea2713bef..ca5d8ac8b63 100644 --- a/config/confighttp/go.mod +++ b/config/confighttp/go.mod @@ -98,3 +98,7 @@ replace go.opentelemetry.io/collector/consumer => ../../consumer replace go.opentelemetry.io/collector/pdata/testdata => ../../pdata/testdata replace go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest diff --git a/config/internal/go.mod b/config/internal/go.mod index 048cc57e806..757d6fff8ff 100644 --- a/config/internal/go.mod +++ b/config/internal/go.mod @@ -37,3 +37,7 @@ replace go.opentelemetry.io/collector/pdata/testdata => ../../pdata/testdata replace go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile replace go.opentelemetry.io/collector/internal/globalgates => ../../internal/globalgates + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest diff --git a/connector/forwardconnector/go.mod b/connector/forwardconnector/go.mod index f42d7423b3a..70286d54f11 100644 --- a/connector/forwardconnector/go.mod +++ b/connector/forwardconnector/go.mod @@ -8,6 +8,7 @@ require ( go.opentelemetry.io/collector/confmap v0.105.0 go.opentelemetry.io/collector/connector v0.105.0 go.opentelemetry.io/collector/consumer v0.105.0 + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 go.opentelemetry.io/collector/pdata v1.12.0 go.uber.org/goleak v1.3.0 ) @@ -38,8 +39,10 @@ require ( github.com/prometheus/procfs v0.15.1 // indirect go.opentelemetry.io/collector v0.105.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect go.opentelemetry.io/collector/featuregate v1.12.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect + go.opentelemetry.io/collector/pdata/pprofile v0.105.0 // indirect go.opentelemetry.io/otel v1.28.0 // indirect go.opentelemetry.io/otel/exporters/prometheus v0.50.0 // indirect go.opentelemetry.io/otel/metric v1.28.0 // indirect @@ -83,3 +86,7 @@ retract ( replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry replace go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest diff --git a/connector/go.mod b/connector/go.mod index 877268cf09b..eedaf4307b5 100644 --- a/connector/go.mod +++ b/connector/go.mod @@ -8,6 +8,7 @@ require ( go.opentelemetry.io/collector v0.105.0 go.opentelemetry.io/collector/component v0.105.0 go.opentelemetry.io/collector/consumer v0.105.0 + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 go.opentelemetry.io/collector/pdata v1.12.0 go.opentelemetry.io/collector/pdata/testdata v0.105.0 go.uber.org/goleak v1.3.0 @@ -32,6 +33,7 @@ require ( github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.105.0 // indirect go.opentelemetry.io/otel v1.28.0 // indirect go.opentelemetry.io/otel/exporters/prometheus v0.50.0 // indirect @@ -67,3 +69,7 @@ replace go.opentelemetry.io/collector/pdata/testdata => ../pdata/testdata replace go.opentelemetry.io/collector/pdata/pprofile => ../pdata/pprofile replace go.opentelemetry.io/collector/internal/globalgates => ../internal/globalgates + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../consumer/consumertest diff --git a/consumer/consumertest/Makefile b/consumer/consumertest/Makefile new file mode 100644 index 00000000000..ded7a36092d --- /dev/null +++ b/consumer/consumertest/Makefile @@ -0,0 +1 @@ +include ../../Makefile.Common diff --git a/consumer/consumertest/consumer.go b/consumer/consumertest/consumer.go index 147ed55c7ed..4b699b9449a 100644 --- a/consumer/consumertest/consumer.go +++ b/consumer/consumertest/consumer.go @@ -7,8 +7,10 @@ import ( "context" "go.opentelemetry.io/collector/consumer" + "go.opentelemetry.io/collector/consumer/consumerprofiles" "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/pprofile" "go.opentelemetry.io/collector/pdata/ptrace" ) @@ -29,12 +31,16 @@ type Consumer interface { // ConsumeLogs to implement the consumer.Logs. ConsumeLogs(context.Context, plog.Logs) error + // ConsumeProfiles to implement the consumerprofiles.Profiles. + ConsumeProfiles(context.Context, pprofile.Profiles) error + unexported() } var _ consumer.Logs = (Consumer)(nil) var _ consumer.Metrics = (Consumer)(nil) var _ consumer.Traces = (Consumer)(nil) +var _ consumerprofiles.Profiles = (Consumer)(nil) type nonMutatingConsumer struct{} @@ -48,6 +54,7 @@ type baseConsumer struct { consumer.ConsumeTracesFunc consumer.ConsumeMetricsFunc consumer.ConsumeLogsFunc + consumerprofiles.ConsumeProfilesFunc } func (bc baseConsumer) unexported() {} diff --git a/consumer/consumertest/err.go b/consumer/consumertest/err.go index d147453aaf7..fdc54ae2452 100644 --- a/consumer/consumertest/err.go +++ b/consumer/consumertest/err.go @@ -7,14 +7,16 @@ import ( "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/pprofile" "go.opentelemetry.io/collector/pdata/ptrace" ) // NewErr returns a Consumer that just drops all received data and returns the specified error to Consume* callers. func NewErr(err error) Consumer { return &baseConsumer{ - ConsumeTracesFunc: func(context.Context, ptrace.Traces) error { return err }, - ConsumeMetricsFunc: func(context.Context, pmetric.Metrics) error { return err }, - ConsumeLogsFunc: func(context.Context, plog.Logs) error { return err }, + ConsumeTracesFunc: func(context.Context, ptrace.Traces) error { return err }, + ConsumeMetricsFunc: func(context.Context, pmetric.Metrics) error { return err }, + ConsumeLogsFunc: func(context.Context, plog.Logs) error { return err }, + ConsumeProfilesFunc: func(context.Context, pprofile.Profiles) error { return err }, } } diff --git a/consumer/consumertest/err_test.go b/consumer/consumertest/err_test.go index 692347becfb..3d88ecf18aa 100644 --- a/consumer/consumertest/err_test.go +++ b/consumer/consumertest/err_test.go @@ -13,6 +13,7 @@ import ( "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/pprofile" "go.opentelemetry.io/collector/pdata/ptrace" ) @@ -24,4 +25,5 @@ func TestErr(t *testing.T) { assert.Equal(t, err, ec.ConsumeLogs(context.Background(), plog.NewLogs())) assert.Equal(t, err, ec.ConsumeMetrics(context.Background(), pmetric.NewMetrics())) assert.Equal(t, err, ec.ConsumeTraces(context.Background(), ptrace.NewTraces())) + assert.Equal(t, err, ec.ConsumeProfiles(context.Background(), pprofile.NewProfiles())) } diff --git a/consumer/consumertest/go.mod b/consumer/consumertest/go.mod new file mode 100644 index 00000000000..24f5ecec4a0 --- /dev/null +++ b/consumer/consumertest/go.mod @@ -0,0 +1,40 @@ +module go.opentelemetry.io/collector/consumer/consumertest + +go 1.21.0 + +replace go.opentelemetry.io/collector/consumer => ../ + +require ( + github.com/stretchr/testify v1.9.0 + go.opentelemetry.io/collector/consumer v0.105.0 + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 + go.opentelemetry.io/collector/pdata v1.12.0 + go.opentelemetry.io/collector/pdata/pprofile v0.105.0 + go.opentelemetry.io/collector/pdata/testdata v0.105.0 + go.uber.org/goleak v1.3.0 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + golang.org/x/net v0.25.0 // indirect + golang.org/x/sys v0.20.0 // indirect + golang.org/x/text v0.15.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect + google.golang.org/grpc v1.65.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +replace go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile + +replace go.opentelemetry.io/collector/pdata => ../../pdata + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../consumerprofiles + +replace go.opentelemetry.io/collector/pdata/testdata => ../../pdata/testdata diff --git a/consumer/consumertest/go.sum b/consumer/consumertest/go.sum new file mode 100644 index 00000000000..528166b78c0 --- /dev/null +++ b/consumer/consumertest/go.sum @@ -0,0 +1,77 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +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/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +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= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= +google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +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/consumer/consumertest/nop.go b/consumer/consumertest/nop.go index fbb01e3bb98..25b898a7751 100644 --- a/consumer/consumertest/nop.go +++ b/consumer/consumertest/nop.go @@ -8,14 +8,16 @@ import ( "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/pprofile" "go.opentelemetry.io/collector/pdata/ptrace" ) // NewNop returns a Consumer that just drops all received data and returns no error. func NewNop() Consumer { return &baseConsumer{ - ConsumeTracesFunc: func(context.Context, ptrace.Traces) error { return nil }, - ConsumeMetricsFunc: func(context.Context, pmetric.Metrics) error { return nil }, - ConsumeLogsFunc: func(context.Context, plog.Logs) error { return nil }, + ConsumeTracesFunc: func(context.Context, ptrace.Traces) error { return nil }, + ConsumeMetricsFunc: func(context.Context, pmetric.Metrics) error { return nil }, + ConsumeLogsFunc: func(context.Context, plog.Logs) error { return nil }, + ConsumeProfilesFunc: func(context.Context, pprofile.Profiles) error { return nil }, } } diff --git a/consumer/consumertest/nop_test.go b/consumer/consumertest/nop_test.go index 21f4f90c9d6..21b9c43240a 100644 --- a/consumer/consumertest/nop_test.go +++ b/consumer/consumertest/nop_test.go @@ -12,6 +12,7 @@ import ( "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/pprofile" "go.opentelemetry.io/collector/pdata/ptrace" ) @@ -22,4 +23,5 @@ func TestNop(t *testing.T) { assert.NoError(t, nc.ConsumeLogs(context.Background(), plog.NewLogs())) assert.NoError(t, nc.ConsumeMetrics(context.Background(), pmetric.NewMetrics())) assert.NoError(t, nc.ConsumeTraces(context.Background(), ptrace.NewTraces())) + assert.NoError(t, nc.ConsumeProfiles(context.Background(), pprofile.NewProfiles())) } diff --git a/consumer/consumertest/sink.go b/consumer/consumertest/sink.go index be7195af18f..ec35e717ae0 100644 --- a/consumer/consumertest/sink.go +++ b/consumer/consumertest/sink.go @@ -8,8 +8,10 @@ import ( "sync" "go.opentelemetry.io/collector/consumer" + "go.opentelemetry.io/collector/consumer/consumerprofiles" "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/pprofile" "go.opentelemetry.io/collector/pdata/ptrace" ) @@ -156,3 +158,41 @@ func (sle *LogsSink) Reset() { sle.logs = nil sle.logRecordCount = 0 } + +// ProfilesSink is a consumerprofiles.Profiles that acts like a sink that +// stores all profiles and allows querying them for testing. +type ProfilesSink struct { + nonMutatingConsumer + mu sync.Mutex + profiles []pprofile.Profiles +} + +var _ consumerprofiles.Profiles = (*ProfilesSink)(nil) + +// ConsumeProfiles stores profiles to this sink. +func (ste *ProfilesSink) ConsumeProfiles(_ context.Context, td pprofile.Profiles) error { + ste.mu.Lock() + defer ste.mu.Unlock() + + ste.profiles = append(ste.profiles, td) + + return nil +} + +// AllProfiles returns the profiles stored by this sink since last Reset. +func (ste *ProfilesSink) AllProfiles() []pprofile.Profiles { + ste.mu.Lock() + defer ste.mu.Unlock() + + copyProfiles := make([]pprofile.Profiles, len(ste.profiles)) + copy(copyProfiles, ste.profiles) + return copyProfiles +} + +// Reset deletes any stored data. +func (ste *ProfilesSink) Reset() { + ste.mu.Lock() + defer ste.mu.Unlock() + + ste.profiles = nil +} diff --git a/consumer/consumertest/sink_test.go b/consumer/consumertest/sink_test.go index bd29ebc6aef..3c813cf2f71 100644 --- a/consumer/consumertest/sink_test.go +++ b/consumer/consumertest/sink_test.go @@ -12,6 +12,7 @@ import ( "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/pprofile" "go.opentelemetry.io/collector/pdata/ptrace" "go.opentelemetry.io/collector/pdata/testdata" ) @@ -60,3 +61,16 @@ func TestLogsSink(t *testing.T) { assert.Equal(t, 0, len(sink.AllLogs())) assert.Equal(t, 0, sink.LogRecordCount()) } + +func TestProfilesSink(t *testing.T) { + sink := new(ProfilesSink) + td := testdata.GenerateProfiles(1) + want := make([]pprofile.Profiles, 0, 7) + for i := 0; i < 7; i++ { + require.NoError(t, sink.ConsumeProfiles(context.Background(), td)) + want = append(want, td) + } + assert.Equal(t, want, sink.AllProfiles()) + sink.Reset() + assert.Equal(t, 0, len(sink.AllProfiles())) +} diff --git a/exporter/debugexporter/go.mod b/exporter/debugexporter/go.mod index 959b20a8763..165281a2318 100644 --- a/exporter/debugexporter/go.mod +++ b/exporter/debugexporter/go.mod @@ -42,6 +42,8 @@ require ( github.com/prometheus/procfs v0.15.1 // indirect go.opentelemetry.io/collector v0.105.0 // indirect go.opentelemetry.io/collector/config/configretry v1.12.0 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 // indirect go.opentelemetry.io/collector/extension v0.105.0 // indirect go.opentelemetry.io/collector/featuregate v1.12.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect @@ -90,3 +92,7 @@ replace go.opentelemetry.io/collector/extension => ../../extension replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry replace go.opentelemetry.io/collector/config/configretry => ../../config/configretry + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest diff --git a/exporter/go.mod b/exporter/go.mod index 26f7e2514de..8858ef764e6 100644 --- a/exporter/go.mod +++ b/exporter/go.mod @@ -11,6 +11,7 @@ require ( go.opentelemetry.io/collector/config/configretry v1.12.0 go.opentelemetry.io/collector/config/configtelemetry v0.105.0 go.opentelemetry.io/collector/consumer v0.105.0 + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 go.opentelemetry.io/collector/extension v0.105.0 go.opentelemetry.io/collector/pdata v1.12.0 go.opentelemetry.io/collector/pdata/testdata v0.105.0 @@ -51,6 +52,7 @@ require ( github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect go.opentelemetry.io/collector/confmap v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect go.opentelemetry.io/collector/featuregate v1.12.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.105.0 // indirect @@ -89,3 +91,7 @@ retract v0.76.0 // Depends on retracted pdata v1.0.0-rc10 module replace go.opentelemetry.io/collector/config/configretry => ../config/configretry replace go.opentelemetry.io/collector/config/configtelemetry => ../config/configtelemetry + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../consumer/consumertest diff --git a/exporter/internal/factory.go b/exporter/internal/factory.go index 193e22a7718..efcc3164caa 100644 --- a/exporter/internal/factory.go +++ b/exporter/internal/factory.go @@ -7,31 +7,33 @@ import ( "context" "go.opentelemetry.io/collector/component" -) // Factory is a factory interface for exporters. +) + +// Factory is a factory interface for exporters. // This interface cannot be directly implemented. Implementations must // use the NewFactory to implement it. type Factory interface { component.Factory // CreateTracesExporter creates a TracesExporter based on this config. - // If the exporter type does not support tracing or if the config is not valid, - // an error will be returned instead. + // If the exporter type does not support tracing, + // this function returns the error [component.ErrDataTypeIsNotSupported]. CreateTracesExporter(ctx context.Context, set Settings, cfg component.Config) (Traces, error) // TracesExporterStability gets the stability level of the TracesExporter. TracesExporterStability() component.StabilityLevel // CreateMetricsExporter creates a MetricsExporter based on this config. - // If the exporter type does not support metrics or if the config is not valid, - // an error will be returned instead. + // If the exporter type does not support metrics, + // this function returns the error [component.ErrDataTypeIsNotSupported]. CreateMetricsExporter(ctx context.Context, set Settings, cfg component.Config) (Metrics, error) // MetricsExporterStability gets the stability level of the MetricsExporter. MetricsExporterStability() component.StabilityLevel // CreateLogsExporter creates a LogsExporter based on the config. - // If the exporter type does not support logs or if the config is not valid, - // an error will be returned instead. + // If the exporter type does not support logs, + // this function returns the error [component.ErrDataTypeIsNotSupported]. CreateLogsExporter(ctx context.Context, set Settings, cfg component.Config) (Logs, error) // LogsExporterStability gets the stability level of the LogsExporter. diff --git a/exporter/loggingexporter/go.mod b/exporter/loggingexporter/go.mod index b4d7de699d1..9b7444e4a0d 100644 --- a/exporter/loggingexporter/go.mod +++ b/exporter/loggingexporter/go.mod @@ -42,9 +42,12 @@ require ( go.opentelemetry.io/collector v0.105.0 // indirect go.opentelemetry.io/collector/config/configretry v1.12.0 // indirect go.opentelemetry.io/collector/consumer v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 // indirect go.opentelemetry.io/collector/extension v0.105.0 // indirect go.opentelemetry.io/collector/featuregate v1.12.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect + go.opentelemetry.io/collector/pdata/pprofile v0.105.0 // indirect go.opentelemetry.io/collector/receiver v0.105.0 // indirect go.opentelemetry.io/otel v1.28.0 // indirect go.opentelemetry.io/otel/exporters/prometheus v0.50.0 // indirect @@ -94,3 +97,7 @@ replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/con replace go.opentelemetry.io/collector/config/configretry => ../../config/configretry replace go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest diff --git a/exporter/nopexporter/go.mod b/exporter/nopexporter/go.mod index 757e0eb0719..a8d37c00208 100644 --- a/exporter/nopexporter/go.mod +++ b/exporter/nopexporter/go.mod @@ -6,7 +6,7 @@ require ( github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.105.0 go.opentelemetry.io/collector/confmap v0.105.0 - go.opentelemetry.io/collector/consumer v0.105.0 + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 go.opentelemetry.io/collector/exporter v0.105.0 go.opentelemetry.io/collector/pdata v1.12.0 go.uber.org/goleak v1.3.0 @@ -37,8 +37,11 @@ require ( github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect + go.opentelemetry.io/collector/consumer v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect go.opentelemetry.io/collector/featuregate v1.12.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect + go.opentelemetry.io/collector/pdata/pprofile v0.105.0 // indirect go.opentelemetry.io/collector/receiver v0.105.0 // indirect go.opentelemetry.io/otel v1.28.0 // indirect go.opentelemetry.io/otel/exporters/prometheus v0.50.0 // indirect @@ -84,3 +87,7 @@ replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/con replace go.opentelemetry.io/collector/extension => ../../extension replace go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest diff --git a/exporter/otlpexporter/go.mod b/exporter/otlpexporter/go.mod index f837c8b0065..191e4bb061d 100644 --- a/exporter/otlpexporter/go.mod +++ b/exporter/otlpexporter/go.mod @@ -57,6 +57,8 @@ require ( go.opentelemetry.io/collector/config/confignet v0.105.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect go.opentelemetry.io/collector/config/internal v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 // indirect go.opentelemetry.io/collector/extension v0.105.0 // indirect go.opentelemetry.io/collector/extension/auth v0.105.0 // indirect go.opentelemetry.io/collector/featuregate v1.12.0 // indirect @@ -138,3 +140,7 @@ replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/con replace go.opentelemetry.io/collector/config/configretry => ../../config/configretry replace go.opentelemetry.io/collector/internal/globalgates => ../../internal/globalgates + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest diff --git a/exporter/otlphttpexporter/go.mod b/exporter/otlphttpexporter/go.mod index 59ba2cc3c42..e6604d26407 100644 --- a/exporter/otlphttpexporter/go.mod +++ b/exporter/otlphttpexporter/go.mod @@ -56,10 +56,13 @@ require ( go.opentelemetry.io/collector/config/configauth v0.105.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect go.opentelemetry.io/collector/config/internal v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 // indirect go.opentelemetry.io/collector/extension v0.105.0 // indirect go.opentelemetry.io/collector/extension/auth v0.105.0 // indirect go.opentelemetry.io/collector/featuregate v1.12.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect + go.opentelemetry.io/collector/pdata/pprofile v0.105.0 // indirect go.opentelemetry.io/collector/receiver v0.105.0 // indirect go.opentelemetry.io/contrib/config v0.8.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect @@ -134,3 +137,7 @@ retract ( replace go.opentelemetry.io/collector/config/configretry => ../../config/configretry replace go.opentelemetry.io/collector/internal/globalgates => ../../internal/globalgates + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest diff --git a/extension/ballastextension/go.mod b/extension/ballastextension/go.mod index 15a7d2d51d7..054f7cd7c10 100644 --- a/extension/ballastextension/go.mod +++ b/extension/ballastextension/go.mod @@ -87,3 +87,7 @@ replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/con replace go.opentelemetry.io/collector/pdata/testdata => ../../pdata/testdata replace go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest diff --git a/extension/memorylimiterextension/go.mod b/extension/memorylimiterextension/go.mod index df7cf0f39b5..09baf6c125f 100644 --- a/extension/memorylimiterextension/go.mod +++ b/extension/memorylimiterextension/go.mod @@ -81,3 +81,7 @@ replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/con replace go.opentelemetry.io/collector/pdata/testdata => ../../pdata/testdata replace go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest diff --git a/extension/zpagesextension/go.mod b/extension/zpagesextension/go.mod index 3e9a20d71ed..08d18b0c05e 100644 --- a/extension/zpagesextension/go.mod +++ b/extension/zpagesextension/go.mod @@ -122,3 +122,7 @@ replace go.opentelemetry.io/collector/config/confighttp => ../../config/confight replace go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile replace go.opentelemetry.io/collector/internal/globalgates => ../../internal/globalgates + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest diff --git a/go.mod b/go.mod index d440896095b..00fd2e54769 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,7 @@ require ( go.opentelemetry.io/collector/component v0.105.0 go.opentelemetry.io/collector/confmap v0.105.0 go.opentelemetry.io/collector/consumer v0.105.0 + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 go.opentelemetry.io/collector/featuregate v1.12.0 go.opentelemetry.io/collector/pdata v1.12.0 go.opentelemetry.io/collector/pdata/testdata v0.105.0 @@ -59,6 +60,7 @@ require ( github.com/tklauser/numcpus v0.6.1 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.105.0 // indirect go.opentelemetry.io/otel v1.28.0 // indirect @@ -95,6 +97,10 @@ replace go.opentelemetry.io/collector/config/configtelemetry => ./config/configt replace go.opentelemetry.io/collector/consumer => ./consumer +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ./consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ./consumer/consumertest + replace go.opentelemetry.io/collector/featuregate => ./featuregate replace go.opentelemetry.io/collector/pdata => ./pdata diff --git a/internal/e2e/go.mod b/internal/e2e/go.mod index 5792d76c2d0..b16094c5fc1 100644 --- a/internal/e2e/go.mod +++ b/internal/e2e/go.mod @@ -13,6 +13,7 @@ require ( go.opentelemetry.io/collector/config/configtls v1.12.0 go.opentelemetry.io/collector/confmap v0.105.0 go.opentelemetry.io/collector/consumer v0.105.0 + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 go.opentelemetry.io/collector/exporter v0.105.0 go.opentelemetry.io/collector/exporter/otlpexporter v0.105.0 go.opentelemetry.io/collector/exporter/otlphttpexporter v0.105.0 @@ -60,6 +61,7 @@ require ( go.opentelemetry.io/collector/config/confignet v0.105.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect go.opentelemetry.io/collector/config/internal v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect go.opentelemetry.io/collector/extension v0.105.0 // indirect go.opentelemetry.io/collector/extension/auth v0.105.0 // indirect go.opentelemetry.io/collector/featuregate v1.12.0 // indirect @@ -148,3 +150,7 @@ replace go.opentelemetry.io/collector/featuregate => ../../featuregate replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry replace go.opentelemetry.io/collector/internal/globalgates => ../globalgates + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest diff --git a/otelcol/go.mod b/otelcol/go.mod index f43a028057a..0699ca0b342 100644 --- a/otelcol/go.mod +++ b/otelcol/go.mod @@ -65,6 +65,8 @@ require ( go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/collector v0.105.0 // indirect go.opentelemetry.io/collector/consumer v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 // indirect go.opentelemetry.io/collector/pdata v1.12.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.105.0 // indirect go.opentelemetry.io/collector/pdata/testdata v0.105.0 // indirect @@ -148,3 +150,7 @@ replace go.opentelemetry.io/collector/config/configtls => ../config/configtls replace go.opentelemetry.io/collector/config/configopaque => ../config/configopaque replace go.opentelemetry.io/collector/internal/globalgates => ../internal/globalgates + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../consumer/consumertest diff --git a/otelcol/otelcoltest/go.mod b/otelcol/otelcoltest/go.mod index 17bccd9fe24..49b19a92393 100644 --- a/otelcol/otelcoltest/go.mod +++ b/otelcol/otelcoltest/go.mod @@ -63,6 +63,8 @@ require ( go.opentelemetry.io/collector v0.105.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect go.opentelemetry.io/collector/consumer v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 // indirect go.opentelemetry.io/collector/featuregate v1.12.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect go.opentelemetry.io/collector/pdata v1.12.0 // indirect @@ -166,3 +168,7 @@ replace go.opentelemetry.io/collector/semconv => ../../semconv replace go.opentelemetry.io/collector/extension/auth => ../../extension/auth replace go.opentelemetry.io/collector/internal/globalgates => ../../internal/globalgates + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest diff --git a/processor/batchprocessor/go.mod b/processor/batchprocessor/go.mod index b50acb84105..32b1d86db1b 100644 --- a/processor/batchprocessor/go.mod +++ b/processor/batchprocessor/go.mod @@ -9,6 +9,7 @@ require ( go.opentelemetry.io/collector/config/configtelemetry v0.105.0 go.opentelemetry.io/collector/confmap v0.105.0 go.opentelemetry.io/collector/consumer v0.105.0 + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 go.opentelemetry.io/collector/pdata v1.12.0 go.opentelemetry.io/collector/pdata/testdata v0.105.0 go.opentelemetry.io/collector/processor v0.105.0 @@ -44,6 +45,7 @@ require ( github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect go.opentelemetry.io/collector/featuregate v1.12.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.105.0 // indirect @@ -85,3 +87,7 @@ retract ( replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry replace go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest diff --git a/processor/go.mod b/processor/go.mod index 4cdcb9b6e2f..f0af3fb6f1b 100644 --- a/processor/go.mod +++ b/processor/go.mod @@ -9,6 +9,7 @@ require ( go.opentelemetry.io/collector/component v0.105.0 go.opentelemetry.io/collector/config/configtelemetry v0.105.0 go.opentelemetry.io/collector/consumer v0.105.0 + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 go.opentelemetry.io/collector/pdata v1.12.0 go.opentelemetry.io/collector/pdata/testdata v0.105.0 go.opentelemetry.io/otel v1.28.0 @@ -35,6 +36,7 @@ require ( github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.105.0 // indirect go.opentelemetry.io/otel/exporters/prometheus v0.50.0 // indirect go.opentelemetry.io/otel/sdk v1.28.0 // indirect @@ -67,3 +69,7 @@ replace go.opentelemetry.io/collector/pdata/pprofile => ../pdata/pprofile replace go.opentelemetry.io/collector/config/configtelemetry => ../config/configtelemetry replace go.opentelemetry.io/collector/internal/globalgates => ../internal/globalgates + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../consumer/consumertest diff --git a/processor/internal/factory.go b/processor/internal/factory.go index 293e65a5ae2..71adc202a1d 100644 --- a/processor/internal/factory.go +++ b/processor/internal/factory.go @@ -18,24 +18,27 @@ type Factory interface { component.Factory // CreateTracesProcessor creates a TracesProcessor based on this config. - // If the processor type does not support tracing or if the config is not valid, - // an error will be returned instead. + // If the processor type does not support traces, + // this function returns the error [component.ErrDataTypeIsNotSupported]. + // Implementers can assume `nextConsumer` is never nil. CreateTracesProcessor(ctx context.Context, set Settings, cfg component.Config, nextConsumer consumer.Traces) (Traces, error) // TracesProcessorStability gets the stability level of the TracesProcessor. TracesProcessorStability() component.StabilityLevel // CreateMetricsProcessor creates a MetricsProcessor based on this config. - // If the processor type does not support metrics or if the config is not valid, - // an error will be returned instead. + // If the processor type does not support metrics, + // this function returns the error [component.ErrDataTypeIsNotSupported]. + // Implementers can assume `nextConsumer` is never nil. CreateMetricsProcessor(ctx context.Context, set Settings, cfg component.Config, nextConsumer consumer.Metrics) (Metrics, error) // MetricsProcessorStability gets the stability level of the MetricsProcessor. MetricsProcessorStability() component.StabilityLevel // CreateLogsProcessor creates a LogsProcessor based on the config. - // If the processor type does not support logs or if the config is not valid, - // an error will be returned instead. + // If the processor type does not support logs, + // this function returns the error [component.ErrDataTypeIsNotSupported]. + // Implementers can assume `nextConsumer` is never nil. CreateLogsProcessor(ctx context.Context, set Settings, cfg component.Config, nextConsumer consumer.Logs) (Logs, error) // LogsProcessorStability gets the stability level of the LogsProcessor. diff --git a/processor/memorylimiterprocessor/go.mod b/processor/memorylimiterprocessor/go.mod index 4e83df6e363..17860bcb612 100644 --- a/processor/memorylimiterprocessor/go.mod +++ b/processor/memorylimiterprocessor/go.mod @@ -8,6 +8,7 @@ require ( go.opentelemetry.io/collector/component v0.105.0 go.opentelemetry.io/collector/confmap v0.105.0 go.opentelemetry.io/collector/consumer v0.105.0 + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 go.opentelemetry.io/collector/pdata v1.12.0 go.opentelemetry.io/collector/processor v0.105.0 go.uber.org/goleak v1.3.0 @@ -45,6 +46,7 @@ require ( github.com/tklauser/numcpus v0.6.1 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect go.opentelemetry.io/collector/featuregate v1.12.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.105.0 // indirect @@ -92,3 +94,7 @@ retract ( replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry replace go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest diff --git a/processor/processorhelper/obsreport.go b/processor/processorhelper/obsreport.go index 2a3bd0dc754..baebb6b3b0c 100644 --- a/processor/processorhelper/obsreport.go +++ b/processor/processorhelper/obsreport.go @@ -32,8 +32,8 @@ func BuildCustomMetricName(configType, metric string) string { // ObsReport is a helper to add observability to a processor. type ObsReport struct { - otelAttrs []attribute.KeyValue - telemetryBuilder *metadata.TelemetryBuilder + otelAttrs []attribute.KeyValue + telBuilder *metadata.TelemetryBuilder } // ObsReportSettings are settings for creating an ObsReport. @@ -48,7 +48,7 @@ func NewObsReport(cfg ObsReportSettings) (*ObsReport, error) { } func newObsReport(cfg ObsReportSettings) (*ObsReport, error) { - telemetryBuilder, err := metadata.NewTelemetryBuilder(cfg.ProcessorCreateSettings.TelemetrySettings, metadata.WithLevel(cfg.ProcessorCreateSettings.MetricsLevel)) + telBuilder, err := metadata.NewTelemetryBuilder(cfg.ProcessorCreateSettings.TelemetrySettings, metadata.WithLevel(cfg.ProcessorCreateSettings.MetricsLevel)) if err != nil { return nil, err } @@ -56,92 +56,66 @@ func newObsReport(cfg ObsReportSettings) (*ObsReport, error) { otelAttrs: []attribute.KeyValue{ attribute.String(obsmetrics.ProcessorKey, cfg.ProcessorID.String()), }, - telemetryBuilder: telemetryBuilder, + telBuilder: telBuilder, }, nil } -func (or *ObsReport) recordData(ctx context.Context, dataType component.DataType, accepted, refused, dropped, inserted int64) { - var acceptedCount, refusedCount, droppedCount, insertedCount metric.Int64Counter - switch dataType { - case component.DataTypeTraces: - acceptedCount = or.telemetryBuilder.ProcessorAcceptedSpans - refusedCount = or.telemetryBuilder.ProcessorRefusedSpans - droppedCount = or.telemetryBuilder.ProcessorDroppedSpans - insertedCount = or.telemetryBuilder.ProcessorInsertedSpans - case component.DataTypeMetrics: - acceptedCount = or.telemetryBuilder.ProcessorAcceptedMetricPoints - refusedCount = or.telemetryBuilder.ProcessorRefusedMetricPoints - droppedCount = or.telemetryBuilder.ProcessorDroppedMetricPoints - insertedCount = or.telemetryBuilder.ProcessorInsertedMetricPoints - case component.DataTypeLogs: - acceptedCount = or.telemetryBuilder.ProcessorAcceptedLogRecords - refusedCount = or.telemetryBuilder.ProcessorRefusedLogRecords - droppedCount = or.telemetryBuilder.ProcessorDroppedLogRecords - insertedCount = or.telemetryBuilder.ProcessorInsertedLogRecords - } - - acceptedCount.Add(ctx, accepted, metric.WithAttributes(or.otelAttrs...)) - refusedCount.Add(ctx, refused, metric.WithAttributes(or.otelAttrs...)) - droppedCount.Add(ctx, dropped, metric.WithAttributes(or.otelAttrs...)) - insertedCount.Add(ctx, inserted, metric.WithAttributes(or.otelAttrs...)) -} - // TracesAccepted reports that the trace data was accepted. func (or *ObsReport) TracesAccepted(ctx context.Context, numSpans int) { - or.recordData(ctx, component.DataTypeTraces, int64(numSpans), int64(0), int64(0), int64(0)) + or.telBuilder.ProcessorAcceptedSpans.Add(ctx, int64(numSpans), metric.WithAttributes(or.otelAttrs...)) } // TracesRefused reports that the trace data was refused. func (or *ObsReport) TracesRefused(ctx context.Context, numSpans int) { - or.recordData(ctx, component.DataTypeTraces, int64(0), int64(numSpans), int64(0), int64(0)) + or.telBuilder.ProcessorRefusedSpans.Add(ctx, int64(numSpans), metric.WithAttributes(or.otelAttrs...)) } // TracesDropped reports that the trace data was dropped. func (or *ObsReport) TracesDropped(ctx context.Context, numSpans int) { - or.recordData(ctx, component.DataTypeTraces, int64(0), int64(0), int64(numSpans), int64(0)) + or.telBuilder.ProcessorDroppedSpans.Add(ctx, int64(numSpans), metric.WithAttributes(or.otelAttrs...)) } // TracesInserted reports that the trace data was inserted. func (or *ObsReport) TracesInserted(ctx context.Context, numSpans int) { - or.recordData(ctx, component.DataTypeTraces, int64(0), int64(0), int64(0), int64(numSpans)) + or.telBuilder.ProcessorInsertedSpans.Add(ctx, int64(numSpans), metric.WithAttributes(or.otelAttrs...)) } // MetricsAccepted reports that the metrics were accepted. func (or *ObsReport) MetricsAccepted(ctx context.Context, numPoints int) { - or.recordData(ctx, component.DataTypeMetrics, int64(numPoints), int64(0), int64(0), int64(0)) + or.telBuilder.ProcessorAcceptedMetricPoints.Add(ctx, int64(numPoints), metric.WithAttributes(or.otelAttrs...)) } // MetricsRefused reports that the metrics were refused. func (or *ObsReport) MetricsRefused(ctx context.Context, numPoints int) { - or.recordData(ctx, component.DataTypeMetrics, int64(0), int64(numPoints), int64(0), int64(0)) + or.telBuilder.ProcessorRefusedMetricPoints.Add(ctx, int64(numPoints), metric.WithAttributes(or.otelAttrs...)) } // MetricsDropped reports that the metrics were dropped. func (or *ObsReport) MetricsDropped(ctx context.Context, numPoints int) { - or.recordData(ctx, component.DataTypeMetrics, int64(0), int64(0), int64(numPoints), int64(0)) + or.telBuilder.ProcessorDroppedMetricPoints.Add(ctx, int64(numPoints), metric.WithAttributes(or.otelAttrs...)) } // MetricsInserted reports that the metrics were inserted. func (or *ObsReport) MetricsInserted(ctx context.Context, numPoints int) { - or.recordData(ctx, component.DataTypeMetrics, int64(0), int64(0), int64(0), int64(numPoints)) + or.telBuilder.ProcessorInsertedMetricPoints.Add(ctx, int64(numPoints), metric.WithAttributes(or.otelAttrs...)) } // LogsAccepted reports that the logs were accepted. func (or *ObsReport) LogsAccepted(ctx context.Context, numRecords int) { - or.recordData(ctx, component.DataTypeLogs, int64(numRecords), int64(0), int64(0), int64(0)) + or.telBuilder.ProcessorAcceptedLogRecords.Add(ctx, int64(numRecords), metric.WithAttributes(or.otelAttrs...)) } // LogsRefused reports that the logs were refused. func (or *ObsReport) LogsRefused(ctx context.Context, numRecords int) { - or.recordData(ctx, component.DataTypeLogs, int64(0), int64(numRecords), int64(0), int64(0)) + or.telBuilder.ProcessorRefusedLogRecords.Add(ctx, int64(numRecords), metric.WithAttributes(or.otelAttrs...)) } // LogsDropped reports that the logs were dropped. func (or *ObsReport) LogsDropped(ctx context.Context, numRecords int) { - or.recordData(ctx, component.DataTypeLogs, int64(0), int64(0), int64(numRecords), int64(0)) + or.telBuilder.ProcessorDroppedLogRecords.Add(ctx, int64(numRecords), metric.WithAttributes(or.otelAttrs...)) } // LogsInserted reports that the logs were inserted. func (or *ObsReport) LogsInserted(ctx context.Context, numRecords int) { - or.recordData(ctx, component.DataTypeLogs, int64(0), int64(0), int64(0), int64(numRecords)) + or.telBuilder.ProcessorInsertedLogRecords.Add(ctx, int64(numRecords), metric.WithAttributes(or.otelAttrs...)) } diff --git a/receiver/go.mod b/receiver/go.mod index 544ed727f44..abe1f937512 100644 --- a/receiver/go.mod +++ b/receiver/go.mod @@ -9,6 +9,7 @@ require ( go.opentelemetry.io/collector/component v0.105.0 go.opentelemetry.io/collector/config/configtelemetry v0.105.0 go.opentelemetry.io/collector/consumer v0.105.0 + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 go.opentelemetry.io/collector/pdata v1.12.0 go.opentelemetry.io/otel v1.28.0 go.opentelemetry.io/otel/metric v1.28.0 @@ -36,6 +37,8 @@ require ( github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect + go.opentelemetry.io/collector/pdata/pprofile v0.105.0 // indirect go.opentelemetry.io/otel/exporters/prometheus v0.50.0 // indirect golang.org/x/net v0.26.0 // indirect golang.org/x/sys v0.21.0 // indirect @@ -67,3 +70,7 @@ replace go.opentelemetry.io/collector/config/configtelemetry => ../config/config replace go.opentelemetry.io/collector/pdata/pprofile => ../pdata/pprofile replace go.opentelemetry.io/collector/internal/globalgates => ../internal/globalgates + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../consumer/consumertest diff --git a/receiver/internal/factory.go b/receiver/internal/factory.go index 0b6cb17c7ef..24d05785ff8 100644 --- a/receiver/internal/factory.go +++ b/receiver/internal/factory.go @@ -18,24 +18,27 @@ type Factory interface { component.Factory // CreateTracesReceiver creates a TracesReceiver based on this config. - // If the receiver type does not support tracing or if the config is not valid - // an error will be returned instead. `nextConsumer` is never nil. + // If the receiver type does not support traces, + // this function returns the error [component.ErrDataTypeIsNotSupported]. + // Implementers can assume `nextConsumer` is never nil. CreateTracesReceiver(ctx context.Context, set Settings, cfg component.Config, nextConsumer consumer.Traces) (Traces, error) // TracesReceiverStability gets the stability level of the TracesReceiver. TracesReceiverStability() component.StabilityLevel // CreateMetricsReceiver creates a MetricsReceiver based on this config. - // If the receiver type does not support metrics or if the config is not valid - // an error will be returned instead. `nextConsumer` is never nil. + // If the receiver type does not support metrics, + // this function returns the error [component.ErrDataTypeIsNotSupported]. + // Implementers can assume `nextConsumer` is never nil. CreateMetricsReceiver(ctx context.Context, set Settings, cfg component.Config, nextConsumer consumer.Metrics) (Metrics, error) // MetricsReceiverStability gets the stability level of the MetricsReceiver. MetricsReceiverStability() component.StabilityLevel // CreateLogsReceiver creates a LogsReceiver based on this config. - // If the receiver type does not support the data type or if the config is not valid - // an error will be returned instead. `nextConsumer` is never nil. + // If the receiver type does not support logs, + // this function returns the error [component.ErrDataTypeIsNotSupported]. + // Implementers can assume `nextConsumer` is never nil. CreateLogsReceiver(ctx context.Context, set Settings, cfg component.Config, nextConsumer consumer.Logs) (Logs, error) // LogsReceiverStability gets the stability level of the LogsReceiver. diff --git a/receiver/nopreceiver/go.mod b/receiver/nopreceiver/go.mod index 8b5eb3f3d4d..dc2f668029c 100644 --- a/receiver/nopreceiver/go.mod +++ b/receiver/nopreceiver/go.mod @@ -7,6 +7,7 @@ require ( go.opentelemetry.io/collector/component v0.105.0 go.opentelemetry.io/collector/confmap v0.105.0 go.opentelemetry.io/collector/consumer v0.105.0 + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 go.opentelemetry.io/collector/receiver v0.105.0 go.uber.org/goleak v1.3.0 ) @@ -36,9 +37,11 @@ require ( github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect go.opentelemetry.io/collector/featuregate v1.12.0 // indirect go.opentelemetry.io/collector/internal/globalgates v0.105.0 // indirect go.opentelemetry.io/collector/pdata v1.12.0 // indirect + go.opentelemetry.io/collector/pdata/pprofile v0.105.0 // indirect go.opentelemetry.io/otel v1.28.0 // indirect go.opentelemetry.io/otel/exporters/prometheus v0.50.0 // indirect go.opentelemetry.io/otel/metric v1.28.0 // indirect @@ -77,3 +80,7 @@ replace go.opentelemetry.io/collector/internal/globalgates => ../../internal/glo replace go.opentelemetry.io/collector/featuregate => ../../featuregate replace go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest diff --git a/receiver/otlpreceiver/go.mod b/receiver/otlpreceiver/go.mod index 69356d7bf91..86e85179259 100644 --- a/receiver/otlpreceiver/go.mod +++ b/receiver/otlpreceiver/go.mod @@ -14,6 +14,7 @@ require ( go.opentelemetry.io/collector/config/configtls v1.12.0 go.opentelemetry.io/collector/confmap v0.105.0 go.opentelemetry.io/collector/consumer v0.105.0 + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 go.opentelemetry.io/collector/pdata v1.12.0 go.opentelemetry.io/collector/pdata/testdata v0.105.0 go.opentelemetry.io/collector/receiver v0.105.0 @@ -59,6 +60,7 @@ require ( go.opentelemetry.io/collector/config/configopaque v1.12.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.105.0 // indirect go.opentelemetry.io/collector/config/internal v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect go.opentelemetry.io/collector/extension v0.105.0 // indirect go.opentelemetry.io/collector/extension/auth v0.105.0 // indirect go.opentelemetry.io/collector/featuregate v1.12.0 // indirect @@ -138,3 +140,7 @@ retract ( replace go.opentelemetry.io/collector/pdata/pprofile => ../../pdata/pprofile replace go.opentelemetry.io/collector/internal/globalgates => ../../internal/globalgates + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest diff --git a/service/go.mod b/service/go.mod index f7c8bec2693..1ff29ae6e66 100644 --- a/service/go.mod +++ b/service/go.mod @@ -17,6 +17,7 @@ require ( go.opentelemetry.io/collector/confmap v0.105.0 go.opentelemetry.io/collector/connector v0.105.0 go.opentelemetry.io/collector/consumer v0.105.0 + go.opentelemetry.io/collector/consumer/consumertest v0.105.0 go.opentelemetry.io/collector/exporter v0.105.0 go.opentelemetry.io/collector/extension v0.105.0 go.opentelemetry.io/collector/extension/zpagesextension v0.105.0 @@ -85,6 +86,7 @@ require ( go.opentelemetry.io/collector/config/configopaque v1.12.0 // indirect go.opentelemetry.io/collector/config/configtls v1.12.0 // indirect go.opentelemetry.io/collector/config/internal v0.105.0 // indirect + go.opentelemetry.io/collector/consumer/consumerprofiles v0.105.0 // indirect go.opentelemetry.io/collector/extension/auth v0.105.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.105.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect @@ -156,3 +158,7 @@ replace go.opentelemetry.io/collector/config/configcompression => ../config/conf replace go.opentelemetry.io/collector/pdata/pprofile => ../pdata/pprofile replace go.opentelemetry.io/collector/internal/globalgates => ../internal/globalgates + +replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../consumer/consumerprofiles + +replace go.opentelemetry.io/collector/consumer/consumertest => ../consumer/consumertest diff --git a/versions.yaml b/versions.yaml index 3c64be06621..9ae387cba32 100644 --- a/versions.yaml +++ b/versions.yaml @@ -37,6 +37,7 @@ module-sets: - go.opentelemetry.io/collector/connector/forwardconnector - go.opentelemetry.io/collector/consumer - go.opentelemetry.io/collector/consumer/consumerprofiles + - go.opentelemetry.io/collector/consumer/consumertest - go.opentelemetry.io/collector/exporter - go.opentelemetry.io/collector/exporter/debugexporter - go.opentelemetry.io/collector/exporter/loggingexporter