diff --git a/extension/healthcheckv2extension/extension.go b/extension/healthcheckv2extension/extension.go index afcaceb36cb9..23a307c9a9cf 100644 --- a/extension/healthcheckv2extension/extension.go +++ b/extension/healthcheckv2extension/extension.go @@ -16,7 +16,7 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/grpc" "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/http" - "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/status" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status" ) type eventSourcePair struct { diff --git a/extension/healthcheckv2extension/extension_test.go b/extension/healthcheckv2extension/extension_test.go index bb15441a1aae..c15acc269245 100644 --- a/extension/healthcheckv2extension/extension_test.go +++ b/extension/healthcheckv2extension/extension_test.go @@ -20,9 +20,9 @@ import ( "go.opentelemetry.io/collector/confmap/confmaptest" "go.opentelemetry.io/collector/extension/extensiontest" - "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/status" - "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/testhelpers" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/testutil" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status/testhelpers" ) func TestComponentStatus(t *testing.T) { diff --git a/extension/healthcheckv2extension/go.mod b/extension/healthcheckv2extension/go.mod index d338ee9d8ff9..b482baefb423 100644 --- a/extension/healthcheckv2extension/go.mod +++ b/extension/healthcheckv2extension/go.mod @@ -4,6 +4,7 @@ go 1.22.0 require ( github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.111.0 + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status v0.111.0 github.com/stretchr/testify v1.9.0 go.opentelemetry.io/collector/component v0.111.0 go.opentelemetry.io/collector/component/componentstatus v0.111.0 @@ -14,7 +15,6 @@ require ( go.opentelemetry.io/collector/confmap v1.17.0 go.opentelemetry.io/collector/extension v0.111.0 go.opentelemetry.io/collector/extension/extensioncapabilities v0.111.0 - go.opentelemetry.io/collector/pipeline v0.111.0 go.uber.org/goleak v1.3.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.27.0 @@ -51,6 +51,7 @@ require ( go.opentelemetry.io/collector/featuregate v1.17.0 // indirect go.opentelemetry.io/collector/internal/globalsignal v0.111.0 // indirect go.opentelemetry.io/collector/pdata v1.17.0 // indirect + go.opentelemetry.io/collector/pipeline v0.111.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.55.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0 // indirect go.opentelemetry.io/otel v1.30.0 // indirect @@ -67,3 +68,5 @@ require ( ) replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/common => ../../internal/common + +replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status => ../../pkg/status diff --git a/extension/healthcheckv2extension/internal/grpc/grpc.go b/extension/healthcheckv2extension/internal/grpc/grpc.go index b457c18e7d4a..2f8ad037c490 100644 --- a/extension/healthcheckv2extension/internal/grpc/grpc.go +++ b/extension/healthcheckv2extension/internal/grpc/grpc.go @@ -12,7 +12,7 @@ import ( healthpb "google.golang.org/grpc/health/grpc_health_v1" grpcstatus "google.golang.org/grpc/status" - "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/status" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status" ) var ( diff --git a/extension/healthcheckv2extension/internal/grpc/grpc_test.go b/extension/healthcheckv2extension/internal/grpc/grpc_test.go index f6f689b01c0a..837a58ebdf63 100644 --- a/extension/healthcheckv2extension/internal/grpc/grpc_test.go +++ b/extension/healthcheckv2extension/internal/grpc/grpc_test.go @@ -22,9 +22,10 @@ import ( grpcstatus "google.golang.org/grpc/status" "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/common" - "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/status" - "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/testhelpers" + internalhelpers "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/testhelpers" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/testutil" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status/testhelpers" ) func TestCheck(t *testing.T) { @@ -695,7 +696,7 @@ func TestCheck(t *testing.T) { config, tc.componentHealthSettings, componenttest.NewNopTelemetrySettings(), - status.NewAggregator(testhelpers.ErrPriority(tc.componentHealthSettings)), + status.NewAggregator(internalhelpers.ErrPriority(tc.componentHealthSettings)), ) require.NoError(t, server.Start(context.Background(), componenttest.NewNopHost())) t.Cleanup(func() { require.NoError(t, server.Shutdown(context.Background())) }) @@ -1532,7 +1533,7 @@ func TestWatch(t *testing.T) { config, tc.componentHealthSettings, componenttest.NewNopTelemetrySettings(), - status.NewAggregator(testhelpers.ErrPriority(tc.componentHealthSettings)), + status.NewAggregator(internalhelpers.ErrPriority(tc.componentHealthSettings)), ) require.NoError(t, server.Start(context.Background(), componenttest.NewNopHost())) t.Cleanup(func() { require.NoError(t, server.Shutdown(context.Background())) }) diff --git a/extension/healthcheckv2extension/internal/grpc/server.go b/extension/healthcheckv2extension/internal/grpc/server.go index e9a9e3ff92ee..2c69e5fb9e61 100644 --- a/extension/healthcheckv2extension/internal/grpc/server.go +++ b/extension/healthcheckv2extension/internal/grpc/server.go @@ -13,7 +13,7 @@ import ( healthpb "google.golang.org/grpc/health/grpc_health_v1" "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/common" - "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/status" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status" ) type Server struct { diff --git a/extension/healthcheckv2extension/internal/http/handlers.go b/extension/healthcheckv2extension/internal/http/handlers.go index 186add81504b..2ae041558038 100644 --- a/extension/healthcheckv2extension/internal/http/handlers.go +++ b/extension/healthcheckv2extension/internal/http/handlers.go @@ -6,7 +6,7 @@ package http // import "github.com/open-telemetry/opentelemetry-collector-contri import ( "net/http" - "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/status" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status" ) func (s *Server) statusHandler() http.Handler { diff --git a/extension/healthcheckv2extension/internal/http/responders.go b/extension/healthcheckv2extension/internal/http/responders.go index 6cb4ed6e3dd0..5dfc3b2cfe09 100644 --- a/extension/healthcheckv2extension/internal/http/responders.go +++ b/extension/healthcheckv2extension/internal/http/responders.go @@ -12,7 +12,7 @@ import ( "go.opentelemetry.io/collector/component/componentstatus" "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/common" - "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/status" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status" ) var responseCodes = map[componentstatus.Status]int{ diff --git a/extension/healthcheckv2extension/internal/http/serialization.go b/extension/healthcheckv2extension/internal/http/serialization.go index ce98541e3678..a1a61c72ebfc 100644 --- a/extension/healthcheckv2extension/internal/http/serialization.go +++ b/extension/healthcheckv2extension/internal/http/serialization.go @@ -8,7 +8,7 @@ import ( "go.opentelemetry.io/collector/component/componentstatus" - "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/status" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status" ) type healthyFunc func(status.Event) bool diff --git a/extension/healthcheckv2extension/internal/http/server.go b/extension/healthcheckv2extension/internal/http/server.go index 42e6b943b3c8..d38f9f3944c0 100644 --- a/extension/healthcheckv2extension/internal/http/server.go +++ b/extension/healthcheckv2extension/internal/http/server.go @@ -20,7 +20,7 @@ import ( "go.uber.org/zap" "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/common" - "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/status" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status" ) type Server struct { diff --git a/extension/healthcheckv2extension/internal/http/server_test.go b/extension/healthcheckv2extension/internal/http/server_test.go index fb3e671a7fd3..4a11d0138d55 100644 --- a/extension/healthcheckv2extension/internal/http/server_test.go +++ b/extension/healthcheckv2extension/internal/http/server_test.go @@ -23,9 +23,10 @@ import ( "go.opentelemetry.io/collector/confmap/confmaptest" "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/common" - "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/status" - "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/testhelpers" + internalhelpers "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/testhelpers" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/testutil" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status/testhelpers" ) // These are used for the legacy test assertions @@ -2942,7 +2943,7 @@ func TestStatus(t *testing.T) { tc.legacyConfig, tc.componentHealthConfig, componenttest.NewNopTelemetrySettings(), - status.NewAggregator(testhelpers.ErrPriority(tc.componentHealthConfig)), + status.NewAggregator(internalhelpers.ErrPriority(tc.componentHealthConfig)), ) require.NoError(t, server.Start(context.Background(), componenttest.NewNopHost())) diff --git a/extension/healthcheckv2extension/internal/testhelpers/helpers.go b/extension/healthcheckv2extension/internal/testhelpers/helpers.go index 57d44301b985..1377c040d84f 100644 --- a/extension/healthcheckv2extension/internal/testhelpers/helpers.go +++ b/extension/healthcheckv2extension/internal/testhelpers/helpers.go @@ -4,61 +4,10 @@ package testhelpers // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/testhelpers" import ( - "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/component/componentstatus" - "go.opentelemetry.io/collector/pipeline" - "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/common" - "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/status" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status" ) -// PipelineMetadata groups together component and instance IDs for a hypothetical pipeline used -// for testing purposes. -type PipelineMetadata struct { - PipelineID pipeline.ID - ReceiverID *componentstatus.InstanceID - ProcessorID *componentstatus.InstanceID - ExporterID *componentstatus.InstanceID -} - -// InstanceIDs returns a slice of instanceIDs for components within the hypothetical pipeline. -func (p *PipelineMetadata) InstanceIDs() []*componentstatus.InstanceID { - return []*componentstatus.InstanceID{p.ReceiverID, p.ProcessorID, p.ExporterID} -} - -// NewPipelineMetadata returns a metadata for a hypothetical pipeline. -func NewPipelineMetadata(typestr string) *PipelineMetadata { - pipelineID := pipeline.MustNewID(typestr) - return &PipelineMetadata{ - PipelineID: pipelineID, - ReceiverID: componentstatus.NewInstanceID(component.NewIDWithName(component.MustNewType(typestr), "in"), component.KindReceiver).WithPipelines(pipelineID), - ProcessorID: componentstatus.NewInstanceID(component.MustNewID("batch"), component.KindProcessor).WithPipelines(pipelineID), - ExporterID: componentstatus.NewInstanceID(component.NewIDWithName(component.MustNewType(typestr), "out"), component.KindExporter).WithPipelines(pipelineID), - } -} - -// NewPipelines returns a map of hypothetical pipelines identified by their stringified typeVal. -func NewPipelines(typestrs ...string) map[string]*PipelineMetadata { - result := make(map[string]*PipelineMetadata, len(typestrs)) - for _, typestr := range typestrs { - result[typestr] = NewPipelineMetadata(typestr) - } - return result -} - -// SeedAggregator records a status event for each instanceID. -func SeedAggregator( - agg *status.Aggregator, - instanceIDs []*componentstatus.InstanceID, - statuses ...componentstatus.Status, -) { - for _, st := range statuses { - for _, id := range instanceIDs { - agg.RecordStatus(id, componentstatus.NewEvent(st)) - } - } -} - func ErrPriority(config *common.ComponentHealthConfig) status.ErrorPriority { if config != nil && config.IncludeRecoverable && !config.IncludePermanent { return status.PriorityRecoverable diff --git a/pkg/status/Makefile b/pkg/status/Makefile new file mode 100644 index 000000000000..ded7a36092dc --- /dev/null +++ b/pkg/status/Makefile @@ -0,0 +1 @@ +include ../../Makefile.Common diff --git a/pkg/status/README.md b/pkg/status/README.md new file mode 100644 index 000000000000..6b0b4c3ed166 --- /dev/null +++ b/pkg/status/README.md @@ -0,0 +1,12 @@ +# pkg/status + +## Overview + +This module contains functionality for aggregating status information about components. Used by extensions that +implement the `extension.StatusWatcher` interface for collecting status information about the internal status of all +components inside the collector. + +### History + +`status` was originally developed for the `healthcheckv2extension`. Other extensions that need to collector status +information needed to use this same implementation to aggregate status information. diff --git a/extension/healthcheckv2extension/internal/status/aggregation.go b/pkg/status/aggregation.go similarity index 98% rename from extension/healthcheckv2extension/internal/status/aggregation.go rename to pkg/status/aggregation.go index 072b55565e7e..c1af5a4c0c7d 100644 --- a/extension/healthcheckv2extension/internal/status/aggregation.go +++ b/pkg/status/aggregation.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package status // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/status" +package status // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status" import ( "time" diff --git a/extension/healthcheckv2extension/internal/status/aggregation_test.go b/pkg/status/aggregation_test.go similarity index 100% rename from extension/healthcheckv2extension/internal/status/aggregation_test.go rename to pkg/status/aggregation_test.go diff --git a/extension/healthcheckv2extension/internal/status/aggregator.go b/pkg/status/aggregator.go similarity index 99% rename from extension/healthcheckv2extension/internal/status/aggregator.go rename to pkg/status/aggregator.go index 7a80717e0682..13193876055d 100644 --- a/extension/healthcheckv2extension/internal/status/aggregator.go +++ b/pkg/status/aggregator.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package status // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/status" +package status // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status" import ( "container/list" diff --git a/extension/healthcheckv2extension/internal/status/aggregator_test.go b/pkg/status/aggregator_test.go similarity index 98% rename from extension/healthcheckv2extension/internal/status/aggregator_test.go rename to pkg/status/aggregator_test.go index d099588c56b2..255c3c1f3dff 100644 --- a/extension/healthcheckv2extension/internal/status/aggregator_test.go +++ b/pkg/status/aggregator_test.go @@ -14,8 +14,8 @@ import ( "go.opentelemetry.io/collector/component/componentstatus" "go.opentelemetry.io/collector/pipeline" - "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/status" - "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/testhelpers" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status/testhelpers" ) func TestAggregateStatus(t *testing.T) { diff --git a/pkg/status/go.mod b/pkg/status/go.mod new file mode 100644 index 000000000000..a2341e72e49e --- /dev/null +++ b/pkg/status/go.mod @@ -0,0 +1,32 @@ +module github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status + +go 1.22.0 + +require ( + github.com/stretchr/testify v1.9.0 + go.opentelemetry.io/collector/component v0.111.0 + go.opentelemetry.io/collector/component/componentstatus v0.111.0 + go.opentelemetry.io/collector/pipeline v0.111.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/pmezard/go-difflib v1.0.0 // indirect + go.opentelemetry.io/collector/config/configtelemetry v0.111.0 // indirect + go.opentelemetry.io/collector/internal/globalsignal v0.111.0 // indirect + go.opentelemetry.io/collector/pdata v1.17.0 // indirect + go.opentelemetry.io/otel v1.30.0 // indirect + go.opentelemetry.io/otel/metric v1.30.0 // indirect + go.opentelemetry.io/otel/trace v1.30.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + go.uber.org/zap v1.27.0 // indirect + golang.org/x/net v0.28.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/text v0.17.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/grpc v1.67.1 // indirect + google.golang.org/protobuf v1.34.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/pkg/status/go.sum b/pkg/status/go.sum new file mode 100644 index 000000000000..a1baa04a2079 --- /dev/null +++ b/pkg/status/go.sum @@ -0,0 +1,90 @@ +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/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +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/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/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/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.opentelemetry.io/collector/component v0.111.0 h1:AiDIrhkq6sbHnU9Rhq6t4DC4Gal43bryd1+NTJNojAQ= +go.opentelemetry.io/collector/component v0.111.0/go.mod h1:wYwbRuhzK5bm5x1bX+ukm1tT50QXYLs4MKwzyfiVGoE= +go.opentelemetry.io/collector/component/componentstatus v0.111.0 h1:DojO8TbkysTtEoxzN6fJqhgCsu0QhxgJ9R+1bitnowM= +go.opentelemetry.io/collector/component/componentstatus v0.111.0/go.mod h1:wKozN6s9dykUB9aLSBXSPT9SJ2fckNvGSFZx4fRZbSY= +go.opentelemetry.io/collector/config/configtelemetry v0.111.0 h1:Q3TJRM2A3FIDjIvzWa3uFArsdFN0I/0GzcWynHjC+oY= +go.opentelemetry.io/collector/config/configtelemetry v0.111.0/go.mod h1:R0MBUxjSMVMIhljuDHWIygzzJWQyZHXXWIgQNxcFwhc= +go.opentelemetry.io/collector/internal/globalsignal v0.111.0 h1:oq0nSD+7K2Q1Fx5d3s6lPRdKZeTL0FEg4sIaR7ZJzIc= +go.opentelemetry.io/collector/internal/globalsignal v0.111.0/go.mod h1:GqMXodPWOxK5uqpX8MaMXC2389y2XJTa5nPwf8FYDK8= +go.opentelemetry.io/collector/pdata v1.17.0 h1:z8cjjT2FThAehWu5fbF48OnZyK5q8xd1UhC4XszDo0w= +go.opentelemetry.io/collector/pdata v1.17.0/go.mod h1:yZaQ9KZAm/qie96LTygRKxOXMq0/54h8OW7330ycuvQ= +go.opentelemetry.io/collector/pipeline v0.111.0 h1:qENDGvWWnDXguEfmj8eO+5kr8Y6XFKytU5SuMinz3Ls= +go.opentelemetry.io/collector/pipeline v0.111.0/go.mod h1:ZZMU3019geEU283rTW5M/LkcqLqHp/YI2Nl6/Vp68PQ= +go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts= +go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc= +go.opentelemetry.io/otel/metric v1.30.0 h1:4xNulvn9gjzo4hjg+wzIKG7iNFEaBMX00Qd4QIZs7+w= +go.opentelemetry.io/otel/metric v1.30.0/go.mod h1:aXTfST94tswhWEb+5QjlSqG+cZlmyXy/u8jFpor3WqQ= +go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc= +go.opentelemetry.io/otel/trace v1.30.0/go.mod h1:5EyKqTzzmyqB9bwtCCq6pDLktPK6fmGf/Dph+8VI02o= +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= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +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.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +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.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.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.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +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-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= +google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= +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/extension/healthcheckv2extension/internal/status/package_test.go b/pkg/status/package_test.go similarity index 77% rename from extension/healthcheckv2extension/internal/status/package_test.go rename to pkg/status/package_test.go index 312e32157c05..c7a4d67bd4a8 100644 --- a/extension/healthcheckv2extension/internal/status/package_test.go +++ b/pkg/status/package_test.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package status // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckv2extension/internal/status" +package status // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status" import ( "testing" diff --git a/pkg/status/testhelpers/helpers.go b/pkg/status/testhelpers/helpers.go new file mode 100644 index 000000000000..cb5ef286734a --- /dev/null +++ b/pkg/status/testhelpers/helpers.go @@ -0,0 +1,59 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package testhelpers // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status/testhelpers" + +import ( + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/component/componentstatus" + "go.opentelemetry.io/collector/pipeline" + + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status" +) + +// PipelineMetadata groups together component and instance IDs for a hypothetical pipeline used +// for testing purposes. +type PipelineMetadata struct { + PipelineID pipeline.ID + ReceiverID *componentstatus.InstanceID + ProcessorID *componentstatus.InstanceID + ExporterID *componentstatus.InstanceID +} + +// InstanceIDs returns a slice of instanceIDs for components within the hypothetical pipeline. +func (p *PipelineMetadata) InstanceIDs() []*componentstatus.InstanceID { + return []*componentstatus.InstanceID{p.ReceiverID, p.ProcessorID, p.ExporterID} +} + +// NewPipelineMetadata returns a metadata for a hypothetical pipeline. +func NewPipelineMetadata(typestr string) *PipelineMetadata { + pipelineID := pipeline.MustNewID(typestr) + return &PipelineMetadata{ + PipelineID: pipelineID, + ReceiverID: componentstatus.NewInstanceID(component.NewIDWithName(component.MustNewType(typestr), "in"), component.KindReceiver).WithPipelines(pipelineID), + ProcessorID: componentstatus.NewInstanceID(component.MustNewID("batch"), component.KindProcessor).WithPipelines(pipelineID), + ExporterID: componentstatus.NewInstanceID(component.NewIDWithName(component.MustNewType(typestr), "out"), component.KindExporter).WithPipelines(pipelineID), + } +} + +// NewPipelines returns a map of hypothetical pipelines identified by their stringified typeVal. +func NewPipelines(typestrs ...string) map[string]*PipelineMetadata { + result := make(map[string]*PipelineMetadata, len(typestrs)) + for _, typestr := range typestrs { + result[typestr] = NewPipelineMetadata(typestr) + } + return result +} + +// SeedAggregator records a status event for each instanceID. +func SeedAggregator( + agg *status.Aggregator, + instanceIDs []*componentstatus.InstanceID, + statuses ...componentstatus.Status, +) { + for _, st := range statuses { + for _, id := range instanceIDs { + agg.RecordStatus(id, componentstatus.NewEvent(st)) + } + } +}