Revert changes to config.[Receiver|Processor|Exporter|Extension]Settings
Signed-off-by: Bogdan <bogdandrutu@gmail.com>
This commit is contained in:
parent
d6ed8246b6
commit
fbf1e2a09c
|
|
@ -5,7 +5,7 @@ change_type: deprecation
|
|||
component: config
|
||||
|
||||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
|
||||
note: Deprecate all types and funcs in `config` package
|
||||
note: Deprecate multiple types and funcs in `config` package
|
||||
|
||||
# One or more tracking issues or pull requests related to the change
|
||||
issues: [6422]
|
||||
|
|
@ -19,13 +19,9 @@ subtext: |
|
|||
- config.DataType => component.DataType
|
||||
- config.Receiver => component.ReceiverConfig
|
||||
- config.UnmarshalReceiver => component.UnmarshalReceiverConfig
|
||||
- config.[New]ReceiverSettings => component.[New]ReceiverConfigSettings
|
||||
- config.Processor => component.ProcessorConfig
|
||||
- config.UnmarshalProcessor => component.UnmarshalProcessorConfig
|
||||
- config.[New]ProcessorSettings => component.[New]ProcessorConfigSettings
|
||||
- config.Exporter => component.ExporterConfig
|
||||
- config.UnmarshalExporter => component.UnmarshalExporterConfig
|
||||
- config.[New]ExporterSettings => component.[New]ExporterConfigSettings
|
||||
- config.Extension => component.ExtensionConfig
|
||||
- config.UnmarshalExtension => component.UnmarshalExtensionConfig
|
||||
- config.[New]ExtensionSettings => component.[New]ExtensionConfigSettings
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"go.opentelemetry.io/collector/config/configtest"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
)
|
||||
|
||||
func TestValidateConfigs(t *testing.T) {
|
||||
|
|
@ -15,15 +15,15 @@ func TestValidateConfigs(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
|
||||
for _, factory := range factories.Receivers {
|
||||
assert.NoError(t, configtest.CheckConfigStruct(factory.CreateDefaultConfig()))
|
||||
assert.NoError(t, componenttest.CheckConfigStruct(factory.CreateDefaultConfig()))
|
||||
}
|
||||
for _, factory := range factories.Processors {
|
||||
assert.NoError(t, configtest.CheckConfigStruct(factory.CreateDefaultConfig()))
|
||||
assert.NoError(t, componenttest.CheckConfigStruct(factory.CreateDefaultConfig()))
|
||||
}
|
||||
for _, factory := range factories.Exporters {
|
||||
assert.NoError(t, configtest.CheckConfigStruct(factory.CreateDefaultConfig()))
|
||||
assert.NoError(t, componenttest.CheckConfigStruct(factory.CreateDefaultConfig()))
|
||||
}
|
||||
for _, factory := range factories.Extensions {
|
||||
assert.NoError(t, configtest.CheckConfigStruct(factory.CreateDefaultConfig()))
|
||||
assert.NoError(t, componenttest.CheckConfigStruct(factory.CreateDefaultConfig()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"context"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer/consumertest"
|
||||
)
|
||||
|
||||
|
|
@ -30,7 +31,7 @@ func NewNopExporterCreateSettings() component.ExporterCreateSettings {
|
|||
}
|
||||
|
||||
type nopExporterConfig struct {
|
||||
component.ExporterConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ExporterSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
}
|
||||
|
||||
// NewNopExporterFactory returns a component.ExporterFactory that constructs nop exporters.
|
||||
|
|
@ -39,7 +40,7 @@ func NewNopExporterFactory() component.ExporterFactory {
|
|||
"nop",
|
||||
func() component.ExporterConfig {
|
||||
return &nopExporterConfig{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID("nop")),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID("nop")),
|
||||
}
|
||||
},
|
||||
component.WithTracesExporter(createTracesExporter, component.StabilityLevelStable),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/pdata/plog"
|
||||
"go.opentelemetry.io/collector/pdata/pmetric"
|
||||
"go.opentelemetry.io/collector/pdata/ptrace"
|
||||
|
|
@ -32,7 +33,7 @@ func TestNewNopExporterFactory(t *testing.T) {
|
|||
require.NotNil(t, factory)
|
||||
assert.Equal(t, component.Type("nop"), factory.Type())
|
||||
cfg := factory.CreateDefaultConfig()
|
||||
assert.Equal(t, &nopExporterConfig{ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID("nop"))}, cfg)
|
||||
assert.Equal(t, &nopExporterConfig{ExporterSettings: config.NewExporterSettings(component.NewID("nop"))}, cfg)
|
||||
|
||||
traces, err := factory.CreateTracesExporter(context.Background(), NewNopExporterCreateSettings(), cfg)
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"context"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
)
|
||||
|
||||
// NewNopExtensionCreateSettings returns a new nop settings for Create*Extension functions.
|
||||
|
|
@ -29,7 +30,7 @@ func NewNopExtensionCreateSettings() component.ExtensionCreateSettings {
|
|||
}
|
||||
|
||||
type nopExtensionConfig struct {
|
||||
component.ExtensionConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ExtensionSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
}
|
||||
|
||||
// NewNopExtensionFactory returns a component.ExtensionFactory that constructs nop extensions.
|
||||
|
|
@ -38,7 +39,7 @@ func NewNopExtensionFactory() component.ExtensionFactory {
|
|||
"nop",
|
||||
func() component.ExtensionConfig {
|
||||
return &nopExtensionConfig{
|
||||
ExtensionConfigSettings: component.NewExtensionConfigSettings(component.NewID("nop")),
|
||||
ExtensionSettings: config.NewExtensionSettings(component.NewID("nop")),
|
||||
}
|
||||
},
|
||||
func(context.Context, component.ExtensionCreateSettings, component.ExtensionConfig) (component.Extension, error) {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
)
|
||||
|
||||
func TestNewNopExtensionFactory(t *testing.T) {
|
||||
|
|
@ -29,7 +30,7 @@ func TestNewNopExtensionFactory(t *testing.T) {
|
|||
require.NotNil(t, factory)
|
||||
assert.Equal(t, component.Type("nop"), factory.Type())
|
||||
cfg := factory.CreateDefaultConfig()
|
||||
assert.Equal(t, &nopExtensionConfig{ExtensionConfigSettings: component.NewExtensionConfigSettings(component.NewID("nop"))}, cfg)
|
||||
assert.Equal(t, &nopExtensionConfig{ExtensionSettings: config.NewExtensionSettings(component.NewID("nop"))}, cfg)
|
||||
|
||||
traces, err := factory.CreateExtension(context.Background(), NewNopExtensionCreateSettings(), cfg)
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"context"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
"go.opentelemetry.io/collector/consumer/consumertest"
|
||||
)
|
||||
|
|
@ -31,7 +32,7 @@ func NewNopProcessorCreateSettings() component.ProcessorCreateSettings {
|
|||
}
|
||||
|
||||
type nopProcessorConfig struct {
|
||||
component.ProcessorConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ProcessorSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
}
|
||||
|
||||
// NewNopProcessorFactory returns a component.ProcessorFactory that constructs nop processors.
|
||||
|
|
@ -40,7 +41,7 @@ func NewNopProcessorFactory() component.ProcessorFactory {
|
|||
"nop",
|
||||
func() component.ProcessorConfig {
|
||||
return &nopProcessorConfig{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID("nop")),
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID("nop")),
|
||||
}
|
||||
},
|
||||
component.WithTracesProcessor(createTracesProcessor, component.StabilityLevelStable),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
"go.opentelemetry.io/collector/consumer/consumertest"
|
||||
"go.opentelemetry.io/collector/pdata/plog"
|
||||
|
|
@ -34,7 +35,7 @@ func TestNewNopProcessorFactory(t *testing.T) {
|
|||
require.NotNil(t, factory)
|
||||
assert.Equal(t, component.Type("nop"), factory.Type())
|
||||
cfg := factory.CreateDefaultConfig()
|
||||
assert.Equal(t, &nopProcessorConfig{ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID("nop"))}, cfg)
|
||||
assert.Equal(t, &nopProcessorConfig{ProcessorSettings: config.NewProcessorSettings(component.NewID("nop"))}, cfg)
|
||||
|
||||
traces, err := factory.CreateTracesProcessor(context.Background(), NewNopProcessorCreateSettings(), cfg, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"context"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
)
|
||||
|
||||
|
|
@ -30,7 +31,7 @@ func NewNopReceiverCreateSettings() component.ReceiverCreateSettings {
|
|||
}
|
||||
|
||||
type nopReceiverConfig struct {
|
||||
component.ReceiverConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ReceiverSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
}
|
||||
|
||||
// NewNopReceiverFactory returns a component.ReceiverFactory that constructs nop receivers.
|
||||
|
|
@ -39,7 +40,7 @@ func NewNopReceiverFactory() component.ReceiverFactory {
|
|||
"nop",
|
||||
func() component.ReceiverConfig {
|
||||
return &nopReceiverConfig{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID("nop")),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID("nop")),
|
||||
}
|
||||
},
|
||||
component.WithTracesReceiver(createTracesReceiver, component.StabilityLevelStable),
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer/consumertest"
|
||||
)
|
||||
|
||||
|
|
@ -30,7 +31,7 @@ func TestNewNopReceiverFactory(t *testing.T) {
|
|||
require.NotNil(t, factory)
|
||||
assert.Equal(t, component.Type("nop"), factory.Type())
|
||||
cfg := factory.CreateDefaultConfig()
|
||||
assert.Equal(t, &nopReceiverConfig{ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID("nop"))}, cfg)
|
||||
assert.Equal(t, &nopReceiverConfig{ReceiverSettings: config.NewReceiverSettings(component.NewID("nop"))}, cfg)
|
||||
|
||||
traces, err := factory.CreateTracesReceiver(context.Background(), NewNopReceiverCreateSettings(), cfg, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -17,9 +17,26 @@ package component // import "go.opentelemetry.io/collector/component"
|
|||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/collector/confmap"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
)
|
||||
|
||||
// ExporterConfig is the configuration of a component.Exporter. Specific extensions must implement
|
||||
// this interface and must embed config.ExporterSettings struct or a struct that extends it.
|
||||
type ExporterConfig interface {
|
||||
identifiable
|
||||
validatable
|
||||
|
||||
privateConfigExporter()
|
||||
}
|
||||
|
||||
// UnmarshalExporterConfig helper function to unmarshal an ExporterConfig.
|
||||
// It checks if the config implements confmap.Unmarshaler and uses that if available,
|
||||
// otherwise uses Map.UnmarshalExact, erroring if a field is nonexistent.
|
||||
func UnmarshalExporterConfig(conf *confmap.Conf, cfg ExporterConfig) error {
|
||||
return unmarshal(conf, cfg)
|
||||
}
|
||||
|
||||
// Exporter exports telemetry data from the collector to a destination.
|
||||
type Exporter interface {
|
||||
Component
|
||||
|
|
|
|||
|
|
@ -1,69 +0,0 @@
|
|||
// 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 component // import "go.opentelemetry.io/collector/component"
|
||||
|
||||
import (
|
||||
"go.opentelemetry.io/collector/confmap"
|
||||
)
|
||||
|
||||
// ExporterConfig is the configuration of a component.Exporter. Specific extensions must implement
|
||||
// this interface and must embed ExporterSettings struct or a struct that extends it.
|
||||
type ExporterConfig interface {
|
||||
identifiable
|
||||
validatable
|
||||
|
||||
privateConfigExporter()
|
||||
}
|
||||
|
||||
// UnmarshalExporterConfig helper function to unmarshal an ExporterConfig.
|
||||
// It checks if the config implements confmap.Unmarshaler and uses that if available,
|
||||
// otherwise uses Map.UnmarshalExact, erroring if a field is nonexistent.
|
||||
func UnmarshalExporterConfig(conf *confmap.Conf, cfg ExporterConfig) error {
|
||||
return unmarshal(conf, cfg)
|
||||
}
|
||||
|
||||
// ExporterConfigSettings defines common settings for a component.Exporter configuration.
|
||||
// Specific exporters can embed this struct and extend it with more fields if needed.
|
||||
//
|
||||
// It is highly recommended to "override" the Validate() function.
|
||||
//
|
||||
// When embedded in the exporter config, it must be with `mapstructure:",squash"` tag.
|
||||
type ExporterConfigSettings struct {
|
||||
id ID `mapstructure:"-"`
|
||||
}
|
||||
|
||||
// NewExporterConfigSettings return a new ExporterSettings with the given ComponentID.
|
||||
func NewExporterConfigSettings(id ID) ExporterConfigSettings {
|
||||
return ExporterConfigSettings{id: ID{typeVal: id.Type(), nameVal: id.Name()}}
|
||||
}
|
||||
|
||||
var _ ExporterConfig = (*ExporterConfigSettings)(nil)
|
||||
|
||||
// ID returns the receiver ComponentID.
|
||||
func (es *ExporterConfigSettings) ID() ID {
|
||||
return es.id
|
||||
}
|
||||
|
||||
// SetIDName sets the receiver name.
|
||||
func (es *ExporterConfigSettings) SetIDName(idName string) {
|
||||
es.id.nameVal = idName
|
||||
}
|
||||
|
||||
// Validate validates the configuration and returns an error if invalid.
|
||||
func (es *ExporterConfigSettings) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (es *ExporterConfigSettings) privateConfigExporter() {}
|
||||
|
|
@ -12,64 +12,69 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package component
|
||||
// TODO: Move tests back to component package after config.*Settings are removed.
|
||||
|
||||
package component_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
)
|
||||
|
||||
func TestNewExporterFactory(t *testing.T) {
|
||||
const typeStr = "test"
|
||||
defaultCfg := NewExporterConfigSettings(NewID(typeStr))
|
||||
factory := NewExporterFactory(
|
||||
defaultCfg := config.NewExporterSettings(component.NewID(typeStr))
|
||||
factory := component.NewExporterFactory(
|
||||
typeStr,
|
||||
func() ExporterConfig { return &defaultCfg })
|
||||
func() component.ExporterConfig { return &defaultCfg })
|
||||
assert.EqualValues(t, typeStr, factory.Type())
|
||||
assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig())
|
||||
_, err := factory.CreateTracesExporter(context.Background(), ExporterCreateSettings{}, &defaultCfg)
|
||||
_, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateSettings{}, &defaultCfg)
|
||||
assert.Error(t, err)
|
||||
_, err = factory.CreateMetricsExporter(context.Background(), ExporterCreateSettings{}, &defaultCfg)
|
||||
_, err = factory.CreateMetricsExporter(context.Background(), component.ExporterCreateSettings{}, &defaultCfg)
|
||||
assert.Error(t, err)
|
||||
_, err = factory.CreateLogsExporter(context.Background(), ExporterCreateSettings{}, &defaultCfg)
|
||||
_, err = factory.CreateLogsExporter(context.Background(), component.ExporterCreateSettings{}, &defaultCfg)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestNewExporterFactory_WithOptions(t *testing.T) {
|
||||
const typeStr = "test"
|
||||
defaultCfg := NewExporterConfigSettings(NewID(typeStr))
|
||||
factory := NewExporterFactory(
|
||||
defaultCfg := config.NewExporterSettings(component.NewID(typeStr))
|
||||
factory := component.NewExporterFactory(
|
||||
typeStr,
|
||||
func() ExporterConfig { return &defaultCfg },
|
||||
WithTracesExporter(createTracesExporter, StabilityLevelInDevelopment),
|
||||
WithMetricsExporter(createMetricsExporter, StabilityLevelAlpha),
|
||||
WithLogsExporter(createLogsExporter, StabilityLevelDeprecated))
|
||||
func() component.ExporterConfig { return &defaultCfg },
|
||||
component.WithTracesExporter(createTracesExporter, component.StabilityLevelInDevelopment),
|
||||
component.WithMetricsExporter(createMetricsExporter, component.StabilityLevelAlpha),
|
||||
component.WithLogsExporter(createLogsExporter, component.StabilityLevelDeprecated))
|
||||
assert.EqualValues(t, typeStr, factory.Type())
|
||||
assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig())
|
||||
|
||||
assert.Equal(t, StabilityLevelInDevelopment, factory.TracesExporterStability())
|
||||
_, err := factory.CreateTracesExporter(context.Background(), ExporterCreateSettings{}, &defaultCfg)
|
||||
assert.Equal(t, component.StabilityLevelInDevelopment, factory.TracesExporterStability())
|
||||
_, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateSettings{}, &defaultCfg)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, StabilityLevelAlpha, factory.MetricsExporterStability())
|
||||
_, err = factory.CreateMetricsExporter(context.Background(), ExporterCreateSettings{}, &defaultCfg)
|
||||
assert.Equal(t, component.StabilityLevelAlpha, factory.MetricsExporterStability())
|
||||
_, err = factory.CreateMetricsExporter(context.Background(), component.ExporterCreateSettings{}, &defaultCfg)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, StabilityLevelDeprecated, factory.LogsExporterStability())
|
||||
_, err = factory.CreateLogsExporter(context.Background(), ExporterCreateSettings{}, &defaultCfg)
|
||||
assert.Equal(t, component.StabilityLevelDeprecated, factory.LogsExporterStability())
|
||||
_, err = factory.CreateLogsExporter(context.Background(), component.ExporterCreateSettings{}, &defaultCfg)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func createTracesExporter(context.Context, ExporterCreateSettings, ExporterConfig) (TracesExporter, error) {
|
||||
func createTracesExporter(context.Context, component.ExporterCreateSettings, component.ExporterConfig) (component.TracesExporter, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func createMetricsExporter(context.Context, ExporterCreateSettings, ExporterConfig) (MetricsExporter, error) {
|
||||
func createMetricsExporter(context.Context, component.ExporterCreateSettings, component.ExporterConfig) (component.MetricsExporter, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func createLogsExporter(context.Context, ExporterCreateSettings, ExporterConfig) (LogsExporter, error) {
|
||||
func createLogsExporter(context.Context, component.ExporterCreateSettings, component.ExporterConfig) (component.LogsExporter, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,26 @@ package component // import "go.opentelemetry.io/collector/component"
|
|||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/collector/confmap"
|
||||
)
|
||||
|
||||
// ExtensionConfig is the configuration of a component.Extension. Specific extensions must implement
|
||||
// this interface and must embed config.ExtensionSettings struct or a struct that extends it.
|
||||
type ExtensionConfig interface {
|
||||
identifiable
|
||||
validatable
|
||||
|
||||
privateConfigExtension()
|
||||
}
|
||||
|
||||
// UnmarshalExtensionConfig helper function to unmarshal an ExtensionConfig.
|
||||
// It checks if the config implements confmap.Unmarshaler and uses that if available,
|
||||
// otherwise uses Map.UnmarshalExact, erroring if a field is nonexistent.
|
||||
func UnmarshalExtensionConfig(conf *confmap.Conf, cfg ExtensionConfig) error {
|
||||
return unmarshal(conf, cfg)
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
|
|
|||
|
|
@ -1,69 +0,0 @@
|
|||
// 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 component // import "go.opentelemetry.io/collector/component"
|
||||
|
||||
import (
|
||||
"go.opentelemetry.io/collector/confmap"
|
||||
)
|
||||
|
||||
// ExtensionConfig is the configuration of a component.Extension. Specific extensions must implement
|
||||
// this interface and must embed ExtensionConfigSettings struct or a struct that extends it.
|
||||
type ExtensionConfig interface {
|
||||
identifiable
|
||||
validatable
|
||||
|
||||
privateConfigExtension()
|
||||
}
|
||||
|
||||
// UnmarshalExtensionConfig helper function to unmarshal an ExtensionConfig.
|
||||
// It checks if the config implements confmap.Unmarshaler and uses that if available,
|
||||
// otherwise uses Map.UnmarshalExact, erroring if a field is nonexistent.
|
||||
func UnmarshalExtensionConfig(conf *confmap.Conf, cfg ExtensionConfig) error {
|
||||
return unmarshal(conf, cfg)
|
||||
}
|
||||
|
||||
// ExtensionConfigSettings defines common settings for a component.Extension configuration.
|
||||
// Specific processors can embed this struct and extend it with more fields if needed.
|
||||
//
|
||||
// It is highly recommended to "override" the Validate() function.
|
||||
//
|
||||
// When embedded in the extension config, it must be with `mapstructure:",squash"` tag.
|
||||
type ExtensionConfigSettings struct {
|
||||
id ID `mapstructure:"-"`
|
||||
}
|
||||
|
||||
// NewExtensionConfigSettings return a new ExtensionConfigSettings with the given ID.
|
||||
func NewExtensionConfigSettings(id ID) ExtensionConfigSettings {
|
||||
return ExtensionConfigSettings{id: ID{typeVal: id.Type(), nameVal: id.Name()}}
|
||||
}
|
||||
|
||||
var _ ExtensionConfig = (*ExtensionConfigSettings)(nil)
|
||||
|
||||
// ID returns the receiver ID.
|
||||
func (es *ExtensionConfigSettings) ID() ID {
|
||||
return es.id
|
||||
}
|
||||
|
||||
// SetIDName sets the receiver name.
|
||||
func (es *ExtensionConfigSettings) SetIDName(idName string) {
|
||||
es.id.nameVal = idName
|
||||
}
|
||||
|
||||
// Validate validates the configuration and returns an error if invalid.
|
||||
func (es *ExtensionConfigSettings) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (es *ExtensionConfigSettings) privateConfigExtension() {}
|
||||
|
|
@ -12,37 +12,42 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package component
|
||||
// TODO: Move tests back to component package after config.*Settings are removed.
|
||||
|
||||
package component_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
)
|
||||
|
||||
type nopExtension struct {
|
||||
StartFunc
|
||||
ShutdownFunc
|
||||
component.StartFunc
|
||||
component.ShutdownFunc
|
||||
}
|
||||
|
||||
func TestNewExtensionFactory(t *testing.T) {
|
||||
const typeStr = "test"
|
||||
defaultCfg := NewExtensionConfigSettings(NewID(typeStr))
|
||||
defaultCfg := config.NewExtensionSettings(component.NewID(typeStr))
|
||||
nopExtensionInstance := new(nopExtension)
|
||||
|
||||
factory := NewExtensionFactory(
|
||||
factory := component.NewExtensionFactory(
|
||||
typeStr,
|
||||
func() ExtensionConfig { return &defaultCfg },
|
||||
func(ctx context.Context, settings ExtensionCreateSettings, extension ExtensionConfig) (Extension, error) {
|
||||
func() component.ExtensionConfig { return &defaultCfg },
|
||||
func(ctx context.Context, settings component.ExtensionCreateSettings, extension component.ExtensionConfig) (component.Extension, error) {
|
||||
return nopExtensionInstance, nil
|
||||
},
|
||||
StabilityLevelInDevelopment)
|
||||
component.StabilityLevelInDevelopment)
|
||||
assert.EqualValues(t, typeStr, factory.Type())
|
||||
assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig())
|
||||
|
||||
assert.Equal(t, StabilityLevelInDevelopment, factory.ExtensionStability())
|
||||
ext, err := factory.CreateExtension(context.Background(), ExtensionCreateSettings{}, &defaultCfg)
|
||||
assert.Equal(t, component.StabilityLevelInDevelopment, factory.ExtensionStability())
|
||||
ext, err := factory.CreateExtension(context.Background(), component.ExtensionCreateSettings{}, &defaultCfg)
|
||||
assert.NoError(t, err)
|
||||
assert.Same(t, nopExtensionInstance, ext)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,26 @@ package component // import "go.opentelemetry.io/collector/component"
|
|||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/collector/confmap"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
)
|
||||
|
||||
// ProcessorConfig is the configuration of a component.Processor. Specific extensions must implement
|
||||
// this interface and must embed ProcessorSettings struct or a struct that extends it.
|
||||
type ProcessorConfig interface {
|
||||
identifiable
|
||||
validatable
|
||||
|
||||
privateConfigProcessor()
|
||||
}
|
||||
|
||||
// UnmarshalProcessorConfig helper function to unmarshal a ProcessorConfig.
|
||||
// It checks if the config implements confmap.Unmarshaler and uses that if available,
|
||||
// otherwise uses Map.UnmarshalExact, erroring if a field is nonexistent.
|
||||
func UnmarshalProcessorConfig(conf *confmap.Conf, cfg ProcessorConfig) error {
|
||||
return unmarshal(conf, cfg)
|
||||
}
|
||||
|
||||
// Processor defines the common functions that must be implemented by TracesProcessor
|
||||
// and MetricsProcessor.
|
||||
type Processor interface {
|
||||
|
|
|
|||
|
|
@ -1,69 +0,0 @@
|
|||
// 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 component // import "go.opentelemetry.io/collector/component"
|
||||
|
||||
import (
|
||||
"go.opentelemetry.io/collector/confmap"
|
||||
)
|
||||
|
||||
// ProcessorConfig is the configuration of a component.Processor. Specific extensions must implement
|
||||
// this interface and must embed ProcessorConfigSettings struct or a struct that extends it.
|
||||
type ProcessorConfig interface {
|
||||
identifiable
|
||||
validatable
|
||||
|
||||
privateConfigProcessor()
|
||||
}
|
||||
|
||||
// UnmarshalProcessorConfig helper function to unmarshal a ProcessorConfig.
|
||||
// It checks if the config implements confmap.Unmarshaler and uses that if available,
|
||||
// otherwise uses Map.UnmarshalExact, erroring if a field is nonexistent.
|
||||
func UnmarshalProcessorConfig(conf *confmap.Conf, cfg ProcessorConfig) error {
|
||||
return unmarshal(conf, cfg)
|
||||
}
|
||||
|
||||
// ProcessorConfigSettings defines common settings for a component.Processor configuration.
|
||||
// Specific processors can embed this struct and extend it with more fields if needed.
|
||||
//
|
||||
// It is highly recommended to "override" the Validate() function.
|
||||
//
|
||||
// When embedded in the processor config it must be with `mapstructure:",squash"` tag.
|
||||
type ProcessorConfigSettings struct {
|
||||
id ID `mapstructure:"-"`
|
||||
}
|
||||
|
||||
// NewProcessorConfigSettings return a new ProcessorConfigSettings with the given ComponentID.
|
||||
func NewProcessorConfigSettings(id ID) ProcessorConfigSettings {
|
||||
return ProcessorConfigSettings{id: ID{typeVal: id.Type(), nameVal: id.Name()}}
|
||||
}
|
||||
|
||||
var _ ProcessorConfig = (*ProcessorConfigSettings)(nil)
|
||||
|
||||
// ID returns the receiver ComponentID.
|
||||
func (ps *ProcessorConfigSettings) ID() ID {
|
||||
return ps.id
|
||||
}
|
||||
|
||||
// SetIDName sets the receiver name.
|
||||
func (ps *ProcessorConfigSettings) SetIDName(idName string) {
|
||||
ps.id.nameVal = idName
|
||||
}
|
||||
|
||||
// Validate validates the configuration and returns an error if invalid.
|
||||
func (ps *ProcessorConfigSettings) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ps *ProcessorConfigSettings) privateConfigProcessor() {}
|
||||
|
|
@ -12,7 +12,9 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package component
|
||||
// TODO: Move tests back to component package after config.*Settings are removed.
|
||||
|
||||
package component_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -20,58 +22,60 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
)
|
||||
|
||||
func TestNewProcessorFactory(t *testing.T) {
|
||||
const typeStr = "test"
|
||||
defaultCfg := NewProcessorConfigSettings(NewID(typeStr))
|
||||
factory := NewProcessorFactory(
|
||||
defaultCfg := config.NewProcessorSettings(component.NewID(typeStr))
|
||||
factory := component.NewProcessorFactory(
|
||||
typeStr,
|
||||
func() ProcessorConfig { return &defaultCfg })
|
||||
func() component.ProcessorConfig { return &defaultCfg })
|
||||
assert.EqualValues(t, typeStr, factory.Type())
|
||||
assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig())
|
||||
_, err := factory.CreateTracesProcessor(context.Background(), ProcessorCreateSettings{}, &defaultCfg, nil)
|
||||
_, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateSettings{}, &defaultCfg, nil)
|
||||
assert.Error(t, err)
|
||||
_, err = factory.CreateMetricsProcessor(context.Background(), ProcessorCreateSettings{}, &defaultCfg, nil)
|
||||
_, err = factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateSettings{}, &defaultCfg, nil)
|
||||
assert.Error(t, err)
|
||||
_, err = factory.CreateLogsProcessor(context.Background(), ProcessorCreateSettings{}, &defaultCfg, nil)
|
||||
_, err = factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateSettings{}, &defaultCfg, nil)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestNewProcessorFactory_WithOptions(t *testing.T) {
|
||||
const typeStr = "test"
|
||||
defaultCfg := NewProcessorConfigSettings(NewID(typeStr))
|
||||
factory := NewProcessorFactory(
|
||||
defaultCfg := config.NewProcessorSettings(component.NewID(typeStr))
|
||||
factory := component.NewProcessorFactory(
|
||||
typeStr,
|
||||
func() ProcessorConfig { return &defaultCfg },
|
||||
WithTracesProcessor(createTracesProcessor, StabilityLevelAlpha),
|
||||
WithMetricsProcessor(createMetricsProcessor, StabilityLevelBeta),
|
||||
WithLogsProcessor(createLogsProcessor, StabilityLevelUnmaintained))
|
||||
func() component.ProcessorConfig { return &defaultCfg },
|
||||
component.WithTracesProcessor(createTracesProcessor, component.StabilityLevelAlpha),
|
||||
component.WithMetricsProcessor(createMetricsProcessor, component.StabilityLevelBeta),
|
||||
component.WithLogsProcessor(createLogsProcessor, component.StabilityLevelUnmaintained))
|
||||
assert.EqualValues(t, typeStr, factory.Type())
|
||||
assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig())
|
||||
|
||||
assert.Equal(t, StabilityLevelAlpha, factory.TracesProcessorStability())
|
||||
_, err := factory.CreateTracesProcessor(context.Background(), ProcessorCreateSettings{}, &defaultCfg, nil)
|
||||
assert.Equal(t, component.StabilityLevelAlpha, factory.TracesProcessorStability())
|
||||
_, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateSettings{}, &defaultCfg, nil)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, StabilityLevelBeta, factory.MetricsProcessorStability())
|
||||
_, err = factory.CreateMetricsProcessor(context.Background(), ProcessorCreateSettings{}, &defaultCfg, nil)
|
||||
assert.Equal(t, component.StabilityLevelBeta, factory.MetricsProcessorStability())
|
||||
_, err = factory.CreateMetricsProcessor(context.Background(), component.ProcessorCreateSettings{}, &defaultCfg, nil)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, StabilityLevelUnmaintained, factory.LogsProcessorStability())
|
||||
_, err = factory.CreateLogsProcessor(context.Background(), ProcessorCreateSettings{}, &defaultCfg, nil)
|
||||
assert.Equal(t, component.StabilityLevelUnmaintained, factory.LogsProcessorStability())
|
||||
_, err = factory.CreateLogsProcessor(context.Background(), component.ProcessorCreateSettings{}, &defaultCfg, nil)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func createTracesProcessor(context.Context, ProcessorCreateSettings, ProcessorConfig, consumer.Traces) (TracesProcessor, error) {
|
||||
func createTracesProcessor(context.Context, component.ProcessorCreateSettings, component.ProcessorConfig, consumer.Traces) (component.TracesProcessor, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func createMetricsProcessor(context.Context, ProcessorCreateSettings, ProcessorConfig, consumer.Metrics) (MetricsProcessor, error) {
|
||||
func createMetricsProcessor(context.Context, component.ProcessorCreateSettings, component.ProcessorConfig, consumer.Metrics) (component.MetricsProcessor, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func createLogsProcessor(context.Context, ProcessorCreateSettings, ProcessorConfig, consumer.Logs) (LogsProcessor, error) {
|
||||
func createLogsProcessor(context.Context, component.ProcessorCreateSettings, component.ProcessorConfig, consumer.Logs) (component.LogsProcessor, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,26 @@ package component // import "go.opentelemetry.io/collector/component"
|
|||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/collector/confmap"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
)
|
||||
|
||||
// ReceiverConfig is the configuration of a component.Receiver. Specific extensions must implement
|
||||
// this interface and must embed ReceiverSettings struct or a struct that extends it.
|
||||
type ReceiverConfig interface {
|
||||
identifiable
|
||||
validatable
|
||||
|
||||
privateConfigReceiver()
|
||||
}
|
||||
|
||||
// UnmarshalReceiverConfig helper function to unmarshal a ReceiverConfig.
|
||||
// It checks if the config implements confmap.Unmarshaler and uses that if available,
|
||||
// otherwise uses Map.UnmarshalExact, erroring if a field is nonexistent.
|
||||
func UnmarshalReceiverConfig(conf *confmap.Conf, cfg ReceiverConfig) error {
|
||||
return unmarshal(conf, cfg)
|
||||
}
|
||||
|
||||
// Receiver allows the collector to receive metrics, traces and logs.
|
||||
//
|
||||
// Receiver receives data from a source (either from a remote source via network
|
||||
|
|
|
|||
|
|
@ -1,69 +0,0 @@
|
|||
// 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 component // import "go.opentelemetry.io/collector/component"
|
||||
|
||||
import (
|
||||
"go.opentelemetry.io/collector/confmap"
|
||||
)
|
||||
|
||||
// ReceiverConfig is the configuration of a component.Receiver. Specific extensions must implement
|
||||
// this interface and must embed ReceiverConfigSettings struct or a struct that extends it.
|
||||
type ReceiverConfig interface {
|
||||
identifiable
|
||||
validatable
|
||||
|
||||
privateConfigReceiver()
|
||||
}
|
||||
|
||||
// UnmarshalReceiverConfig helper function to unmarshal a ReceiverConfig.
|
||||
// It checks if the config implements confmap.Unmarshaler and uses that if available,
|
||||
// otherwise uses Map.UnmarshalExact, erroring if a field is nonexistent.
|
||||
func UnmarshalReceiverConfig(conf *confmap.Conf, cfg ReceiverConfig) error {
|
||||
return unmarshal(conf, cfg)
|
||||
}
|
||||
|
||||
// ReceiverConfigSettings defines common settings for a component.Receiver configuration.
|
||||
// Specific receivers can embed this struct and extend it with more fields if needed.
|
||||
//
|
||||
// It is highly recommended to "override" the Validate() function.
|
||||
//
|
||||
// When embedded in the receiver config it must be with `mapstructure:",squash"` tag.
|
||||
type ReceiverConfigSettings struct {
|
||||
id ID `mapstructure:"-"`
|
||||
}
|
||||
|
||||
// NewReceiverConfigSettings return a new ReceiverConfigSettings with the given ID.
|
||||
func NewReceiverConfigSettings(id ID) ReceiverConfigSettings {
|
||||
return ReceiverConfigSettings{id: ID{typeVal: id.Type(), nameVal: id.Name()}}
|
||||
}
|
||||
|
||||
var _ ReceiverConfig = (*ReceiverConfigSettings)(nil)
|
||||
|
||||
// ID returns the receiver ID.
|
||||
func (rs *ReceiverConfigSettings) ID() ID {
|
||||
return rs.id
|
||||
}
|
||||
|
||||
// SetIDName sets the receiver name.
|
||||
func (rs *ReceiverConfigSettings) SetIDName(idName string) {
|
||||
rs.id.nameVal = idName
|
||||
}
|
||||
|
||||
// Validate validates the configuration and returns an error if invalid.
|
||||
func (rs *ReceiverConfigSettings) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rs *ReceiverConfigSettings) privateConfigReceiver() {}
|
||||
|
|
@ -12,7 +12,9 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package component
|
||||
// TODO: Move tests back to component package after config.*Settings are removed.
|
||||
|
||||
package component_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -20,58 +22,60 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
)
|
||||
|
||||
func TestNewReceiverFactory(t *testing.T) {
|
||||
const typeStr = "test"
|
||||
defaultCfg := NewReceiverConfigSettings(NewID(typeStr))
|
||||
factory := NewReceiverFactory(
|
||||
defaultCfg := config.NewReceiverSettings(component.NewID(typeStr))
|
||||
factory := component.NewReceiverFactory(
|
||||
typeStr,
|
||||
func() ReceiverConfig { return &defaultCfg })
|
||||
func() component.ReceiverConfig { return &defaultCfg })
|
||||
assert.EqualValues(t, typeStr, factory.Type())
|
||||
assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig())
|
||||
_, err := factory.CreateTracesReceiver(context.Background(), ReceiverCreateSettings{}, &defaultCfg, nil)
|
||||
_, err := factory.CreateTracesReceiver(context.Background(), component.ReceiverCreateSettings{}, &defaultCfg, nil)
|
||||
assert.Error(t, err)
|
||||
_, err = factory.CreateMetricsReceiver(context.Background(), ReceiverCreateSettings{}, &defaultCfg, nil)
|
||||
_, err = factory.CreateMetricsReceiver(context.Background(), component.ReceiverCreateSettings{}, &defaultCfg, nil)
|
||||
assert.Error(t, err)
|
||||
_, err = factory.CreateLogsReceiver(context.Background(), ReceiverCreateSettings{}, &defaultCfg, nil)
|
||||
_, err = factory.CreateLogsReceiver(context.Background(), component.ReceiverCreateSettings{}, &defaultCfg, nil)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestNewReceiverFactory_WithOptions(t *testing.T) {
|
||||
const typeStr = "test"
|
||||
defaultCfg := NewReceiverConfigSettings(NewID(typeStr))
|
||||
factory := NewReceiverFactory(
|
||||
defaultCfg := config.NewReceiverSettings(component.NewID(typeStr))
|
||||
factory := component.NewReceiverFactory(
|
||||
typeStr,
|
||||
func() ReceiverConfig { return &defaultCfg },
|
||||
WithTracesReceiver(createTracesReceiver, StabilityLevelDeprecated),
|
||||
WithMetricsReceiver(createMetricsReceiver, StabilityLevelAlpha),
|
||||
WithLogsReceiver(createLogsReceiver, StabilityLevelStable))
|
||||
func() component.ReceiverConfig { return &defaultCfg },
|
||||
component.WithTracesReceiver(createTracesReceiver, component.StabilityLevelDeprecated),
|
||||
component.WithMetricsReceiver(createMetricsReceiver, component.StabilityLevelAlpha),
|
||||
component.WithLogsReceiver(createLogsReceiver, component.StabilityLevelStable))
|
||||
assert.EqualValues(t, typeStr, factory.Type())
|
||||
assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig())
|
||||
|
||||
assert.Equal(t, StabilityLevelDeprecated, factory.TracesReceiverStability())
|
||||
_, err := factory.CreateTracesReceiver(context.Background(), ReceiverCreateSettings{}, &defaultCfg, nil)
|
||||
assert.Equal(t, component.StabilityLevelDeprecated, factory.TracesReceiverStability())
|
||||
_, err := factory.CreateTracesReceiver(context.Background(), component.ReceiverCreateSettings{}, &defaultCfg, nil)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, StabilityLevelAlpha, factory.MetricsReceiverStability())
|
||||
_, err = factory.CreateMetricsReceiver(context.Background(), ReceiverCreateSettings{}, &defaultCfg, nil)
|
||||
assert.Equal(t, component.StabilityLevelAlpha, factory.MetricsReceiverStability())
|
||||
_, err = factory.CreateMetricsReceiver(context.Background(), component.ReceiverCreateSettings{}, &defaultCfg, nil)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, StabilityLevelStable, factory.LogsReceiverStability())
|
||||
_, err = factory.CreateLogsReceiver(context.Background(), ReceiverCreateSettings{}, &defaultCfg, nil)
|
||||
assert.Equal(t, component.StabilityLevelStable, factory.LogsReceiverStability())
|
||||
_, err = factory.CreateLogsReceiver(context.Background(), component.ReceiverCreateSettings{}, &defaultCfg, nil)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func createTracesReceiver(context.Context, ReceiverCreateSettings, ReceiverConfig, consumer.Traces) (TracesReceiver, error) {
|
||||
func createTracesReceiver(context.Context, component.ReceiverCreateSettings, component.ReceiverConfig, consumer.Traces) (component.TracesReceiver, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func createMetricsReceiver(context.Context, ReceiverCreateSettings, ReceiverConfig, consumer.Metrics) (MetricsReceiver, error) {
|
||||
func createMetricsReceiver(context.Context, component.ReceiverCreateSettings, component.ReceiverConfig, consumer.Metrics) (component.MetricsReceiver, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func createLogsReceiver(context.Context, ReceiverCreateSettings, ReceiverConfig, consumer.Logs) (LogsReceiver, error) {
|
||||
func createLogsReceiver(context.Context, component.ReceiverCreateSettings, component.ReceiverConfig, consumer.Logs) (component.LogsReceiver, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
// 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 config // import "go.opentelemetry.io/collector/config"
|
||||
import (
|
||||
"go.opentelemetry.io/collector/component"
|
||||
)
|
||||
|
||||
// ExporterSettings defines common settings for a component.Exporter configuration.
|
||||
// Specific exporters can embed this struct and extend it with more fields if needed.
|
||||
//
|
||||
// It is highly recommended to "override" the Validate() function.
|
||||
//
|
||||
// When embedded in the exporter config, it must be with `mapstructure:",squash"` tag.
|
||||
type ExporterSettings struct {
|
||||
id component.ID `mapstructure:"-"`
|
||||
component.ExporterConfig
|
||||
}
|
||||
|
||||
// NewExporterSettings return a new ExporterSettings with the given ComponentID.
|
||||
func NewExporterSettings(id component.ID) ExporterSettings {
|
||||
return ExporterSettings{id: id}
|
||||
}
|
||||
|
||||
var _ component.ExporterConfig = (*ExporterSettings)(nil)
|
||||
|
||||
// ID returns the receiver component.ID.
|
||||
func (es *ExporterSettings) ID() component.ID {
|
||||
return es.id
|
||||
}
|
||||
|
||||
// SetIDName sets the receiver name.
|
||||
func (es *ExporterSettings) SetIDName(idName string) {
|
||||
es.id = component.NewIDWithName(es.id.Type(), idName)
|
||||
}
|
||||
|
||||
// Validate validates the configuration and returns an error if invalid.
|
||||
func (es *ExporterSettings) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
// 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 config // import "go.opentelemetry.io/collector/config"
|
||||
import (
|
||||
"go.opentelemetry.io/collector/component"
|
||||
)
|
||||
|
||||
// ExtensionSettings defines common settings for a component.Extension configuration.
|
||||
// Specific processors can embed this struct and extend it with more fields if needed.
|
||||
//
|
||||
// It is highly recommended to "override" the Validate() function.
|
||||
//
|
||||
// When embedded in the extension config, it must be with `mapstructure:",squash"` tag.
|
||||
type ExtensionSettings struct {
|
||||
id component.ID `mapstructure:"-"`
|
||||
component.ExtensionConfig
|
||||
}
|
||||
|
||||
// NewExtensionSettings return a new ExtensionSettings with the given ID.
|
||||
func NewExtensionSettings(id component.ID) ExtensionSettings {
|
||||
return ExtensionSettings{id: id}
|
||||
}
|
||||
|
||||
var _ component.ExtensionConfig = (*ExtensionSettings)(nil)
|
||||
|
||||
// ID returns the receiver ID.
|
||||
func (es *ExtensionSettings) ID() component.ID {
|
||||
return es.id
|
||||
}
|
||||
|
||||
// SetIDName sets the receiver name.
|
||||
func (es *ExtensionSettings) SetIDName(idName string) {
|
||||
es.id = component.NewIDWithName(es.id.Type(), idName)
|
||||
}
|
||||
|
||||
// Validate validates the configuration and returns an error if invalid.
|
||||
func (es *ExtensionSettings) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -35,48 +35,24 @@ type Receiver = component.ReceiverConfig
|
|||
// Deprecated: [v0.64.0] use component.UnmarshalReceiverConfig.
|
||||
var UnmarshalReceiver = component.UnmarshalReceiverConfig
|
||||
|
||||
// Deprecated: [v0.64.0] use component.ReceiverConfigSettings.
|
||||
type ReceiverSettings = component.ReceiverConfigSettings
|
||||
|
||||
// Deprecated: [v0.64.0] use component.NewReceiverConfigSettings.
|
||||
var NewReceiverSettings = component.NewReceiverConfigSettings
|
||||
|
||||
// Deprecated: [v0.64.0] use component.ProcessorConfig.
|
||||
type Processor = component.ProcessorConfig
|
||||
|
||||
// Deprecated: [v0.64.0] use component.UnmarshalProcessorConfig.
|
||||
var UnmarshalProcessor = component.UnmarshalProcessorConfig
|
||||
|
||||
// Deprecated: [v0.64.0] use component.ProcessorConfigSettings.
|
||||
type ProcessorSettings = component.ProcessorConfigSettings
|
||||
|
||||
// Deprecated: [v0.64.0] use component.NewProcessorConfigSettings.
|
||||
var NewProcessorSettings = component.NewProcessorConfigSettings
|
||||
|
||||
// Deprecated: [v0.64.0] use component.ExporterConfig.
|
||||
type Exporter = component.ExporterConfig
|
||||
|
||||
// Deprecated: [v0.64.0] use component.UnmarshalExporterConfig.
|
||||
var UnmarshalExporter = component.UnmarshalExporterConfig
|
||||
|
||||
// Deprecated: [v0.64.0] use component.ExporterConfigSettings.
|
||||
type ExporterSettings = component.ExporterConfigSettings
|
||||
|
||||
// Deprecated: [v0.64.0] use component.NewExporterConfigSettings.
|
||||
var NewExporterSettings = component.NewExporterConfigSettings
|
||||
|
||||
// Deprecated: [v0.64.0] use component.ExtensionConfig.
|
||||
type Extension = component.ExtensionConfig
|
||||
|
||||
// Deprecated: [v0.64.0] use component.UnmarshalExtensionConfig.
|
||||
var UnmarshalExtension = component.UnmarshalExtensionConfig
|
||||
|
||||
// Deprecated: [v0.64.0] use component.ExtensionConfigSettings.
|
||||
type ExtensionSettings = component.ExtensionConfigSettings
|
||||
|
||||
// Deprecated: [v0.64.0] use component.NewExtensionConfigSettings.
|
||||
var NewExtensionSettings = component.NewExtensionConfigSettings
|
||||
|
||||
// Deprecated: [v0.64.0] use component.Type.
|
||||
type Type = component.Type
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
// 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 config // import "go.opentelemetry.io/collector/config"
|
||||
import (
|
||||
"go.opentelemetry.io/collector/component"
|
||||
)
|
||||
|
||||
// ProcessorSettings defines common settings for a component.Processor configuration.
|
||||
// Specific processors can embed this struct and extend it with more fields if needed.
|
||||
//
|
||||
// It is highly recommended to "override" the Validate() function.
|
||||
//
|
||||
// When embedded in the processor config it must be with `mapstructure:",squash"` tag.
|
||||
type ProcessorSettings struct {
|
||||
id component.ID `mapstructure:"-"`
|
||||
component.ProcessorConfig
|
||||
}
|
||||
|
||||
// NewProcessorSettings return a new ProcessorSettings with the given ComponentID.
|
||||
func NewProcessorSettings(id component.ID) ProcessorSettings {
|
||||
return ProcessorSettings{id: id}
|
||||
}
|
||||
|
||||
var _ component.ProcessorConfig = (*ProcessorSettings)(nil)
|
||||
|
||||
// ID returns the receiver ComponentID.
|
||||
func (ps *ProcessorSettings) ID() component.ID {
|
||||
return ps.id
|
||||
}
|
||||
|
||||
// SetIDName sets the receiver name.
|
||||
func (ps *ProcessorSettings) SetIDName(idName string) {
|
||||
ps.id = component.NewIDWithName(ps.id.Type(), idName)
|
||||
}
|
||||
|
||||
// Validate validates the configuration and returns an error if invalid.
|
||||
func (ps *ProcessorSettings) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
// 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 config // import "go.opentelemetry.io/collector/config"
|
||||
import (
|
||||
"go.opentelemetry.io/collector/component"
|
||||
)
|
||||
|
||||
// ReceiverSettings defines common settings for a component.Receiver configuration.
|
||||
// Specific receivers can embed this struct and extend it with more fields if needed.
|
||||
//
|
||||
// It is highly recommended to "override" the Validate() function.
|
||||
//
|
||||
// When embedded in the receiver config it must be with `mapstructure:",squash"` tag.
|
||||
type ReceiverSettings struct {
|
||||
id component.ID `mapstructure:"-"`
|
||||
component.ReceiverConfig
|
||||
}
|
||||
|
||||
// NewReceiverSettings return a new ReceiverSettings with the given ID.
|
||||
func NewReceiverSettings(id component.ID) ReceiverSettings {
|
||||
return ReceiverSettings{id: id}
|
||||
}
|
||||
|
||||
var _ component.ReceiverConfig = (*ReceiverSettings)(nil)
|
||||
|
||||
// ID returns the receiver ID.
|
||||
func (rs *ReceiverSettings) ID() component.ID {
|
||||
return rs.id
|
||||
}
|
||||
|
||||
// SetIDName sets the receiver name.
|
||||
func (rs *ReceiverSettings) SetIDName(idName string) {
|
||||
rs.id = component.NewIDWithName(rs.id.Type(), idName)
|
||||
}
|
||||
|
||||
// Validate validates the configuration and returns an error if invalid.
|
||||
func (rs *ReceiverSettings) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -25,13 +25,14 @@ import (
|
|||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
"go.opentelemetry.io/collector/exporter/exporterhelper/internal"
|
||||
"go.opentelemetry.io/collector/pdata/ptrace"
|
||||
)
|
||||
|
||||
var (
|
||||
defaultExporterCfg = component.NewExporterConfigSettings(component.NewID("test"))
|
||||
defaultExporterCfg = config.NewExporterSettings(component.NewID("test"))
|
||||
exporterTag, _ = tag.NewKey("exporter")
|
||||
defaultExporterTags = []tag.Tag{
|
||||
{Key: exporterTag, Value: "test"},
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import (
|
|||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
"go.opentelemetry.io/collector/consumer/consumererror"
|
||||
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
|
||||
|
|
@ -43,7 +44,7 @@ const (
|
|||
var fakeLogsExporterName = component.NewIDWithName("fake_logs_exporter", "with_name")
|
||||
|
||||
var (
|
||||
fakeLogsExporterConfig = component.NewExporterConfigSettings(fakeLogsExporterName)
|
||||
fakeLogsExporterConfig = config.NewExporterSettings(fakeLogsExporterName)
|
||||
)
|
||||
|
||||
func TestLogsRequest(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import (
|
|||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
"go.opentelemetry.io/collector/consumer/consumererror"
|
||||
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
|
||||
|
|
@ -42,7 +43,7 @@ const (
|
|||
|
||||
var (
|
||||
fakeMetricsExporterName = component.NewIDWithName("fake_metrics_exporter", "with_name")
|
||||
fakeMetricsExporterConfig = component.NewExporterConfigSettings(fakeMetricsExporterName)
|
||||
fakeMetricsExporterConfig = config.NewExporterSettings(fakeMetricsExporterName)
|
||||
)
|
||||
|
||||
func TestMetricsRequest(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import (
|
|||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
"go.opentelemetry.io/collector/consumer/consumererror"
|
||||
"go.opentelemetry.io/collector/internal/obsreportconfig/obsmetrics"
|
||||
|
|
@ -42,7 +43,7 @@ const (
|
|||
|
||||
var (
|
||||
fakeTracesExporterName = component.NewIDWithName("fake_traces_exporter", "with_name")
|
||||
fakeTracesExporterConfig = component.NewExporterConfigSettings(fakeTracesExporterName)
|
||||
fakeTracesExporterConfig = config.NewExporterSettings(fakeTracesExporterName)
|
||||
)
|
||||
|
||||
func TestTracesRequest(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import (
|
|||
"go.uber.org/zap/zapcore"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/configtelemetry"
|
||||
"go.opentelemetry.io/collector/confmap"
|
||||
)
|
||||
|
|
@ -36,7 +37,7 @@ var (
|
|||
|
||||
// Config defines configuration for logging exporter.
|
||||
type Config struct {
|
||||
component.ExporterConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ExporterSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
|
||||
// LogLevel defines log level of the logging exporter; options are debug, info, warn, error.
|
||||
// Deprecated: Use `Verbosity` instead.
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import (
|
|||
"go.uber.org/zap/zapcore"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/configtelemetry"
|
||||
"go.opentelemetry.io/collector/confmap"
|
||||
"go.opentelemetry.io/collector/confmap/confmaptest"
|
||||
|
|
@ -44,33 +45,33 @@ func TestUnmarshalConfig(t *testing.T) {
|
|||
{
|
||||
filename: "config_loglevel.yaml",
|
||||
cfg: &Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
LogLevel: zapcore.DebugLevel,
|
||||
Verbosity: configtelemetry.LevelDetailed,
|
||||
SamplingInitial: 10,
|
||||
SamplingThereafter: 50,
|
||||
warnLogLevel: true,
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
LogLevel: zapcore.DebugLevel,
|
||||
Verbosity: configtelemetry.LevelDetailed,
|
||||
SamplingInitial: 10,
|
||||
SamplingThereafter: 50,
|
||||
warnLogLevel: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
filename: "config_verbosity.yaml",
|
||||
cfg: &Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
LogLevel: zapcore.InfoLevel,
|
||||
Verbosity: configtelemetry.LevelDetailed,
|
||||
SamplingInitial: 10,
|
||||
SamplingThereafter: 50,
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
LogLevel: zapcore.InfoLevel,
|
||||
Verbosity: configtelemetry.LevelDetailed,
|
||||
SamplingInitial: 10,
|
||||
SamplingThereafter: 50,
|
||||
},
|
||||
},
|
||||
{
|
||||
filename: "loglevel_info.yaml",
|
||||
cfg: &Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
LogLevel: zapcore.InfoLevel,
|
||||
Verbosity: configtelemetry.LevelNormal,
|
||||
SamplingInitial: 2,
|
||||
SamplingThereafter: 500,
|
||||
warnLogLevel: true,
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
LogLevel: zapcore.InfoLevel,
|
||||
Verbosity: configtelemetry.LevelNormal,
|
||||
SamplingInitial: 2,
|
||||
SamplingThereafter: 500,
|
||||
warnLogLevel: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import (
|
|||
"go.uber.org/zap/zapcore"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/configtelemetry"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
"go.opentelemetry.io/collector/exporter/exporterhelper"
|
||||
|
|
@ -50,11 +51,11 @@ func NewFactory() component.ExporterFactory {
|
|||
|
||||
func createDefaultConfig() component.ExporterConfig {
|
||||
return &Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
LogLevel: zapcore.InfoLevel,
|
||||
Verbosity: configtelemetry.LevelNormal,
|
||||
SamplingInitial: defaultSamplingInitial,
|
||||
SamplingThereafter: defaultSamplingThereafter,
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
LogLevel: zapcore.InfoLevel,
|
||||
Verbosity: configtelemetry.LevelNormal,
|
||||
SamplingInitial: defaultSamplingInitial,
|
||||
SamplingThereafter: defaultSamplingThereafter,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,16 +18,17 @@ import (
|
|||
"fmt"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/configgrpc"
|
||||
"go.opentelemetry.io/collector/exporter/exporterhelper"
|
||||
)
|
||||
|
||||
// Config defines configuration for OpenCensus exporter.
|
||||
type Config struct {
|
||||
component.ExporterConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
exporterhelper.TimeoutSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
|
||||
exporterhelper.QueueSettings `mapstructure:"sending_queue"`
|
||||
exporterhelper.RetrySettings `mapstructure:"retry_on_failure"`
|
||||
config.ExporterSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
exporterhelper.TimeoutSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
|
||||
exporterhelper.QueueSettings `mapstructure:"sending_queue"`
|
||||
exporterhelper.RetrySettings `mapstructure:"retry_on_failure"`
|
||||
|
||||
configgrpc.GRPCClientSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/configauth"
|
||||
"go.opentelemetry.io/collector/config/configgrpc"
|
||||
"go.opentelemetry.io/collector/config/configtls"
|
||||
|
|
@ -46,7 +47,7 @@ func TestUnmarshalConfig(t *testing.T) {
|
|||
assert.NoError(t, component.UnmarshalExporterConfig(cm, cfg))
|
||||
assert.Equal(t,
|
||||
&Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
TimeoutSettings: exporterhelper.TimeoutSettings{
|
||||
Timeout: 10 * time.Second,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"context"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/configcompression"
|
||||
"go.opentelemetry.io/collector/config/configgrpc"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
|
|
@ -42,10 +43,10 @@ func NewFactory() component.ExporterFactory {
|
|||
|
||||
func createDefaultConfig() component.ExporterConfig {
|
||||
return &Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
TimeoutSettings: exporterhelper.NewDefaultTimeoutSettings(),
|
||||
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
|
||||
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
TimeoutSettings: exporterhelper.NewDefaultTimeoutSettings(),
|
||||
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
|
||||
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
|
||||
GRPCClientSettings: configgrpc.GRPCClientSettings{
|
||||
Headers: map[string]string{},
|
||||
// Default to gzip compression
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import (
|
|||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/configcompression"
|
||||
"go.opentelemetry.io/collector/config/configgrpc"
|
||||
"go.opentelemetry.io/collector/config/configtls"
|
||||
|
|
@ -67,7 +68,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
{
|
||||
name: "NoEndpoint",
|
||||
config: Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
GRPCClientSettings: configgrpc.GRPCClientSettings{
|
||||
Endpoint: "",
|
||||
},
|
||||
|
|
@ -77,7 +78,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
{
|
||||
name: "UseSecure",
|
||||
config: Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
GRPCClientSettings: configgrpc.GRPCClientSettings{
|
||||
Endpoint: endpoint,
|
||||
TLSSetting: configtls.TLSClientSetting{
|
||||
|
|
@ -89,7 +90,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
{
|
||||
name: "Keepalive",
|
||||
config: Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
GRPCClientSettings: configgrpc.GRPCClientSettings{
|
||||
Endpoint: endpoint,
|
||||
Keepalive: &configgrpc.KeepaliveClientConfig{
|
||||
|
|
@ -103,7 +104,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
{
|
||||
name: "NoneCompression",
|
||||
config: Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
GRPCClientSettings: configgrpc.GRPCClientSettings{
|
||||
Endpoint: endpoint,
|
||||
Compression: "none",
|
||||
|
|
@ -113,7 +114,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
{
|
||||
name: "GzipCompression",
|
||||
config: Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
GRPCClientSettings: configgrpc.GRPCClientSettings{
|
||||
Endpoint: endpoint,
|
||||
Compression: configcompression.Gzip,
|
||||
|
|
@ -141,7 +142,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
{
|
||||
name: "Headers",
|
||||
config: Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
GRPCClientSettings: configgrpc.GRPCClientSettings{
|
||||
Endpoint: endpoint,
|
||||
Headers: map[string]string{
|
||||
|
|
@ -154,7 +155,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
{
|
||||
name: "NumConsumers",
|
||||
config: Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
GRPCClientSettings: configgrpc.GRPCClientSettings{
|
||||
Endpoint: endpoint,
|
||||
},
|
||||
|
|
@ -163,7 +164,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
{
|
||||
name: "CaCert",
|
||||
config: Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
GRPCClientSettings: configgrpc.GRPCClientSettings{
|
||||
Endpoint: endpoint,
|
||||
TLSSetting: configtls.TLSClientSetting{
|
||||
|
|
@ -177,7 +178,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
{
|
||||
name: "CertPemFileError",
|
||||
config: Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
GRPCClientSettings: configgrpc.GRPCClientSettings{
|
||||
Endpoint: endpoint,
|
||||
TLSSetting: configtls.TLSClientSetting{
|
||||
|
|
|
|||
|
|
@ -18,16 +18,17 @@ import (
|
|||
"errors"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/confighttp"
|
||||
"go.opentelemetry.io/collector/exporter/exporterhelper"
|
||||
)
|
||||
|
||||
// Config defines configuration for OTLP/HTTP exporter.
|
||||
type Config struct {
|
||||
component.ExporterConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
confighttp.HTTPClientSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
|
||||
exporterhelper.QueueSettings `mapstructure:"sending_queue"`
|
||||
exporterhelper.RetrySettings `mapstructure:"retry_on_failure"`
|
||||
config.ExporterSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
confighttp.HTTPClientSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
|
||||
exporterhelper.QueueSettings `mapstructure:"sending_queue"`
|
||||
exporterhelper.RetrySettings `mapstructure:"retry_on_failure"`
|
||||
|
||||
// The URL to send traces to. If omitted the Endpoint + "/v1/traces" will be used.
|
||||
TracesEndpoint string `mapstructure:"traces_endpoint"`
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/confighttp"
|
||||
"go.opentelemetry.io/collector/config/configtls"
|
||||
"go.opentelemetry.io/collector/confmap"
|
||||
|
|
@ -47,7 +48,7 @@ func TestUnmarshalConfig(t *testing.T) {
|
|||
assert.NoError(t, component.UnmarshalExporterConfig(cm, cfg))
|
||||
assert.Equal(t,
|
||||
&Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
RetrySettings: exporterhelper.RetrySettings{
|
||||
Enabled: true,
|
||||
InitialInterval: 10 * time.Second,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import (
|
|||
"time"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/configcompression"
|
||||
"go.opentelemetry.io/collector/config/confighttp"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
|
|
@ -45,9 +46,9 @@ func NewFactory() component.ExporterFactory {
|
|||
|
||||
func createDefaultConfig() component.ExporterConfig {
|
||||
return &Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
|
||||
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
|
||||
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
|
||||
HTTPClientSettings: confighttp.HTTPClientSettings{
|
||||
Endpoint: "",
|
||||
Timeout: 30 * time.Second,
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import (
|
|||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/configcompression"
|
||||
"go.opentelemetry.io/collector/config/confighttp"
|
||||
"go.opentelemetry.io/collector/config/configtls"
|
||||
|
|
@ -71,7 +72,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
{
|
||||
name: "NoEndpoint",
|
||||
config: Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
HTTPClientSettings: confighttp.HTTPClientSettings{
|
||||
Endpoint: "",
|
||||
},
|
||||
|
|
@ -81,7 +82,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
{
|
||||
name: "UseSecure",
|
||||
config: Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
HTTPClientSettings: confighttp.HTTPClientSettings{
|
||||
Endpoint: endpoint,
|
||||
TLSSetting: configtls.TLSClientSetting{
|
||||
|
|
@ -93,7 +94,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
{
|
||||
name: "Headers",
|
||||
config: Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
HTTPClientSettings: confighttp.HTTPClientSettings{
|
||||
Endpoint: endpoint,
|
||||
Headers: map[string]string{
|
||||
|
|
@ -106,7 +107,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
{
|
||||
name: "CaCert",
|
||||
config: Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
HTTPClientSettings: confighttp.HTTPClientSettings{
|
||||
Endpoint: endpoint,
|
||||
TLSSetting: configtls.TLSClientSetting{
|
||||
|
|
@ -120,7 +121,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
{
|
||||
name: "CertPemFileError",
|
||||
config: Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
HTTPClientSettings: confighttp.HTTPClientSettings{
|
||||
Endpoint: endpoint,
|
||||
TLSSetting: configtls.TLSClientSetting{
|
||||
|
|
@ -136,7 +137,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
{
|
||||
name: "NoneCompression",
|
||||
config: Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
HTTPClientSettings: confighttp.HTTPClientSettings{
|
||||
Endpoint: endpoint,
|
||||
Compression: "none",
|
||||
|
|
@ -146,7 +147,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
{
|
||||
name: "GzipCompression",
|
||||
config: Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
HTTPClientSettings: confighttp.HTTPClientSettings{
|
||||
Endpoint: endpoint,
|
||||
Compression: configcompression.Gzip,
|
||||
|
|
@ -156,7 +157,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
{
|
||||
name: "SnappyCompression",
|
||||
config: Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
HTTPClientSettings: confighttp.HTTPClientSettings{
|
||||
Endpoint: endpoint,
|
||||
Compression: configcompression.Snappy,
|
||||
|
|
@ -166,7 +167,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
{
|
||||
name: "ZstdCompression",
|
||||
config: Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
HTTPClientSettings: confighttp.HTTPClientSettings{
|
||||
Endpoint: endpoint,
|
||||
Compression: configcompression.Zstd,
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import (
|
|||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/confighttp"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
"go.opentelemetry.io/collector/consumer/consumererror"
|
||||
|
|
@ -480,8 +481,8 @@ func TestErrorResponses(t *testing.T) {
|
|||
}()
|
||||
|
||||
cfg := &Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
TracesEndpoint: fmt.Sprintf("http://%s/v1/traces", addr),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
TracesEndpoint: fmt.Sprintf("http://%s/v1/traces", addr),
|
||||
// Create without QueueSettings and RetrySettings so that ConsumeTraces
|
||||
// returns the errors that we want to check immediately.
|
||||
}
|
||||
|
|
@ -557,8 +558,8 @@ func TestUserAgent(t *testing.T) {
|
|||
}()
|
||||
|
||||
cfg := &Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
TracesEndpoint: fmt.Sprintf("http://%s/v1/traces", addr),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
TracesEndpoint: fmt.Sprintf("http://%s/v1/traces", addr),
|
||||
HTTPClientSettings: confighttp.HTTPClientSettings{
|
||||
Headers: test.headers,
|
||||
},
|
||||
|
|
@ -602,8 +603,8 @@ func TestUserAgent(t *testing.T) {
|
|||
}()
|
||||
|
||||
cfg := &Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
MetricsEndpoint: fmt.Sprintf("http://%s/v1/metrics", addr),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
MetricsEndpoint: fmt.Sprintf("http://%s/v1/metrics", addr),
|
||||
HTTPClientSettings: confighttp.HTTPClientSettings{
|
||||
Headers: test.headers,
|
||||
},
|
||||
|
|
@ -647,8 +648,8 @@ func TestUserAgent(t *testing.T) {
|
|||
}()
|
||||
|
||||
cfg := &Config{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
LogsEndpoint: fmt.Sprintf("http://%s/v1/logs", addr),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
LogsEndpoint: fmt.Sprintf("http://%s/v1/logs", addr),
|
||||
HTTPClientSettings: confighttp.HTTPClientSettings{
|
||||
Headers: test.headers,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ package ballastextension // import "go.opentelemetry.io/collector/extension/ball
|
|||
import (
|
||||
"errors"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
)
|
||||
|
||||
// Config has the configuration for the ballast extension.
|
||||
type Config struct {
|
||||
component.ExtensionConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ExtensionSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
|
||||
// SizeMiB is the size, in MiB, of the memory ballast
|
||||
// to be created for this process.
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/confmap"
|
||||
"go.opentelemetry.io/collector/confmap/confmaptest"
|
||||
)
|
||||
|
|
@ -41,9 +42,9 @@ func TestUnmarshalConfig(t *testing.T) {
|
|||
assert.NoError(t, component.UnmarshalExtensionConfig(cm, cfg))
|
||||
assert.Equal(t,
|
||||
&Config{
|
||||
ExtensionConfigSettings: component.NewExtensionConfigSettings(component.NewID(typeStr)),
|
||||
SizeMiB: 123,
|
||||
SizeInPercentage: 20,
|
||||
ExtensionSettings: config.NewExtensionSettings(component.NewID(typeStr)),
|
||||
SizeMiB: 123,
|
||||
SizeInPercentage: 20,
|
||||
}, cfg)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"context"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/internal/iruntime"
|
||||
)
|
||||
|
||||
|
|
@ -36,7 +37,7 @@ func NewFactory() component.ExtensionFactory {
|
|||
|
||||
func createDefaultConfig() component.ExtensionConfig {
|
||||
return &Config{
|
||||
ExtensionConfigSettings: component.NewExtensionConfigSettings(component.NewID(typeStr)),
|
||||
ExtensionSettings: config.NewExtensionSettings(component.NewID(typeStr)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,11 +23,12 @@ import (
|
|||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
)
|
||||
|
||||
func TestFactory_CreateDefaultConfig(t *testing.T) {
|
||||
cfg := createDefaultConfig()
|
||||
assert.Equal(t, &Config{ExtensionConfigSettings: component.NewExtensionConfigSettings(component.NewID(typeStr))}, cfg)
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -18,12 +18,13 @@ import (
|
|||
"errors"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/confignet"
|
||||
)
|
||||
|
||||
// Config has the configuration for the extension enabling the zPages extension.
|
||||
type Config struct {
|
||||
component.ExtensionConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ExtensionSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
|
||||
// TCPAddr is the address and port in which the zPages will be listening to.
|
||||
// Use localhost:<port> to make it available only locally, or ":<port>" to
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/confignet"
|
||||
"go.opentelemetry.io/collector/confmap"
|
||||
"go.opentelemetry.io/collector/confmap/confmaptest"
|
||||
|
|
@ -42,7 +43,7 @@ func TestUnmarshalConfig(t *testing.T) {
|
|||
assert.NoError(t, component.UnmarshalExtensionConfig(cm, cfg))
|
||||
assert.Equal(t,
|
||||
&Config{
|
||||
ExtensionConfigSettings: component.NewExtensionConfigSettings(component.NewID(typeStr)),
|
||||
ExtensionSettings: config.NewExtensionSettings(component.NewID(typeStr)),
|
||||
TCPAddr: confignet.TCPAddr{
|
||||
Endpoint: "localhost:56888",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"context"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/confignet"
|
||||
)
|
||||
|
||||
|
|
@ -35,7 +36,7 @@ func NewFactory() component.ExtensionFactory {
|
|||
|
||||
func createDefaultConfig() component.ExtensionConfig {
|
||||
return &Config{
|
||||
ExtensionConfigSettings: component.NewExtensionConfigSettings(component.NewID(typeStr)),
|
||||
ExtensionSettings: config.NewExtensionSettings(component.NewID(typeStr)),
|
||||
TCPAddr: confignet.TCPAddr{
|
||||
Endpoint: defaultEndpoint,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import (
|
|||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/confignet"
|
||||
"go.opentelemetry.io/collector/internal/testutil"
|
||||
)
|
||||
|
|
@ -30,7 +31,7 @@ import (
|
|||
func TestFactory_CreateDefaultConfig(t *testing.T) {
|
||||
cfg := createDefaultConfig()
|
||||
assert.Equal(t, &Config{
|
||||
ExtensionConfigSettings: component.NewExtensionConfigSettings(component.NewID(typeStr)),
|
||||
ExtensionSettings: config.NewExtensionSettings(component.NewID(typeStr)),
|
||||
TCPAddr: confignet.TCPAddr{
|
||||
Endpoint: "localhost:55679",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import (
|
|||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/configtelemetry"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
"go.opentelemetry.io/collector/consumer/consumertest"
|
||||
|
|
@ -285,9 +286,9 @@ func TestBatchProcessorSentByTimeout(t *testing.T) {
|
|||
|
||||
func TestBatchProcessorTraceSendWhenClosing(t *testing.T) {
|
||||
cfg := Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID(typeStr)),
|
||||
Timeout: 3 * time.Second,
|
||||
SendBatchSize: 1000,
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)),
|
||||
Timeout: 3 * time.Second,
|
||||
SendBatchSize: 1000,
|
||||
}
|
||||
sink := new(consumertest.TracesSink)
|
||||
|
||||
|
|
@ -313,9 +314,9 @@ func TestBatchMetricProcessor_ReceivingData(t *testing.T) {
|
|||
// Instantiate the batch processor with low config values to test data
|
||||
// gets sent through the processor.
|
||||
cfg := Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID(typeStr)),
|
||||
Timeout: 200 * time.Millisecond,
|
||||
SendBatchSize: 50,
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)),
|
||||
Timeout: 200 * time.Millisecond,
|
||||
SendBatchSize: 50,
|
||||
}
|
||||
|
||||
requestCount := 100
|
||||
|
|
@ -367,9 +368,9 @@ func TestBatchMetricProcessor_BatchSize(t *testing.T) {
|
|||
// Instantiate the batch processor with low config values to test data
|
||||
// gets sent through the processor.
|
||||
cfg := Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID(typeStr)),
|
||||
Timeout: 100 * time.Millisecond,
|
||||
SendBatchSize: 50,
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)),
|
||||
Timeout: 100 * time.Millisecond,
|
||||
SendBatchSize: 50,
|
||||
}
|
||||
|
||||
requestCount := 100
|
||||
|
|
@ -446,9 +447,9 @@ func TestBatchMetrics_UnevenBatchMaxSize(t *testing.T) {
|
|||
|
||||
func TestBatchMetricsProcessor_Timeout(t *testing.T) {
|
||||
cfg := Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID(typeStr)),
|
||||
Timeout: 100 * time.Millisecond,
|
||||
SendBatchSize: 101,
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)),
|
||||
Timeout: 100 * time.Millisecond,
|
||||
SendBatchSize: 101,
|
||||
}
|
||||
requestCount := 5
|
||||
metricsPerRequest := 10
|
||||
|
|
@ -495,9 +496,9 @@ func TestBatchMetricsProcessor_Timeout(t *testing.T) {
|
|||
|
||||
func TestBatchMetricProcessor_Shutdown(t *testing.T) {
|
||||
cfg := Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID(typeStr)),
|
||||
Timeout: 3 * time.Second,
|
||||
SendBatchSize: 1000,
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)),
|
||||
Timeout: 3 * time.Second,
|
||||
SendBatchSize: 1000,
|
||||
}
|
||||
requestCount := 5
|
||||
metricsPerRequest := 10
|
||||
|
|
@ -581,9 +582,9 @@ func BenchmarkTraceSizeSpanCount(b *testing.B) {
|
|||
func BenchmarkBatchMetricProcessor(b *testing.B) {
|
||||
b.StopTimer()
|
||||
cfg := Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID(typeStr)),
|
||||
Timeout: 100 * time.Millisecond,
|
||||
SendBatchSize: 2000,
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)),
|
||||
Timeout: 100 * time.Millisecond,
|
||||
SendBatchSize: 2000,
|
||||
}
|
||||
ctx := context.Background()
|
||||
sink := new(metricsSink)
|
||||
|
|
@ -631,9 +632,9 @@ func TestBatchLogProcessor_ReceivingData(t *testing.T) {
|
|||
// Instantiate the batch processor with low config values to test data
|
||||
// gets sent through the processor.
|
||||
cfg := Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID(typeStr)),
|
||||
Timeout: 200 * time.Millisecond,
|
||||
SendBatchSize: 50,
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)),
|
||||
Timeout: 200 * time.Millisecond,
|
||||
SendBatchSize: 50,
|
||||
}
|
||||
|
||||
requestCount := 100
|
||||
|
|
@ -685,9 +686,9 @@ func TestBatchLogProcessor_BatchSize(t *testing.T) {
|
|||
// Instantiate the batch processor with low config values to test data
|
||||
// gets sent through the processor.
|
||||
cfg := Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID(typeStr)),
|
||||
Timeout: 100 * time.Millisecond,
|
||||
SendBatchSize: 50,
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)),
|
||||
Timeout: 100 * time.Millisecond,
|
||||
SendBatchSize: 50,
|
||||
}
|
||||
|
||||
requestCount := 100
|
||||
|
|
@ -743,9 +744,9 @@ func TestBatchLogProcessor_BatchSize(t *testing.T) {
|
|||
|
||||
func TestBatchLogsProcessor_Timeout(t *testing.T) {
|
||||
cfg := Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID(typeStr)),
|
||||
Timeout: 100 * time.Millisecond,
|
||||
SendBatchSize: 100,
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)),
|
||||
Timeout: 100 * time.Millisecond,
|
||||
SendBatchSize: 100,
|
||||
}
|
||||
requestCount := 5
|
||||
logsPerRequest := 10
|
||||
|
|
@ -792,9 +793,9 @@ func TestBatchLogsProcessor_Timeout(t *testing.T) {
|
|||
|
||||
func TestBatchLogProcessor_Shutdown(t *testing.T) {
|
||||
cfg := Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID(typeStr)),
|
||||
Timeout: 3 * time.Second,
|
||||
SendBatchSize: 1000,
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)),
|
||||
Timeout: 3 * time.Second,
|
||||
SendBatchSize: 1000,
|
||||
}
|
||||
requestCount := 5
|
||||
logsPerRequest := 10
|
||||
|
|
|
|||
|
|
@ -19,11 +19,12 @@ import (
|
|||
"time"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
)
|
||||
|
||||
// Config defines configuration for batch processor.
|
||||
type Config struct {
|
||||
component.ProcessorConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ProcessorSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
|
||||
// Timeout sets the time after which a batch will be sent regardless of size.
|
||||
Timeout time.Duration `mapstructure:"timeout"`
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/confmap"
|
||||
"go.opentelemetry.io/collector/confmap/confmaptest"
|
||||
)
|
||||
|
|
@ -42,27 +43,27 @@ func TestUnmarshalConfig(t *testing.T) {
|
|||
assert.NoError(t, component.UnmarshalProcessorConfig(cm, cfg))
|
||||
assert.Equal(t,
|
||||
&Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID(typeStr)),
|
||||
SendBatchSize: uint32(10000),
|
||||
SendBatchMaxSize: uint32(11000),
|
||||
Timeout: time.Second * 10,
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)),
|
||||
SendBatchSize: uint32(10000),
|
||||
SendBatchMaxSize: uint32(11000),
|
||||
Timeout: time.Second * 10,
|
||||
}, cfg)
|
||||
}
|
||||
|
||||
func TestValidateConfig_DefaultBatchMaxSize(t *testing.T) {
|
||||
cfg := &Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewIDWithName(typeStr, "2")),
|
||||
SendBatchSize: 100,
|
||||
SendBatchMaxSize: 0,
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewIDWithName(typeStr, "2")),
|
||||
SendBatchSize: 100,
|
||||
SendBatchMaxSize: 0,
|
||||
}
|
||||
assert.NoError(t, cfg.Validate())
|
||||
}
|
||||
|
||||
func TestValidateConfig_ValidBatchSizes(t *testing.T) {
|
||||
cfg := &Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewIDWithName(typeStr, "2")),
|
||||
SendBatchSize: 100,
|
||||
SendBatchMaxSize: 1000,
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewIDWithName(typeStr, "2")),
|
||||
SendBatchSize: 100,
|
||||
SendBatchMaxSize: 1000,
|
||||
}
|
||||
assert.NoError(t, cfg.Validate())
|
||||
|
||||
|
|
@ -70,9 +71,9 @@ func TestValidateConfig_ValidBatchSizes(t *testing.T) {
|
|||
|
||||
func TestValidateConfig_InvalidBatchSize(t *testing.T) {
|
||||
cfg := &Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewIDWithName(typeStr, "2")),
|
||||
SendBatchSize: 1000,
|
||||
SendBatchMaxSize: 100,
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewIDWithName(typeStr, "2")),
|
||||
SendBatchSize: 1000,
|
||||
SendBatchMaxSize: 100,
|
||||
}
|
||||
assert.Error(t, cfg.Validate())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import (
|
|||
"time"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
)
|
||||
|
||||
|
|
@ -42,9 +43,9 @@ func NewFactory() component.ProcessorFactory {
|
|||
|
||||
func createDefaultConfig() component.ProcessorConfig {
|
||||
return &Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID(typeStr)),
|
||||
SendBatchSize: defaultSendBatchSize,
|
||||
Timeout: defaultTimeout,
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)),
|
||||
SendBatchSize: defaultSendBatchSize,
|
||||
Timeout: defaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,11 +21,12 @@ import (
|
|||
"time"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
)
|
||||
|
||||
// Config defines configuration for memory memoryLimiter processor.
|
||||
type Config struct {
|
||||
component.ProcessorConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ProcessorSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
|
||||
// CheckInterval is the time between measurements of memory usage for the
|
||||
// purposes of avoiding going over the limits. Defaults to zero, so no
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/confmap"
|
||||
"go.opentelemetry.io/collector/confmap/confmaptest"
|
||||
)
|
||||
|
|
@ -42,9 +43,9 @@ func TestUnmarshalConfig(t *testing.T) {
|
|||
assert.NoError(t, component.UnmarshalProcessorConfig(cm, cfg))
|
||||
assert.Equal(t,
|
||||
&Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID(typeStr)),
|
||||
CheckInterval: 5 * time.Second,
|
||||
MemoryLimitMiB: 4000,
|
||||
MemorySpikeLimitMiB: 500,
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)),
|
||||
CheckInterval: 5 * time.Second,
|
||||
MemoryLimitMiB: 4000,
|
||||
MemorySpikeLimitMiB: 500,
|
||||
}, cfg)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import (
|
|||
"sync"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
"go.opentelemetry.io/collector/processor/processorhelper"
|
||||
)
|
||||
|
|
@ -54,7 +55,7 @@ func NewFactory() component.ProcessorFactory {
|
|||
// that the default configuration is expected to fail for this processor.
|
||||
func createDefaultConfig() component.ProcessorConfig {
|
||||
return &Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID(typeStr)),
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import (
|
|||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/configtelemetry"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
"go.opentelemetry.io/collector/consumer/consumertest"
|
||||
|
|
@ -122,7 +123,7 @@ func TestMetricsMemoryPressureResponse(t *testing.T) {
|
|||
context.Background(),
|
||||
componenttest.NewNopProcessorCreateSettings(),
|
||||
&Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID(typeStr)),
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)),
|
||||
},
|
||||
consumertest.NewNop(),
|
||||
ml.processMetrics,
|
||||
|
|
@ -193,7 +194,7 @@ func TestTraceMemoryPressureResponse(t *testing.T) {
|
|||
context.Background(),
|
||||
componenttest.NewNopProcessorCreateSettings(),
|
||||
&Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID(typeStr)),
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)),
|
||||
},
|
||||
consumertest.NewNop(),
|
||||
ml.processTraces,
|
||||
|
|
@ -264,7 +265,7 @@ func TestLogMemoryPressureResponse(t *testing.T) {
|
|||
context.Background(),
|
||||
componenttest.NewNopProcessorCreateSettings(),
|
||||
&Config{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID(typeStr)),
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID(typeStr)),
|
||||
},
|
||||
consumertest.NewNop(),
|
||||
ml.processLogs,
|
||||
|
|
|
|||
|
|
@ -24,12 +24,13 @@ import (
|
|||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
"go.opentelemetry.io/collector/consumer/consumertest"
|
||||
"go.opentelemetry.io/collector/pdata/plog"
|
||||
)
|
||||
|
||||
var testLogsCfg = component.NewProcessorConfigSettings(component.NewID("test"))
|
||||
var testLogsCfg = config.NewProcessorSettings(component.NewID("test"))
|
||||
|
||||
func TestNewLogsProcessor(t *testing.T) {
|
||||
lp, err := NewLogsProcessor(context.Background(), componenttest.NewNopProcessorCreateSettings(), &testLogsCfg, consumertest.NewNop(), newTestLProcessor(nil))
|
||||
|
|
|
|||
|
|
@ -24,12 +24,13 @@ import (
|
|||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
"go.opentelemetry.io/collector/consumer/consumertest"
|
||||
"go.opentelemetry.io/collector/pdata/pmetric"
|
||||
)
|
||||
|
||||
var testMetricsCfg = component.NewProcessorConfigSettings(component.NewID("test"))
|
||||
var testMetricsCfg = config.NewProcessorSettings(component.NewID("test"))
|
||||
|
||||
func TestNewMetricsProcessor(t *testing.T) {
|
||||
mp, err := NewMetricsProcessor(context.Background(), componenttest.NewNopProcessorCreateSettings(), &testMetricsCfg, consumertest.NewNop(), newTestMProcessor(nil))
|
||||
|
|
|
|||
|
|
@ -24,12 +24,13 @@ import (
|
|||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
"go.opentelemetry.io/collector/consumer/consumertest"
|
||||
"go.opentelemetry.io/collector/pdata/ptrace"
|
||||
)
|
||||
|
||||
var testTracesCfg = component.NewProcessorConfigSettings(component.NewID("test"))
|
||||
var testTracesCfg = config.NewProcessorSettings(component.NewID("test"))
|
||||
|
||||
func TestNewTracesProcessor(t *testing.T) {
|
||||
tp, err := NewTracesProcessor(context.Background(), componenttest.NewNopProcessorCreateSettings(), &testTracesCfg, consumertest.NewNop(), newTestTProcessor(nil))
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"errors"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/configgrpc"
|
||||
"go.opentelemetry.io/collector/config/confighttp"
|
||||
"go.opentelemetry.io/collector/confmap"
|
||||
|
|
@ -38,7 +39,7 @@ type Protocols struct {
|
|||
|
||||
// Config defines configuration for OTLP receiver.
|
||||
type Config struct {
|
||||
component.ReceiverConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ReceiverSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
// Protocols is the configuration for the supported protocols, currently gRPC and HTTP (Proto and JSON).
|
||||
Protocols `mapstructure:"protocols"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/configgrpc"
|
||||
"go.opentelemetry.io/collector/config/confighttp"
|
||||
"go.opentelemetry.io/collector/config/confignet"
|
||||
|
|
@ -96,7 +97,7 @@ func TestUnmarshalConfig(t *testing.T) {
|
|||
assert.NoError(t, component.UnmarshalReceiverConfig(cm, cfg))
|
||||
assert.Equal(t,
|
||||
&Config{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(typeStr)),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{
|
||||
GRPC: &configgrpc.GRPCServerSettings{
|
||||
NetAddr: confignet.NetAddr{
|
||||
|
|
@ -153,7 +154,7 @@ func TestUnmarshalConfigUnix(t *testing.T) {
|
|||
assert.NoError(t, component.UnmarshalReceiverConfig(cm, cfg))
|
||||
assert.Equal(t,
|
||||
&Config{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(typeStr)),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{
|
||||
GRPC: &configgrpc.GRPCServerSettings{
|
||||
NetAddr: confignet.NetAddr{
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"context"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/configgrpc"
|
||||
"go.opentelemetry.io/collector/config/confighttp"
|
||||
"go.opentelemetry.io/collector/config/confignet"
|
||||
|
|
@ -45,7 +46,7 @@ func NewFactory() component.ReceiverFactory {
|
|||
// createDefaultConfig creates the default configuration for receiver.
|
||||
func createDefaultConfig() component.ReceiverConfig {
|
||||
return &Config{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(typeStr)),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{
|
||||
GRPC: &configgrpc.GRPCServerSettings{
|
||||
NetAddr: confignet.NetAddr{
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import (
|
|||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/configgrpc"
|
||||
"go.opentelemetry.io/collector/config/confighttp"
|
||||
"go.opentelemetry.io/collector/config/confignet"
|
||||
|
|
@ -74,7 +75,7 @@ func TestCreateTracesReceiver(t *testing.T) {
|
|||
{
|
||||
name: "default",
|
||||
cfg: &Config{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(typeStr)),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{
|
||||
GRPC: defaultGRPCSettings,
|
||||
HTTP: defaultHTTPSettings,
|
||||
|
|
@ -84,7 +85,7 @@ func TestCreateTracesReceiver(t *testing.T) {
|
|||
{
|
||||
name: "invalid_grpc_port",
|
||||
cfg: &Config{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(typeStr)),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{
|
||||
GRPC: &configgrpc.GRPCServerSettings{
|
||||
NetAddr: confignet.NetAddr{
|
||||
|
|
@ -100,7 +101,7 @@ func TestCreateTracesReceiver(t *testing.T) {
|
|||
{
|
||||
name: "invalid_http_port",
|
||||
cfg: &Config{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(typeStr)),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{
|
||||
GRPC: defaultGRPCSettings,
|
||||
HTTP: &confighttp.HTTPServerSettings{
|
||||
|
|
@ -150,7 +151,7 @@ func TestCreateMetricReceiver(t *testing.T) {
|
|||
{
|
||||
name: "default",
|
||||
cfg: &Config{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(typeStr)),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{
|
||||
GRPC: defaultGRPCSettings,
|
||||
HTTP: defaultHTTPSettings,
|
||||
|
|
@ -160,7 +161,7 @@ func TestCreateMetricReceiver(t *testing.T) {
|
|||
{
|
||||
name: "invalid_grpc_address",
|
||||
cfg: &Config{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(typeStr)),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{
|
||||
GRPC: &configgrpc.GRPCServerSettings{
|
||||
NetAddr: confignet.NetAddr{
|
||||
|
|
@ -176,7 +177,7 @@ func TestCreateMetricReceiver(t *testing.T) {
|
|||
{
|
||||
name: "invalid_http_address",
|
||||
cfg: &Config{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(typeStr)),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{
|
||||
GRPC: defaultGRPCSettings,
|
||||
HTTP: &confighttp.HTTPServerSettings{
|
||||
|
|
@ -227,7 +228,7 @@ func TestCreateLogReceiver(t *testing.T) {
|
|||
{
|
||||
name: "default",
|
||||
cfg: &Config{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(typeStr)),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{
|
||||
GRPC: defaultGRPCSettings,
|
||||
HTTP: defaultHTTPSettings,
|
||||
|
|
@ -238,7 +239,7 @@ func TestCreateLogReceiver(t *testing.T) {
|
|||
{
|
||||
name: "invalid_grpc_address",
|
||||
cfg: &Config{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(typeStr)),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{
|
||||
GRPC: &configgrpc.GRPCServerSettings{
|
||||
NetAddr: confignet.NetAddr{
|
||||
|
|
@ -255,7 +256,7 @@ func TestCreateLogReceiver(t *testing.T) {
|
|||
{
|
||||
name: "invalid_http_address",
|
||||
cfg: &Config{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(typeStr)),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{
|
||||
GRPC: defaultGRPCSettings,
|
||||
HTTP: &confighttp.HTTPServerSettings{
|
||||
|
|
@ -269,7 +270,7 @@ func TestCreateLogReceiver(t *testing.T) {
|
|||
{
|
||||
name: "no_next_consumer",
|
||||
cfg: &Config{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(typeStr)),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{
|
||||
GRPC: defaultGRPCSettings,
|
||||
HTTP: &confighttp.HTTPServerSettings{
|
||||
|
|
@ -283,8 +284,8 @@ func TestCreateLogReceiver(t *testing.T) {
|
|||
{
|
||||
name: "no_http_or_grcp_config",
|
||||
cfg: &Config{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{},
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{},
|
||||
},
|
||||
wantErr: false,
|
||||
sink: new(consumertest.LogsSink),
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import (
|
|||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/configgrpc"
|
||||
"go.opentelemetry.io/collector/config/confighttp"
|
||||
"go.opentelemetry.io/collector/config/confignet"
|
||||
|
|
@ -183,8 +184,8 @@ func TestJsonHttp(t *testing.T) {
|
|||
func TestHandleInvalidRequests(t *testing.T) {
|
||||
endpoint := testutil.GetAvailableLocalAddress(t)
|
||||
cfg := &Config{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{HTTP: &confighttp.HTTPServerSettings{Endpoint: endpoint}},
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{HTTP: &confighttp.HTTPServerSettings{Endpoint: endpoint}},
|
||||
}
|
||||
|
||||
// Traces
|
||||
|
|
@ -707,7 +708,7 @@ func TestOTLPReceiverTrace_HandleNextConsumerResponse(t *testing.T) {
|
|||
|
||||
func TestGRPCInvalidTLSCredentials(t *testing.T) {
|
||||
cfg := &Config{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(typeStr)),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{
|
||||
GRPC: &configgrpc.GRPCServerSettings{
|
||||
NetAddr: confignet.NetAddr{
|
||||
|
|
@ -778,7 +779,7 @@ func TestGRPCMaxRecvSize(t *testing.T) {
|
|||
|
||||
func TestHTTPInvalidTLSCredentials(t *testing.T) {
|
||||
cfg := &Config{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(typeStr)),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{
|
||||
HTTP: &confighttp.HTTPServerSettings{
|
||||
Endpoint: testutil.GetAvailableLocalAddress(t),
|
||||
|
|
@ -807,7 +808,7 @@ func testHTTPMaxRequestBodySizeJSON(t *testing.T, payload []byte, size int, expe
|
|||
endpoint := testutil.GetAvailableLocalAddress(t)
|
||||
url := fmt.Sprintf("http://%s/v1/traces", endpoint)
|
||||
cfg := &Config{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(typeStr)),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)),
|
||||
Protocols: Protocols{
|
||||
HTTP: &confighttp.HTTPServerSettings{
|
||||
Endpoint: endpoint,
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import (
|
|||
"go.uber.org/zap"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
"go.opentelemetry.io/collector/obsreport"
|
||||
"go.opentelemetry.io/collector/pdata/pmetric"
|
||||
|
|
@ -31,18 +32,18 @@ import (
|
|||
|
||||
// ScraperControllerSettings defines common settings for a scraper controller
|
||||
// configuration. Scraper controller receivers can embed this struct, instead
|
||||
// of component.ReceiverConfigSettings, and extend it with more fields if needed.
|
||||
// of component.ReceiverSettings, and extend it with more fields if needed.
|
||||
type ScraperControllerSettings struct {
|
||||
component.ReceiverConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
CollectionInterval time.Duration `mapstructure:"collection_interval"`
|
||||
config.ReceiverSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
CollectionInterval time.Duration `mapstructure:"collection_interval"`
|
||||
}
|
||||
|
||||
// NewDefaultScraperControllerSettings returns default scraper controller
|
||||
// settings with a collection interval of one minute.
|
||||
func NewDefaultScraperControllerSettings(cfgType component.Type) ScraperControllerSettings {
|
||||
return ScraperControllerSettings{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(cfgType)),
|
||||
CollectionInterval: time.Minute,
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(cfgType)),
|
||||
CollectionInterval: time.Minute,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import (
|
|||
"go.uber.org/zap/zapcore"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/config/configtelemetry"
|
||||
"go.opentelemetry.io/collector/service/telemetry"
|
||||
)
|
||||
|
|
@ -35,7 +36,7 @@ var (
|
|||
)
|
||||
|
||||
type nopRecvConfig struct {
|
||||
component.ReceiverConfigSettings
|
||||
config.ReceiverSettings
|
||||
validateErr error
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +45,7 @@ func (nc *nopRecvConfig) Validate() error {
|
|||
}
|
||||
|
||||
type nopExpConfig struct {
|
||||
component.ExporterConfigSettings
|
||||
config.ExporterSettings
|
||||
validateErr error
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +54,7 @@ func (nc *nopExpConfig) Validate() error {
|
|||
}
|
||||
|
||||
type nopProcConfig struct {
|
||||
component.ProcessorConfigSettings
|
||||
config.ProcessorSettings
|
||||
validateErr error
|
||||
}
|
||||
|
||||
|
|
@ -62,7 +63,7 @@ func (nc *nopProcConfig) Validate() error {
|
|||
}
|
||||
|
||||
type nopExtConfig struct {
|
||||
component.ExtensionConfigSettings
|
||||
config.ExtensionSettings
|
||||
validateErr error
|
||||
}
|
||||
|
||||
|
|
@ -181,8 +182,8 @@ func TestConfigValidate(t *testing.T) {
|
|||
cfgFn: func() *Config {
|
||||
cfg := generateConfig()
|
||||
cfg.Receivers[component.NewID("nop")] = &nopRecvConfig{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID("nop")),
|
||||
validateErr: errInvalidRecvConfig,
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID("nop")),
|
||||
validateErr: errInvalidRecvConfig,
|
||||
}
|
||||
return cfg
|
||||
},
|
||||
|
|
@ -193,8 +194,8 @@ func TestConfigValidate(t *testing.T) {
|
|||
cfgFn: func() *Config {
|
||||
cfg := generateConfig()
|
||||
cfg.Exporters[component.NewID("nop")] = &nopExpConfig{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID("nop")),
|
||||
validateErr: errInvalidExpConfig,
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID("nop")),
|
||||
validateErr: errInvalidExpConfig,
|
||||
}
|
||||
return cfg
|
||||
},
|
||||
|
|
@ -205,8 +206,8 @@ func TestConfigValidate(t *testing.T) {
|
|||
cfgFn: func() *Config {
|
||||
cfg := generateConfig()
|
||||
cfg.Processors[component.NewID("nop")] = &nopProcConfig{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID("nop")),
|
||||
validateErr: errInvalidProcConfig,
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID("nop")),
|
||||
validateErr: errInvalidProcConfig,
|
||||
}
|
||||
return cfg
|
||||
},
|
||||
|
|
@ -217,8 +218,8 @@ func TestConfigValidate(t *testing.T) {
|
|||
cfgFn: func() *Config {
|
||||
cfg := generateConfig()
|
||||
cfg.Extensions[component.NewID("nop")] = &nopExtConfig{
|
||||
ExtensionConfigSettings: component.NewExtensionConfigSettings(component.NewID("nop")),
|
||||
validateErr: errInvalidExtConfig,
|
||||
ExtensionSettings: config.NewExtensionSettings(component.NewID("nop")),
|
||||
validateErr: errInvalidExtConfig,
|
||||
}
|
||||
return cfg
|
||||
},
|
||||
|
|
@ -251,22 +252,22 @@ func generateConfig() *Config {
|
|||
return &Config{
|
||||
Receivers: map[component.ID]component.ReceiverConfig{
|
||||
component.NewID("nop"): &nopRecvConfig{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID("nop")),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID("nop")),
|
||||
},
|
||||
},
|
||||
Exporters: map[component.ID]component.ExporterConfig{
|
||||
component.NewID("nop"): &nopExpConfig{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID("nop")),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID("nop")),
|
||||
},
|
||||
},
|
||||
Processors: map[component.ID]component.ProcessorConfig{
|
||||
component.NewID("nop"): &nopProcConfig{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID("nop")),
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID("nop")),
|
||||
},
|
||||
},
|
||||
Extensions: map[component.ID]component.ExtensionConfig{
|
||||
component.NewID("nop"): &nopExtConfig{
|
||||
ExtensionConfigSettings: component.NewExtensionConfigSettings(component.NewID("nop")),
|
||||
ExtensionSettings: config.NewExtensionSettings(component.NewID("nop")),
|
||||
},
|
||||
},
|
||||
Service: ConfigService{
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import (
|
|||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
)
|
||||
|
||||
func TestBuildExtensions(t *testing.T) {
|
||||
|
|
@ -109,9 +110,9 @@ func newBadExtensionFactory() component.ExtensionFactory {
|
|||
"bf",
|
||||
func() component.ExtensionConfig {
|
||||
return &struct {
|
||||
component.ExtensionConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ExtensionSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
}{
|
||||
ExtensionConfigSettings: component.NewExtensionConfigSettings(component.NewID("bf")),
|
||||
ExtensionSettings: config.NewExtensionSettings(component.NewID("bf")),
|
||||
}
|
||||
},
|
||||
func(ctx context.Context, set component.ExtensionCreateSettings, extension component.ExtensionConfig) (component.Extension, error) {
|
||||
|
|
@ -126,9 +127,9 @@ func newCreateErrorExtensionFactory() component.ExtensionFactory {
|
|||
"err",
|
||||
func() component.ExtensionConfig {
|
||||
return &struct {
|
||||
component.ExtensionConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ExtensionSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
}{
|
||||
ExtensionConfigSettings: component.NewExtensionConfigSettings(component.NewID("err")),
|
||||
ExtensionSettings: config.NewExtensionSettings(component.NewID("err")),
|
||||
}
|
||||
},
|
||||
func(ctx context.Context, set component.ExtensionCreateSettings, extension component.ExtensionConfig) (component.Extension, error) {
|
||||
|
|
|
|||
|
|
@ -348,9 +348,9 @@ func TestFailToStartAndShutdown(t *testing.T) {
|
|||
func newBadReceiverFactory() component.ReceiverFactory {
|
||||
return component.NewReceiverFactory("bf", func() component.ReceiverConfig {
|
||||
return &struct {
|
||||
component.ReceiverConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ReceiverSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
}{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID("bf")),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID("bf")),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -358,9 +358,9 @@ func newBadReceiverFactory() component.ReceiverFactory {
|
|||
func newBadProcessorFactory() component.ProcessorFactory {
|
||||
return component.NewProcessorFactory("bf", func() component.ProcessorConfig {
|
||||
return &struct {
|
||||
component.ProcessorConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ProcessorSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
}{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID("bf")),
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID("bf")),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -368,9 +368,9 @@ func newBadProcessorFactory() component.ProcessorFactory {
|
|||
func newBadExporterFactory() component.ExporterFactory {
|
||||
return component.NewExporterFactory("bf", func() component.ExporterConfig {
|
||||
return &struct {
|
||||
component.ExporterConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ExporterSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
}{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID("bf")),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID("bf")),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -378,9 +378,9 @@ func newBadExporterFactory() component.ExporterFactory {
|
|||
func newErrReceiverFactory() component.ReceiverFactory {
|
||||
return component.NewReceiverFactory("err", func() component.ReceiverConfig {
|
||||
return &struct {
|
||||
component.ReceiverConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ReceiverSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
}{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID("bf")),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID("bf")),
|
||||
}
|
||||
},
|
||||
component.WithTracesReceiver(func(context.Context, component.ReceiverCreateSettings, component.ReceiverConfig, consumer.Traces) (component.TracesReceiver, error) {
|
||||
|
|
@ -398,9 +398,9 @@ func newErrReceiverFactory() component.ReceiverFactory {
|
|||
func newErrProcessorFactory() component.ProcessorFactory {
|
||||
return component.NewProcessorFactory("err", func() component.ProcessorConfig {
|
||||
return &struct {
|
||||
component.ProcessorConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ProcessorSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
}{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID("bf")),
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID("bf")),
|
||||
}
|
||||
},
|
||||
component.WithTracesProcessor(func(context.Context, component.ProcessorCreateSettings, component.ProcessorConfig, consumer.Traces) (component.TracesProcessor, error) {
|
||||
|
|
@ -418,9 +418,9 @@ func newErrProcessorFactory() component.ProcessorFactory {
|
|||
func newErrExporterFactory() component.ExporterFactory {
|
||||
return component.NewExporterFactory("err", func() component.ExporterConfig {
|
||||
return &struct {
|
||||
component.ExporterConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ExporterSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
}{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID("bf")),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID("bf")),
|
||||
}
|
||||
},
|
||||
component.WithTracesExporter(func(context.Context, component.ExporterCreateSettings, component.ExporterConfig) (component.TracesExporter, error) {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"context"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
"go.opentelemetry.io/collector/pdata/plog"
|
||||
"go.opentelemetry.io/collector/pdata/pmetric"
|
||||
|
|
@ -31,7 +32,7 @@ const (
|
|||
|
||||
// ExampleExporterConfig config for ExampleExporter.
|
||||
type ExampleExporterConfig struct {
|
||||
component.ExporterConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ExporterSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
}
|
||||
|
||||
// ExampleExporterFactory is factory for ExampleExporter.
|
||||
|
|
@ -45,7 +46,7 @@ var ExampleExporterFactory = component.NewExporterFactory(
|
|||
|
||||
func createExporterDefaultConfig() component.ExporterConfig {
|
||||
return &ExampleExporterConfig{
|
||||
ExporterConfigSettings: component.NewExporterConfigSettings(component.NewID(typeStr)),
|
||||
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"context"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
)
|
||||
|
||||
|
|
@ -25,7 +26,7 @@ const procType = "exampleprocessor"
|
|||
|
||||
// ExampleProcessorConfig config for ExampleProcessor.
|
||||
type ExampleProcessorConfig struct {
|
||||
component.ProcessorConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ProcessorSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
}
|
||||
|
||||
// ExampleProcessorFactory is factory for ExampleProcessor.
|
||||
|
|
@ -39,7 +40,7 @@ var ExampleProcessorFactory = component.NewProcessorFactory(
|
|||
// CreateDefaultConfig creates the default configuration for the Processor.
|
||||
func createDefaultConfig() component.ProcessorConfig {
|
||||
return &ExampleProcessorConfig{
|
||||
ProcessorConfigSettings: component.NewProcessorConfigSettings(component.NewID(procType)),
|
||||
ProcessorSettings: config.NewProcessorSettings(component.NewID(procType)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"context"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/config"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
)
|
||||
|
||||
|
|
@ -25,7 +26,7 @@ const receiverType = component.Type("examplereceiver")
|
|||
|
||||
// ExampleReceiverConfig config for ExampleReceiver.
|
||||
type ExampleReceiverConfig struct {
|
||||
component.ReceiverConfigSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
config.ReceiverSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
|
||||
}
|
||||
|
||||
// ExampleReceiverFactory is factory for ExampleReceiver.
|
||||
|
|
@ -38,7 +39,7 @@ var ExampleReceiverFactory = component.NewReceiverFactory(
|
|||
|
||||
func createReceiverDefaultConfig() component.ReceiverConfig {
|
||||
return &ExampleReceiverConfig{
|
||||
ReceiverConfigSettings: component.NewReceiverConfigSettings(component.NewID(receiverType)),
|
||||
ReceiverSettings: config.NewReceiverSettings(component.NewID(receiverType)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue