Documentation ¶
Overview ¶
Package componenttest define types and functions used to help test packages implementing the component package interfaces.
Index ¶
- func CheckDocs(projectPath string, relativeComponentsPath string, projectGoModule string) error
- func NewNopHost() component.Host
- type ErrorWaitingHost
- func (ews *ErrorWaitingHost) GetExporters() map[configmodels.DataType]map[configmodels.Exporter]component.Exporter
- func (ews *ErrorWaitingHost) GetExtensions() map[configmodels.Extension]component.ServiceExtension
- func (ews *ErrorWaitingHost) GetFactory(_ component.Kind, _ configmodels.Type) component.Factory
- func (ews *ErrorWaitingHost) ReportFatalError(err error)
- func (ews *ErrorWaitingHost) WaitForFatalError(timeout time.Duration) (receivedError bool, err error)
- type NopHost
- func (nh *NopHost) GetExporters() map[configmodels.DataType]map[configmodels.Exporter]component.Exporter
- func (nh *NopHost) GetExtensions() map[configmodels.Extension]component.ServiceExtension
- func (nh *NopHost) GetFactory(_ component.Kind, _ configmodels.Type) component.Factory
- func (nh *NopHost) ReportFatalError(_ error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckDocs ¶ added in v0.5.0
CheckDocs returns an error if README.md for at least one enabled component is missing. "projectPath" is the absolute path to the root of the project to which the components belong. "defaultComponentsFilePath" is the path to the file that contains imports to all required components, "goModule" is the Go module to which the imports belong. This method is intended to be used only to verify documentation in Opentelemetry core and contrib repositories. Examples, 1) Usage in the core repo:
componenttest.CheckDocs(
"path/to/project", "service/defaultcomponents/defaults.go", "go.opentelemetry.io/collector", )
2) Usage in the contrib repo: componenttest.CheckDocs(
"path/to/project", "cmd/otelcontrib/components.go", "github.com/open-telemetry/opentelemetry-collector-contrib", ).
func NewNopHost ¶
NewNopHost returns a new instance of NopHost with proper defaults for most tests.
Types ¶
type ErrorWaitingHost ¶
type ErrorWaitingHost struct {
// contains filtered or unexported fields
}
ErrorWaitingHost mocks an component.Host for test purposes.
func NewErrorWaitingHost ¶
func NewErrorWaitingHost() *ErrorWaitingHost
NewErrorWaitingHost returns a new instance of ErrorWaitingHost with proper defaults for most tests.
func (*ErrorWaitingHost) GetExporters ¶
func (ews *ErrorWaitingHost) GetExporters() map[configmodels.DataType]map[configmodels.Exporter]component.Exporter
func (*ErrorWaitingHost) GetExtensions ¶
func (ews *ErrorWaitingHost) GetExtensions() map[configmodels.Extension]component.ServiceExtension
func (*ErrorWaitingHost) GetFactory ¶
func (ews *ErrorWaitingHost) GetFactory(_ component.Kind, _ configmodels.Type) component.Factory
GetFactory of the specified kind. Returns the factory for a component type.
func (*ErrorWaitingHost) ReportFatalError ¶
func (ews *ErrorWaitingHost) ReportFatalError(err error)
ReportFatalError is used to report to the host that the extension encountered a fatal error (i.e.: an error that the instance can't recover from) after its start function has already returned.
func (*ErrorWaitingHost) WaitForFatalError ¶
func (ews *ErrorWaitingHost) WaitForFatalError(timeout time.Duration) (receivedError bool, err error)
WaitForFatalError waits the given amount of time until an error is reported via ReportFatalError. It returns the error, if any, and a bool to indicated if an error was received before the time out.
type NopHost ¶
type NopHost struct { }
NopHost mocks a receiver.ReceiverHost for test purposes.
func (*NopHost) GetExporters ¶
func (nh *NopHost) GetExporters() map[configmodels.DataType]map[configmodels.Exporter]component.Exporter
func (*NopHost) GetExtensions ¶
func (nh *NopHost) GetExtensions() map[configmodels.Extension]component.ServiceExtension
func (*NopHost) GetFactory ¶
GetFactory of the specified kind. Returns the factory for a component type.
func (*NopHost) ReportFatalError ¶
ReportFatalError is used to report to the host that the receiver encountered a fatal error (i.e.: an error that the instance can't recover from) after its start function has already returned.