Move Extension/ExtensionFactory to extension package (#6642)

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
This commit is contained in:
Bogdan Drutu 2022-12-01 10:39:09 -08:00 committed by GitHub
parent 6c05df860b
commit 03370c7ff5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 170 additions and 68 deletions

25
.chloggen/moveext.yaml Executable file
View File

@ -0,0 +1,25 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: deprecation
# 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: Deprecate Extension related -s from component package in favor of extension package.
# One or more tracking issues or pull requests related to the change
issues: [6578]
# (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: |-
- `component.Extension` -> `extension.Extension`
- `component.PipelineWatcher` -> extension.PipelineWatcher
- `component.ExtensionCreateSettings` -> `extension.CreateSettings`
- `component.CreateExtensionFunc` -> `extension.CreateFunc`
- `component.ExtensionFactory` -> `extension.Factory`
- `component.NewExtensionFactory` -> `extension.NewFactory`
- `component.MakeExtensionFactoryMap` -> `extension.MakeFactoryMap`
- `componenttest.NewNopExtensionCreateSettings` -> `extensiontest.NewNopCreateSettings`
- `componenttest.NewNopExtensionFactory` -> `extensiontest.NewNopFactory`

View File

@ -19,11 +19,12 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/extension"
)
// NewNopExtensionCreateSettings returns a new nop settings for Create*Extension functions.
func NewNopExtensionCreateSettings() component.ExtensionCreateSettings {
return component.ExtensionCreateSettings{
// Deprecated: [v0.67.0] use extensiontest.NewNopCreateSettings.
func NewNopExtensionCreateSettings() extension.CreateSettings {
return extension.CreateSettings{
TelemetrySettings: NewNopTelemetrySettings(),
BuildInfo: component.NewDefaultBuildInfo(),
}
@ -33,9 +34,9 @@ type nopExtensionConfig struct {
config.ExtensionSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
}
// NewNopExtensionFactory returns a component.ExtensionFactory that constructs nop extensions.
func NewNopExtensionFactory() component.ExtensionFactory {
return component.NewExtensionFactory(
// Deprecated: [v0.67.0] use extensiontest.NewNopFactory.
func NewNopExtensionFactory() extension.Factory {
return extension.NewFactory(
"nop",
func() component.Config {
return &nopExtensionConfig{

View File

@ -23,6 +23,7 @@ func NopFactories() (component.Factories, error) {
var factories component.Factories
var err error
//nolint:staticcheck
if factories.Extensions, err = component.MakeExtensionFactoryMap(NewNopExtensionFactory()); err != nil {
return component.Factories{}, err
}

View File

@ -24,15 +24,13 @@ type ExtensionConfig = Config
// Deprecated: [v0.67.0] use UnmarshalConfig.
var UnmarshalExtensionConfig = UnmarshalConfig
// 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.
// Deprecated: [v0.67.0] use CreateDefaultConfigFunc.
type ExtensionCreateDefaultConfigFunc = CreateDefaultConfigFunc
// Deprecated: [v0.67.0] use extension.Extension.
type Extension = Component
// 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.
// Deprecated: [v0.67.0] use extension.PipelineWatcher.
type PipelineWatcher interface {
// Ready notifies the Extension that all pipelines were built and the
// receivers were started, i.e.: the service is ready to receive data
@ -46,7 +44,7 @@ type PipelineWatcher interface {
NotReady() error
}
// ExtensionCreateSettings is passed to ExtensionFactory.Create* functions.
// Deprecated: [v0.67.0] use extension.CreateSettings.
type ExtensionCreateSettings struct {
// ID returns the ID of the component that will be created.
ID ID
@ -57,10 +55,7 @@ type ExtensionCreateSettings struct {
BuildInfo BuildInfo
}
// Deprecated: [v0.67.0] use CreateDefaultConfigFunc.
type ExtensionCreateDefaultConfigFunc = CreateDefaultConfigFunc
// CreateExtensionFunc is the equivalent of ExtensionFactory.CreateExtension()
// Deprecated: [v0.67.0] use extension.CreateFunc.
type CreateExtensionFunc func(context.Context, ExtensionCreateSettings, Config) (Extension, error)
// CreateExtension implements ExtensionFactory.CreateExtension.
@ -68,7 +63,7 @@ func (f CreateExtensionFunc) CreateExtension(ctx context.Context, set ExtensionC
return f(ctx, set, cfg)
}
// ExtensionFactory is a factory for extensions to the service.
// Deprecated: [v0.67.0] use extension.Factory.
type ExtensionFactory interface {
Factory
@ -89,7 +84,7 @@ func (ef *extensionFactory) ExtensionStability() StabilityLevel {
return ef.extensionStability
}
// NewExtensionFactory returns a new ExtensionFactory based on this configuration.
// Deprecated: [v0.67.0] use extension.NewFactory.
func NewExtensionFactory(
cfgType Type,
createDefaultConfig CreateDefaultConfigFunc,

View File

@ -76,9 +76,7 @@ func MakeExporterFactoryMap(factories ...ExporterFactory) (map[Type]ExporterFact
return fMap, nil
}
// MakeExtensionFactoryMap takes a list of extension factories and returns a map
// with factory type as keys. It returns a non-nil error when more than one factories
// have the same type.
// Deprecated: [v0.67.0] use extension.MakeFactoryMap
func MakeExtensionFactoryMap(factories ...ExtensionFactory) (map[Type]ExtensionFactory, error) {
fMap := map[Type]ExtensionFactory{}
for _, f := range factories {

View File

@ -20,13 +20,14 @@ import (
"github.com/stretchr/testify/assert"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/extension"
"go.opentelemetry.io/collector/extension/auth"
)
func TestGetServer(t *testing.T) {
testCases := []struct {
desc string
authenticator component.Extension
authenticator extension.Extension
expected error
}{
{
@ -77,7 +78,7 @@ func TestGetServerFails(t *testing.T) {
func TestGetClient(t *testing.T) {
testCases := []struct {
desc string
authenticator component.Extension
authenticator extension.Extension
expected error
}{
{

View File

@ -35,6 +35,7 @@ import (
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
"go.opentelemetry.io/collector/extension/experimental/storage"
"go.opentelemetry.io/collector/extension/extensiontest"
"go.opentelemetry.io/collector/internal/testdata"
"go.opentelemetry.io/collector/obsreport/obsreporttest"
"go.opentelemetry.io/collector/pdata/ptrace"
@ -462,9 +463,9 @@ func TestInvalidStorageExtensionType(t *testing.T) {
storageID := component.NewIDWithName("extension", "extension")
// make a test extension
factory := componenttest.NewNopExtensionFactory()
factory := extensiontest.NewNopFactory()
extConfig := factory.CreateDefaultConfig()
settings := componenttest.NewNopExtensionCreateSettings()
settings := extensiontest.NewNopCreateSettings()
extension, err := factory.CreateExtension(context.Background(), settings, extConfig)
assert.NoError(t, err)
var extensions = map[component.ID]component.Component{

View File

@ -19,14 +19,14 @@ import (
"google.golang.org/grpc/credentials"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/extension"
)
// Client is an Extension that can be used as an authenticator for the configauth.Authentication option.
// Authenticators are then included as part of OpenTelemetry Collector builds and can be referenced by their
// names from the Authentication configuration.
type Client interface {
component.Extension
extension.Extension
// RoundTripper returns a RoundTripper that can be used to authenticate HTTP requests.
RoundTripper(base http.RoundTripper) (http.RoundTripper, error)

View File

@ -17,7 +17,7 @@ package auth // import "go.opentelemetry.io/collector/extension/auth"
import (
"context"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/extension"
)
// Server is an Extension that can be used as an authenticator for the configauth.Authentication option.
@ -26,7 +26,7 @@ import (
// but note that the expectations that come as part of Extensions exist here as well. For instance, multiple instances of the same
// authenticator should be possible to exist under different names.
type Server interface {
component.Extension
extension.Extension
// Authenticate checks whether the given headers map contains valid auth data. Successfully authenticated calls will always return a nil error.
// When the authentication fails, an error must be returned and the caller must not retry. This function is typically called from interceptors,

View File

@ -19,6 +19,7 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/extension"
"go.opentelemetry.io/collector/internal/iruntime"
)
@ -31,8 +32,8 @@ const (
var memHandler = iruntime.TotalMemory
// NewFactory creates a factory for FluentBit extension.
func NewFactory() component.ExtensionFactory {
return component.NewExtensionFactory(typeStr, createDefaultConfig, createExtension, component.StabilityLevelBeta)
func NewFactory() extension.Factory {
return extension.NewFactory(typeStr, createDefaultConfig, createExtension, component.StabilityLevelBeta)
}
func createDefaultConfig() component.Config {
@ -41,6 +42,6 @@ func createDefaultConfig() component.Config {
}
}
func createExtension(_ context.Context, set component.ExtensionCreateSettings, cfg component.Config) (component.Extension, error) {
return newMemoryBallast(cfg.(*Config), set.Logger, memHandler), nil
func createExtension(_ context.Context, set extension.CreateSettings, cfg component.Config) (extension.Extension, error) {
return newMemoryBallast(cfg.(*Config), set.TelemetrySettings.Logger, memHandler), nil
}

View File

@ -24,6 +24,7 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/extension/extensiontest"
)
func TestFactory_CreateDefaultConfig(t *testing.T) {
@ -31,14 +32,14 @@ func TestFactory_CreateDefaultConfig(t *testing.T) {
assert.Equal(t, &Config{ExtensionSettings: config.NewExtensionSettings(component.NewID(typeStr))}, cfg)
assert.NoError(t, componenttest.CheckConfigStruct(cfg))
ext, err := createExtension(context.Background(), componenttest.NewNopExtensionCreateSettings(), cfg)
ext, err := createExtension(context.Background(), extensiontest.NewNopCreateSettings(), cfg)
require.NoError(t, err)
require.NotNil(t, ext)
}
func TestFactory_CreateExtension(t *testing.T) {
cfg := createDefaultConfig().(*Config)
ext, err := createExtension(context.Background(), componenttest.NewNopExtensionCreateSettings(), cfg)
ext, err := createExtension(context.Background(), extensiontest.NewNopCreateSettings(), cfg)
require.NoError(t, err)
require.NotNil(t, ext)
}

View File

@ -18,11 +18,12 @@ import (
"context"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/extension"
)
// Extension is the interface that storage extensions must implement
type Extension interface {
component.Extension
extension.Extension
// GetClient will create a client for use by the specified component.
// Each component can have multiple storages (e.g. one for each signal),

47
extension/extension.go Normal file
View File

@ -0,0 +1,47 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package extension // import "go.opentelemetry.io/collector/extension"
import (
"go.opentelemetry.io/collector/component"
)
// 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 Extension = component.Extension //nolint:staticcheck
// 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 = component.PipelineWatcher //nolint:staticcheck
// CreateSettings is passed to Factory.Create(...) function.
type CreateSettings = component.ExtensionCreateSettings //nolint:staticcheck
// CreateFunc is the equivalent of Factory.Create(...) function.
type CreateFunc = component.CreateExtensionFunc //nolint:staticcheck
// Factory is a factory for extensions to the service.
type Factory = component.ExtensionFactory //nolint:staticcheck
// NewFactory returns a new Factory based on this configuration.
var NewFactory = component.NewExtensionFactory //nolint:staticcheck
// MakeFactoryMap takes a list of extension factories and returns a map
// with factory type as keys. It returns a non-nil error when more than one factories
// have the same type.
var MakeFactoryMap = component.MakeExtensionFactoryMap //nolint:staticcheck

View File

@ -12,9 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// TODO: Move tests back to component package after config.*Settings are removed.
package component_test
package extension
import (
"context"
@ -36,10 +34,10 @@ func TestNewExtensionFactory(t *testing.T) {
defaultCfg := config.NewExtensionSettings(component.NewID(typeStr))
nopExtensionInstance := new(nopExtension)
factory := component.NewExtensionFactory(
factory := NewFactory(
typeStr,
func() component.Config { return &defaultCfg },
func(ctx context.Context, settings component.ExtensionCreateSettings, extension component.Config) (component.Extension, error) {
func(ctx context.Context, settings CreateSettings, extension component.Config) (Extension, error) {
return nopExtensionInstance, nil
},
component.StabilityLevelDevelopment)
@ -47,7 +45,7 @@ func TestNewExtensionFactory(t *testing.T) {
assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig())
assert.Equal(t, component.StabilityLevelDevelopment, factory.ExtensionStability())
ext, err := factory.CreateExtension(context.Background(), component.ExtensionCreateSettings{}, &defaultCfg)
ext, err := factory.CreateExtension(context.Background(), CreateSettings{}, &defaultCfg)
assert.NoError(t, err)
assert.Same(t, nopExtensionInstance, ext)
}

View File

@ -0,0 +1,25 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package extensiontest // import "go.opentelemetry.io/collector/extension/extensiontest"
import (
"go.opentelemetry.io/collector/component/componenttest"
)
// NewNopCreateSettings returns a new nop settings for extension.Factory Create* functions.
var NewNopCreateSettings = componenttest.NewNopExtensionCreateSettings //nolint:staticcheck
// NewNopFactory returns an extension.Factory that constructs nop extensions.
var NewNopFactory = componenttest.NewNopExtensionFactory //nolint:staticcheck

View File

@ -20,6 +20,7 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/confignet"
"go.opentelemetry.io/collector/extension"
)
const (
@ -30,8 +31,8 @@ const (
)
// NewFactory creates a factory for Z-Pages extension.
func NewFactory() component.ExtensionFactory {
return component.NewExtensionFactory(typeStr, createDefaultConfig, createExtension, component.StabilityLevelBeta)
func NewFactory() extension.Factory {
return extension.NewFactory(typeStr, createDefaultConfig, createExtension, component.StabilityLevelBeta)
}
func createDefaultConfig() component.Config {
@ -44,6 +45,6 @@ func createDefaultConfig() component.Config {
}
// createExtension creates the extension based on this config.
func createExtension(_ context.Context, set component.ExtensionCreateSettings, cfg component.Config) (component.Extension, error) {
func createExtension(_ context.Context, set extension.CreateSettings, cfg component.Config) (extension.Extension, error) {
return newServer(cfg.(*Config), set.TelemetrySettings), nil
}

View File

@ -25,6 +25,7 @@ import (
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/confignet"
"go.opentelemetry.io/collector/extension/extensiontest"
"go.opentelemetry.io/collector/internal/testutil"
)
@ -39,7 +40,7 @@ func TestFactory_CreateDefaultConfig(t *testing.T) {
cfg)
assert.NoError(t, componenttest.CheckConfigStruct(cfg))
ext, err := createExtension(context.Background(), componenttest.NewNopExtensionCreateSettings(), cfg)
ext, err := createExtension(context.Background(), extensiontest.NewNopCreateSettings(), cfg)
require.NoError(t, err)
require.NotNil(t, ext)
}
@ -48,7 +49,7 @@ func TestFactory_CreateExtension(t *testing.T) {
cfg := createDefaultConfig().(*Config)
cfg.TCPAddr.Endpoint = testutil.GetAvailableLocalAddress(t)
ext, err := createExtension(context.Background(), componenttest.NewNopExtensionCreateSettings(), cfg)
ext, err := createExtension(context.Background(), extensiontest.NewNopCreateSettings(), cfg)
require.NoError(t, err)
require.NotNil(t, ext)
}

View File

@ -30,6 +30,7 @@ import (
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/confmap/provider/fileprovider"
"go.opentelemetry.io/collector/confmap/provider/yamlprovider"
"go.opentelemetry.io/collector/extension/extensiontest"
"go.opentelemetry.io/collector/service/telemetry"
)
@ -37,7 +38,7 @@ var configNop = &Config{
Receivers: map[component.ID]component.Config{component.NewID("nop"): componenttest.NewNopReceiverFactory().CreateDefaultConfig()},
Processors: map[component.ID]component.Config{component.NewID("nop"): componenttest.NewNopProcessorFactory().CreateDefaultConfig()},
Exporters: map[component.ID]component.Config{component.NewID("nop"): componenttest.NewNopExporterFactory().CreateDefaultConfig()},
Extensions: map[component.ID]component.Config{component.NewID("nop"): componenttest.NewNopExtensionFactory().CreateDefaultConfig()},
Extensions: map[component.ID]component.Config{component.NewID("nop"): extensiontest.NewNopFactory().CreateDefaultConfig()},
Service: ConfigService{
Extensions: []component.ID{component.NewID("nop")},
Pipelines: map[component.ID]*ConfigServicePipeline{

View File

@ -24,6 +24,7 @@ import (
"go.uber.org/zap"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/extension"
"go.opentelemetry.io/collector/service/internal/components"
"go.opentelemetry.io/collector/service/internal/zpages"
)
@ -33,7 +34,7 @@ const zExtensionName = "zextensionname"
// Extensions is a map of extensions created from extension configs.
type Extensions struct {
telemetry component.TelemetrySettings
extMap map[component.ID]component.Extension
extMap map[component.ID]extension.Extension
}
// Start starts all extensions.
@ -63,7 +64,7 @@ func (bes *Extensions) Shutdown(ctx context.Context) error {
func (bes *Extensions) NotifyPipelineReady() error {
for extID, ext := range bes.extMap {
if pw, ok := ext.(component.PipelineWatcher); ok {
if pw, ok := ext.(extension.PipelineWatcher); ok {
if err := pw.Ready(); err != nil {
return fmt.Errorf("failed to notify extension %q: %w", extID, err)
}
@ -76,7 +77,7 @@ func (bes *Extensions) NotifyPipelineNotReady() error {
// Notify extensions in reverse order.
var errs error
for _, ext := range bes.extMap {
if pw, ok := ext.(component.PipelineWatcher); ok {
if pw, ok := ext.(extension.PipelineWatcher); ok {
errs = multierr.Append(errs, pw.NotReady())
}
}
@ -125,15 +126,15 @@ type Settings struct {
// Configs is a map of component.ID to component.Config.
Configs map[component.ID]component.Config
// Factories maps extension type names in the config to the respective component.ExtensionFactory.
Factories map[component.Type]component.ExtensionFactory
// Factories maps extension type names in the config to the respective extension.Factory.
Factories map[component.Type]extension.Factory
}
// New creates a new Extensions from Config.
func New(ctx context.Context, set Settings, cfg Config) (*Extensions, error) {
exts := &Extensions{
telemetry: set.Telemetry,
extMap: make(map[component.ID]component.Extension),
extMap: make(map[component.ID]extension.Extension),
}
for _, extID := range cfg {
extCfg, existsCfg := set.Configs[extID]
@ -146,7 +147,7 @@ func New(ctx context.Context, set Settings, cfg Config) (*Extensions, error) {
return nil, fmt.Errorf("extension factory for type %q is not configured", extID.Type())
}
extSet := component.ExtensionCreateSettings{
extSet := extension.CreateSettings{
ID: extID,
TelemetrySettings: set.Telemetry,
BuildInfo: set.BuildInfo,

View File

@ -25,10 +25,12 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/extension"
"go.opentelemetry.io/collector/extension/extensiontest"
)
func TestBuildExtensions(t *testing.T) {
nopExtensionFactory := componenttest.NewNopExtensionFactory()
nopExtensionFactory := extensiontest.NewNopFactory()
nopExtensionConfig := nopExtensionFactory.CreateDefaultConfig()
errExtensionFactory := newCreateErrorExtensionFactory()
errExtensionConfig := errExtensionFactory.CreateDefaultConfig()
@ -62,7 +64,7 @@ func TestBuildExtensions(t *testing.T) {
{
name: "error_on_create_extension",
factories: component.Factories{
Extensions: map[component.Type]component.ExtensionFactory{
Extensions: map[component.Type]extension.Factory{
errExtensionFactory.Type(): errExtensionFactory,
},
},
@ -77,7 +79,7 @@ func TestBuildExtensions(t *testing.T) {
{
name: "bad_factory",
factories: component.Factories{
Extensions: map[component.Type]component.ExtensionFactory{
Extensions: map[component.Type]extension.Factory{
badExtensionFactory.Type(): badExtensionFactory,
},
},
@ -105,8 +107,8 @@ func TestBuildExtensions(t *testing.T) {
}
}
func newBadExtensionFactory() component.ExtensionFactory {
return component.NewExtensionFactory(
func newBadExtensionFactory() extension.Factory {
return extension.NewFactory(
"bf",
func() component.Config {
return &struct {
@ -115,15 +117,15 @@ func newBadExtensionFactory() component.ExtensionFactory {
ExtensionSettings: config.NewExtensionSettings(component.NewID("bf")),
}
},
func(ctx context.Context, set component.ExtensionCreateSettings, extension component.Config) (component.Extension, error) {
func(ctx context.Context, set extension.CreateSettings, extension component.Config) (extension.Extension, error) {
return nil, nil
},
component.StabilityLevelDevelopment,
)
}
func newCreateErrorExtensionFactory() component.ExtensionFactory {
return component.NewExtensionFactory(
func newCreateErrorExtensionFactory() extension.Factory {
return extension.NewFactory(
"err",
func() component.Config {
return &struct {
@ -132,7 +134,7 @@ func newCreateErrorExtensionFactory() component.ExtensionFactory {
ExtensionSettings: config.NewExtensionSettings(component.NewID("err")),
}
},
func(ctx context.Context, set component.ExtensionCreateSettings, extension component.Config) (component.Extension, error) {
func(ctx context.Context, set extension.CreateSettings, extension component.Config) (extension.Extension, error) {
return nil, errors.New("cannot create \"err\" extension type")
},
component.StabilityLevelDevelopment,

View File

@ -19,6 +19,7 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/extension"
)
// extensionsKeyName is the configuration key name for extensions section.
@ -27,10 +28,10 @@ const extensionsKeyName = "extensions"
type Extensions struct {
exts map[component.ID]component.Config
factories map[component.Type]component.ExtensionFactory
factories map[component.Type]extension.Factory
}
func NewExtensions(factories map[component.Type]component.ExtensionFactory) *Extensions {
func NewExtensions(factories map[component.Type]extension.Factory) *Extensions {
return &Extensions{factories: factories}
}