Skip to content

Commit

Permalink
Try removing ReportStatus from TelemetrySettings
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerHelmuth committed Jul 25, 2024
1 parent 95902c1 commit 6f486c7
Show file tree
Hide file tree
Showing 69 changed files with 958 additions and 849 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ check-contrib:
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit \
-replace go.opentelemetry.io/collector=$(CURDIR) \
-replace go.opentelemetry.io/collector/component=$(CURDIR)/component \
-replace go.opentelemetry.io/collector/component/componentstatus=$(CURDIR)/component/componentstatus \
-replace go.opentelemetry.io/collector/config/configauth=$(CURDIR)/config/configauth \
-replace go.opentelemetry.io/collector/config/configcompression=$(CURDIR)/config/configcompression \
-replace go.opentelemetry.io/collector/config/configgrpc=$(CURDIR)/config/configgrpc \
Expand Down Expand Up @@ -319,6 +320,7 @@ restore-contrib:
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit \
-dropreplace go.opentelemetry.io/collector \
-dropreplace go.opentelemetry.io/collector/component \
-dropreplace go.opentelemetry.io/collector/component/componentstatus \
-dropreplace go.opentelemetry.io/collector/config/configauth \
-dropreplace go.opentelemetry.io/collector/config/configcompression \
-dropreplace go.opentelemetry.io/collector/config/configgrpc \
Expand Down
1 change: 1 addition & 0 deletions cmd/builder/internal/builder/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var (
replaceModules = []string{
"",
"/component",
"/component/componentstatus",
"/config/configauth",
"/config/configcompression",
"/config/configgrpc",
Expand Down
1 change: 1 addition & 0 deletions cmd/builder/test/core.builder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ exporters:
replaces:
- go.opentelemetry.io/collector => ${WORKSPACE_DIR}
- go.opentelemetry.io/collector/component => ${WORKSPACE_DIR}/component
- go.opentelemetry.io/collector/component/componentstatus => ${WORKSPACE_DIR}/component/componentstatus
- go.opentelemetry.io/collector/config/configauth => ${WORKSPACE_DIR}/config/configauth
- go.opentelemetry.io/collector/config/configcompression => ${WORKSPACE_DIR}/config/configcompression
- go.opentelemetry.io/collector/config/configgrpc => ${WORKSPACE_DIR}/config/configgrpc
Expand Down
2 changes: 2 additions & 0 deletions cmd/mdatagen/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,5 @@ replace go.opentelemetry.io/collector/internal/globalgates => ../../internal/glo
replace go.opentelemetry.io/collector/consumer/consumerprofiles => ../../consumer/consumerprofiles

replace go.opentelemetry.io/collector/consumer/consumertest => ../../consumer/consumertest

replace go.opentelemetry.io/collector/component/componentstatus => ../../component/componentstatus
1 change: 1 addition & 0 deletions cmd/otelcorecol/builder-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ replaces:
- go.opentelemetry.io/collector/internal/globalgates => ../../internal/globalgates
- go.opentelemetry.io/collector/otelcol => ../../otelcol
- go.opentelemetry.io/collector/component => ../../component
- go.opentelemetry.io/collector/component/componentstatus => ../../component/componentstatus
- go.opentelemetry.io/collector/config/configauth => ../../config/configauth
- go.opentelemetry.io/collector/config/configcompression => ../../config/configcompression
- go.opentelemetry.io/collector/config/configgrpc => ../../config/configgrpc
Expand Down
3 changes: 3 additions & 0 deletions cmd/otelcorecol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ require (
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/collector v0.105.0 // indirect
go.opentelemetry.io/collector/component/componentstatus v0.105.0 // indirect
go.opentelemetry.io/collector/config/configauth v0.105.0 // indirect
go.opentelemetry.io/collector/config/configcompression v1.12.0 // indirect
go.opentelemetry.io/collector/config/configgrpc v0.105.0 // indirect
Expand Down Expand Up @@ -145,6 +146,8 @@ replace go.opentelemetry.io/collector/otelcol => ../../otelcol

replace go.opentelemetry.io/collector/component => ../../component

replace go.opentelemetry.io/collector/component/componentstatus => ../../component/componentstatus

replace go.opentelemetry.io/collector/config/configauth => ../../config/configauth

replace go.opentelemetry.io/collector/config/configcompression => ../../config/configcompression
Expand Down
1 change: 1 addition & 0 deletions component/componentstatus/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
36 changes: 36 additions & 0 deletions component/componentstatus/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module go.opentelemetry.io/collector/component/componentstatus

go 1.21.0

toolchain go1.21.12

require (
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/collector/component v0.105.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.105.0 // indirect
go.opentelemetry.io/collector/pdata v1.12.0 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.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 => ../../pdata

replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry

replace go.opentelemetry.io/collector/component => ../
78 changes: 78 additions & 0 deletions component/componentstatus/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion component/status.go → component/componentstatus/status.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package component // import "go.opentelemetry.io/collector/component"
package componentstatus // import "go.opentelemetry.io/collector/component/componentstatus"

import (
"time"
)

type StatusReporter interface {
// ReportStatus allows a component to report runtime changes in status. The service
// will automatically report status for a component during startup and shutdown. Components can
// use this method to report status after start and before shutdown. For more details about
// component status reporting see: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-status.md
ReportStatus(*StatusEvent)
}

type Status int32

// Enumeration of possible component statuses
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package component
package componentstatus

import (
"fmt"
Expand All @@ -9,6 +9,8 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.opentelemetry.io/collector/component"
)

func TestNewStatusEvent(t *testing.T) {
Expand Down Expand Up @@ -52,12 +54,12 @@ func TestStatusEventsWithError(t *testing.T) {
func TestAggregateStatus(t *testing.T) {
for _, tc := range []struct {
name string
statusMap map[*InstanceID]*StatusEvent
statusMap map[*component.InstanceID]*StatusEvent
expectedStatus Status
}{
{
name: "aggregate status with fatal is FatalError",
statusMap: map[*InstanceID]*StatusEvent{
statusMap: map[*component.InstanceID]*StatusEvent{
{}: NewStatusEvent(StatusStarting),
{}: NewStatusEvent(StatusOK),
{}: NewStatusEvent(StatusFatalError),
Expand All @@ -67,7 +69,7 @@ func TestAggregateStatus(t *testing.T) {
},
{
name: "aggregate status with permanent is PermanentError",
statusMap: map[*InstanceID]*StatusEvent{
statusMap: map[*component.InstanceID]*StatusEvent{
{}: NewStatusEvent(StatusStarting),
{}: NewStatusEvent(StatusOK),
{}: NewStatusEvent(StatusPermanentError),
Expand All @@ -77,7 +79,7 @@ func TestAggregateStatus(t *testing.T) {
},
{
name: "aggregate status with stopping is Stopping",
statusMap: map[*InstanceID]*StatusEvent{
statusMap: map[*component.InstanceID]*StatusEvent{
{}: NewStatusEvent(StatusStarting),
{}: NewStatusEvent(StatusOK),
{}: NewStatusEvent(StatusRecoverableError),
Expand All @@ -87,7 +89,7 @@ func TestAggregateStatus(t *testing.T) {
},
{
name: "aggregate status with stopped and non-stopped is Stopping",
statusMap: map[*InstanceID]*StatusEvent{
statusMap: map[*component.InstanceID]*StatusEvent{
{}: NewStatusEvent(StatusStarting),
{}: NewStatusEvent(StatusOK),
{}: NewStatusEvent(StatusRecoverableError),
Expand All @@ -97,7 +99,7 @@ func TestAggregateStatus(t *testing.T) {
},
{
name: "aggregate status with all stopped is Stopped",
statusMap: map[*InstanceID]*StatusEvent{
statusMap: map[*component.InstanceID]*StatusEvent{
{}: NewStatusEvent(StatusStopped),
{}: NewStatusEvent(StatusStopped),
{}: NewStatusEvent(StatusStopped),
Expand All @@ -106,7 +108,7 @@ func TestAggregateStatus(t *testing.T) {
},
{
name: "aggregate status with recoverable is RecoverableError",
statusMap: map[*InstanceID]*StatusEvent{
statusMap: map[*component.InstanceID]*StatusEvent{
{}: NewStatusEvent(StatusStarting),
{}: NewStatusEvent(StatusOK),
{}: NewStatusEvent(StatusRecoverableError),
Expand All @@ -115,15 +117,15 @@ func TestAggregateStatus(t *testing.T) {
},
{
name: "aggregate status with starting is Starting",
statusMap: map[*InstanceID]*StatusEvent{
statusMap: map[*component.InstanceID]*StatusEvent{
{}: NewStatusEvent(StatusStarting),
{}: NewStatusEvent(StatusOK),
},
expectedStatus: StatusStarting,
},
{
name: "aggregate status with all ok is OK",
statusMap: map[*InstanceID]*StatusEvent{
statusMap: map[*component.InstanceID]*StatusEvent{
{}: NewStatusEvent(StatusOK),
{}: NewStatusEvent(StatusOK),
{}: NewStatusEvent(StatusOK),
Expand Down Expand Up @@ -189,12 +191,12 @@ func TestAggregateStatusEvent(t *testing.T) {

for _, tc := range []struct {
name string
statusMap map[*InstanceID]*StatusEvent
statusMap map[*component.InstanceID]*StatusEvent
expectedStatus *StatusEvent
}{
{
name: "FatalError - existing event",
statusMap: map[*InstanceID]*StatusEvent{
statusMap: map[*component.InstanceID]*StatusEvent{
{}: NewStatusEvent(StatusStarting),
{}: NewStatusEvent(StatusOK),
{}: latest(NewFatalErrorEvent(assert.AnError)),
Expand All @@ -208,7 +210,7 @@ func TestAggregateStatusEvent(t *testing.T) {
},
{
name: "FatalError - synthetic event",
statusMap: map[*InstanceID]*StatusEvent{
statusMap: map[*component.InstanceID]*StatusEvent{
{}: NewStatusEvent(StatusStarting),
{}: NewStatusEvent(StatusOK),
{}: NewFatalErrorEvent(assert.AnError),
Expand All @@ -222,7 +224,7 @@ func TestAggregateStatusEvent(t *testing.T) {
},
{
name: "PermanentError - existing event",
statusMap: map[*InstanceID]*StatusEvent{
statusMap: map[*component.InstanceID]*StatusEvent{
{}: NewStatusEvent(StatusStarting),
{}: NewStatusEvent(StatusOK),
{}: latest(NewPermanentErrorEvent(assert.AnError)),
Expand All @@ -236,7 +238,7 @@ func TestAggregateStatusEvent(t *testing.T) {
},
{
name: "PermanentError - synthetic event",
statusMap: map[*InstanceID]*StatusEvent{
statusMap: map[*component.InstanceID]*StatusEvent{
{}: NewStatusEvent(StatusStarting),
{}: NewStatusEvent(StatusOK),
{}: NewPermanentErrorEvent(assert.AnError),
Expand All @@ -250,7 +252,7 @@ func TestAggregateStatusEvent(t *testing.T) {
},
{
name: "Stopping - existing event",
statusMap: map[*InstanceID]*StatusEvent{
statusMap: map[*component.InstanceID]*StatusEvent{
{}: NewStatusEvent(StatusStarting),
{}: NewStatusEvent(StatusOK),
{}: NewStatusEvent(StatusRecoverableError),
Expand All @@ -263,7 +265,7 @@ func TestAggregateStatusEvent(t *testing.T) {
},
{
name: "Stopping - synthetic event",
statusMap: map[*InstanceID]*StatusEvent{
statusMap: map[*component.InstanceID]*StatusEvent{
{}: NewStatusEvent(StatusStarting),
{}: NewStatusEvent(StatusOK),
{}: NewStatusEvent(StatusRecoverableError),
Expand All @@ -276,7 +278,7 @@ func TestAggregateStatusEvent(t *testing.T) {
},
{
name: "Stopped - existing event",
statusMap: map[*InstanceID]*StatusEvent{
statusMap: map[*component.InstanceID]*StatusEvent{
{}: NewStatusEvent(StatusStopped),
{}: latest(NewStatusEvent(StatusStopped)),
{}: NewStatusEvent(StatusStopped),
Expand All @@ -288,7 +290,7 @@ func TestAggregateStatusEvent(t *testing.T) {
},
{
name: "RecoverableError - existing event",
statusMap: map[*InstanceID]*StatusEvent{
statusMap: map[*component.InstanceID]*StatusEvent{
{}: NewStatusEvent(StatusStarting),
{}: NewStatusEvent(StatusOK),
{}: latest(NewRecoverableErrorEvent(assert.AnError)),
Expand All @@ -301,7 +303,7 @@ func TestAggregateStatusEvent(t *testing.T) {
},
{
name: "Starting - synthetic event",
statusMap: map[*InstanceID]*StatusEvent{
statusMap: map[*component.InstanceID]*StatusEvent{
{}: NewStatusEvent(StatusStarting),
{}: latest(NewStatusEvent(StatusOK)),
},
Expand All @@ -312,7 +314,7 @@ func TestAggregateStatusEvent(t *testing.T) {
},
{
name: "OK - existing event",
statusMap: map[*InstanceID]*StatusEvent{
statusMap: map[*component.InstanceID]*StatusEvent{
{}: NewStatusEvent(StatusOK),
{}: latest(NewStatusEvent(StatusOK)),
{}: NewStatusEvent(StatusOK),
Expand Down
Loading

0 comments on commit 6f486c7

Please sign in to comment.