-
Notifications
You must be signed in to change notification settings - Fork 487
/
factory.go
79 lines (62 loc) · 2.36 KB
/
factory.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package pushreceiver
import (
"context"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/consumer"
)
const (
//TypeStr for push receiver.
TypeStr = "push_receiver"
)
// Type returns the receiver type that PushReceiverFactory produces
func (f Factory) Type() config.Type {
return TypeStr
}
// NewFactory creates a new push receiver factory.
func NewFactory() component.ReceiverFactory {
return &Factory{}
}
// CreateDefaultConfig creates a default push receiver config.
func (f *Factory) CreateDefaultConfig() config.Receiver {
s := config.NewReceiverSettings(config.NewComponentIDWithName(TypeStr, TypeStr))
return &s
}
// Factory is a factory that sneakily exposes a Traces consumer for use within the agent.
type Factory struct {
component.Factory
Consumer consumer.Traces
}
// MetricsReceiverStability implements component.ReceiverFactory.
func (f *Factory) MetricsReceiverStability() component.StabilityLevel {
return component.StabilityLevelUndefined
}
// LogsReceiverStability implements component.ReceiverFactory.
func (f *Factory) LogsReceiverStability() component.StabilityLevel {
return component.StabilityLevelUndefined
}
// TracesReceiverStability implements component.ReceiverFactory.
func (f *Factory) TracesReceiverStability() component.StabilityLevel {
return component.StabilityLevelUndefined
}
// CreateTracesReceiver creates a stub receiver while also sneakily keeping a reference to the provided Traces consumer.
func (f *Factory) CreateTracesReceiver(
_ context.Context,
_ component.ReceiverCreateSettings,
_ config.Receiver,
c consumer.Traces,
) (component.TracesReceiver, error) {
r, err := newPushReceiver()
f.Consumer = c
return r, err
}
// CreateMetricsReceiver returns an error because metrics are not supported by push receiver.
func (f *Factory) CreateMetricsReceiver(ctx context.Context, set component.ReceiverCreateSettings,
cfg config.Receiver, nextConsumer consumer.Metrics) (component.MetricsReceiver, error) {
return nil, component.ErrDataTypeIsNotSupported
}
// CreateLogsReceiver returns an error because logs are not supported by push receiver.
func (f *Factory) CreateLogsReceiver(ctx context.Context, set component.ReceiverCreateSettings,
cfg config.Receiver, nextConsumer consumer.Logs) (component.LogsReceiver, error) {
return nil, component.ErrDataTypeIsNotSupported
}