/
host.go
51 lines (41 loc) · 1.49 KB
/
host.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//go:build !no_traces
package traces
import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"github.com/F1997/categraf/pkg/otel/extensions"
"github.com/F1997/categraf/pkg/otel/pipelines"
)
var _ component.Host = (*serviceHost)(nil)
type serviceHost struct {
asyncErrorChannel chan error
factories component.Factories
buildInfo component.BuildInfo
pipelines *pipelines.Pipelines
builtExtensions *extensions.BuiltExtensions
}
// 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.
func (host *serviceHost) ReportFatalError(err error) {
host.asyncErrorChannel <- err
}
func (host *serviceHost) GetFactory(kind component.Kind, componentType config.Type) component.Factory {
switch kind {
case component.KindReceiver:
return host.factories.Receivers[componentType]
case component.KindProcessor:
return host.factories.Processors[componentType]
case component.KindExporter:
return host.factories.Exporters[componentType]
case component.KindExtension:
return host.factories.Extensions[componentType]
}
return nil
}
func (host *serviceHost) GetExtensions() map[config.ComponentID]component.Extension {
return host.builtExtensions.GetExtensions()
}
func (host *serviceHost) GetExporters() map[config.DataType]map[config.ComponentID]component.Exporter {
return host.pipelines.GetExporters()
}