Remove builders that were deprecated in 0.108.0 (#11019)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description There builders were deprecated in 0.108.0, so they can be removed now. PRs that deprecated the builders: * https://github.com/open-telemetry/opentelemetry-collector/pull/10781 * https://github.com/open-telemetry/opentelemetry-collector/pull/10782 * https://github.com/open-telemetry/opentelemetry-collector/pull/10783 * https://github.com/open-telemetry/opentelemetry-collector/pull/10784 * https://github.com/open-telemetry/opentelemetry-collector/pull/10785 cc @mx-psi
This commit is contained in:
parent
da863adf48
commit
c4e527e7e8
|
|
@ -0,0 +1,25 @@
|
|||
# Use this changelog template to create an entry for release notes.
|
||||
|
||||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
|
||||
change_type: breaking
|
||||
|
||||
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
|
||||
component: connector
|
||||
|
||||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
|
||||
note: Remove deprecated connector builder
|
||||
|
||||
# One or more tracking issues or pull requests related to the change
|
||||
issues: [11019]
|
||||
|
||||
# (Optional) One or more lines of additional information to render under the primary note.
|
||||
# These lines will be padded with 2 spaces and then inserted directly into the document.
|
||||
# Use pipe (|) for multiline entries.
|
||||
subtext:
|
||||
|
||||
# Optional: The change log or logs in which this entry should be included.
|
||||
# e.g. '[user]' or '[user, api]'
|
||||
# Include 'user' if the change is relevant to end users.
|
||||
# Include 'api' if there is a change to a library API.
|
||||
# Default: '[user]'
|
||||
change_logs: [api]
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
# Use this changelog template to create an entry for release notes.
|
||||
|
||||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
|
||||
change_type: breaking
|
||||
|
||||
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
|
||||
component: exporter
|
||||
|
||||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
|
||||
note: Remove deprecated exporter builder
|
||||
|
||||
# One or more tracking issues or pull requests related to the change
|
||||
issues: [11019]
|
||||
|
||||
# (Optional) One or more lines of additional information to render under the primary note.
|
||||
# These lines will be padded with 2 spaces and then inserted directly into the document.
|
||||
# Use pipe (|) for multiline entries.
|
||||
subtext:
|
||||
|
||||
# Optional: The change log or logs in which this entry should be included.
|
||||
# e.g. '[user]' or '[user, api]'
|
||||
# Include 'user' if the change is relevant to end users.
|
||||
# Include 'api' if there is a change to a library API.
|
||||
# Default: '[user]'
|
||||
change_logs: [api]
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
# Use this changelog template to create an entry for release notes.
|
||||
|
||||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
|
||||
change_type: breaking
|
||||
|
||||
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
|
||||
component: extension
|
||||
|
||||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
|
||||
note: Remove deprecated extension builder
|
||||
|
||||
# One or more tracking issues or pull requests related to the change
|
||||
issues: [11019]
|
||||
|
||||
# (Optional) One or more lines of additional information to render under the primary note.
|
||||
# These lines will be padded with 2 spaces and then inserted directly into the document.
|
||||
# Use pipe (|) for multiline entries.
|
||||
subtext:
|
||||
|
||||
# Optional: The change log or logs in which this entry should be included.
|
||||
# e.g. '[user]' or '[user, api]'
|
||||
# Include 'user' if the change is relevant to end users.
|
||||
# Include 'api' if there is a change to a library API.
|
||||
# Default: '[user]'
|
||||
change_logs: [api]
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
# Use this changelog template to create an entry for release notes.
|
||||
|
||||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
|
||||
change_type: breaking
|
||||
|
||||
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
|
||||
component: processor
|
||||
|
||||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
|
||||
note: Remove deprecated processor builder
|
||||
|
||||
# One or more tracking issues or pull requests related to the change
|
||||
issues: [11019]
|
||||
|
||||
# (Optional) One or more lines of additional information to render under the primary note.
|
||||
# These lines will be padded with 2 spaces and then inserted directly into the document.
|
||||
# Use pipe (|) for multiline entries.
|
||||
subtext:
|
||||
|
||||
# Optional: The change log or logs in which this entry should be included.
|
||||
# e.g. '[user]' or '[user, api]'
|
||||
# Include 'user' if the change is relevant to end users.
|
||||
# Include 'api' if there is a change to a library API.
|
||||
# Default: '[user]'
|
||||
change_logs: [api]
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
# Use this changelog template to create an entry for release notes.
|
||||
|
||||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
|
||||
change_type: breaking
|
||||
|
||||
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
|
||||
component: receiver
|
||||
|
||||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
|
||||
note: Remove deprecated receiver builder
|
||||
|
||||
# One or more tracking issues or pull requests related to the change
|
||||
issues: [11019]
|
||||
|
||||
# (Optional) One or more lines of additional information to render under the primary note.
|
||||
# These lines will be padded with 2 spaces and then inserted directly into the document.
|
||||
# Use pipe (|) for multiline entries.
|
||||
subtext:
|
||||
|
||||
# Optional: The change log or logs in which this entry should be included.
|
||||
# e.g. '[user]' or '[user, api]'
|
||||
# Include 'user' if the change is relevant to end users.
|
||||
# Include 'api' if there is a change to a library API.
|
||||
# Default: '[user]'
|
||||
change_logs: [api]
|
||||
|
|
@ -1,225 +0,0 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package connector // import "go.opentelemetry.io/collector/connector"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
)
|
||||
|
||||
var errNilNextConsumer = errors.New("nil next Consumer")
|
||||
|
||||
// Builder is a helper struct that given a set of Configs and Factories helps with creating connectors.
|
||||
//
|
||||
// Deprecated: [v0.108.0] this builder is being internalized within the service module,
|
||||
// and will be removed soon.
|
||||
type Builder struct {
|
||||
cfgs map[component.ID]component.Config
|
||||
factories map[component.Type]Factory
|
||||
}
|
||||
|
||||
// NewBuilder creates a new connector.Builder to help with creating components form a set of configs and factories.
|
||||
//
|
||||
// Deprecated: [v0.108.0] this builder is being internalized within the service module,
|
||||
// and will be removed soon.
|
||||
func NewBuilder(cfgs map[component.ID]component.Config, factories map[component.Type]Factory) *Builder {
|
||||
return &Builder{cfgs: cfgs, factories: factories}
|
||||
}
|
||||
|
||||
// CreateTracesToTraces creates a Traces connector based on the settings and config.
|
||||
func (b *Builder) CreateTracesToTraces(ctx context.Context, set Settings, next consumer.Traces) (Traces, error) {
|
||||
if next == nil {
|
||||
return nil, errNilNextConsumer
|
||||
}
|
||||
cfg, existsCfg := b.cfgs[set.ID]
|
||||
if !existsCfg {
|
||||
return nil, fmt.Errorf("connector %q is not configured", set.ID)
|
||||
}
|
||||
|
||||
f, existsFactory := b.factories[set.ID.Type()]
|
||||
if !existsFactory {
|
||||
return nil, fmt.Errorf("connector factory not available for: %q", set.ID)
|
||||
}
|
||||
|
||||
logStabilityLevel(set.Logger, f.TracesToTracesStability())
|
||||
return f.CreateTracesToTraces(ctx, set, cfg, next)
|
||||
}
|
||||
|
||||
// CreateTracesToMetrics creates a Traces connector based on the settings and config.
|
||||
func (b *Builder) CreateTracesToMetrics(ctx context.Context, set Settings, next consumer.Metrics) (Traces, error) {
|
||||
if next == nil {
|
||||
return nil, errNilNextConsumer
|
||||
}
|
||||
cfg, existsCfg := b.cfgs[set.ID]
|
||||
if !existsCfg {
|
||||
return nil, fmt.Errorf("connector %q is not configured", set.ID)
|
||||
}
|
||||
|
||||
f, existsFactory := b.factories[set.ID.Type()]
|
||||
if !existsFactory {
|
||||
return nil, fmt.Errorf("connector factory not available for: %q", set.ID)
|
||||
}
|
||||
|
||||
logStabilityLevel(set.Logger, f.TracesToMetricsStability())
|
||||
return f.CreateTracesToMetrics(ctx, set, cfg, next)
|
||||
}
|
||||
|
||||
// CreateTracesToLogs creates a Traces connector based on the settings and config.
|
||||
func (b *Builder) CreateTracesToLogs(ctx context.Context, set Settings, next consumer.Logs) (Traces, error) {
|
||||
if next == nil {
|
||||
return nil, errNilNextConsumer
|
||||
}
|
||||
cfg, existsCfg := b.cfgs[set.ID]
|
||||
if !existsCfg {
|
||||
return nil, fmt.Errorf("connector %q is not configured", set.ID)
|
||||
}
|
||||
|
||||
f, existsFactory := b.factories[set.ID.Type()]
|
||||
if !existsFactory {
|
||||
return nil, fmt.Errorf("connector factory not available for: %q", set.ID)
|
||||
}
|
||||
|
||||
logStabilityLevel(set.Logger, f.TracesToLogsStability())
|
||||
return f.CreateTracesToLogs(ctx, set, cfg, next)
|
||||
}
|
||||
|
||||
// CreateMetricsToTraces creates a Metrics connector based on the settings and config.
|
||||
func (b *Builder) CreateMetricsToTraces(ctx context.Context, set Settings, next consumer.Traces) (Metrics, error) {
|
||||
if next == nil {
|
||||
return nil, errNilNextConsumer
|
||||
}
|
||||
cfg, existsCfg := b.cfgs[set.ID]
|
||||
if !existsCfg {
|
||||
return nil, fmt.Errorf("connector %q is not configured", set.ID)
|
||||
}
|
||||
|
||||
f, existsFactory := b.factories[set.ID.Type()]
|
||||
if !existsFactory {
|
||||
return nil, fmt.Errorf("connector factory not available for: %q", set.ID)
|
||||
}
|
||||
|
||||
logStabilityLevel(set.Logger, f.MetricsToTracesStability())
|
||||
return f.CreateMetricsToTraces(ctx, set, cfg, next)
|
||||
}
|
||||
|
||||
// CreateMetricsToMetrics creates a Metrics connector based on the settings and config.
|
||||
func (b *Builder) CreateMetricsToMetrics(ctx context.Context, set Settings, next consumer.Metrics) (Metrics, error) {
|
||||
if next == nil {
|
||||
return nil, errNilNextConsumer
|
||||
}
|
||||
cfg, existsCfg := b.cfgs[set.ID]
|
||||
if !existsCfg {
|
||||
return nil, fmt.Errorf("connector %q is not configured", set.ID)
|
||||
}
|
||||
|
||||
f, existsFactory := b.factories[set.ID.Type()]
|
||||
if !existsFactory {
|
||||
return nil, fmt.Errorf("connector factory not available for: %q", set.ID)
|
||||
}
|
||||
|
||||
logStabilityLevel(set.Logger, f.MetricsToMetricsStability())
|
||||
return f.CreateMetricsToMetrics(ctx, set, cfg, next)
|
||||
}
|
||||
|
||||
// CreateMetricsToLogs creates a Metrics connector based on the settings and config.
|
||||
func (b *Builder) CreateMetricsToLogs(ctx context.Context, set Settings, next consumer.Logs) (Metrics, error) {
|
||||
if next == nil {
|
||||
return nil, errNilNextConsumer
|
||||
}
|
||||
cfg, existsCfg := b.cfgs[set.ID]
|
||||
if !existsCfg {
|
||||
return nil, fmt.Errorf("connector %q is not configured", set.ID)
|
||||
}
|
||||
|
||||
f, existsFactory := b.factories[set.ID.Type()]
|
||||
if !existsFactory {
|
||||
return nil, fmt.Errorf("connector factory not available for: %q", set.ID)
|
||||
}
|
||||
|
||||
logStabilityLevel(set.Logger, f.MetricsToLogsStability())
|
||||
return f.CreateMetricsToLogs(ctx, set, cfg, next)
|
||||
}
|
||||
|
||||
// CreateLogsToTraces creates a Logs connector based on the settings and config.
|
||||
func (b *Builder) CreateLogsToTraces(ctx context.Context, set Settings, next consumer.Traces) (Logs, error) {
|
||||
if next == nil {
|
||||
return nil, errNilNextConsumer
|
||||
}
|
||||
cfg, existsCfg := b.cfgs[set.ID]
|
||||
if !existsCfg {
|
||||
return nil, fmt.Errorf("connector %q is not configured", set.ID)
|
||||
}
|
||||
|
||||
f, existsFactory := b.factories[set.ID.Type()]
|
||||
if !existsFactory {
|
||||
return nil, fmt.Errorf("connector factory not available for: %q", set.ID)
|
||||
}
|
||||
|
||||
logStabilityLevel(set.Logger, f.LogsToTracesStability())
|
||||
return f.CreateLogsToTraces(ctx, set, cfg, next)
|
||||
}
|
||||
|
||||
// CreateLogsToMetrics creates a Logs connector based on the settings and config.
|
||||
func (b *Builder) CreateLogsToMetrics(ctx context.Context, set Settings, next consumer.Metrics) (Logs, error) {
|
||||
if next == nil {
|
||||
return nil, errNilNextConsumer
|
||||
}
|
||||
cfg, existsCfg := b.cfgs[set.ID]
|
||||
if !existsCfg {
|
||||
return nil, fmt.Errorf("connector %q is not configured", set.ID)
|
||||
}
|
||||
|
||||
f, existsFactory := b.factories[set.ID.Type()]
|
||||
if !existsFactory {
|
||||
return nil, fmt.Errorf("connector factory not available for: %q", set.ID)
|
||||
}
|
||||
|
||||
logStabilityLevel(set.Logger, f.LogsToMetricsStability())
|
||||
return f.CreateLogsToMetrics(ctx, set, cfg, next)
|
||||
}
|
||||
|
||||
// CreateLogsToLogs creates a Logs connector based on the settings and config.
|
||||
func (b *Builder) CreateLogsToLogs(ctx context.Context, set Settings, next consumer.Logs) (Logs, error) {
|
||||
if next == nil {
|
||||
return nil, errNilNextConsumer
|
||||
}
|
||||
cfg, existsCfg := b.cfgs[set.ID]
|
||||
if !existsCfg {
|
||||
return nil, fmt.Errorf("connector %q is not configured", set.ID)
|
||||
}
|
||||
|
||||
f, existsFactory := b.factories[set.ID.Type()]
|
||||
if !existsFactory {
|
||||
return nil, fmt.Errorf("connector factory not available for: %q", set.ID)
|
||||
}
|
||||
|
||||
logStabilityLevel(set.Logger, f.LogsToLogsStability())
|
||||
return f.CreateLogsToLogs(ctx, set, cfg, next)
|
||||
}
|
||||
|
||||
func (b *Builder) IsConfigured(componentID component.ID) bool {
|
||||
_, ok := b.cfgs[componentID]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (b *Builder) Factory(componentType component.Type) component.Factory {
|
||||
return b.factories[componentType]
|
||||
}
|
||||
|
||||
// logStabilityLevel logs the stability level of a component. The log level is set to info for
|
||||
// undefined, unmaintained, deprecated and development. The log level is set to debug
|
||||
// for alpha, beta and stable.
|
||||
func logStabilityLevel(logger *zap.Logger, sl component.StabilityLevel) {
|
||||
if sl >= component.StabilityLevelAlpha {
|
||||
logger.Debug(sl.LogMessage())
|
||||
} else {
|
||||
logger.Info(sl.LogMessage())
|
||||
}
|
||||
}
|
||||
|
|
@ -5,14 +5,11 @@ package connector // import "go.opentelemetry.io/collector/connector"
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/connector/internal"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
"go.opentelemetry.io/collector/consumer/consumertest"
|
||||
|
|
@ -216,247 +213,6 @@ func TestMakeFactoryMap(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestBuilder(t *testing.T) {
|
||||
defaultCfg := struct{}{}
|
||||
factories, err := MakeFactoryMap([]Factory{
|
||||
NewFactory(component.MustNewType("err"), nil),
|
||||
NewFactory(
|
||||
component.MustNewType("all"),
|
||||
func() component.Config { return &defaultCfg },
|
||||
WithTracesToTraces(createTracesToTraces, component.StabilityLevelDevelopment),
|
||||
WithTracesToMetrics(createTracesToMetrics, component.StabilityLevelDevelopment),
|
||||
WithTracesToLogs(createTracesToLogs, component.StabilityLevelDevelopment),
|
||||
WithMetricsToTraces(createMetricsToTraces, component.StabilityLevelAlpha),
|
||||
WithMetricsToMetrics(createMetricsToMetrics, component.StabilityLevelAlpha),
|
||||
WithMetricsToLogs(createMetricsToLogs, component.StabilityLevelAlpha),
|
||||
WithLogsToTraces(createLogsToTraces, component.StabilityLevelDeprecated),
|
||||
WithLogsToMetrics(createLogsToMetrics, component.StabilityLevelDeprecated),
|
||||
WithLogsToLogs(createLogsToLogs, component.StabilityLevelDeprecated),
|
||||
),
|
||||
}...)
|
||||
require.NoError(t, err)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
id component.ID
|
||||
err func(component.DataType, component.DataType) string
|
||||
nextTraces consumer.Traces
|
||||
nextLogs consumer.Logs
|
||||
nextMetrics consumer.Metrics
|
||||
}{
|
||||
{
|
||||
name: "unknown",
|
||||
id: component.MustNewID("unknown"),
|
||||
err: func(component.DataType, component.DataType) string {
|
||||
return "connector factory not available for: \"unknown\""
|
||||
},
|
||||
nextTraces: consumertest.NewNop(),
|
||||
nextLogs: consumertest.NewNop(),
|
||||
nextMetrics: consumertest.NewNop(),
|
||||
},
|
||||
{
|
||||
name: "err",
|
||||
id: component.MustNewID("err"),
|
||||
err: func(expType, rcvType component.DataType) string {
|
||||
return fmt.Sprintf("connector \"err\" cannot connect from %s to %s: telemetry type is not supported", expType, rcvType)
|
||||
},
|
||||
nextTraces: consumertest.NewNop(),
|
||||
nextLogs: consumertest.NewNop(),
|
||||
nextMetrics: consumertest.NewNop(),
|
||||
},
|
||||
{
|
||||
name: "all",
|
||||
id: component.MustNewID("all"),
|
||||
err: func(component.DataType, component.DataType) string {
|
||||
return ""
|
||||
},
|
||||
nextTraces: consumertest.NewNop(),
|
||||
nextLogs: consumertest.NewNop(),
|
||||
nextMetrics: consumertest.NewNop(),
|
||||
},
|
||||
{
|
||||
name: "all/named",
|
||||
id: component.MustNewIDWithName("all", "named"),
|
||||
err: func(component.DataType, component.DataType) string {
|
||||
return ""
|
||||
},
|
||||
nextTraces: consumertest.NewNop(),
|
||||
nextLogs: consumertest.NewNop(),
|
||||
nextMetrics: consumertest.NewNop(),
|
||||
},
|
||||
{
|
||||
name: "no next consumer",
|
||||
id: component.MustNewID("unknown"),
|
||||
err: func(_, _ component.DataType) string {
|
||||
return "nil next Consumer"
|
||||
},
|
||||
nextTraces: nil,
|
||||
nextLogs: nil,
|
||||
nextMetrics: nil,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range testCases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
cfgs := map[component.ID]component.Config{tt.id: defaultCfg}
|
||||
b := NewBuilder(cfgs, factories)
|
||||
|
||||
t2t, err := b.CreateTracesToTraces(context.Background(), createSettings(tt.id), tt.nextTraces)
|
||||
if expectedErr := tt.err(component.DataTypeTraces, component.DataTypeTraces); expectedErr != "" {
|
||||
assert.EqualError(t, err, expectedErr)
|
||||
assert.Nil(t, t2t)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, nopInstance, t2t)
|
||||
}
|
||||
t2m, err := b.CreateTracesToMetrics(context.Background(), createSettings(tt.id), tt.nextMetrics)
|
||||
if expectedErr := tt.err(component.DataTypeTraces, component.DataTypeMetrics); expectedErr != "" {
|
||||
assert.EqualError(t, err, expectedErr)
|
||||
assert.Nil(t, t2m)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, nopInstance, t2m)
|
||||
}
|
||||
t2l, err := b.CreateTracesToLogs(context.Background(), createSettings(tt.id), tt.nextLogs)
|
||||
if expectedErr := tt.err(component.DataTypeTraces, component.DataTypeLogs); expectedErr != "" {
|
||||
assert.EqualError(t, err, expectedErr)
|
||||
assert.Nil(t, t2l)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, nopInstance, t2l)
|
||||
}
|
||||
|
||||
m2t, err := b.CreateMetricsToTraces(context.Background(), createSettings(tt.id), tt.nextTraces)
|
||||
if expectedErr := tt.err(component.DataTypeMetrics, component.DataTypeTraces); expectedErr != "" {
|
||||
assert.EqualError(t, err, expectedErr)
|
||||
assert.Nil(t, m2t)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, nopInstance, m2t)
|
||||
}
|
||||
|
||||
m2m, err := b.CreateMetricsToMetrics(context.Background(), createSettings(tt.id), tt.nextMetrics)
|
||||
if expectedErr := tt.err(component.DataTypeMetrics, component.DataTypeMetrics); expectedErr != "" {
|
||||
assert.EqualError(t, err, expectedErr)
|
||||
assert.Nil(t, m2m)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, nopInstance, m2m)
|
||||
}
|
||||
|
||||
m2l, err := b.CreateMetricsToLogs(context.Background(), createSettings(tt.id), tt.nextLogs)
|
||||
if expectedErr := tt.err(component.DataTypeMetrics, component.DataTypeLogs); expectedErr != "" {
|
||||
assert.EqualError(t, err, expectedErr)
|
||||
assert.Nil(t, m2l)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, nopInstance, m2l)
|
||||
}
|
||||
|
||||
l2t, err := b.CreateLogsToTraces(context.Background(), createSettings(tt.id), tt.nextTraces)
|
||||
if expectedErr := tt.err(component.DataTypeLogs, component.DataTypeTraces); expectedErr != "" {
|
||||
assert.EqualError(t, err, expectedErr)
|
||||
assert.Nil(t, l2t)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, nopInstance, l2t)
|
||||
}
|
||||
|
||||
l2m, err := b.CreateLogsToMetrics(context.Background(), createSettings(tt.id), tt.nextMetrics)
|
||||
if expectedErr := tt.err(component.DataTypeLogs, component.DataTypeMetrics); expectedErr != "" {
|
||||
assert.EqualError(t, err, expectedErr)
|
||||
assert.Nil(t, l2m)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, nopInstance, l2m)
|
||||
}
|
||||
|
||||
l2l, err := b.CreateLogsToLogs(context.Background(), createSettings(tt.id), tt.nextLogs)
|
||||
if expectedErr := tt.err(component.DataTypeLogs, component.DataTypeLogs); expectedErr != "" {
|
||||
assert.EqualError(t, err, expectedErr)
|
||||
assert.Nil(t, l2l)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, nopInstance, l2l)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderMissingConfig(t *testing.T) {
|
||||
defaultCfg := struct{}{}
|
||||
factories, err := MakeFactoryMap([]Factory{
|
||||
NewFactory(
|
||||
component.MustNewType("all"),
|
||||
func() component.Config { return &defaultCfg },
|
||||
WithTracesToTraces(createTracesToTraces, component.StabilityLevelDevelopment),
|
||||
WithTracesToMetrics(createTracesToMetrics, component.StabilityLevelDevelopment),
|
||||
WithTracesToLogs(createTracesToLogs, component.StabilityLevelDevelopment),
|
||||
WithMetricsToTraces(createMetricsToTraces, component.StabilityLevelAlpha),
|
||||
WithMetricsToMetrics(createMetricsToMetrics, component.StabilityLevelAlpha),
|
||||
WithMetricsToLogs(createMetricsToLogs, component.StabilityLevelAlpha),
|
||||
WithLogsToTraces(createLogsToTraces, component.StabilityLevelDeprecated),
|
||||
WithLogsToMetrics(createLogsToMetrics, component.StabilityLevelDeprecated),
|
||||
WithLogsToLogs(createLogsToLogs, component.StabilityLevelDeprecated),
|
||||
),
|
||||
}...)
|
||||
|
||||
require.NoError(t, err)
|
||||
|
||||
bErr := NewBuilder(map[component.ID]component.Config{}, factories)
|
||||
missingID := component.MustNewIDWithName("all", "missing")
|
||||
|
||||
t2t, err := bErr.CreateTracesToTraces(context.Background(), createSettings(missingID), consumertest.NewNop())
|
||||
assert.EqualError(t, err, "connector \"all/missing\" is not configured")
|
||||
assert.Nil(t, t2t)
|
||||
|
||||
t2m, err := bErr.CreateTracesToMetrics(context.Background(), createSettings(missingID), consumertest.NewNop())
|
||||
assert.EqualError(t, err, "connector \"all/missing\" is not configured")
|
||||
assert.Nil(t, t2m)
|
||||
|
||||
t2l, err := bErr.CreateTracesToLogs(context.Background(), createSettings(missingID), consumertest.NewNop())
|
||||
assert.EqualError(t, err, "connector \"all/missing\" is not configured")
|
||||
assert.Nil(t, t2l)
|
||||
|
||||
m2t, err := bErr.CreateMetricsToTraces(context.Background(), createSettings(missingID), consumertest.NewNop())
|
||||
assert.EqualError(t, err, "connector \"all/missing\" is not configured")
|
||||
assert.Nil(t, m2t)
|
||||
|
||||
m2m, err := bErr.CreateMetricsToMetrics(context.Background(), createSettings(missingID), consumertest.NewNop())
|
||||
assert.EqualError(t, err, "connector \"all/missing\" is not configured")
|
||||
assert.Nil(t, m2m)
|
||||
|
||||
m2l, err := bErr.CreateMetricsToLogs(context.Background(), createSettings(missingID), consumertest.NewNop())
|
||||
assert.EqualError(t, err, "connector \"all/missing\" is not configured")
|
||||
assert.Nil(t, m2l)
|
||||
|
||||
l2t, err := bErr.CreateLogsToTraces(context.Background(), createSettings(missingID), consumertest.NewNop())
|
||||
assert.EqualError(t, err, "connector \"all/missing\" is not configured")
|
||||
assert.Nil(t, l2t)
|
||||
|
||||
l2m, err := bErr.CreateLogsToMetrics(context.Background(), createSettings(missingID), consumertest.NewNop())
|
||||
assert.EqualError(t, err, "connector \"all/missing\" is not configured")
|
||||
assert.Nil(t, l2m)
|
||||
|
||||
l2l, err := bErr.CreateLogsToLogs(context.Background(), createSettings(missingID), consumertest.NewNop())
|
||||
assert.EqualError(t, err, "connector \"all/missing\" is not configured")
|
||||
assert.Nil(t, l2l)
|
||||
}
|
||||
|
||||
func TestBuilderGetters(t *testing.T) {
|
||||
factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustNewType("foo"), nil)}...)
|
||||
require.NoError(t, err)
|
||||
|
||||
cfgs := map[component.ID]component.Config{component.MustNewID("foo"): struct{}{}}
|
||||
b := NewBuilder(cfgs, factories)
|
||||
|
||||
assert.True(t, b.IsConfigured(component.MustNewID("foo")))
|
||||
assert.False(t, b.IsConfigured(component.MustNewID("bar")))
|
||||
|
||||
assert.NotNil(t, b.Factory(component.MustNewID("foo").Type()))
|
||||
assert.Nil(t, b.Factory(component.MustNewID("bar").Type()))
|
||||
}
|
||||
|
||||
var nopInstance = &nopConnector{
|
||||
Consumer: consumertest.NewNop(),
|
||||
}
|
||||
|
|
@ -497,11 +253,3 @@ func createLogsToMetrics(context.Context, Settings, component.Config, consumer.M
|
|||
func createLogsToLogs(context.Context, Settings, component.Config, consumer.Logs) (Logs, error) {
|
||||
return nopInstance, nil
|
||||
}
|
||||
|
||||
func createSettings(id component.ID) Settings {
|
||||
return Settings{
|
||||
ID: id,
|
||||
TelemetrySettings: componenttest.NewNopTelemetrySettings(),
|
||||
BuildInfo: component.NewDefaultBuildInfo(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
|
|
@ -14,14 +10,10 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69
|
|||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
||||
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
|
|
@ -31,18 +23,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
|
|||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg=
|
||||
github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
|
||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||
github.com/prometheus/common v0.56.0 h1:UffReloqkBtvtQEYDg2s+uDPGRrJyC6vZWPGXf6OhPY=
|
||||
github.com/prometheus/common v0.56.0/go.mod h1:7uRPFSUTbfZWsJ7MHY56sqt7hLQu3bxXHDnNhl8E9qI=
|
||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
|
|
@ -53,14 +35,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
|
|||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw=
|
||||
go.opentelemetry.io/otel v1.29.0/go.mod h1:N/WtXPs1CNCUEx+Agz5uouwCba+i+bJGFicT8SR4NP8=
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.51.0 h1:G7uexXb/K3T+T9fNLCCKncweEtNEBMTO+46hKX5EdKw=
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.51.0/go.mod h1:v0mFe5Kk7woIh938mrZBJBmENYquyA0IICrlYm4Y0t4=
|
||||
go.opentelemetry.io/otel/metric v1.29.0 h1:vPf/HFWTNkPu1aYeIsc98l4ktOQaL6LeSoeV2g+8YLc=
|
||||
go.opentelemetry.io/otel/metric v1.29.0/go.mod h1:auu/QWieFVWx+DmQOUMgj0F8LHWdgalxXqvp7BII/W8=
|
||||
go.opentelemetry.io/otel/sdk v1.29.0 h1:vkqKjk7gwhS8VaWb0POZKmIEDimRCMsopNYnriHyryo=
|
||||
go.opentelemetry.io/otel/sdk v1.29.0/go.mod h1:pM8Dx5WKnvxLCb+8lG1PRNIDxu9g9b9g59Qr7hfAAok=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.29.0 h1:K2CfmJohnRgvZ9UAj2/FhIf/okdWcNdBwe1m8xFXiSY=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.29.0/go.mod h1:6zZLdCl2fkauYoZIOn/soQIDSWFmNSRcICarHfuhNJQ=
|
||||
go.opentelemetry.io/otel/trace v1.29.0 h1:J/8ZNK4XgR7a21DZUAsbF8pZ5Jcw1VhACmnYt39JTi4=
|
||||
go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
|
|
|
|||
|
|
@ -123,18 +123,3 @@ type nopConnector struct {
|
|||
component.ShutdownFunc
|
||||
consumertest.Consumer
|
||||
}
|
||||
|
||||
// NewNopBuilder returns a connector.Builder that constructs nop receivers.
|
||||
//
|
||||
// Deprecated: [v0.108.0] this builder is being internalized within the service module,
|
||||
// and will be removed soon.
|
||||
func NewNopBuilder() *connector.Builder {
|
||||
nopFactory := NewNopFactory()
|
||||
// Use a different ID than receivertest and exportertest to avoid ambiguous
|
||||
// configuration scenarios. Ambiguous IDs are detected in the 'otelcol' package,
|
||||
// but lower level packages such as 'service' assume that IDs are disambiguated.
|
||||
connID := component.NewIDWithName(nopType, "conn")
|
||||
return connector.NewBuilder(
|
||||
map[component.ID]component.Config{connID: nopFactory.CreateDefaultConfig()},
|
||||
map[component.Type]connector.Factory{nopType: nopFactory})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,67 +122,3 @@ func TestNewNopConnectorFactory(t *testing.T) {
|
|||
assert.NoError(t, profilesToProfiles.ConsumeProfiles(context.Background(), pprofile.NewProfiles()))
|
||||
assert.NoError(t, profilesToProfiles.Shutdown(context.Background()))
|
||||
}
|
||||
|
||||
func TestNewNopBuilder(t *testing.T) {
|
||||
builder := NewNopBuilder()
|
||||
require.NotNil(t, builder)
|
||||
|
||||
factory := NewNopFactory()
|
||||
cfg := factory.CreateDefaultConfig()
|
||||
set := NewNopSettings()
|
||||
set.ID = component.NewIDWithName(nopType, "conn")
|
||||
|
||||
tracesToTraces, err := factory.CreateTracesToTraces(context.Background(), set, cfg, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
bTracesToTraces, err := builder.CreateTracesToTraces(context.Background(), set, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
assert.IsType(t, tracesToTraces, bTracesToTraces)
|
||||
|
||||
tracesToMetrics, err := factory.CreateTracesToMetrics(context.Background(), set, cfg, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
bTracesToMetrics, err := builder.CreateTracesToMetrics(context.Background(), set, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
assert.IsType(t, tracesToMetrics, bTracesToMetrics)
|
||||
|
||||
tracesToLogs, err := factory.CreateTracesToLogs(context.Background(), set, cfg, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
bTracesToLogs, err := builder.CreateTracesToLogs(context.Background(), set, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
assert.IsType(t, tracesToLogs, bTracesToLogs)
|
||||
|
||||
metricsToTraces, err := factory.CreateMetricsToTraces(context.Background(), set, cfg, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
bMetricsToTraces, err := builder.CreateMetricsToTraces(context.Background(), set, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
assert.IsType(t, metricsToTraces, bMetricsToTraces)
|
||||
|
||||
metricsToMetrics, err := factory.CreateMetricsToMetrics(context.Background(), set, cfg, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
bMetricsToMetrics, err := builder.CreateMetricsToMetrics(context.Background(), set, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
assert.IsType(t, metricsToMetrics, bMetricsToMetrics)
|
||||
|
||||
metricsToLogs, err := factory.CreateMetricsToLogs(context.Background(), set, cfg, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
bMetricsToLogs, err := builder.CreateMetricsToLogs(context.Background(), set, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
assert.IsType(t, metricsToLogs, bMetricsToLogs)
|
||||
|
||||
logsToTraces, err := factory.CreateLogsToTraces(context.Background(), set, cfg, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
bLogsToTraces, err := builder.CreateLogsToTraces(context.Background(), set, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
assert.IsType(t, logsToTraces, bLogsToTraces)
|
||||
|
||||
logsToMetrics, err := factory.CreateLogsToMetrics(context.Background(), set, cfg, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
bLogsToMetrics, err := builder.CreateLogsToMetrics(context.Background(), set, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
assert.IsType(t, logsToMetrics, bLogsToMetrics)
|
||||
|
||||
logsToLogs, err := factory.CreateLogsToLogs(context.Background(), set, cfg, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
bLogsToLogs, err := builder.CreateLogsToLogs(context.Background(), set, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
assert.IsType(t, logsToLogs, bLogsToLogs)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ require (
|
|||
go.opentelemetry.io/collector/pdata/testdata v0.108.1
|
||||
go.uber.org/goleak v1.3.0
|
||||
go.uber.org/multierr v1.11.0
|
||||
go.uber.org/zap v1.27.0
|
||||
)
|
||||
|
||||
require (
|
||||
|
|
@ -44,6 +43,7 @@ require (
|
|||
go.opentelemetry.io/otel/sdk v1.29.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk/metric v1.29.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.29.0 // indirect
|
||||
go.uber.org/zap v1.27.0 // indirect
|
||||
golang.org/x/net v0.28.0 // indirect
|
||||
golang.org/x/sys v0.24.0 // indirect
|
||||
golang.org/x/text v0.17.0 // indirect
|
||||
|
|
|
|||
|
|
@ -1,93 +0,0 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package exporter // import "go.opentelemetry.io/collector/exporter"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
)
|
||||
|
||||
// Builder exporter is a helper struct that given a set of Configs and Factories helps with creating exporters.
|
||||
//
|
||||
// Deprecated: [v0.108.0] this builder is being internalized within the service module,
|
||||
// and will be removed soon.
|
||||
type Builder struct {
|
||||
cfgs map[component.ID]component.Config
|
||||
factories map[component.Type]Factory
|
||||
}
|
||||
|
||||
// NewBuilder creates a new exporter.Builder to help with creating components form a set of configs and factories.
|
||||
//
|
||||
// Deprecated: [v0.108.0] this builder is being internalized within the service module,
|
||||
// and will be removed soon.
|
||||
func NewBuilder(cfgs map[component.ID]component.Config, factories map[component.Type]Factory) *Builder {
|
||||
return &Builder{cfgs: cfgs, factories: factories}
|
||||
}
|
||||
|
||||
// CreateTraces creates a Traces exporter based on the settings and config.
|
||||
func (b *Builder) CreateTraces(ctx context.Context, set Settings) (Traces, error) {
|
||||
cfg, existsCfg := b.cfgs[set.ID]
|
||||
if !existsCfg {
|
||||
return nil, fmt.Errorf("exporter %q is not configured", set.ID)
|
||||
}
|
||||
|
||||
f, existsFactory := b.factories[set.ID.Type()]
|
||||
if !existsFactory {
|
||||
return nil, fmt.Errorf("exporter factory not available for: %q", set.ID)
|
||||
}
|
||||
|
||||
logStabilityLevel(set.Logger, f.TracesExporterStability())
|
||||
return f.CreateTracesExporter(ctx, set, cfg)
|
||||
}
|
||||
|
||||
// CreateMetrics creates a Metrics exporter based on the settings and config.
|
||||
func (b *Builder) CreateMetrics(ctx context.Context, set Settings) (Metrics, error) {
|
||||
cfg, existsCfg := b.cfgs[set.ID]
|
||||
if !existsCfg {
|
||||
return nil, fmt.Errorf("exporter %q is not configured", set.ID)
|
||||
}
|
||||
|
||||
f, existsFactory := b.factories[set.ID.Type()]
|
||||
if !existsFactory {
|
||||
return nil, fmt.Errorf("exporter factory not available for: %q", set.ID)
|
||||
}
|
||||
|
||||
logStabilityLevel(set.Logger, f.MetricsExporterStability())
|
||||
return f.CreateMetricsExporter(ctx, set, cfg)
|
||||
}
|
||||
|
||||
// CreateLogs creates a Logs exporter based on the settings and config.
|
||||
func (b *Builder) CreateLogs(ctx context.Context, set Settings) (Logs, error) {
|
||||
cfg, existsCfg := b.cfgs[set.ID]
|
||||
if !existsCfg {
|
||||
return nil, fmt.Errorf("exporter %q is not configured", set.ID)
|
||||
}
|
||||
|
||||
f, existsFactory := b.factories[set.ID.Type()]
|
||||
if !existsFactory {
|
||||
return nil, fmt.Errorf("exporter factory not available for: %q", set.ID)
|
||||
}
|
||||
|
||||
logStabilityLevel(set.Logger, f.LogsExporterStability())
|
||||
return f.CreateLogsExporter(ctx, set, cfg)
|
||||
}
|
||||
|
||||
func (b *Builder) Factory(componentType component.Type) component.Factory {
|
||||
return b.factories[componentType]
|
||||
}
|
||||
|
||||
// logStabilityLevel logs the stability level of a component. The log level is set to info for
|
||||
// undefined, unmaintained, deprecated and development. The log level is set to debug
|
||||
// for alpha, beta and stable.
|
||||
func logStabilityLevel(logger *zap.Logger, sl component.StabilityLevel) {
|
||||
if sl >= component.StabilityLevelAlpha {
|
||||
logger.Debug(sl.LogMessage())
|
||||
} else {
|
||||
logger.Info(sl.LogMessage())
|
||||
}
|
||||
}
|
||||
|
|
@ -8,10 +8,8 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/consumer/consumertest"
|
||||
)
|
||||
|
||||
|
|
@ -94,121 +92,6 @@ func TestMakeFactoryMap(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestBuilder(t *testing.T) {
|
||||
defaultCfg := struct{}{}
|
||||
factories, err := MakeFactoryMap([]Factory{
|
||||
NewFactory(component.MustNewType("err"), nil),
|
||||
NewFactory(
|
||||
component.MustNewType("all"),
|
||||
func() component.Config { return &defaultCfg },
|
||||
WithTraces(createTraces, component.StabilityLevelDevelopment),
|
||||
WithMetrics(createMetrics, component.StabilityLevelAlpha),
|
||||
WithLogs(createLogs, component.StabilityLevelDeprecated),
|
||||
),
|
||||
}...)
|
||||
require.NoError(t, err)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
id component.ID
|
||||
err string
|
||||
}{
|
||||
{
|
||||
name: "unknown",
|
||||
id: component.MustNewID("unknown"),
|
||||
err: "exporter factory not available for: \"unknown\"",
|
||||
},
|
||||
{
|
||||
name: "err",
|
||||
id: component.MustNewID("err"),
|
||||
err: "telemetry type is not supported",
|
||||
},
|
||||
{
|
||||
name: "all",
|
||||
id: component.MustNewID("all"),
|
||||
},
|
||||
{
|
||||
name: "all/named",
|
||||
id: component.MustNewIDWithName("all", "named"),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range testCases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
cfgs := map[component.ID]component.Config{tt.id: defaultCfg}
|
||||
b := NewBuilder(cfgs, factories)
|
||||
|
||||
te, err := b.CreateTraces(context.Background(), createSettings(tt.id))
|
||||
if tt.err != "" {
|
||||
assert.EqualError(t, err, tt.err)
|
||||
assert.Nil(t, te)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, nopInstance, te)
|
||||
}
|
||||
|
||||
me, err := b.CreateMetrics(context.Background(), createSettings(tt.id))
|
||||
if tt.err != "" {
|
||||
assert.EqualError(t, err, tt.err)
|
||||
assert.Nil(t, me)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, nopInstance, me)
|
||||
}
|
||||
|
||||
le, err := b.CreateLogs(context.Background(), createSettings(tt.id))
|
||||
if tt.err != "" {
|
||||
assert.EqualError(t, err, tt.err)
|
||||
assert.Nil(t, le)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, nopInstance, le)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderMissingConfig(t *testing.T) {
|
||||
defaultCfg := struct{}{}
|
||||
factories, err := MakeFactoryMap([]Factory{
|
||||
NewFactory(
|
||||
component.MustNewType("all"),
|
||||
func() component.Config { return &defaultCfg },
|
||||
WithTraces(createTraces, component.StabilityLevelDevelopment),
|
||||
WithMetrics(createMetrics, component.StabilityLevelAlpha),
|
||||
WithLogs(createLogs, component.StabilityLevelDeprecated),
|
||||
),
|
||||
}...)
|
||||
|
||||
require.NoError(t, err)
|
||||
|
||||
bErr := NewBuilder(map[component.ID]component.Config{}, factories)
|
||||
missingID := component.MustNewIDWithName("all", "missing")
|
||||
|
||||
te, err := bErr.CreateTraces(context.Background(), createSettings(missingID))
|
||||
assert.EqualError(t, err, "exporter \"all/missing\" is not configured")
|
||||
assert.Nil(t, te)
|
||||
|
||||
me, err := bErr.CreateMetrics(context.Background(), createSettings(missingID))
|
||||
assert.EqualError(t, err, "exporter \"all/missing\" is not configured")
|
||||
assert.Nil(t, me)
|
||||
|
||||
le, err := bErr.CreateLogs(context.Background(), createSettings(missingID))
|
||||
assert.EqualError(t, err, "exporter \"all/missing\" is not configured")
|
||||
assert.Nil(t, le)
|
||||
}
|
||||
|
||||
func TestBuilderFactory(t *testing.T) {
|
||||
factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustNewType("foo"), nil)}...)
|
||||
require.NoError(t, err)
|
||||
|
||||
cfgs := map[component.ID]component.Config{component.MustNewID("foo"): struct{}{}}
|
||||
b := NewBuilder(cfgs, factories)
|
||||
|
||||
assert.NotNil(t, b.Factory(component.MustNewID("foo").Type()))
|
||||
assert.Nil(t, b.Factory(component.MustNewID("bar").Type()))
|
||||
}
|
||||
|
||||
var nopInstance = &nopExporter{
|
||||
Consumer: consumertest.NewNop(),
|
||||
}
|
||||
|
|
@ -231,11 +114,3 @@ func createMetrics(context.Context, Settings, component.Config) (Metrics, error)
|
|||
func createLogs(context.Context, Settings, component.Config) (Logs, error) {
|
||||
return nopInstance, nil
|
||||
}
|
||||
|
||||
func createSettings(id component.ID) Settings {
|
||||
return Settings{
|
||||
ID: id,
|
||||
TelemetrySettings: componenttest.NewNopTelemetrySettings(),
|
||||
BuildInfo: component.NewDefaultBuildInfo(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
|
|
@ -14,14 +10,10 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69
|
|||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
||||
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
|
|
@ -31,18 +23,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
|
|||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg=
|
||||
github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
|
||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||
github.com/prometheus/common v0.56.0 h1:UffReloqkBtvtQEYDg2s+uDPGRrJyC6vZWPGXf6OhPY=
|
||||
github.com/prometheus/common v0.56.0/go.mod h1:7uRPFSUTbfZWsJ7MHY56sqt7hLQu3bxXHDnNhl8E9qI=
|
||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
|
|
@ -53,14 +35,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
|
|||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw=
|
||||
go.opentelemetry.io/otel v1.29.0/go.mod h1:N/WtXPs1CNCUEx+Agz5uouwCba+i+bJGFicT8SR4NP8=
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.51.0 h1:G7uexXb/K3T+T9fNLCCKncweEtNEBMTO+46hKX5EdKw=
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.51.0/go.mod h1:v0mFe5Kk7woIh938mrZBJBmENYquyA0IICrlYm4Y0t4=
|
||||
go.opentelemetry.io/otel/metric v1.29.0 h1:vPf/HFWTNkPu1aYeIsc98l4ktOQaL6LeSoeV2g+8YLc=
|
||||
go.opentelemetry.io/otel/metric v1.29.0/go.mod h1:auu/QWieFVWx+DmQOUMgj0F8LHWdgalxXqvp7BII/W8=
|
||||
go.opentelemetry.io/otel/sdk v1.29.0 h1:vkqKjk7gwhS8VaWb0POZKmIEDimRCMsopNYnriHyryo=
|
||||
go.opentelemetry.io/otel/sdk v1.29.0/go.mod h1:pM8Dx5WKnvxLCb+8lG1PRNIDxu9g9b9g59Qr7hfAAok=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.29.0 h1:K2CfmJohnRgvZ9UAj2/FhIf/okdWcNdBwe1m8xFXiSY=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.29.0/go.mod h1:6zZLdCl2fkauYoZIOn/soQIDSWFmNSRcICarHfuhNJQ=
|
||||
go.opentelemetry.io/otel/trace v1.29.0 h1:J/8ZNK4XgR7a21DZUAsbF8pZ5Jcw1VhACmnYt39JTi4=
|
||||
go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
|
|
|
|||
|
|
@ -66,14 +66,3 @@ type nopExporter struct {
|
|||
component.ShutdownFunc
|
||||
consumertest.Consumer
|
||||
}
|
||||
|
||||
// NewNopBuilder returns an exporter.Builder that constructs nop receivers.
|
||||
//
|
||||
// Deprecated: [v0.108.0] this builder is being internalized within the service module,
|
||||
// and will be removed soon.
|
||||
func NewNopBuilder() *exporter.Builder {
|
||||
nopFactory := NewNopFactory()
|
||||
return exporter.NewBuilder(
|
||||
map[component.ID]component.Config{component.NewID(nopType): nopFactory.CreateDefaultConfig()},
|
||||
map[component.Type]exporter.Factory{nopType: nopFactory})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,31 +49,3 @@ func TestNewNopFactory(t *testing.T) {
|
|||
assert.NoError(t, profiles.ConsumeProfiles(context.Background(), pprofile.NewProfiles()))
|
||||
assert.NoError(t, profiles.Shutdown(context.Background()))
|
||||
}
|
||||
|
||||
func TestNewNopBuilder(t *testing.T) {
|
||||
builder := NewNopBuilder()
|
||||
require.NotNil(t, builder)
|
||||
|
||||
factory := NewNopFactory()
|
||||
cfg := factory.CreateDefaultConfig()
|
||||
set := NewNopSettings()
|
||||
set.ID = component.NewID(nopType)
|
||||
|
||||
traces, err := factory.CreateTracesExporter(context.Background(), set, cfg)
|
||||
require.NoError(t, err)
|
||||
bTraces, err := builder.CreateTraces(context.Background(), set)
|
||||
require.NoError(t, err)
|
||||
assert.IsType(t, traces, bTraces)
|
||||
|
||||
metrics, err := factory.CreateMetricsExporter(context.Background(), set, cfg)
|
||||
require.NoError(t, err)
|
||||
bMetrics, err := builder.CreateMetrics(context.Background(), set)
|
||||
require.NoError(t, err)
|
||||
assert.IsType(t, metrics, bMetrics)
|
||||
|
||||
logs, err := factory.CreateLogsExporter(context.Background(), set, cfg)
|
||||
require.NoError(t, err)
|
||||
bLogs, err := builder.CreateLogs(context.Background(), set)
|
||||
require.NoError(t, err)
|
||||
assert.IsType(t, logs, bLogs)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,45 +137,3 @@ func MakeFactoryMap(factories ...Factory) (map[component.Type]Factory, error) {
|
|||
}
|
||||
return fMap, nil
|
||||
}
|
||||
|
||||
// Builder extension is a helper struct that given a set of Configs and Factories helps with creating extensions.
|
||||
//
|
||||
// Deprecated: [v0.108.0] this builder is being internalized within the service module,
|
||||
// and will be removed soon.
|
||||
type Builder struct {
|
||||
cfgs map[component.ID]component.Config
|
||||
factories map[component.Type]Factory
|
||||
}
|
||||
|
||||
// NewBuilder creates a new extension.Builder to help with creating components form a set of configs and factories.
|
||||
//
|
||||
// Deprecated: [v0.108.0] this builder is being internalized within the service module,
|
||||
// and will be removed soon.
|
||||
func NewBuilder(cfgs map[component.ID]component.Config, factories map[component.Type]Factory) *Builder {
|
||||
return &Builder{cfgs: cfgs, factories: factories}
|
||||
}
|
||||
|
||||
// Create creates an extension based on the settings and configs available.
|
||||
func (b *Builder) Create(ctx context.Context, set Settings) (Extension, error) {
|
||||
cfg, existsCfg := b.cfgs[set.ID]
|
||||
if !existsCfg {
|
||||
return nil, fmt.Errorf("extension %q is not configured", set.ID)
|
||||
}
|
||||
|
||||
f, existsFactory := b.factories[set.ID.Type()]
|
||||
if !existsFactory {
|
||||
return nil, fmt.Errorf("extension factory not available for: %q", set.ID)
|
||||
}
|
||||
|
||||
sl := f.ExtensionStability()
|
||||
if sl >= component.StabilityLevelAlpha {
|
||||
set.Logger.Debug(sl.LogMessage())
|
||||
} else {
|
||||
set.Logger.Info(sl.LogMessage())
|
||||
}
|
||||
return f.CreateExtension(ctx, set, cfg)
|
||||
}
|
||||
|
||||
func (b *Builder) Factory(componentType component.Type) component.Factory {
|
||||
return b.factories[componentType]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,8 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
)
|
||||
|
||||
type nopExtension struct {
|
||||
|
|
@ -77,71 +75,3 @@ func TestMakeFactoryMap(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilder(t *testing.T) {
|
||||
var testType = component.MustNewType("test")
|
||||
defaultCfg := struct{}{}
|
||||
testID := component.NewID(testType)
|
||||
unknownID := component.MustNewID("unknown")
|
||||
|
||||
factories, err := MakeFactoryMap([]Factory{
|
||||
NewFactory(
|
||||
testType,
|
||||
func() component.Config { return &defaultCfg },
|
||||
func(_ context.Context, settings Settings, _ component.Config) (Extension, error) {
|
||||
return nopExtension{Settings: settings}, nil
|
||||
},
|
||||
component.StabilityLevelDevelopment),
|
||||
}...)
|
||||
require.NoError(t, err)
|
||||
|
||||
cfgs := map[component.ID]component.Config{testID: defaultCfg, unknownID: defaultCfg}
|
||||
b := NewBuilder(cfgs, factories)
|
||||
|
||||
testIDSettings := createSettings(testID)
|
||||
testIDModuleInfo := ModuleInfo{
|
||||
Extension: map[component.Type]string{
|
||||
testType: "go.opentelemetry.io/collector/extension/extensiontest v1.2.3",
|
||||
},
|
||||
}
|
||||
testIDSettings.ModuleInfo = testIDModuleInfo
|
||||
|
||||
e, err := b.Create(context.Background(), testIDSettings)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, e)
|
||||
|
||||
// Check that the extension has access to the resource attributes.
|
||||
nop, ok := e.(nopExtension)
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, nop.Settings.Resource.Attributes().Len(), 0)
|
||||
|
||||
// Check that the extension has access to the module info.
|
||||
assert.Equal(t, testIDModuleInfo, nop.ModuleInfo)
|
||||
|
||||
missingType, err := b.Create(context.Background(), createSettings(unknownID))
|
||||
assert.EqualError(t, err, "extension factory not available for: \"unknown\"")
|
||||
assert.Nil(t, missingType)
|
||||
|
||||
missingCfg, err := b.Create(context.Background(), createSettings(component.NewIDWithName(testType, "foo")))
|
||||
assert.EqualError(t, err, "extension \"test/foo\" is not configured")
|
||||
assert.Nil(t, missingCfg)
|
||||
}
|
||||
|
||||
func TestBuilderFactory(t *testing.T) {
|
||||
factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustNewType("foo"), nil, nil, component.StabilityLevelDevelopment)}...)
|
||||
require.NoError(t, err)
|
||||
|
||||
cfgs := map[component.ID]component.Config{component.MustNewID("foo"): struct{}{}}
|
||||
b := NewBuilder(cfgs, factories)
|
||||
|
||||
assert.NotNil(t, b.Factory(component.MustNewID("foo").Type()))
|
||||
assert.Nil(t, b.Factory(component.MustNewID("bar").Type()))
|
||||
}
|
||||
|
||||
func createSettings(id component.ID) Settings {
|
||||
return Settings{
|
||||
ID: id,
|
||||
TelemetrySettings: componenttest.NewNopTelemetrySettings(),
|
||||
BuildInfo: component.NewDefaultBuildInfo(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,14 +46,3 @@ type nopExtension struct {
|
|||
component.StartFunc
|
||||
component.ShutdownFunc
|
||||
}
|
||||
|
||||
// NewNopBuilder returns a extension.Builder that constructs nop extension.
|
||||
//
|
||||
// Deprecated: [v0.108.0] this builder is being internalized within the service module,
|
||||
// and will be removed soon.
|
||||
func NewNopBuilder() *extension.Builder {
|
||||
nopFactory := NewNopFactory()
|
||||
return extension.NewBuilder(
|
||||
map[component.ID]component.Config{component.NewID(nopType): nopFactory.CreateDefaultConfig()},
|
||||
map[component.Type]extension.Factory{nopType: nopFactory})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,19 +26,3 @@ func TestNewNopFactory(t *testing.T) {
|
|||
assert.NoError(t, traces.Start(context.Background(), componenttest.NewNopHost()))
|
||||
assert.NoError(t, traces.Shutdown(context.Background()))
|
||||
}
|
||||
|
||||
func TestNewNopBuilder(t *testing.T) {
|
||||
builder := NewNopBuilder()
|
||||
require.NotNil(t, builder)
|
||||
|
||||
factory := NewNopFactory()
|
||||
cfg := factory.CreateDefaultConfig()
|
||||
set := NewNopSettings()
|
||||
set.ID = component.NewID(nopType)
|
||||
|
||||
ext, err := factory.CreateExtension(context.Background(), set, cfg)
|
||||
require.NoError(t, err)
|
||||
bExt, err := builder.Create(context.Background(), set)
|
||||
require.NoError(t, err)
|
||||
assert.IsType(t, ext, bExt)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,106 +0,0 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package processor // import "go.opentelemetry.io/collector/processor"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
)
|
||||
|
||||
var errNilNextConsumer = errors.New("nil next Consumer")
|
||||
|
||||
// Builder processor is a helper struct that given a set of Configs and Factories helps with creating processors.
|
||||
//
|
||||
// Deprecated: [v0.108.0] this builder is being internalized within the service module,
|
||||
// and will be removed soon.
|
||||
type Builder struct {
|
||||
cfgs map[component.ID]component.Config
|
||||
factories map[component.Type]Factory
|
||||
}
|
||||
|
||||
// NewBuilder creates a new processor.Builder to help with creating components form a set of configs and factories.
|
||||
//
|
||||
// Deprecated: [v0.108.0] this builder is being internalized within the service module,
|
||||
// and will be removed soon.
|
||||
func NewBuilder(cfgs map[component.ID]component.Config, factories map[component.Type]Factory) *Builder {
|
||||
return &Builder{cfgs: cfgs, factories: factories}
|
||||
}
|
||||
|
||||
// CreateTraces creates a Traces processor based on the settings and config.
|
||||
func (b *Builder) CreateTraces(ctx context.Context, set Settings, next consumer.Traces) (Traces, error) {
|
||||
if next == nil {
|
||||
return nil, errNilNextConsumer
|
||||
}
|
||||
cfg, existsCfg := b.cfgs[set.ID]
|
||||
if !existsCfg {
|
||||
return nil, fmt.Errorf("processor %q is not configured", set.ID)
|
||||
}
|
||||
|
||||
f, existsFactory := b.factories[set.ID.Type()]
|
||||
if !existsFactory {
|
||||
return nil, fmt.Errorf("processor factory not available for: %q", set.ID)
|
||||
}
|
||||
|
||||
logStabilityLevel(set.Logger, f.TracesProcessorStability())
|
||||
return f.CreateTracesProcessor(ctx, set, cfg, next)
|
||||
}
|
||||
|
||||
// CreateMetrics creates a Metrics processor based on the settings and config.
|
||||
func (b *Builder) CreateMetrics(ctx context.Context, set Settings, next consumer.Metrics) (Metrics, error) {
|
||||
if next == nil {
|
||||
return nil, errNilNextConsumer
|
||||
}
|
||||
cfg, existsCfg := b.cfgs[set.ID]
|
||||
if !existsCfg {
|
||||
return nil, fmt.Errorf("processor %q is not configured", set.ID)
|
||||
}
|
||||
|
||||
f, existsFactory := b.factories[set.ID.Type()]
|
||||
if !existsFactory {
|
||||
return nil, fmt.Errorf("processor factory not available for: %q", set.ID)
|
||||
}
|
||||
|
||||
logStabilityLevel(set.Logger, f.MetricsProcessorStability())
|
||||
return f.CreateMetricsProcessor(ctx, set, cfg, next)
|
||||
}
|
||||
|
||||
// CreateLogs creates a Logs processor based on the settings and config.
|
||||
func (b *Builder) CreateLogs(ctx context.Context, set Settings, next consumer.Logs) (Logs, error) {
|
||||
if next == nil {
|
||||
return nil, errNilNextConsumer
|
||||
}
|
||||
cfg, existsCfg := b.cfgs[set.ID]
|
||||
if !existsCfg {
|
||||
return nil, fmt.Errorf("processor %q is not configured", set.ID)
|
||||
}
|
||||
|
||||
f, existsFactory := b.factories[set.ID.Type()]
|
||||
if !existsFactory {
|
||||
return nil, fmt.Errorf("processor factory not available for: %q", set.ID)
|
||||
}
|
||||
|
||||
logStabilityLevel(set.Logger, f.LogsProcessorStability())
|
||||
return f.CreateLogsProcessor(ctx, set, cfg, next)
|
||||
}
|
||||
|
||||
func (b *Builder) Factory(componentType component.Type) component.Factory {
|
||||
return b.factories[componentType]
|
||||
}
|
||||
|
||||
// logStabilityLevel logs the stability level of a component. The log level is set to info for
|
||||
// undefined, unmaintained, deprecated and development. The log level is set to debug
|
||||
// for alpha, beta and stable.
|
||||
func logStabilityLevel(logger *zap.Logger, sl component.StabilityLevel) {
|
||||
if sl >= component.StabilityLevelAlpha {
|
||||
logger.Debug(sl.LogMessage())
|
||||
} else {
|
||||
logger.Info(sl.LogMessage())
|
||||
}
|
||||
}
|
||||
|
|
@ -21,7 +21,6 @@ require (
|
|||
go.opentelemetry.io/otel/sdk/metric v1.29.0
|
||||
go.opentelemetry.io/otel/trace v1.29.0
|
||||
go.uber.org/goleak v1.3.0
|
||||
go.uber.org/zap v1.27.0
|
||||
)
|
||||
|
||||
require (
|
||||
|
|
@ -44,6 +43,7 @@ require (
|
|||
go.opentelemetry.io/otel/exporters/prometheus v0.51.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.29.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.27.0 // indirect
|
||||
golang.org/x/net v0.28.0 // indirect
|
||||
golang.org/x/sys v0.24.0 // indirect
|
||||
golang.org/x/text v0.17.0 // indirect
|
||||
|
|
|
|||
|
|
@ -8,10 +8,8 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
"go.opentelemetry.io/collector/consumer/consumertest"
|
||||
)
|
||||
|
|
@ -95,144 +93,6 @@ func TestMakeFactoryMap(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestBuilder(t *testing.T) {
|
||||
defaultCfg := struct{}{}
|
||||
factories, err := MakeFactoryMap([]Factory{
|
||||
NewFactory(component.MustNewType("err"), nil),
|
||||
NewFactory(
|
||||
component.MustNewType("all"),
|
||||
func() component.Config { return &defaultCfg },
|
||||
WithTraces(createTraces, component.StabilityLevelDevelopment),
|
||||
WithMetrics(createMetrics, component.StabilityLevelAlpha),
|
||||
WithLogs(createLogs, component.StabilityLevelDeprecated),
|
||||
),
|
||||
}...)
|
||||
require.NoError(t, err)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
id component.ID
|
||||
err string
|
||||
nextTraces consumer.Traces
|
||||
nextLogs consumer.Logs
|
||||
nextMetrics consumer.Metrics
|
||||
}{
|
||||
{
|
||||
name: "unknown",
|
||||
id: component.MustNewID("unknown"),
|
||||
err: "processor factory not available for: \"unknown\"",
|
||||
nextTraces: consumertest.NewNop(),
|
||||
nextLogs: consumertest.NewNop(),
|
||||
nextMetrics: consumertest.NewNop(),
|
||||
},
|
||||
{
|
||||
name: "err",
|
||||
id: component.MustNewID("err"),
|
||||
err: "telemetry type is not supported",
|
||||
nextTraces: consumertest.NewNop(),
|
||||
nextLogs: consumertest.NewNop(),
|
||||
nextMetrics: consumertest.NewNop(),
|
||||
},
|
||||
{
|
||||
name: "all",
|
||||
id: component.MustNewID("all"),
|
||||
nextTraces: consumertest.NewNop(),
|
||||
nextLogs: consumertest.NewNop(),
|
||||
nextMetrics: consumertest.NewNop(),
|
||||
},
|
||||
{
|
||||
name: "all/named",
|
||||
id: component.MustNewIDWithName("all", "named"),
|
||||
nextTraces: consumertest.NewNop(),
|
||||
nextLogs: consumertest.NewNop(),
|
||||
nextMetrics: consumertest.NewNop(),
|
||||
},
|
||||
{
|
||||
name: "no next consumer",
|
||||
id: component.MustNewID("unknown"),
|
||||
err: "nil next Consumer",
|
||||
nextTraces: nil,
|
||||
nextLogs: nil,
|
||||
nextMetrics: nil,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range testCases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
cfgs := map[component.ID]component.Config{tt.id: defaultCfg}
|
||||
b := NewBuilder(cfgs, factories)
|
||||
|
||||
te, err := b.CreateTraces(context.Background(), createSettings(tt.id), tt.nextTraces)
|
||||
if tt.err != "" {
|
||||
assert.EqualError(t, err, tt.err)
|
||||
assert.Nil(t, te)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, nopInstance, te)
|
||||
}
|
||||
|
||||
me, err := b.CreateMetrics(context.Background(), createSettings(tt.id), tt.nextMetrics)
|
||||
if tt.err != "" {
|
||||
assert.EqualError(t, err, tt.err)
|
||||
assert.Nil(t, me)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, nopInstance, me)
|
||||
}
|
||||
|
||||
le, err := b.CreateLogs(context.Background(), createSettings(tt.id), tt.nextLogs)
|
||||
if tt.err != "" {
|
||||
assert.EqualError(t, err, tt.err)
|
||||
assert.Nil(t, le)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, nopInstance, le)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderMissingConfig(t *testing.T) {
|
||||
defaultCfg := struct{}{}
|
||||
factories, err := MakeFactoryMap([]Factory{
|
||||
NewFactory(
|
||||
component.MustNewType("all"),
|
||||
func() component.Config { return &defaultCfg },
|
||||
WithTraces(createTraces, component.StabilityLevelDevelopment),
|
||||
WithMetrics(createMetrics, component.StabilityLevelAlpha),
|
||||
WithLogs(createLogs, component.StabilityLevelDeprecated),
|
||||
),
|
||||
}...)
|
||||
|
||||
require.NoError(t, err)
|
||||
|
||||
bErr := NewBuilder(map[component.ID]component.Config{}, factories)
|
||||
missingID := component.MustNewIDWithName("all", "missing")
|
||||
|
||||
te, err := bErr.CreateTraces(context.Background(), createSettings(missingID), consumertest.NewNop())
|
||||
assert.EqualError(t, err, "processor \"all/missing\" is not configured")
|
||||
assert.Nil(t, te)
|
||||
|
||||
me, err := bErr.CreateMetrics(context.Background(), createSettings(missingID), consumertest.NewNop())
|
||||
assert.EqualError(t, err, "processor \"all/missing\" is not configured")
|
||||
assert.Nil(t, me)
|
||||
|
||||
le, err := bErr.CreateLogs(context.Background(), createSettings(missingID), consumertest.NewNop())
|
||||
assert.EqualError(t, err, "processor \"all/missing\" is not configured")
|
||||
assert.Nil(t, le)
|
||||
}
|
||||
|
||||
func TestBuilderFactory(t *testing.T) {
|
||||
factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustNewType("foo"), nil)}...)
|
||||
require.NoError(t, err)
|
||||
|
||||
cfgs := map[component.ID]component.Config{component.MustNewID("foo"): struct{}{}}
|
||||
b := NewBuilder(cfgs, factories)
|
||||
|
||||
assert.NotNil(t, b.Factory(component.MustNewID("foo").Type()))
|
||||
assert.Nil(t, b.Factory(component.MustNewID("bar").Type()))
|
||||
}
|
||||
|
||||
var nopInstance = &nopProcessor{
|
||||
Consumer: consumertest.NewNop(),
|
||||
}
|
||||
|
|
@ -255,11 +115,3 @@ func createMetrics(context.Context, Settings, component.Config, consumer.Metrics
|
|||
func createLogs(context.Context, Settings, component.Config, consumer.Logs) (Logs, error) {
|
||||
return nopInstance, nil
|
||||
}
|
||||
|
||||
func createSettings(id component.ID) Settings {
|
||||
return Settings{
|
||||
ID: id,
|
||||
TelemetrySettings: componenttest.NewNopTelemetrySettings(),
|
||||
BuildInfo: component.NewDefaultBuildInfo(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
|
|
@ -14,14 +10,10 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69
|
|||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
||||
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
|
|
@ -31,18 +23,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
|
|||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg=
|
||||
github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
|
||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||
github.com/prometheus/common v0.56.0 h1:UffReloqkBtvtQEYDg2s+uDPGRrJyC6vZWPGXf6OhPY=
|
||||
github.com/prometheus/common v0.56.0/go.mod h1:7uRPFSUTbfZWsJ7MHY56sqt7hLQu3bxXHDnNhl8E9qI=
|
||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
|
|
@ -53,14 +35,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
|
|||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw=
|
||||
go.opentelemetry.io/otel v1.29.0/go.mod h1:N/WtXPs1CNCUEx+Agz5uouwCba+i+bJGFicT8SR4NP8=
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.51.0 h1:G7uexXb/K3T+T9fNLCCKncweEtNEBMTO+46hKX5EdKw=
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.51.0/go.mod h1:v0mFe5Kk7woIh938mrZBJBmENYquyA0IICrlYm4Y0t4=
|
||||
go.opentelemetry.io/otel/metric v1.29.0 h1:vPf/HFWTNkPu1aYeIsc98l4ktOQaL6LeSoeV2g+8YLc=
|
||||
go.opentelemetry.io/otel/metric v1.29.0/go.mod h1:auu/QWieFVWx+DmQOUMgj0F8LHWdgalxXqvp7BII/W8=
|
||||
go.opentelemetry.io/otel/sdk v1.29.0 h1:vkqKjk7gwhS8VaWb0POZKmIEDimRCMsopNYnriHyryo=
|
||||
go.opentelemetry.io/otel/sdk v1.29.0/go.mod h1:pM8Dx5WKnvxLCb+8lG1PRNIDxu9g9b9g59Qr7hfAAok=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.29.0 h1:K2CfmJohnRgvZ9UAj2/FhIf/okdWcNdBwe1m8xFXiSY=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.29.0/go.mod h1:6zZLdCl2fkauYoZIOn/soQIDSWFmNSRcICarHfuhNJQ=
|
||||
go.opentelemetry.io/otel/trace v1.29.0 h1:J/8ZNK4XgR7a21DZUAsbF8pZ5Jcw1VhACmnYt39JTi4=
|
||||
go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
|
|
|
|||
|
|
@ -68,14 +68,3 @@ type nopProcessor struct {
|
|||
component.ShutdownFunc
|
||||
consumertest.Consumer
|
||||
}
|
||||
|
||||
// NewNopBuilder returns a processor.Builder that constructs nop processors.
|
||||
//
|
||||
// Deprecated: [v0.108.0] this builder is being internalized within the service module,
|
||||
// and will be removed soon.
|
||||
func NewNopBuilder() *processor.Builder {
|
||||
nopFactory := NewNopFactory()
|
||||
return processor.NewBuilder(
|
||||
map[component.ID]component.Config{component.NewID(nopType): nopFactory.CreateDefaultConfig()},
|
||||
map[component.Type]processor.Factory{nopType: nopFactory})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,31 +55,3 @@ func TestNewNopFactory(t *testing.T) {
|
|||
assert.NoError(t, profiles.ConsumeProfiles(context.Background(), pprofile.NewProfiles()))
|
||||
assert.NoError(t, profiles.Shutdown(context.Background()))
|
||||
}
|
||||
|
||||
func TestNewNopBuilder(t *testing.T) {
|
||||
builder := NewNopBuilder()
|
||||
require.NotNil(t, builder)
|
||||
|
||||
factory := NewNopFactory()
|
||||
cfg := factory.CreateDefaultConfig()
|
||||
set := NewNopSettings()
|
||||
set.ID = component.NewID(nopType)
|
||||
|
||||
traces, err := factory.CreateTracesProcessor(context.Background(), set, cfg, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
bTraces, err := builder.CreateTraces(context.Background(), set, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
assert.IsType(t, traces, bTraces)
|
||||
|
||||
metrics, err := factory.CreateMetricsProcessor(context.Background(), set, cfg, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
bMetrics, err := builder.CreateMetrics(context.Background(), set, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
assert.IsType(t, metrics, bMetrics)
|
||||
|
||||
logs, err := factory.CreateLogsProcessor(context.Background(), set, cfg, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
bLogs, err := builder.CreateLogs(context.Background(), set, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
assert.IsType(t, logs, bLogs)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,107 +0,0 @@
|
|||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package receiver // import "go.opentelemetry.io/collector/receiver"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
)
|
||||
|
||||
var errNilNextConsumer = errors.New("nil next Consumer")
|
||||
|
||||
// Builder receiver is a helper struct that given a set of Configs and
|
||||
// Factories helps with creating receivers.
|
||||
//
|
||||
// Deprecated: [v0.108.0] this builder is being internalized within the service module,
|
||||
// and will be removed soon.
|
||||
type Builder struct {
|
||||
cfgs map[component.ID]component.Config
|
||||
factories map[component.Type]Factory
|
||||
}
|
||||
|
||||
// NewBuilder creates a new receiver.Builder to help with creating components form a set of configs and factories.
|
||||
//
|
||||
// Deprecated: [v0.108.0] this builder is being internalized within the service module,
|
||||
// and will be removed soon.
|
||||
func NewBuilder(cfgs map[component.ID]component.Config, factories map[component.Type]Factory) *Builder {
|
||||
return &Builder{cfgs: cfgs, factories: factories}
|
||||
}
|
||||
|
||||
// CreateTraces creates a Traces receiver based on the settings and config.
|
||||
func (b *Builder) CreateTraces(ctx context.Context, set Settings, next consumer.Traces) (Traces, error) {
|
||||
if next == nil {
|
||||
return nil, errNilNextConsumer
|
||||
}
|
||||
cfg, existsCfg := b.cfgs[set.ID]
|
||||
if !existsCfg {
|
||||
return nil, fmt.Errorf("receiver %q is not configured", set.ID)
|
||||
}
|
||||
|
||||
f, existsFactory := b.factories[set.ID.Type()]
|
||||
if !existsFactory {
|
||||
return nil, fmt.Errorf("receiver factory not available for: %q", set.ID)
|
||||
}
|
||||
|
||||
logStabilityLevel(set.Logger, f.TracesReceiverStability())
|
||||
return f.CreateTracesReceiver(ctx, set, cfg, next)
|
||||
}
|
||||
|
||||
// CreateMetrics creates a Metrics receiver based on the settings and config.
|
||||
func (b *Builder) CreateMetrics(ctx context.Context, set Settings, next consumer.Metrics) (Metrics, error) {
|
||||
if next == nil {
|
||||
return nil, errNilNextConsumer
|
||||
}
|
||||
cfg, existsCfg := b.cfgs[set.ID]
|
||||
if !existsCfg {
|
||||
return nil, fmt.Errorf("receiver %q is not configured", set.ID)
|
||||
}
|
||||
|
||||
f, existsFactory := b.factories[set.ID.Type()]
|
||||
if !existsFactory {
|
||||
return nil, fmt.Errorf("receiver factory not available for: %q", set.ID)
|
||||
}
|
||||
|
||||
logStabilityLevel(set.Logger, f.MetricsReceiverStability())
|
||||
return f.CreateMetricsReceiver(ctx, set, cfg, next)
|
||||
}
|
||||
|
||||
// CreateLogs creates a Logs receiver based on the settings and config.
|
||||
func (b *Builder) CreateLogs(ctx context.Context, set Settings, next consumer.Logs) (Logs, error) {
|
||||
if next == nil {
|
||||
return nil, errNilNextConsumer
|
||||
}
|
||||
cfg, existsCfg := b.cfgs[set.ID]
|
||||
if !existsCfg {
|
||||
return nil, fmt.Errorf("receiver %q is not configured", set.ID)
|
||||
}
|
||||
|
||||
f, existsFactory := b.factories[set.ID.Type()]
|
||||
if !existsFactory {
|
||||
return nil, fmt.Errorf("receiver factory not available for: %q", set.ID)
|
||||
}
|
||||
|
||||
logStabilityLevel(set.Logger, f.LogsReceiverStability())
|
||||
return f.CreateLogsReceiver(ctx, set, cfg, next)
|
||||
}
|
||||
|
||||
func (b *Builder) Factory(componentType component.Type) component.Factory {
|
||||
return b.factories[componentType]
|
||||
}
|
||||
|
||||
// logStabilityLevel logs the stability level of a component. The log level is set to info for
|
||||
// undefined, unmaintained, deprecated and development. The log level is set to debug
|
||||
// for alpha, beta and stable.
|
||||
func logStabilityLevel(logger *zap.Logger, sl component.StabilityLevel) {
|
||||
if sl >= component.StabilityLevelAlpha {
|
||||
logger.Debug(sl.LogMessage())
|
||||
} else {
|
||||
logger.Info(sl.LogMessage())
|
||||
}
|
||||
}
|
||||
|
|
@ -8,10 +8,8 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.opentelemetry.io/collector/component"
|
||||
"go.opentelemetry.io/collector/component/componenttest"
|
||||
"go.opentelemetry.io/collector/consumer"
|
||||
"go.opentelemetry.io/collector/consumer/consumertest"
|
||||
)
|
||||
|
|
@ -95,144 +93,6 @@ func TestMakeFactoryMap(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestBuilder(t *testing.T) {
|
||||
defaultCfg := struct{}{}
|
||||
factories, err := MakeFactoryMap([]Factory{
|
||||
NewFactory(component.MustNewType("err"), nil),
|
||||
NewFactory(
|
||||
component.MustNewType("all"),
|
||||
func() component.Config { return &defaultCfg },
|
||||
WithTraces(createTraces, component.StabilityLevelDevelopment),
|
||||
WithMetrics(createMetrics, component.StabilityLevelAlpha),
|
||||
WithLogs(createLogs, component.StabilityLevelDeprecated),
|
||||
),
|
||||
}...)
|
||||
require.NoError(t, err)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
id component.ID
|
||||
err string
|
||||
nextTraces consumer.Traces
|
||||
nextLogs consumer.Logs
|
||||
nextMetrics consumer.Metrics
|
||||
}{
|
||||
{
|
||||
name: "unknown",
|
||||
id: component.MustNewID("unknown"),
|
||||
err: "receiver factory not available for: \"unknown\"",
|
||||
nextTraces: consumertest.NewNop(),
|
||||
nextLogs: consumertest.NewNop(),
|
||||
nextMetrics: consumertest.NewNop(),
|
||||
},
|
||||
{
|
||||
name: "err",
|
||||
id: component.MustNewID("err"),
|
||||
err: "telemetry type is not supported",
|
||||
nextTraces: consumertest.NewNop(),
|
||||
nextLogs: consumertest.NewNop(),
|
||||
nextMetrics: consumertest.NewNop(),
|
||||
},
|
||||
{
|
||||
name: "all",
|
||||
id: component.MustNewID("all"),
|
||||
nextTraces: consumertest.NewNop(),
|
||||
nextLogs: consumertest.NewNop(),
|
||||
nextMetrics: consumertest.NewNop(),
|
||||
},
|
||||
{
|
||||
name: "all/named",
|
||||
id: component.MustNewIDWithName("all", "named"),
|
||||
nextTraces: consumertest.NewNop(),
|
||||
nextLogs: consumertest.NewNop(),
|
||||
nextMetrics: consumertest.NewNop(),
|
||||
},
|
||||
{
|
||||
name: "no next consumer",
|
||||
id: component.MustNewID("unknown"),
|
||||
err: "nil next Consumer",
|
||||
nextTraces: nil,
|
||||
nextLogs: nil,
|
||||
nextMetrics: nil,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range testCases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
cfgs := map[component.ID]component.Config{tt.id: defaultCfg}
|
||||
b := NewBuilder(cfgs, factories)
|
||||
|
||||
te, err := b.CreateTraces(context.Background(), settings(tt.id), tt.nextTraces)
|
||||
if tt.err != "" {
|
||||
assert.EqualError(t, err, tt.err)
|
||||
assert.Nil(t, te)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, nopInstance, te)
|
||||
}
|
||||
|
||||
me, err := b.CreateMetrics(context.Background(), settings(tt.id), tt.nextMetrics)
|
||||
if tt.err != "" {
|
||||
assert.EqualError(t, err, tt.err)
|
||||
assert.Nil(t, me)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, nopInstance, me)
|
||||
}
|
||||
|
||||
le, err := b.CreateLogs(context.Background(), settings(tt.id), tt.nextLogs)
|
||||
if tt.err != "" {
|
||||
assert.EqualError(t, err, tt.err)
|
||||
assert.Nil(t, le)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, nopInstance, le)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderMissingConfig(t *testing.T) {
|
||||
defaultCfg := struct{}{}
|
||||
factories, err := MakeFactoryMap([]Factory{
|
||||
NewFactory(
|
||||
component.MustNewType("all"),
|
||||
func() component.Config { return &defaultCfg },
|
||||
WithTraces(createTraces, component.StabilityLevelDevelopment),
|
||||
WithMetrics(createMetrics, component.StabilityLevelAlpha),
|
||||
WithLogs(createLogs, component.StabilityLevelDeprecated),
|
||||
),
|
||||
}...)
|
||||
|
||||
require.NoError(t, err)
|
||||
|
||||
bErr := NewBuilder(map[component.ID]component.Config{}, factories)
|
||||
missingID := component.MustNewIDWithName("all", "missing")
|
||||
|
||||
te, err := bErr.CreateTraces(context.Background(), settings(missingID), consumertest.NewNop())
|
||||
assert.EqualError(t, err, "receiver \"all/missing\" is not configured")
|
||||
assert.Nil(t, te)
|
||||
|
||||
me, err := bErr.CreateMetrics(context.Background(), settings(missingID), consumertest.NewNop())
|
||||
assert.EqualError(t, err, "receiver \"all/missing\" is not configured")
|
||||
assert.Nil(t, me)
|
||||
|
||||
le, err := bErr.CreateLogs(context.Background(), settings(missingID), consumertest.NewNop())
|
||||
assert.EqualError(t, err, "receiver \"all/missing\" is not configured")
|
||||
assert.Nil(t, le)
|
||||
}
|
||||
|
||||
func TestBuilderFactory(t *testing.T) {
|
||||
factories, err := MakeFactoryMap([]Factory{NewFactory(component.MustNewType("foo"), nil)}...)
|
||||
require.NoError(t, err)
|
||||
|
||||
cfgs := map[component.ID]component.Config{component.MustNewID("foo"): struct{}{}}
|
||||
b := NewBuilder(cfgs, factories)
|
||||
|
||||
assert.NotNil(t, b.Factory(component.MustNewID("foo").Type()))
|
||||
assert.Nil(t, b.Factory(component.MustNewID("bar").Type()))
|
||||
}
|
||||
|
||||
var nopInstance = &nopReceiver{
|
||||
Consumer: consumertest.NewNop(),
|
||||
}
|
||||
|
|
@ -255,11 +115,3 @@ func createMetrics(context.Context, Settings, component.Config, consumer.Metrics
|
|||
func createLogs(context.Context, Settings, component.Config, consumer.Logs) (Logs, error) {
|
||||
return nopInstance, nil
|
||||
}
|
||||
|
||||
func settings(id component.ID) Settings {
|
||||
return Settings{
|
||||
ID: id,
|
||||
TelemetrySettings: componenttest.NewNopTelemetrySettings(),
|
||||
BuildInfo: component.NewDefaultBuildInfo(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
|
|
@ -14,14 +10,10 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69
|
|||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
||||
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
|
|
@ -31,18 +23,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
|
|||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg=
|
||||
github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
|
||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||
github.com/prometheus/common v0.56.0 h1:UffReloqkBtvtQEYDg2s+uDPGRrJyC6vZWPGXf6OhPY=
|
||||
github.com/prometheus/common v0.56.0/go.mod h1:7uRPFSUTbfZWsJ7MHY56sqt7hLQu3bxXHDnNhl8E9qI=
|
||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
|
|
@ -53,14 +35,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
|
|||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw=
|
||||
go.opentelemetry.io/otel v1.29.0/go.mod h1:N/WtXPs1CNCUEx+Agz5uouwCba+i+bJGFicT8SR4NP8=
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.51.0 h1:G7uexXb/K3T+T9fNLCCKncweEtNEBMTO+46hKX5EdKw=
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.51.0/go.mod h1:v0mFe5Kk7woIh938mrZBJBmENYquyA0IICrlYm4Y0t4=
|
||||
go.opentelemetry.io/otel/metric v1.29.0 h1:vPf/HFWTNkPu1aYeIsc98l4ktOQaL6LeSoeV2g+8YLc=
|
||||
go.opentelemetry.io/otel/metric v1.29.0/go.mod h1:auu/QWieFVWx+DmQOUMgj0F8LHWdgalxXqvp7BII/W8=
|
||||
go.opentelemetry.io/otel/sdk v1.29.0 h1:vkqKjk7gwhS8VaWb0POZKmIEDimRCMsopNYnriHyryo=
|
||||
go.opentelemetry.io/otel/sdk v1.29.0/go.mod h1:pM8Dx5WKnvxLCb+8lG1PRNIDxu9g9b9g59Qr7hfAAok=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.29.0 h1:K2CfmJohnRgvZ9UAj2/FhIf/okdWcNdBwe1m8xFXiSY=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.29.0/go.mod h1:6zZLdCl2fkauYoZIOn/soQIDSWFmNSRcICarHfuhNJQ=
|
||||
go.opentelemetry.io/otel/trace v1.29.0 h1:J/8ZNK4XgR7a21DZUAsbF8pZ5Jcw1VhACmnYt39JTi4=
|
||||
go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
|
|
|
|||
|
|
@ -83,14 +83,3 @@ type nopReceiver struct {
|
|||
component.StartFunc
|
||||
component.ShutdownFunc
|
||||
}
|
||||
|
||||
// NewNopBuilder returns a receiver.Builder that constructs nop receivers.
|
||||
//
|
||||
// Deprecated: [v0.108.0] this builder is being internalized within the service module,
|
||||
// and will be removed soon.
|
||||
func NewNopBuilder() *receiver.Builder {
|
||||
nopFactory := NewNopFactory()
|
||||
return receiver.NewBuilder(
|
||||
map[component.ID]component.Config{component.NewID(defaultComponentType): nopFactory.CreateDefaultConfig()},
|
||||
map[component.Type]receiver.Factory{defaultComponentType: nopFactory})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,31 +44,3 @@ func TestNewNopFactory(t *testing.T) {
|
|||
assert.NoError(t, profiles.Start(context.Background(), componenttest.NewNopHost()))
|
||||
assert.NoError(t, profiles.Shutdown(context.Background()))
|
||||
}
|
||||
|
||||
func TestNewNopBuilder(t *testing.T) {
|
||||
builder := NewNopBuilder()
|
||||
require.NotNil(t, builder)
|
||||
|
||||
factory := NewNopFactory()
|
||||
cfg := factory.CreateDefaultConfig()
|
||||
set := NewNopSettings()
|
||||
set.ID = component.NewID(nopType)
|
||||
|
||||
traces, err := factory.CreateTracesReceiver(context.Background(), set, cfg, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
bTraces, err := builder.CreateTraces(context.Background(), set, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
assert.IsType(t, traces, bTraces)
|
||||
|
||||
metrics, err := factory.CreateMetricsReceiver(context.Background(), set, cfg, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
bMetrics, err := builder.CreateMetrics(context.Background(), set, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
assert.IsType(t, metrics, bMetrics)
|
||||
|
||||
logs, err := factory.CreateLogsReceiver(context.Background(), set, cfg, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
bLogs, err := builder.CreateLogs(context.Background(), set, consumertest.NewNop())
|
||||
require.NoError(t, err)
|
||||
assert.IsType(t, logs, bLogs)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,42 +45,18 @@ type Settings struct {
|
|||
// CollectorConf contains the Collector's current configuration
|
||||
CollectorConf *confmap.Conf
|
||||
|
||||
// Receivers builder for receivers.
|
||||
//
|
||||
// Deprecated: [v0.108.0] use the [ReceiversConfigs] and [ReceiversFactories] options
|
||||
// instead.
|
||||
Receivers builders.Receiver
|
||||
|
||||
// Receivers configuration to its builder.
|
||||
ReceiversConfigs map[component.ID]component.Config
|
||||
ReceiversFactories map[component.Type]receiver.Factory
|
||||
|
||||
// Processors builder for processors.
|
||||
//
|
||||
// Deprecated: [v0.108.0] use the [ProcessorsConfigs] and [ProcessorsFactories] options
|
||||
// instead.
|
||||
Processors builders.Processor
|
||||
|
||||
// Processors configuration to its builder.
|
||||
ProcessorsConfigs map[component.ID]component.Config
|
||||
ProcessorsFactories map[component.Type]processor.Factory
|
||||
|
||||
// Exporters builder for exporters.
|
||||
//
|
||||
// Deprecated: [v0.108.0] use the [ReceiversConfigs] and [ReceiversFactories] options
|
||||
// instead.
|
||||
Exporters builders.Exporter
|
||||
|
||||
// exporters configuration to its builder.
|
||||
ExportersConfigs map[component.ID]component.Config
|
||||
ExportersFactories map[component.Type]exporter.Factory
|
||||
|
||||
// Connectors builder for connectors.
|
||||
//
|
||||
// Deprecated: [v0.108.0] use the [ConnectorsConfigs] and [ConnectorsFactories] options
|
||||
// instead.
|
||||
Connectors builders.Connector
|
||||
|
||||
// Connectors configuration to its builder.
|
||||
ConnectorsConfigs map[component.ID]component.Config
|
||||
ConnectorsFactories map[component.Type]connector.Factory
|
||||
|
|
@ -115,39 +91,15 @@ func New(ctx context.Context, set Settings, cfg Config) (*Service, error) {
|
|||
disableHighCard := obsreportconfig.DisableHighCardinalityMetricsfeatureGate.IsEnabled()
|
||||
extendedConfig := obsreportconfig.UseOtelWithSDKConfigurationForInternalTelemetryFeatureGate.IsEnabled()
|
||||
|
||||
receivers := set.Receivers
|
||||
if receivers == nil {
|
||||
receivers = builders.NewReceiver(set.ReceiversConfigs, set.ReceiversFactories)
|
||||
}
|
||||
|
||||
processors := set.Processors
|
||||
if processors == nil {
|
||||
processors = builders.NewProcessor(set.ProcessorsConfigs, set.ProcessorsFactories)
|
||||
}
|
||||
|
||||
exporters := set.Exporters
|
||||
if exporters == nil {
|
||||
exporters = builders.NewExporter(set.ExportersConfigs, set.ExportersFactories)
|
||||
}
|
||||
|
||||
connectors := set.Connectors
|
||||
if connectors == nil {
|
||||
connectors = builders.NewConnector(set.ConnectorsConfigs, set.ConnectorsFactories)
|
||||
}
|
||||
|
||||
extensions := set.Extensions
|
||||
if extensions == nil {
|
||||
extensions = builders.NewExtension(set.ExtensionsConfigs, set.ExtensionsFactories)
|
||||
}
|
||||
|
||||
srv := &Service{
|
||||
buildInfo: set.BuildInfo,
|
||||
host: &graph.Host{
|
||||
Receivers: receivers,
|
||||
Processors: processors,
|
||||
Exporters: exporters,
|
||||
Connectors: connectors,
|
||||
Extensions: extensions,
|
||||
Receivers: builders.NewReceiver(set.ReceiversConfigs, set.ReceiversFactories),
|
||||
Processors: builders.NewProcessor(set.ProcessorsConfigs, set.ProcessorsFactories),
|
||||
Exporters: builders.NewExporter(set.ExportersConfigs, set.ExportersFactories),
|
||||
Connectors: builders.NewConnector(set.ConnectorsConfigs, set.ConnectorsFactories),
|
||||
Extensions: builders.NewExtension(set.ExtensionsConfigs, set.ExtensionsFactories),
|
||||
|
||||
ModuleInfo: set.ModuleInfo,
|
||||
BuildInfo: set.BuildInfo,
|
||||
AsyncErrorChannel: set.AsyncErrorChannel,
|
||||
|
|
|
|||
Loading…
Reference in New Issue