Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] Remove telemetryInitializer from CollectorSettings #6728

Merged
merged 1 commit into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 5 additions & 22 deletions service/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"go.uber.org/multierr"
"go.uber.org/zap"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/featuregate"
"go.opentelemetry.io/collector/service/internal/grpclog"
)
Expand Down Expand Up @@ -76,17 +75,16 @@ func (s State) String() string {
// Collector represents a server providing the OpenTelemetry Collector service.
// Deprecated: [v0.67.0] use otelcol.Collector
type Collector struct {
set CollectorSettings
set CollectorSettings
telemetry *telemetryInitializer

service *service
state *atomic.Int32

// shutdownChan is used to terminate the collector.
shutdownChan chan struct{}

// signalsChannel is used to receive termination signals from the OS.
signalsChannel chan os.Signal

// asyncErrorChannel is used to signal a fatal error from any component.
asyncErrorChannel chan error
}
Expand All @@ -98,12 +96,9 @@ func New(set CollectorSettings) (*Collector, error) {
return nil, errors.New("invalid nil config provider")
}

if set.telemetry == nil {
set.telemetry = newColTelemetry(featuregate.GetRegistry())
}

return &Collector{
set: set,
telemetry: newColTelemetry(featuregate.GetRegistry()),
state: atomic.NewInt32(int32(StateStarting)),
shutdownChan: make(chan struct{}),
// Per signal.Notify documentation, a size of the channel equaled with
Expand Down Expand Up @@ -150,7 +145,7 @@ func (col *Collector) setupConfigurationComponents(ctx context.Context) error {
Config: cfg,
AsyncErrorChannel: col.asyncErrorChannel,
LoggingOptions: col.set.LoggingOptions,
telemetry: col.set.telemetry,
telemetry: col.telemetry,
})
if err != nil {
return err
Expand Down Expand Up @@ -262,7 +257,7 @@ func (col *Collector) shutdownServiceAndTelemetry(ctx context.Context) error {

// TODO: Move this as part of the service shutdown.
// shutdown telemetryInitializer
if err := col.service.telemetryInitializer.shutdown(); err != nil {
if err := col.telemetry.shutdown(); err != nil {
errs = multierr.Append(errs, fmt.Errorf("failed to shutdown collector telemetry: %w", err))
}
return errs
Expand All @@ -272,15 +267,3 @@ func (col *Collector) shutdownServiceAndTelemetry(ctx context.Context) error {
func (col *Collector) setCollectorState(state State) {
col.state.Store(int32(state))
}

func getBallastSize(host component.Host) uint64 {
var ballastSize uint64
extensions := host.GetExtensions()
for _, extension := range extensions {
if ext, ok := extension.(interface{ GetBallastSize() uint64 }); ok {
ballastSize = ext.GetBallastSize()
break
}
}
return ballastSize
}
Loading