Remove a lot of deprecated symbols (#12421)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description <!-- Issue number if applicable --> Remove deprecated symbols #### Link to tracking issue Updates #12222, #12305, #11524
This commit is contained in:
		
							parent
							
								
									f2dfc290b7
								
							
						
					
					
						commit
						9ea6963fca
					
				| 
						 | 
				
			
			@ -0,0 +1,26 @@
 | 
			
		|||
# 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, connector, processor, receiver, exporter, scraper
 | 
			
		||||
 | 
			
		||||
# A brief description of the change.  Surround your text with quotes ("") if it needs to start with a backtick (`).
 | 
			
		||||
note: Remove deprecated `Create*` methods from `Create*Func` types.
 | 
			
		||||
 | 
			
		||||
# One or more tracking issues or pull requests related to the change
 | 
			
		||||
issues: [12305]
 | 
			
		||||
 | 
			
		||||
# (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: |
 | 
			
		||||
  The `xconnector.CreateMetricsToProfilesFunc.CreateMetricsToProfiles` method has been removed without a deprecation.
 | 
			
		||||
 | 
			
		||||
# 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,26 @@
 | 
			
		|||
# 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: component
 | 
			
		||||
 | 
			
		||||
# A brief description of the change.  Surround your text with quotes ("") if it needs to start with a backtick (`).
 | 
			
		||||
note: Remove deprecated function and interface `ConfigValidator` and `ValidateConfig`.
 | 
			
		||||
 | 
			
		||||
# One or more tracking issues or pull requests related to the change
 | 
			
		||||
issues: [11524]
 | 
			
		||||
 | 
			
		||||
# (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: | 
 | 
			
		||||
  - Use `xconfmap.Validator` and `xconfmap.Validate` instead.
 | 
			
		||||
 | 
			
		||||
# 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, scraper, processor, exporter, extension
 | 
			
		||||
 | 
			
		||||
# A brief description of the change.  Surround your text with quotes ("") if it needs to start with a backtick (`).
 | 
			
		||||
note:  Remove deprecated MakeFactoryMap functions in favor of generic implementation
 | 
			
		||||
 | 
			
		||||
# One or more tracking issues or pull requests related to the change
 | 
			
		||||
issues: [12222]
 | 
			
		||||
 | 
			
		||||
# (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]
 | 
			
		||||
| 
						 | 
				
			
			@ -3,14 +3,6 @@
 | 
			
		|||
 | 
			
		||||
package component // import "go.opentelemetry.io/collector/component"
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"reflect"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Config defines the configuration for a component.Component.
 | 
			
		||||
//
 | 
			
		||||
// Implementations and/or any sub-configs (other types embedded or included in the Config implementation)
 | 
			
		||||
| 
						 | 
				
			
			@ -19,192 +11,3 @@ import (
 | 
			
		|||
//
 | 
			
		||||
// A valid implementation MUST pass the check componenttest.CheckConfigStruct (return nil error).
 | 
			
		||||
type Config any
 | 
			
		||||
 | 
			
		||||
// As interface types are only used for static typing, a common idiom to find the reflection Type
 | 
			
		||||
// for an interface type Foo is to use a *Foo value.
 | 
			
		||||
var configValidatorType = reflect.TypeOf((*ConfigValidator)(nil)).Elem()
 | 
			
		||||
 | 
			
		||||
// ConfigValidator defines an optional interface for configurations to implement to do validation.
 | 
			
		||||
//
 | 
			
		||||
// Deprecated: [v0.120.0] use xconfmap.Validator.
 | 
			
		||||
type ConfigValidator interface {
 | 
			
		||||
	// Validate the configuration and returns an error if invalid.
 | 
			
		||||
	Validate() error
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ValidateConfig validates a config, by doing this:
 | 
			
		||||
//   - Call Validate on the config itself if the config implements ConfigValidator.
 | 
			
		||||
//
 | 
			
		||||
// Deprecated: [v0.120.0] use xconfmap.Validate.
 | 
			
		||||
func ValidateConfig(cfg Config) error {
 | 
			
		||||
	var err error
 | 
			
		||||
 | 
			
		||||
	for _, validationErr := range validate(reflect.ValueOf(cfg)) {
 | 
			
		||||
		err = errors.Join(err, validationErr)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type pathError struct {
 | 
			
		||||
	err  error
 | 
			
		||||
	path []string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (pe pathError) Error() string {
 | 
			
		||||
	if len(pe.path) > 0 {
 | 
			
		||||
		var path string
 | 
			
		||||
		sb := strings.Builder{}
 | 
			
		||||
 | 
			
		||||
		_, _ = sb.WriteString(pe.path[len(pe.path)-1])
 | 
			
		||||
		for i := len(pe.path) - 2; i >= 0; i-- {
 | 
			
		||||
			_, _ = sb.WriteString("::")
 | 
			
		||||
			_, _ = sb.WriteString(pe.path[i])
 | 
			
		||||
		}
 | 
			
		||||
		path = sb.String()
 | 
			
		||||
 | 
			
		||||
		return fmt.Sprintf("%s: %s", path, pe.err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return pe.err.Error()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (pe pathError) Unwrap() error {
 | 
			
		||||
	return pe.err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func validate(v reflect.Value) []pathError {
 | 
			
		||||
	errs := []pathError{}
 | 
			
		||||
	// Validate the value itself.
 | 
			
		||||
	switch v.Kind() {
 | 
			
		||||
	case reflect.Invalid:
 | 
			
		||||
		return nil
 | 
			
		||||
	case reflect.Ptr, reflect.Interface:
 | 
			
		||||
		return validate(v.Elem())
 | 
			
		||||
	case reflect.Struct:
 | 
			
		||||
		err := callValidateIfPossible(v)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			errs = append(errs, pathError{err: err})
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Reflect on the pointed data and check each of its fields.
 | 
			
		||||
		for i := 0; i < v.NumField(); i++ {
 | 
			
		||||
			if !v.Type().Field(i).IsExported() {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
			field := v.Type().Field(i)
 | 
			
		||||
			path := fieldName(field)
 | 
			
		||||
 | 
			
		||||
			subpathErrs := validate(v.Field(i))
 | 
			
		||||
			for _, err := range subpathErrs {
 | 
			
		||||
				errs = append(errs, pathError{
 | 
			
		||||
					err:  err.err,
 | 
			
		||||
					path: append(err.path, path),
 | 
			
		||||
				})
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return errs
 | 
			
		||||
	case reflect.Slice, reflect.Array:
 | 
			
		||||
		err := callValidateIfPossible(v)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			errs = append(errs, pathError{err: err})
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Reflect on the pointed data and check each of its fields.
 | 
			
		||||
		for i := 0; i < v.Len(); i++ {
 | 
			
		||||
			subPathErrs := validate(v.Index(i))
 | 
			
		||||
 | 
			
		||||
			for _, err := range subPathErrs {
 | 
			
		||||
				errs = append(errs, pathError{
 | 
			
		||||
					err:  err.err,
 | 
			
		||||
					path: append(err.path, strconv.Itoa(i)),
 | 
			
		||||
				})
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return errs
 | 
			
		||||
	case reflect.Map:
 | 
			
		||||
		err := callValidateIfPossible(v)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			errs = append(errs, pathError{err: err})
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		iter := v.MapRange()
 | 
			
		||||
		for iter.Next() {
 | 
			
		||||
			keyErrs := validate(iter.Key())
 | 
			
		||||
			valueErrs := validate(iter.Value())
 | 
			
		||||
			key := stringifyMapKey(iter.Key())
 | 
			
		||||
 | 
			
		||||
			for _, err := range keyErrs {
 | 
			
		||||
				errs = append(errs, pathError{err: err.err, path: append(err.path, key)})
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			for _, err := range valueErrs {
 | 
			
		||||
				errs = append(errs, pathError{err: err.err, path: append(err.path, key)})
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return errs
 | 
			
		||||
	default:
 | 
			
		||||
		err := callValidateIfPossible(v)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return []pathError{{err: err}}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func callValidateIfPossible(v reflect.Value) error {
 | 
			
		||||
	// If the value type implements ConfigValidator just call Validate
 | 
			
		||||
	if v.Type().Implements(configValidatorType) {
 | 
			
		||||
		return v.Interface().(ConfigValidator).Validate()
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// If the pointer type implements ConfigValidator call Validate on the pointer to the current value.
 | 
			
		||||
	if reflect.PointerTo(v.Type()).Implements(configValidatorType) {
 | 
			
		||||
		// If not addressable, then create a new *V pointer and set the value to current v.
 | 
			
		||||
		if !v.CanAddr() {
 | 
			
		||||
			pv := reflect.New(reflect.PointerTo(v.Type()).Elem())
 | 
			
		||||
			pv.Elem().Set(v)
 | 
			
		||||
			v = pv.Elem()
 | 
			
		||||
		}
 | 
			
		||||
		return v.Addr().Interface().(ConfigValidator).Validate()
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func fieldName(field reflect.StructField) string {
 | 
			
		||||
	var fieldName string
 | 
			
		||||
	if tag, ok := field.Tag.Lookup("mapstructure"); ok {
 | 
			
		||||
		tags := strings.Split(tag, ",")
 | 
			
		||||
		if len(tags) > 0 {
 | 
			
		||||
			fieldName = tags[0]
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	// Even if the mapstructure tag exists, the field name may not
 | 
			
		||||
	// be available, so set it if it is still blank.
 | 
			
		||||
	if len(fieldName) == 0 {
 | 
			
		||||
		fieldName = strings.ToLower(field.Name)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return fieldName
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func stringifyMapKey(val reflect.Value) string {
 | 
			
		||||
	var key string
 | 
			
		||||
 | 
			
		||||
	if str, ok := val.Interface().(string); ok {
 | 
			
		||||
		key = str
 | 
			
		||||
	} else if stringer, ok := val.Interface().(fmt.Stringer); ok {
 | 
			
		||||
		key = stringer.String()
 | 
			
		||||
	} else {
 | 
			
		||||
		switch val.Kind() {
 | 
			
		||||
		case reflect.Ptr, reflect.Interface, reflect.Struct, reflect.Slice, reflect.Array, reflect.Map:
 | 
			
		||||
			key = fmt.Sprintf("[%T key]", val.Interface())
 | 
			
		||||
		default:
 | 
			
		||||
			key = fmt.Sprintf("%v", val.Interface())
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return key
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,321 +0,0 @@
 | 
			
		|||
// Copyright The OpenTelemetry Authors
 | 
			
		||||
// SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 | 
			
		||||
package component
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type configChildStruct struct {
 | 
			
		||||
	Child    errConfig
 | 
			
		||||
	ChildPtr *errConfig
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type configChildSlice struct {
 | 
			
		||||
	Child    []errConfig
 | 
			
		||||
	ChildPtr []*errConfig
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type configChildMapValue struct {
 | 
			
		||||
	Child    map[string]errConfig
 | 
			
		||||
	ChildPtr map[string]*errConfig
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type configChildMapKey struct {
 | 
			
		||||
	Child    map[errType]string
 | 
			
		||||
	ChildPtr map[*errType]string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type configChildTypeDef struct {
 | 
			
		||||
	Child    errType
 | 
			
		||||
	ChildPtr *errType
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type configChildInterface struct {
 | 
			
		||||
	Child Config
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type errConfig struct {
 | 
			
		||||
	err error
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (e *errConfig) Validate() error {
 | 
			
		||||
	return e.err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type errType string
 | 
			
		||||
 | 
			
		||||
func (e errType) Validate() error {
 | 
			
		||||
	if e == "" {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	return errors.New(string(e))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newErrType(etStr string) *errType {
 | 
			
		||||
	et := errType(etStr)
 | 
			
		||||
	return &et
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type errMapType map[string]string
 | 
			
		||||
 | 
			
		||||
func (e errMapType) Validate() error {
 | 
			
		||||
	return errors.New(e["err"])
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type structKey struct {
 | 
			
		||||
	k string
 | 
			
		||||
	e error
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s structKey) String() string {
 | 
			
		||||
	return s.k
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s structKey) Validate() error {
 | 
			
		||||
	return s.e
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type configChildMapCustomKey struct {
 | 
			
		||||
	Child map[structKey]errConfig
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func newErrMapType() *errMapType {
 | 
			
		||||
	et := errMapType(nil)
 | 
			
		||||
	return &et
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type configMapstructure struct {
 | 
			
		||||
	Valid  *errConfig `mapstructure:"validtag,omitempty"`
 | 
			
		||||
	NoData *errConfig `mapstructure:""`
 | 
			
		||||
	NoName *errConfig `mapstructure:",remain"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type configDeeplyNested struct {
 | 
			
		||||
	MapKeyChild   map[configChildStruct]string
 | 
			
		||||
	MapValueChild map[string]configChildStruct
 | 
			
		||||
	SliceChild    []configChildSlice
 | 
			
		||||
	MapIntKey     map[int]errConfig
 | 
			
		||||
	MapFloatKey   map[float64]errConfig
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type sliceTypeAlias []configChildSlice
 | 
			
		||||
 | 
			
		||||
func (sliceTypeAlias) Validate() error {
 | 
			
		||||
	return errors.New("sliceTypeAlias error")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestValidateConfig(t *testing.T) {
 | 
			
		||||
	tests := []struct {
 | 
			
		||||
		name     string
 | 
			
		||||
		cfg      any
 | 
			
		||||
		expected error
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			name:     "struct",
 | 
			
		||||
			cfg:      errConfig{err: errors.New("struct")},
 | 
			
		||||
			expected: errors.New("struct"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "pointer struct",
 | 
			
		||||
			cfg:      &errConfig{err: errors.New("pointer struct")},
 | 
			
		||||
			expected: errors.New("pointer struct"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "type",
 | 
			
		||||
			cfg:      errType("type"),
 | 
			
		||||
			expected: errors.New("type"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "pointer child",
 | 
			
		||||
			cfg:      newErrType("pointer type"),
 | 
			
		||||
			expected: errors.New("pointer type"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "child interface with nil",
 | 
			
		||||
			cfg:      configChildInterface{},
 | 
			
		||||
			expected: nil,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "pointer to child interface with nil",
 | 
			
		||||
			cfg:      &configChildInterface{},
 | 
			
		||||
			expected: nil,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "nil",
 | 
			
		||||
			cfg:      nil,
 | 
			
		||||
			expected: nil,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "nil map type",
 | 
			
		||||
			cfg:      errMapType(nil),
 | 
			
		||||
			expected: errors.New(""),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "nil pointer map type",
 | 
			
		||||
			cfg:      newErrMapType(),
 | 
			
		||||
			expected: errors.New(""),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "child struct",
 | 
			
		||||
			cfg:      configChildStruct{Child: errConfig{err: errors.New("child struct")}},
 | 
			
		||||
			expected: errors.New("child: child struct"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "pointer child struct",
 | 
			
		||||
			cfg:      &configChildStruct{Child: errConfig{err: errors.New("pointer child struct")}},
 | 
			
		||||
			expected: errors.New("child: pointer child struct"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "child struct pointer",
 | 
			
		||||
			cfg:      &configChildStruct{ChildPtr: &errConfig{err: errors.New("child struct pointer")}},
 | 
			
		||||
			expected: errors.New("childptr: child struct pointer"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "child interface",
 | 
			
		||||
			cfg:      configChildInterface{Child: errConfig{err: errors.New("child interface")}},
 | 
			
		||||
			expected: errors.New("child: child interface"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "pointer to child interface",
 | 
			
		||||
			cfg:      &configChildInterface{Child: errConfig{err: errors.New("pointer to child interface")}},
 | 
			
		||||
			expected: errors.New("child: pointer to child interface"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "child interface with pointer",
 | 
			
		||||
			cfg:      configChildInterface{Child: &errConfig{err: errors.New("child interface with pointer")}},
 | 
			
		||||
			expected: errors.New("child: child interface with pointer"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "pointer to child interface with pointer",
 | 
			
		||||
			cfg:      &configChildInterface{Child: &errConfig{err: errors.New("pointer to child interface with pointer")}},
 | 
			
		||||
			expected: errors.New("child: pointer to child interface with pointer"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "child slice",
 | 
			
		||||
			cfg:      configChildSlice{Child: []errConfig{{}, {err: errors.New("child slice")}}},
 | 
			
		||||
			expected: errors.New("child::1: child slice"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "pointer child slice",
 | 
			
		||||
			cfg:      &configChildSlice{Child: []errConfig{{}, {err: errors.New("pointer child slice")}}},
 | 
			
		||||
			expected: errors.New("child::1: pointer child slice"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "child slice pointer",
 | 
			
		||||
			cfg:      &configChildSlice{ChildPtr: []*errConfig{{}, {err: errors.New("child slice pointer")}}},
 | 
			
		||||
			expected: errors.New("childptr::1: child slice pointer"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "child map value",
 | 
			
		||||
			cfg:      configChildMapValue{Child: map[string]errConfig{"test": {err: errors.New("child map")}}},
 | 
			
		||||
			expected: errors.New("child::test: child map"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "pointer child map value",
 | 
			
		||||
			cfg:      &configChildMapValue{Child: map[string]errConfig{"test": {err: errors.New("pointer child map")}}},
 | 
			
		||||
			expected: errors.New("child::test: pointer child map"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "child map value pointer",
 | 
			
		||||
			cfg:      &configChildMapValue{ChildPtr: map[string]*errConfig{"test": {err: errors.New("child map pointer")}}},
 | 
			
		||||
			expected: errors.New("childptr::test: child map pointer"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "child map key",
 | 
			
		||||
			cfg:      configChildMapKey{Child: map[errType]string{"child_map_key": ""}},
 | 
			
		||||
			expected: errors.New("child::child_map_key: child_map_key"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "pointer child map key",
 | 
			
		||||
			cfg:      &configChildMapKey{Child: map[errType]string{"pointer_child_map_key": ""}},
 | 
			
		||||
			expected: errors.New("child::pointer_child_map_key: pointer_child_map_key"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "child map key pointer",
 | 
			
		||||
			cfg:      &configChildMapKey{ChildPtr: map[*errType]string{newErrType("child map key pointer"): ""}},
 | 
			
		||||
			expected: errors.New("childptr::[*component.errType key]: child map key pointer"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "map with stringified non-string key type",
 | 
			
		||||
			cfg:      &configChildMapCustomKey{Child: map[structKey]errConfig{{k: "struct_key", e: errors.New("custom key error")}: {err: errors.New("value error")}}},
 | 
			
		||||
			expected: errors.New("child::struct_key: custom key error\nchild::struct_key: value error"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "child type",
 | 
			
		||||
			cfg:      configChildTypeDef{Child: "child type"},
 | 
			
		||||
			expected: errors.New("child: child type"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "pointer child type",
 | 
			
		||||
			cfg:      &configChildTypeDef{Child: "pointer child type"},
 | 
			
		||||
			expected: errors.New("child: pointer child type"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "child type pointer",
 | 
			
		||||
			cfg:      &configChildTypeDef{ChildPtr: newErrType("child type pointer")},
 | 
			
		||||
			expected: errors.New("childptr: child type pointer"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "valid mapstructure tag",
 | 
			
		||||
			cfg:      configMapstructure{Valid: &errConfig{errors.New("test")}},
 | 
			
		||||
			expected: errors.New("validtag: test"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "zero-length mapstructure tag",
 | 
			
		||||
			cfg:      configMapstructure{NoData: &errConfig{errors.New("test")}},
 | 
			
		||||
			expected: errors.New("nodata: test"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "no field name in mapstructure tag",
 | 
			
		||||
			cfg:      configMapstructure{NoName: &errConfig{errors.New("test")}},
 | 
			
		||||
			expected: errors.New("noname: test"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "nested map key error",
 | 
			
		||||
			cfg:      configDeeplyNested{MapKeyChild: map[configChildStruct]string{{Child: errConfig{err: errors.New("child key error")}}: "val"}},
 | 
			
		||||
			expected: errors.New("mapkeychild::[component.configChildStruct key]::child: child key error"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "nested map value error",
 | 
			
		||||
			cfg:      configDeeplyNested{MapValueChild: map[string]configChildStruct{"key": {Child: errConfig{err: errors.New("child key error")}}}},
 | 
			
		||||
			expected: errors.New("mapvaluechild::key::child: child key error"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "nested slice value error",
 | 
			
		||||
			cfg:      configDeeplyNested{SliceChild: []configChildSlice{{Child: []errConfig{{err: errors.New("child key error")}}}}},
 | 
			
		||||
			expected: errors.New("slicechild::0::child::0: child key error"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "nested map with int key",
 | 
			
		||||
			cfg:      configDeeplyNested{MapIntKey: map[int]errConfig{1: {err: errors.New("int key error")}}},
 | 
			
		||||
			expected: errors.New("mapintkey::1: int key error"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "nested map with float key",
 | 
			
		||||
			cfg:      configDeeplyNested{MapFloatKey: map[float64]errConfig{1.2: {err: errors.New("float key error")}}},
 | 
			
		||||
			expected: errors.New("mapfloatkey::1.2: float key error"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name:     "slice type alias",
 | 
			
		||||
			cfg:      sliceTypeAlias{},
 | 
			
		||||
			expected: errors.New("sliceTypeAlias error"),
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, tt := range tests {
 | 
			
		||||
		t.Run(tt.name, func(t *testing.T) {
 | 
			
		||||
			err := ValidateConfig(tt.cfg)
 | 
			
		||||
 | 
			
		||||
			if tt.expected != nil {
 | 
			
		||||
				assert.EqualError(t, err, tt.expected.Error())
 | 
			
		||||
			} else {
 | 
			
		||||
				assert.NoError(t, err)
 | 
			
		||||
			}
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -5,7 +5,6 @@ package connector // import "go.opentelemetry.io/collector/connector"
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	"go.opentelemetry.io/collector/component"
 | 
			
		||||
	"go.opentelemetry.io/collector/connector/internal"
 | 
			
		||||
| 
						 | 
				
			
			@ -133,111 +132,30 @@ func (f factoryOptionFunc) apply(o *factory) {
 | 
			
		|||
// CreateTracesToTracesFunc is the equivalent of Factory.CreateTracesToTraces().
 | 
			
		||||
type CreateTracesToTracesFunc func(context.Context, Settings, component.Config, consumer.Traces) (Traces, error)
 | 
			
		||||
 | 
			
		||||
// CreateTracesToTraces implements Factory.CreateTracesToTraces().
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateTracesToTracesFunc) CreateTracesToTraces(ctx context.Context, set Settings, cfg component.Config, next consumer.Traces) (Traces, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, internal.ErrDataTypes(set.ID, pipeline.SignalTraces, pipeline.SignalTraces)
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateTracesToMetricsFunc is the equivalent of Factory.CreateTracesToMetrics().
 | 
			
		||||
type CreateTracesToMetricsFunc func(context.Context, Settings, component.Config, consumer.Metrics) (Traces, error)
 | 
			
		||||
 | 
			
		||||
// CreateTracesToMetrics implements Factory.CreateTracesToMetrics().
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateTracesToMetricsFunc) CreateTracesToMetrics(ctx context.Context, set Settings, cfg component.Config, next consumer.Metrics) (Traces, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, internal.ErrDataTypes(set.ID, pipeline.SignalTraces, pipeline.SignalMetrics)
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateTracesToLogsFunc is the equivalent of Factory.CreateTracesToLogs().
 | 
			
		||||
type CreateTracesToLogsFunc func(context.Context, Settings, component.Config, consumer.Logs) (Traces, error)
 | 
			
		||||
 | 
			
		||||
// CreateTracesToLogs implements Factory.CreateTracesToLogs().
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateTracesToLogsFunc) CreateTracesToLogs(ctx context.Context, set Settings, cfg component.Config, next consumer.Logs) (Traces, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, internal.ErrDataTypes(set.ID, pipeline.SignalTraces, pipeline.SignalLogs)
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateMetricsToTracesFunc is the equivalent of Factory.CreateMetricsToTraces().
 | 
			
		||||
type CreateMetricsToTracesFunc func(context.Context, Settings, component.Config, consumer.Traces) (Metrics, error)
 | 
			
		||||
 | 
			
		||||
// CreateMetricsToTraces implements Factory.CreateMetricsToTraces().
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateMetricsToTracesFunc) CreateMetricsToTraces(ctx context.Context, set Settings, cfg component.Config, next consumer.Traces) (Metrics, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, internal.ErrDataTypes(set.ID, pipeline.SignalMetrics, pipeline.SignalTraces)
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateMetricsToMetricsFunc is the equivalent of Factory.CreateMetricsToTraces().
 | 
			
		||||
type CreateMetricsToMetricsFunc func(context.Context, Settings, component.Config, consumer.Metrics) (Metrics, error)
 | 
			
		||||
 | 
			
		||||
// CreateMetricsToMetrics implements Factory.CreateMetricsToTraces().
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateMetricsToMetricsFunc) CreateMetricsToMetrics(ctx context.Context, set Settings, cfg component.Config, next consumer.Metrics) (Metrics, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, internal.ErrDataTypes(set.ID, pipeline.SignalMetrics, pipeline.SignalMetrics)
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateMetricsToLogsFunc is the equivalent of Factory.CreateMetricsToLogs().
 | 
			
		||||
type CreateMetricsToLogsFunc func(context.Context, Settings, component.Config, consumer.Logs) (Metrics, error)
 | 
			
		||||
 | 
			
		||||
// CreateMetricsToLogs implements Factory.CreateMetricsToLogs().
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateMetricsToLogsFunc) CreateMetricsToLogs(ctx context.Context, set Settings, cfg component.Config, next consumer.Logs) (Metrics, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, internal.ErrDataTypes(set.ID, pipeline.SignalMetrics, pipeline.SignalLogs)
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateLogsToTracesFunc is the equivalent of Factory.CreateLogsToTraces().
 | 
			
		||||
type CreateLogsToTracesFunc func(context.Context, Settings, component.Config, consumer.Traces) (Logs, error)
 | 
			
		||||
 | 
			
		||||
// CreateLogsToTraces implements Factory.CreateLogsToTraces().
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateLogsToTracesFunc) CreateLogsToTraces(ctx context.Context, set Settings, cfg component.Config, next consumer.Traces) (Logs, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, internal.ErrDataTypes(set.ID, pipeline.SignalLogs, pipeline.SignalTraces)
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateLogsToMetricsFunc is the equivalent of Factory.CreateLogsToMetrics().
 | 
			
		||||
type CreateLogsToMetricsFunc func(context.Context, Settings, component.Config, consumer.Metrics) (Logs, error)
 | 
			
		||||
 | 
			
		||||
// CreateLogsToMetrics implements Factory.CreateLogsToMetrics().
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateLogsToMetricsFunc) CreateLogsToMetrics(ctx context.Context, set Settings, cfg component.Config, next consumer.Metrics) (Logs, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, internal.ErrDataTypes(set.ID, pipeline.SignalLogs, pipeline.SignalMetrics)
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateLogsToLogsFunc is the equivalent of Factory.CreateLogsToLogs().
 | 
			
		||||
type CreateLogsToLogsFunc func(context.Context, Settings, component.Config, consumer.Logs) (Logs, error)
 | 
			
		||||
 | 
			
		||||
// CreateLogsToLogs implements Factory.CreateLogsToLogs().
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateLogsToLogsFunc) CreateLogsToLogs(ctx context.Context, set Settings, cfg component.Config, next consumer.Logs) (Logs, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, internal.ErrDataTypes(set.ID, pipeline.SignalLogs, pipeline.SignalLogs)
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// WithTracesToTraces overrides the default "error not supported" implementation for WithTracesToTraces and the default "undefined" stability level.
 | 
			
		||||
func WithTracesToTraces(createTracesToTraces CreateTracesToTracesFunc, sl component.StabilityLevel) FactoryOption {
 | 
			
		||||
	return factoryOptionFunc(func(o *factory) {
 | 
			
		||||
| 
						 | 
				
			
			@ -457,18 +375,3 @@ func NewFactory(cfgType component.Type, createDefaultConfig component.CreateDefa
 | 
			
		|||
	}
 | 
			
		||||
	return f
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MakeFactoryMap takes a list of connector factories and returns a map with factory type as keys.
 | 
			
		||||
// It returns a non-nil error when there are factories with duplicate type.
 | 
			
		||||
//
 | 
			
		||||
// Deprecated: [v0.120.0] Use otelcol.MakeFactoryMap[connector.Factory] instead
 | 
			
		||||
func MakeFactoryMap(factories ...Factory) (map[component.Type]Factory, error) {
 | 
			
		||||
	fMap := map[component.Type]Factory{}
 | 
			
		||||
	for _, f := range factories {
 | 
			
		||||
		if _, ok := fMap[f.Type()]; ok {
 | 
			
		||||
			return fMap, fmt.Errorf("duplicate connector factory %q", f.Type())
 | 
			
		||||
		}
 | 
			
		||||
		fMap[f.Type()] = f
 | 
			
		||||
	}
 | 
			
		||||
	return fMap, nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -177,43 +177,6 @@ func TestNewFactoryWithAllTypes(t *testing.T) {
 | 
			
		|||
	assert.NoError(t, err)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestMakeFactoryMap(t *testing.T) {
 | 
			
		||||
	type testCase struct {
 | 
			
		||||
		name string
 | 
			
		||||
		in   []Factory
 | 
			
		||||
		out  map[component.Type]Factory
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	p1 := NewFactory(component.MustNewType("p1"), nil)
 | 
			
		||||
	p2 := NewFactory(component.MustNewType("p2"), nil)
 | 
			
		||||
	testCases := []testCase{
 | 
			
		||||
		{
 | 
			
		||||
			name: "different names",
 | 
			
		||||
			in:   []Factory{p1, p2},
 | 
			
		||||
			out: map[component.Type]Factory{
 | 
			
		||||
				p1.Type(): p1,
 | 
			
		||||
				p2.Type(): p2,
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: "same name",
 | 
			
		||||
			in:   []Factory{p1, p2, NewFactory(component.MustNewType("p1"), nil)},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, tt := range testCases {
 | 
			
		||||
		t.Run(tt.name, func(t *testing.T) {
 | 
			
		||||
			out, err := MakeFactoryMap(tt.in...)
 | 
			
		||||
			if tt.out == nil {
 | 
			
		||||
				assert.Error(t, err)
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
			require.NoError(t, err)
 | 
			
		||||
			assert.Equal(t, tt.out, out)
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var nopInstance = &nopConnector{
 | 
			
		||||
	Consumer: consumertest.NewNop(),
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -57,86 +57,24 @@ type Profiles interface {
 | 
			
		|||
// CreateTracesToProfilesFunc is the equivalent of Factory.CreateTracesToProfiles().
 | 
			
		||||
type CreateTracesToProfilesFunc func(context.Context, connector.Settings, component.Config, xconsumer.Profiles) (connector.Traces, error)
 | 
			
		||||
 | 
			
		||||
// CreateTracesToProfiles implements Factory.CreateTracesToProfiles().
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateTracesToProfilesFunc) CreateTracesToProfiles(ctx context.Context, set connector.Settings, cfg component.Config, next xconsumer.Profiles) (connector.Traces, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, internal.ErrDataTypes(set.ID, pipeline.SignalTraces, xpipeline.SignalProfiles)
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateMetricsToProfilesFunc is the equivalent of Factory.CreateMetricsToProfiles().
 | 
			
		||||
type CreateMetricsToProfilesFunc func(context.Context, connector.Settings, component.Config, xconsumer.Profiles) (connector.Metrics, error)
 | 
			
		||||
 | 
			
		||||
// CreateMetricsToProfiles implements Factory.CreateMetricsToProfiles().
 | 
			
		||||
func (f CreateMetricsToProfilesFunc) CreateMetricsToProfiles(ctx context.Context, set connector.Settings, cfg component.Config, next xconsumer.Profiles) (connector.Metrics, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, internal.ErrDataTypes(set.ID, pipeline.SignalMetrics, xpipeline.SignalProfiles)
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateLogsToProfilesFunc is the equivalent of Factory.CreateLogsToProfiles().
 | 
			
		||||
type CreateLogsToProfilesFunc func(context.Context, connector.Settings, component.Config, xconsumer.Profiles) (connector.Logs, error)
 | 
			
		||||
 | 
			
		||||
// CreateLogsToProfiles implements Factory.CreateLogsToProfiles().
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateLogsToProfilesFunc) CreateLogsToProfiles(ctx context.Context, set connector.Settings, cfg component.Config, next xconsumer.Profiles) (connector.Logs, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, internal.ErrDataTypes(set.ID, pipeline.SignalLogs, xpipeline.SignalProfiles)
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateProfilesToProfilesFunc is the equivalent of Factory.CreateProfilesToProfiles().
 | 
			
		||||
type CreateProfilesToProfilesFunc func(context.Context, connector.Settings, component.Config, xconsumer.Profiles) (Profiles, error)
 | 
			
		||||
 | 
			
		||||
// CreateProfilesToProfiles implements Factory.CreateProfilesToProfiles().
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateProfilesToProfilesFunc) CreateProfilesToProfiles(ctx context.Context, set connector.Settings, cfg component.Config, next xconsumer.Profiles) (Profiles, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, internal.ErrDataTypes(set.ID, xpipeline.SignalProfiles, xpipeline.SignalProfiles)
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateProfilesToTracesFunc is the equivalent of Factory.CreateProfilesToTraces().
 | 
			
		||||
type CreateProfilesToTracesFunc func(context.Context, connector.Settings, component.Config, consumer.Traces) (Profiles, error)
 | 
			
		||||
 | 
			
		||||
// CreateProfilesToTraces implements Factory.CreateProfilesToTraces().
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateProfilesToTracesFunc) CreateProfilesToTraces(ctx context.Context, set connector.Settings, cfg component.Config, next consumer.Traces) (Profiles, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, internal.ErrDataTypes(set.ID, xpipeline.SignalProfiles, pipeline.SignalTraces)
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateProfilesToMetricsFunc is the equivalent of Factory.CreateProfilesToMetrics().
 | 
			
		||||
type CreateProfilesToMetricsFunc func(context.Context, connector.Settings, component.Config, consumer.Metrics) (Profiles, error)
 | 
			
		||||
 | 
			
		||||
// CreateProfilesToMetrics implements Factory.CreateProfilesToMetrics().
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateProfilesToMetricsFunc) CreateProfilesToMetrics(ctx context.Context, set connector.Settings, cfg component.Config, next consumer.Metrics) (Profiles, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, internal.ErrDataTypes(set.ID, xpipeline.SignalProfiles, pipeline.SignalMetrics)
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateProfilesToLogsFunc is the equivalent of Factory.CreateProfilesToLogs().
 | 
			
		||||
type CreateProfilesToLogsFunc func(context.Context, connector.Settings, component.Config, consumer.Logs) (Profiles, error)
 | 
			
		||||
 | 
			
		||||
// CreateProfilesToLogs implements Factory.CreateProfilesToLogs().
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateProfilesToLogsFunc) CreateProfilesToLogs(ctx context.Context, set connector.Settings, cfg component.Config, next consumer.Logs) (Profiles, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, internal.ErrDataTypes(set.ID, xpipeline.SignalProfiles, pipeline.SignalLogs)
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FactoryOption apply changes to ReceiverOptions.
 | 
			
		||||
type FactoryOption interface {
 | 
			
		||||
	// applyOption applies the option.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@ package exporter // import "go.opentelemetry.io/collector/exporter"
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	"go.opentelemetry.io/collector/component"
 | 
			
		||||
	"go.opentelemetry.io/collector/consumer"
 | 
			
		||||
| 
						 | 
				
			
			@ -93,39 +92,12 @@ func (f factoryOptionFunc) applyOption(o *factory) {
 | 
			
		|||
// CreateTracesFunc is the equivalent of Factory.CreateTraces.
 | 
			
		||||
type CreateTracesFunc func(context.Context, Settings, component.Config) (Traces, error)
 | 
			
		||||
 | 
			
		||||
// CreateTraces implements Factory.CreateTraces.
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateTracesFunc) CreateTraces(ctx context.Context, set Settings, cfg component.Config) (Traces, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, pipeline.ErrSignalNotSupported
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateMetricsFunc is the equivalent of Factory.CreateMetrics.
 | 
			
		||||
type CreateMetricsFunc func(context.Context, Settings, component.Config) (Metrics, error)
 | 
			
		||||
 | 
			
		||||
// CreateMetrics implements Factory.CreateMetrics.
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateMetricsFunc) CreateMetrics(ctx context.Context, set Settings, cfg component.Config) (Metrics, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, pipeline.ErrSignalNotSupported
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateLogsFunc is the equivalent of Factory.CreateLogs.
 | 
			
		||||
type CreateLogsFunc func(context.Context, Settings, component.Config) (Logs, error)
 | 
			
		||||
 | 
			
		||||
// CreateLogs implements Factory.CreateLogs.
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateLogsFunc) CreateLogs(ctx context.Context, set Settings, cfg component.Config) (Logs, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, pipeline.ErrSignalNotSupported
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type factory struct {
 | 
			
		||||
	cfgType component.Type
 | 
			
		||||
	component.CreateDefaultConfigFunc
 | 
			
		||||
| 
						 | 
				
			
			@ -214,18 +186,3 @@ func NewFactory(cfgType component.Type, createDefaultConfig component.CreateDefa
 | 
			
		|||
	}
 | 
			
		||||
	return f
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MakeFactoryMap takes a list of factories and returns a map with Factory type as keys.
 | 
			
		||||
// It returns a non-nil error when there are factories with duplicate type.
 | 
			
		||||
//
 | 
			
		||||
// Deprecated: [v0.120.0] Use otelcol.MakeFactoryMap[exporter.Factory] instead
 | 
			
		||||
func MakeFactoryMap(factories ...Factory) (map[component.Type]Factory, error) {
 | 
			
		||||
	fMap := map[component.Type]Factory{}
 | 
			
		||||
	for _, f := range factories {
 | 
			
		||||
		if _, ok := fMap[f.Type()]; ok {
 | 
			
		||||
			return fMap, fmt.Errorf("duplicate exporter factory %q", f.Type())
 | 
			
		||||
		}
 | 
			
		||||
		fMap[f.Type()] = f
 | 
			
		||||
	}
 | 
			
		||||
	return fMap, nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -56,43 +56,6 @@ func TestNewFactoryWithOptions(t *testing.T) {
 | 
			
		|||
	assert.NoError(t, err)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestMakeFactoryMap(t *testing.T) {
 | 
			
		||||
	type testCase struct {
 | 
			
		||||
		name string
 | 
			
		||||
		in   []Factory
 | 
			
		||||
		out  map[component.Type]Factory
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	p1 := NewFactory(component.MustNewType("p1"), nil)
 | 
			
		||||
	p2 := NewFactory(component.MustNewType("p2"), nil)
 | 
			
		||||
	testCases := []testCase{
 | 
			
		||||
		{
 | 
			
		||||
			name: "different names",
 | 
			
		||||
			in:   []Factory{p1, p2},
 | 
			
		||||
			out: map[component.Type]Factory{
 | 
			
		||||
				p1.Type(): p1,
 | 
			
		||||
				p2.Type(): p2,
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: "same name",
 | 
			
		||||
			in:   []Factory{p1, p2, NewFactory(component.MustNewType("p1"), nil)},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, tt := range testCases {
 | 
			
		||||
		t.Run(tt.name, func(t *testing.T) {
 | 
			
		||||
			out, err := MakeFactoryMap(tt.in...)
 | 
			
		||||
			if tt.out == nil {
 | 
			
		||||
				assert.Error(t, err)
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
			require.NoError(t, err)
 | 
			
		||||
			assert.Equal(t, tt.out, out)
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var nopInstance = &nop{
 | 
			
		||||
	Consumer: consumertest.NewNop(),
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -51,15 +51,6 @@ type factoryOpts struct {
 | 
			
		|||
// CreateProfilesFunc is the equivalent of Factory.CreateProfiles.
 | 
			
		||||
type CreateProfilesFunc func(context.Context, exporter.Settings, component.Config) (Profiles, error)
 | 
			
		||||
 | 
			
		||||
// CreateProfiles implements Factory.CreateProfiles.
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateProfilesFunc) CreateProfiles(ctx context.Context, set exporter.Settings, cfg component.Config) (Profiles, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, pipeline.ErrSignalNotSupported
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// WithTraces overrides the default "error not supported" implementation for CreateTraces and the default "undefined" stability level.
 | 
			
		||||
func WithTraces(createTraces exporter.CreateTracesFunc, sl component.StabilityLevel) FactoryOption {
 | 
			
		||||
	return factoryOptionFunc(func(o *factoryOpts) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,12 +31,6 @@ type Settings struct {
 | 
			
		|||
// CreateFunc is the equivalent of Factory.Create(...) function.
 | 
			
		||||
type CreateFunc func(context.Context, Settings, component.Config) (Extension, error)
 | 
			
		||||
 | 
			
		||||
// Create implements Factory.Create.
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateFunc) Create(ctx context.Context, set Settings, cfg component.Config) (Extension, error) {
 | 
			
		||||
	return f(ctx, set, cfg)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type Factory interface {
 | 
			
		||||
	component.Factory
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -88,18 +82,3 @@ func NewFactory(
 | 
			
		|||
		extensionStability:      sl,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MakeFactoryMap takes a list of factories and returns a map with Factory type as keys.
 | 
			
		||||
// It returns a non-nil error when there are factories with duplicate type.
 | 
			
		||||
//
 | 
			
		||||
// Deprecated: [v0.120.0] Use otelcol.MakeFactoryMap[extension.Factory] instead
 | 
			
		||||
func MakeFactoryMap(factories ...Factory) (map[component.Type]Factory, error) {
 | 
			
		||||
	fMap := map[component.Type]Factory{}
 | 
			
		||||
	for _, f := range factories {
 | 
			
		||||
		if _, ok := fMap[f.Type()]; ok {
 | 
			
		||||
			return fMap, fmt.Errorf("duplicate extension factory %q", f.Type())
 | 
			
		||||
		}
 | 
			
		||||
		fMap[f.Type()] = f
 | 
			
		||||
	}
 | 
			
		||||
	return fMap, nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,39 +42,3 @@ func TestNewFactory(t *testing.T) {
 | 
			
		|||
	_, err = factory.Create(context.Background(), Settings{ID: component.NewID(component.MustNewType("mismatch"))}, &defaultCfg)
 | 
			
		||||
	require.Error(t, err)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestMakeFactoryMap(t *testing.T) {
 | 
			
		||||
	type testCase struct {
 | 
			
		||||
		name string
 | 
			
		||||
		in   []Factory
 | 
			
		||||
		out  map[component.Type]Factory
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	p1 := NewFactory(component.MustNewType("p1"), nil, nil, component.StabilityLevelAlpha)
 | 
			
		||||
	p2 := NewFactory(component.MustNewType("p2"), nil, nil, component.StabilityLevelAlpha)
 | 
			
		||||
	testCases := []testCase{
 | 
			
		||||
		{
 | 
			
		||||
			name: "different names",
 | 
			
		||||
			in:   []Factory{p1, p2},
 | 
			
		||||
			out: map[component.Type]Factory{
 | 
			
		||||
				p1.Type(): p1,
 | 
			
		||||
				p2.Type(): p2,
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: "same name",
 | 
			
		||||
			in:   []Factory{p1, p2, NewFactory(component.MustNewType("p1"), nil, nil, component.StabilityLevelAlpha)},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	for _, tt := range testCases {
 | 
			
		||||
		t.Run(tt.name, func(t *testing.T) {
 | 
			
		||||
			out, err := MakeFactoryMap(tt.in...)
 | 
			
		||||
			if tt.out == nil {
 | 
			
		||||
				assert.Error(t, err)
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
			require.NoError(t, err)
 | 
			
		||||
			assert.Equal(t, tt.out, out)
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@ package processor // import "go.opentelemetry.io/collector/processor"
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	"go.opentelemetry.io/collector/component"
 | 
			
		||||
	"go.opentelemetry.io/collector/consumer"
 | 
			
		||||
| 
						 | 
				
			
			@ -146,39 +145,12 @@ func (f *factory) CreateLogs(ctx context.Context, set Settings, cfg component.Co
 | 
			
		|||
// CreateTracesFunc is the equivalent of Factory.CreateTraces().
 | 
			
		||||
type CreateTracesFunc func(context.Context, Settings, component.Config, consumer.Traces) (Traces, error)
 | 
			
		||||
 | 
			
		||||
// CreateTraces implements Factory.CreateTraces.
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateTracesFunc) CreateTraces(ctx context.Context, set Settings, cfg component.Config, next consumer.Traces) (Traces, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, pipeline.ErrSignalNotSupported
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateMetricsFunc is the equivalent of Factory.CreateMetrics().
 | 
			
		||||
type CreateMetricsFunc func(context.Context, Settings, component.Config, consumer.Metrics) (Metrics, error)
 | 
			
		||||
 | 
			
		||||
// CreateMetrics implements Factory.CreateMetrics.
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateMetricsFunc) CreateMetrics(ctx context.Context, set Settings, cfg component.Config, next consumer.Metrics) (Metrics, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, pipeline.ErrSignalNotSupported
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateLogsFunc is the equivalent of Factory.CreateLogs.
 | 
			
		||||
type CreateLogsFunc func(context.Context, Settings, component.Config, consumer.Logs) (Logs, error)
 | 
			
		||||
 | 
			
		||||
// CreateLogs implements Factory.CreateLogs().
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateLogsFunc) CreateLogs(ctx context.Context, set Settings, cfg component.Config, next consumer.Logs) (Logs, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, pipeline.ErrSignalNotSupported
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// WithTraces overrides the default "error not supported" implementation for CreateTraces and the default "undefined" stability level.
 | 
			
		||||
func WithTraces(createTraces CreateTracesFunc, sl component.StabilityLevel) FactoryOption {
 | 
			
		||||
	return factoryOptionFunc(func(o *factory) {
 | 
			
		||||
| 
						 | 
				
			
			@ -214,18 +186,3 @@ func NewFactory(cfgType component.Type, createDefaultConfig component.CreateDefa
 | 
			
		|||
	}
 | 
			
		||||
	return f
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MakeFactoryMap takes a list of factories and returns a map with Factory type as keys.
 | 
			
		||||
// It returns a non-nil error when there are factories with duplicate type.
 | 
			
		||||
//
 | 
			
		||||
// Deprecated: [v0.120.0] Use otelcol.MakeFactoryMap[processor.Factory] instead
 | 
			
		||||
func MakeFactoryMap(factories ...Factory) (map[component.Type]Factory, error) {
 | 
			
		||||
	fMap := map[component.Type]Factory{}
 | 
			
		||||
	for _, f := range factories {
 | 
			
		||||
		if _, ok := fMap[f.Type()]; ok {
 | 
			
		||||
			return fMap, fmt.Errorf("duplicate processor factory %q", f.Type())
 | 
			
		||||
		}
 | 
			
		||||
		fMap[f.Type()] = f
 | 
			
		||||
	}
 | 
			
		||||
	return fMap, nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -57,43 +57,6 @@ func TestNewFactoryWithOptions(t *testing.T) {
 | 
			
		|||
	assert.NoError(t, err)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestMakeFactoryMap(t *testing.T) {
 | 
			
		||||
	type testCase struct {
 | 
			
		||||
		name string
 | 
			
		||||
		in   []Factory
 | 
			
		||||
		out  map[component.Type]Factory
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	p1 := NewFactory(component.MustNewType("p1"), nil)
 | 
			
		||||
	p2 := NewFactory(component.MustNewType("p2"), nil)
 | 
			
		||||
	testCases := []testCase{
 | 
			
		||||
		{
 | 
			
		||||
			name: "different names",
 | 
			
		||||
			in:   []Factory{p1, p2},
 | 
			
		||||
			out: map[component.Type]Factory{
 | 
			
		||||
				p1.Type(): p1,
 | 
			
		||||
				p2.Type(): p2,
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: "same name",
 | 
			
		||||
			in:   []Factory{p1, p2, NewFactory(component.MustNewType("p1"), nil)},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, tt := range testCases {
 | 
			
		||||
		t.Run(tt.name, func(t *testing.T) {
 | 
			
		||||
			out, err := MakeFactoryMap(tt.in...)
 | 
			
		||||
			if tt.out == nil {
 | 
			
		||||
				assert.Error(t, err)
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
			require.NoError(t, err)
 | 
			
		||||
			assert.Equal(t, tt.out, out)
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var nopInstance = &nopProcessor{
 | 
			
		||||
	Consumer: consumertest.NewNop(),
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,15 +38,6 @@ type Profiles interface {
 | 
			
		|||
// CreateProfilesFunc is the equivalent of Factory.CreateProfiles().
 | 
			
		||||
type CreateProfilesFunc func(context.Context, processor.Settings, component.Config, xconsumer.Profiles) (Profiles, error)
 | 
			
		||||
 | 
			
		||||
// CreateProfiles implements Factory.CreateProfiles.
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateProfilesFunc) CreateProfiles(ctx context.Context, set processor.Settings, cfg component.Config, next xconsumer.Profiles) (Profiles, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, pipeline.ErrSignalNotSupported
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FactoryOption apply changes to ReceiverOptions.
 | 
			
		||||
type FactoryOption interface {
 | 
			
		||||
	// applyOption applies the option.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@ package receiver // import "go.opentelemetry.io/collector/receiver"
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	"go.opentelemetry.io/collector/component"
 | 
			
		||||
	"go.opentelemetry.io/collector/consumer"
 | 
			
		||||
| 
						 | 
				
			
			@ -103,39 +102,12 @@ func (f factoryOptionFunc) applyOption(o *factory) {
 | 
			
		|||
// CreateTracesFunc is the equivalent of Factory.CreateTraces.
 | 
			
		||||
type CreateTracesFunc func(context.Context, Settings, component.Config, consumer.Traces) (Traces, error)
 | 
			
		||||
 | 
			
		||||
// CreateTraces implements Factory.CreateTraces().
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateTracesFunc) CreateTraces(ctx context.Context, set Settings, cfg component.Config, next consumer.Traces) (Traces, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, pipeline.ErrSignalNotSupported
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateMetricsFunc is the equivalent of Factory.CreateMetrics.
 | 
			
		||||
type CreateMetricsFunc func(context.Context, Settings, component.Config, consumer.Metrics) (Metrics, error)
 | 
			
		||||
 | 
			
		||||
// CreateMetrics implements Factory.CreateMetrics.
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateMetricsFunc) CreateMetrics(ctx context.Context, set Settings, cfg component.Config, next consumer.Metrics) (Metrics, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, pipeline.ErrSignalNotSupported
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateLogsFunc is the equivalent of Factory.CreateLogs.
 | 
			
		||||
type CreateLogsFunc func(context.Context, Settings, component.Config, consumer.Logs) (Logs, error)
 | 
			
		||||
 | 
			
		||||
// CreateLogs implements Factory.CreateLogs.
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateLogsFunc) CreateLogs(ctx context.Context, set Settings, cfg component.Config, next consumer.Logs) (Logs, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, pipeline.ErrSignalNotSupported
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type factory struct {
 | 
			
		||||
	cfgType component.Type
 | 
			
		||||
	component.CreateDefaultConfigFunc
 | 
			
		||||
| 
						 | 
				
			
			@ -221,18 +193,3 @@ func NewFactory(cfgType component.Type, createDefaultConfig component.CreateDefa
 | 
			
		|||
	}
 | 
			
		||||
	return f
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MakeFactoryMap takes a list of receiver factories and returns a map with factory type as keys.
 | 
			
		||||
// It returns a non-nil error when there are factories with duplicate type.
 | 
			
		||||
//
 | 
			
		||||
// Deprecated: [v0.120.0] Use otelcol.MakeFactoryMap[receiver.Factory] instead
 | 
			
		||||
func MakeFactoryMap(factories ...Factory) (map[component.Type]Factory, error) {
 | 
			
		||||
	fMap := map[component.Type]Factory{}
 | 
			
		||||
	for _, f := range factories {
 | 
			
		||||
		if _, ok := fMap[f.Type()]; ok {
 | 
			
		||||
			return fMap, fmt.Errorf("duplicate receiver factory %q", f.Type())
 | 
			
		||||
		}
 | 
			
		||||
		fMap[f.Type()] = f
 | 
			
		||||
	}
 | 
			
		||||
	return fMap, nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -57,43 +57,6 @@ func TestNewFactoryWithOptions(t *testing.T) {
 | 
			
		|||
	assert.NoError(t, err)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestMakeFactoryMap(t *testing.T) {
 | 
			
		||||
	type testCase struct {
 | 
			
		||||
		name string
 | 
			
		||||
		in   []Factory
 | 
			
		||||
		out  map[component.Type]Factory
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	p1 := NewFactory(component.MustNewType("p1"), nil)
 | 
			
		||||
	p2 := NewFactory(component.MustNewType("p2"), nil)
 | 
			
		||||
	testCases := []testCase{
 | 
			
		||||
		{
 | 
			
		||||
			name: "different names",
 | 
			
		||||
			in:   []Factory{p1, p2},
 | 
			
		||||
			out: map[component.Type]Factory{
 | 
			
		||||
				p1.Type(): p1,
 | 
			
		||||
				p2.Type(): p2,
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: "same name",
 | 
			
		||||
			in:   []Factory{p1, p2, NewFactory(component.MustNewType("p1"), nil)},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, tt := range testCases {
 | 
			
		||||
		t.Run(tt.name, func(t *testing.T) {
 | 
			
		||||
			out, err := MakeFactoryMap(tt.in...)
 | 
			
		||||
			if tt.out == nil {
 | 
			
		||||
				assert.Error(t, err)
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
			require.NoError(t, err)
 | 
			
		||||
			assert.Equal(t, tt.out, out)
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var nopInstance = &nopReceiver{
 | 
			
		||||
	Consumer: consumertest.NewNop(),
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,15 +40,6 @@ type Factory interface {
 | 
			
		|||
// CreateProfilesFunc is the equivalent of Factory.CreateProfiles.
 | 
			
		||||
type CreateProfilesFunc func(context.Context, receiver.Settings, component.Config, xconsumer.Profiles) (Profiles, error)
 | 
			
		||||
 | 
			
		||||
// CreateProfiles implements Factory.CreateProfiles.
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateProfilesFunc) CreateProfiles(ctx context.Context, set receiver.Settings, cfg component.Config, next xconsumer.Profiles) (Profiles, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, pipeline.ErrSignalNotSupported
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg, next)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FactoryOption apply changes to Factory.
 | 
			
		||||
type FactoryOption interface {
 | 
			
		||||
	// applyOption applies the option.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@ package scraper // import "go.opentelemetry.io/collector/scraper"
 | 
			
		|||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	"go.opentelemetry.io/collector/component"
 | 
			
		||||
	"go.opentelemetry.io/collector/pipeline"
 | 
			
		||||
| 
						 | 
				
			
			@ -106,24 +105,6 @@ type CreateLogsFunc func(context.Context, Settings, component.Config) (Logs, err
 | 
			
		|||
// CreateMetricsFunc is the equivalent of Factory.CreateMetrics().
 | 
			
		||||
type CreateMetricsFunc func(context.Context, Settings, component.Config) (Metrics, error)
 | 
			
		||||
 | 
			
		||||
// CreateLogs implements Factory.CreateLogs.
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateLogsFunc) CreateLogs(ctx context.Context, set Settings, cfg component.Config) (Logs, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, pipeline.ErrSignalNotSupported
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateMetrics implements Factory.CreateMetrics.
 | 
			
		||||
// Deprecated: [v0.120.0] No longer used, will be removed.
 | 
			
		||||
func (f CreateMetricsFunc) CreateMetrics(ctx context.Context, set Settings, cfg component.Config) (Metrics, error) {
 | 
			
		||||
	if f == nil {
 | 
			
		||||
		return nil, pipeline.ErrSignalNotSupported
 | 
			
		||||
	}
 | 
			
		||||
	return f(ctx, set, cfg)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// WithLogs overrides the default "error not supported" implementation for CreateLogs and the default "undefined" stability level.
 | 
			
		||||
func WithLogs(createLogs CreateLogsFunc, sl component.StabilityLevel) FactoryOption {
 | 
			
		||||
	return factoryOptionFunc(func(o *factory) {
 | 
			
		||||
| 
						 | 
				
			
			@ -151,18 +132,3 @@ func NewFactory(cfgType component.Type, createDefaultConfig component.CreateDefa
 | 
			
		|||
	}
 | 
			
		||||
	return f
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MakeFactoryMap takes a list of receiver factories and returns a map with factory type as keys.
 | 
			
		||||
// It returns a non-nil error when there are factories with duplicate type.
 | 
			
		||||
//
 | 
			
		||||
// Deprecated: [v0.120.0] Use otelcol.MakeFactoryMap[scraper.Factory] instead
 | 
			
		||||
func MakeFactoryMap(factories ...Factory) (map[component.Type]Factory, error) {
 | 
			
		||||
	fMap := map[component.Type]Factory{}
 | 
			
		||||
	for _, f := range factories {
 | 
			
		||||
		if _, ok := fMap[f.Type()]; ok {
 | 
			
		||||
			return fMap, fmt.Errorf("duplicate scraper factory %q", f.Type())
 | 
			
		||||
		}
 | 
			
		||||
		fMap[f.Type()] = f
 | 
			
		||||
	}
 | 
			
		||||
	return fMap, nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -57,43 +57,6 @@ func TestNewFactoryWithOptions(t *testing.T) {
 | 
			
		|||
	require.NoError(t, err)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestMakeFactoryMap(t *testing.T) {
 | 
			
		||||
	type testCase struct {
 | 
			
		||||
		name string
 | 
			
		||||
		in   []Factory
 | 
			
		||||
		out  map[component.Type]Factory
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	p1 := NewFactory(component.MustNewType("p1"), nil)
 | 
			
		||||
	p2 := NewFactory(component.MustNewType("p2"), nil)
 | 
			
		||||
	testCases := []testCase{
 | 
			
		||||
		{
 | 
			
		||||
			name: "different names",
 | 
			
		||||
			in:   []Factory{p1, p2},
 | 
			
		||||
			out: map[component.Type]Factory{
 | 
			
		||||
				p1.Type(): p1,
 | 
			
		||||
				p2.Type(): p2,
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: "same name",
 | 
			
		||||
			in:   []Factory{p1, p2, NewFactory(component.MustNewType("p1"), nil)},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, tt := range testCases {
 | 
			
		||||
		t.Run(tt.name, func(t *testing.T) {
 | 
			
		||||
			out, err := MakeFactoryMap(tt.in...)
 | 
			
		||||
			if tt.out == nil {
 | 
			
		||||
				assert.Error(t, err)
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
			require.NoError(t, err)
 | 
			
		||||
			assert.Equal(t, tt.out, out)
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func createLogs(context.Context, Settings, component.Config) (Logs, error) {
 | 
			
		||||
	return NewLogs(newTestScrapeLogsFunc(nil))
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue