| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
package receivertest |
| 5 |
|
| 6 |
import ( |
| 7 |
"context" |
| 8 |
|
| 9 |
"github.com/google/uuid" |
| 10 |
|
| 11 |
"go.opentelemetry.io/collector/component" |
| 12 |
"go.opentelemetry.io/collector/component/componenttest" |
| 13 |
"go.opentelemetry.io/collector/consumer" |
| 14 |
"go.opentelemetry.io/collector/consumer/xconsumer" |
| 15 |
"go.opentelemetry.io/collector/receiver" |
| 16 |
"go.opentelemetry.io/collector/receiver/xreceiver" |
| 17 |
) |
| 18 |
|
| 19 |
var NopType = component.MustNewType("nop") |
| 20 |
|
| 21 |
|
| 22 |
func NewNopSettings(typ component.Type) receiver.Settings { |
| 23 |
return receiver.Settings{ |
| 24 |
ID: component.NewIDWithName(typ, uuid.NewString()), |
| 25 |
TelemetrySettings: componenttest.NewNopTelemetrySettings(), |
| 26 |
BuildInfo: component.NewDefaultBuildInfo(), |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
func NewNopFactory() receiver.Factory { |
| 32 |
return xreceiver.NewFactory( |
| 33 |
NopType, |
| 34 |
func() component.Config { return &nopConfig{} }, |
| 35 |
xreceiver.WithTraces(createTraces, component.StabilityLevelStable), |
| 36 |
xreceiver.WithMetrics(createMetrics, component.StabilityLevelStable), |
| 37 |
xreceiver.WithLogs(createLogs, component.StabilityLevelStable), |
| 38 |
xreceiver.WithProfiles(createProfiles, component.StabilityLevelAlpha), |
| 39 |
) |
| 40 |
} |
| 41 |
|
| 42 |
type nopConfig struct{} |
| 43 |
|
| 44 |
func createTraces(context.Context, receiver.Settings, component.Config, consumer.Traces) (receiver.Traces, error) { |
| 45 |
return nopInstance, nil |
| 46 |
} |
| 47 |
|
| 48 |
func createMetrics(context.Context, receiver.Settings, component.Config, consumer.Metrics) (receiver.Metrics, error) { |
| 49 |
return nopInstance, nil |
| 50 |
} |
| 51 |
|
| 52 |
func createLogs(context.Context, receiver.Settings, component.Config, consumer.Logs) (receiver.Logs, error) { |
| 53 |
return nopInstance, nil |
| 54 |
} |
| 55 |
|
| 56 |
func createProfiles(context.Context, receiver.Settings, component.Config, xconsumer.Profiles) (xreceiver.Profiles, error) { |
| 57 |
return nopInstance, nil |
| 58 |
} |
| 59 |
|
| 60 |
var nopInstance = &nopReceiver{} |
| 61 |
|
| 62 |
|
| 63 |
type nopReceiver struct { |
| 64 |
component.StartFunc |
| 65 |
component.ShutdownFunc |
| 66 |
} |