@@ -23,14 +23,14 @@ import (
2323
2424 "github.com/census-instrumentation/opencensus-service/consumer"
2525 "github.com/census-instrumentation/opencensus-service/internal/configmodels"
26+ "github.com/census-instrumentation/opencensus-service/processor"
2627 "github.com/census-instrumentation/opencensus-service/receiver"
2728)
2829
2930///////////////////////////////////////////////////////////////////////////////
3031// Receiver factory and its registry.
3132
32- // ReceiverFactory is factory interface for receivers. Note: only configuration-related
33- // functionality exists for now. We will add more factory functionality in the future.
33+ // ReceiverFactory is factory interface for receivers.
3434type ReceiverFactory interface {
3535 // Type gets the type of the Receiver created by this factory.
3636 Type () string
@@ -115,32 +115,43 @@ func GetExporterFactory(typeStr string) ExporterFactory {
115115}
116116
117117///////////////////////////////////////////////////////////////////////////////
118- // Option factory and its registry.
118+ // Processor factory and its registry.
119119
120- // OptionFactory is factory interface for options. Note: only configuration-related
121- // functionality exists for now. We will add more factory functionality in the future.
122- type OptionFactory interface {
123- // Type gets the type of the Option created by this factory.
120+ // ProcessorFactory is factory interface for processors.
121+ type ProcessorFactory interface {
122+ // Type gets the type of the Processor created by this factory.
124123 Type () string
125124
126- // CreateDefaultConfig creates the default configuration for the Option .
125+ // CreateDefaultConfig creates the default configuration for the Processor .
127126 CreateDefaultConfig () configmodels.Processor
127+
128+ // CreateTraceProcessor creates a trace processor based on this config.
129+ // If the processor type does not support tracing or if the config is not valid
130+ // error will be returned instead.
131+ CreateTraceProcessor (nextConsumer consumer.TraceConsumer ,
132+ cfg configmodels.Processor ) (processor.TraceProcessor , error )
133+
134+ // CreateMetricsProcessor creates a metrics processor based on this config.
135+ // If the processor type does not support metrics or if the config is not valid
136+ // error will be returned instead.
137+ CreateMetricsProcessor (nextConsumer consumer.MetricsConsumer ,
138+ cfg configmodels.Processor ) (processor.MetricsProcessor , error )
128139}
129140
130- // List of registered option factories.
131- var optionFactories = make (map [string ]OptionFactory )
141+ // List of registered processor factories.
142+ var processorFactories = make (map [string ]ProcessorFactory )
132143
133- // RegisterProcessorFactory registers a option factory.
134- func RegisterProcessorFactory (factory OptionFactory ) error {
135- if optionFactories [factory .Type ()] != nil {
136- panic (fmt .Sprintf ("duplicate option factory %q" , factory .Type ()))
144+ // RegisterProcessorFactory registers a processor factory.
145+ func RegisterProcessorFactory (factory ProcessorFactory ) error {
146+ if processorFactories [factory .Type ()] != nil {
147+ panic (fmt .Sprintf ("duplicate processor factory %q" , factory .Type ()))
137148 }
138149
139- optionFactories [factory .Type ()] = factory
150+ processorFactories [factory .Type ()] = factory
140151 return nil
141152}
142153
143- // GetProcessorFactory gets a option factory by type string.
144- func GetProcessorFactory (typeStr string ) OptionFactory {
145- return optionFactories [typeStr ]
154+ // GetProcessorFactory gets a processor factory by type string.
155+ func GetProcessorFactory (typeStr string ) ProcessorFactory {
156+ return processorFactories [typeStr ]
146157}
0 commit comments