Skip to content

Commit

Permalink
Rename ServiceExtension to just Extension (#2581)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Mar 5, 2021
1 parent 983bb07 commit 7cdbd1c
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## 🛑 Breaking changes 🛑

- Rename ServiceExtension to just Extension (#2581)
- Remove `consumerdata.TraceData` (#2551)
- Move `consumerdata.MetricsData` to `internaldata.MetricsData` (#2512)
- Remove custom OpenCensus sematic conventions that have equivalent in otel (#2552)
Expand Down
2 changes: 1 addition & 1 deletion component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type Host interface {
// Typically is used to find an extension by type or by full config name. Both cases
// can be done by iterating the returned map. There are typically very few extensions
// so there there is no performance implications due to iteration.
GetExtensions() map[configmodels.Extension]ServiceExtension
GetExtensions() map[configmodels.Extension]Extension

// Return map of exporters. Only enabled and created exporters will be returned.
// Typically is used to find exporters by type or by full config name. Both cases
Expand Down
2 changes: 1 addition & 1 deletion component/componenttest/error_waiting_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (ews *ErrorWaitingHost) GetFactory(_ component.Kind, _ configmodels.Type) c
return nil
}

func (ews *ErrorWaitingHost) GetExtensions() map[configmodels.Extension]component.ServiceExtension {
func (ews *ErrorWaitingHost) GetExtensions() map[configmodels.Extension]component.Extension {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion component/componenttest/example_factories.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ func (f *ExampleExtensionFactory) CreateDefaultConfig() configmodels.Extension {
}

// CreateExtension creates an Extension based on this config.
func (f *ExampleExtensionFactory) CreateExtension(_ context.Context, _ component.ExtensionCreateParams, _ configmodels.Extension) (component.ServiceExtension, error) {
func (f *ExampleExtensionFactory) CreateExtension(_ context.Context, _ component.ExtensionCreateParams, _ configmodels.Extension) (component.Extension, error) {
if f.FailCreation {
return nil, fmt.Errorf("cannot create %q extension type", f.Type())
}
Expand Down
2 changes: 1 addition & 1 deletion component/componenttest/nop_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (nh *nopHost) GetFactory(_ component.Kind, _ configmodels.Type) component.F
return nil
}

func (nh *nopHost) GetExtensions() map[configmodels.Extension]component.ServiceExtension {
func (nh *nopHost) GetExtensions() map[configmodels.Extension]component.Extension {
return nil
}

Expand Down
14 changes: 7 additions & 7 deletions component/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@ import (
"go.opentelemetry.io/collector/config/configmodels"
)

// ServiceExtension is the interface for objects hosted by the OpenTelemetry Collector that
// Extension is the interface for objects hosted by the OpenTelemetry Collector that
// don't participate directly on data pipelines but provide some functionality
// to the service, examples: health check endpoint, z-pages, etc.
type ServiceExtension interface {
type Extension interface {
Component
}

// PipelineWatcher is an extra interface for ServiceExtension hosted by the OpenTelemetry
// PipelineWatcher is an extra interface for Extension hosted by the OpenTelemetry
// Collector that is to be implemented by extensions interested in changes to pipeline
// states. Typically this will be used by extensions that change their behavior if data is
// being ingested or not, e.g.: a k8s readiness probe.
type PipelineWatcher interface {
// Ready notifies the ServiceExtension that all pipelines were built and the
// Ready notifies the Extension that all pipelines were built and the
// receivers were started, i.e.: the service is ready to receive data
// (notice that it may already have received data when this method is called).
Ready() error

// NotReady notifies the ServiceExtension that all receivers are about to be stopped,
// NotReady notifies the Extension that all receivers are about to be stopped,
// i.e.: pipeline receivers will not accept new data.
// This is sent before receivers are stopped, so the ServiceExtension can take any
// This is sent before receivers are stopped, so the Extension can take any
// appropriate action before that happens.
NotReady() error
}
Expand Down Expand Up @@ -70,5 +70,5 @@ type ExtensionFactory interface {
CreateDefaultConfig() configmodels.Extension

// CreateExtension creates a service extension based on the given config.
CreateExtension(ctx context.Context, params ExtensionCreateParams, cfg configmodels.Extension) (ServiceExtension, error)
CreateExtension(ctx context.Context, params ExtensionCreateParams, cfg configmodels.Extension) (Extension, error)
}
2 changes: 1 addition & 1 deletion config/configcheck/configcheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,6 @@ func (b badConfigExtensionFactory) CreateDefaultConfig() configmodels.Extension
}{}
}

func (b badConfigExtensionFactory) CreateExtension(_ context.Context, _ component.ExtensionCreateParams, _ configmodels.Extension) (component.ServiceExtension, error) {
func (b badConfigExtensionFactory) CreateExtension(_ context.Context, _ component.ExtensionCreateParams, _ configmodels.Extension) (component.Extension, error) {
return nil, nil
}
4 changes: 2 additions & 2 deletions extension/extensionhelper/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type FactoryOption func(o *factory)
type CreateDefaultConfig func() configmodels.Extension

// CreateServiceExtension is the equivalent of component.ExtensionFactory.CreateExtension()
type CreateServiceExtension func(context.Context, component.ExtensionCreateParams, configmodels.Extension) (component.ServiceExtension, error)
type CreateServiceExtension func(context.Context, component.ExtensionCreateParams, configmodels.Extension) (component.Extension, error)

type factory struct {
cfgType configmodels.Type
Expand Down Expand Up @@ -83,7 +83,7 @@ func (f *factory) CreateDefaultConfig() configmodels.Extension {
func (f *factory) CreateExtension(
ctx context.Context,
params component.ExtensionCreateParams,
cfg configmodels.Extension) (component.ServiceExtension, error) {
cfg configmodels.Extension) (component.Extension, error) {
return f.createServiceExtension(ctx, params, cfg)
}

Expand Down
2 changes: 1 addition & 1 deletion extension/extensionhelper/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func defaultConfig() configmodels.Extension {
return defaultCfg
}

func createExtension(context.Context, component.ExtensionCreateParams, configmodels.Extension) (component.ServiceExtension, error) {
func createExtension(context.Context, component.ExtensionCreateParams, configmodels.Extension) (component.Extension, error) {
return nopExtensionInstance, nil
}

Expand Down
2 changes: 1 addition & 1 deletion extension/fluentbitextension/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func createDefaultConfig() configmodels.Extension {
}
}

func createExtension(_ context.Context, params component.ExtensionCreateParams, cfg configmodels.Extension) (component.ServiceExtension, error) {
func createExtension(_ context.Context, params component.ExtensionCreateParams, cfg configmodels.Extension) (component.Extension, error) {
config := cfg.(*Config)
return newProcessManager(config, params.Logger), nil
}
2 changes: 1 addition & 1 deletion extension/healthcheckextension/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func createDefaultConfig() configmodels.Extension {
}
}

func createExtension(_ context.Context, params component.ExtensionCreateParams, cfg configmodels.Extension) (component.ServiceExtension, error) {
func createExtension(_ context.Context, params component.ExtensionCreateParams, cfg configmodels.Extension) (component.Extension, error) {
config := cfg.(*Config)

// The runtime settings are global to the application, so while in principle it
Expand Down
2 changes: 1 addition & 1 deletion extension/pprofextension/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func createDefaultConfig() configmodels.Extension {
}
}

func createExtension(_ context.Context, params component.ExtensionCreateParams, cfg configmodels.Extension) (component.ServiceExtension, error) {
func createExtension(_ context.Context, params component.ExtensionCreateParams, cfg configmodels.Extension) (component.Extension, error) {
config := cfg.(*Config)
if config.Endpoint == "" {
return nil, errors.New("\"endpoint\" is required when using the \"pprof\" extension")
Expand Down
2 changes: 1 addition & 1 deletion extension/zpagesextension/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func createDefaultConfig() configmodels.Extension {
}

// createExtension creates the extension based on this config.
func createExtension(_ context.Context, params component.ExtensionCreateParams, cfg configmodels.Extension) (component.ServiceExtension, error) {
func createExtension(_ context.Context, params component.ExtensionCreateParams, cfg configmodels.Extension) (component.Extension, error) {
config := cfg.(*Config)
if config.Endpoint == "" {
return nil, errors.New("\"endpoint\" is required when using the \"zpages\" extension")
Expand Down
8 changes: 4 additions & 4 deletions service/builder/extensions_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
// a trace and/or a metrics consumer and have a shutdown function.
type builtExtension struct {
logger *zap.Logger
extension component.ServiceExtension
extension component.Extension
}

// Start the receiver.
Expand All @@ -42,7 +42,7 @@ func (ext *builtExtension) Shutdown(ctx context.Context) error {
return ext.extension.Shutdown(ctx)
}

var _ component.ServiceExtension = (*builtExtension)(nil)
var _ component.Extension = (*builtExtension)(nil)

// Exporters is a map of exporters created from exporter configs.
type Extensions map[configmodels.Extension]*builtExtension
Expand Down Expand Up @@ -102,8 +102,8 @@ func (exts Extensions) NotifyPipelineNotReady() error {
return consumererror.CombineErrors(errs)
}

func (exts Extensions) ToMap() map[configmodels.Extension]component.ServiceExtension {
result := make(map[configmodels.Extension]component.ServiceExtension, len(exts))
func (exts Extensions) ToMap() map[configmodels.Extension]component.Extension {
result := make(map[configmodels.Extension]component.Extension, len(exts))
for k, v := range exts {
result[k] = v.extension
}
Expand Down
2 changes: 1 addition & 1 deletion service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (app *Application) GetFactory(kind component.Kind, componentType configmode
return nil
}

func (app *Application) GetExtensions() map[configmodels.Extension]component.ServiceExtension {
func (app *Application) GetExtensions() map[configmodels.Extension]component.Extension {
return app.builtExtensions.ToMap()
}

Expand Down
2 changes: 1 addition & 1 deletion service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ func (b badExtensionFactory) CreateDefaultConfig() configmodels.Extension {
return &configmodels.ExtensionSettings{}
}

func (b badExtensionFactory) CreateExtension(_ context.Context, _ component.ExtensionCreateParams, _ configmodels.Extension) (component.ServiceExtension, error) {
func (b badExtensionFactory) CreateExtension(_ context.Context, _ component.ExtensionCreateParams, _ configmodels.Extension) (component.Extension, error) {
return nil, nil
}

Expand Down
2 changes: 1 addition & 1 deletion testbed/testbed/receivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (mb *DataReceiverBase) GetFactory(_ component.Kind, _ configmodels.Type) co
}

// Return map of extensions. Only enabled and created extensions will be returned.
func (mb *DataReceiverBase) GetExtensions() map[configmodels.Extension]component.ServiceExtension {
func (mb *DataReceiverBase) GetExtensions() map[configmodels.Extension]component.Extension {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion testbed/testbed/senders.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (dsb *DataSenderBase) GetFactory(_ component.Kind, _ configmodels.Type) com
}

// Return map of extensions. Only enabled and created extensions will be returned.
func (dsb *DataSenderBase) GetExtensions() map[configmodels.Extension]component.ServiceExtension {
func (dsb *DataSenderBase) GetExtensions() map[configmodels.Extension]component.Extension {
return nil
}

Expand Down

0 comments on commit 7cdbd1c

Please sign in to comment.