|
| 1 | +// Copyright 2019, OpenTelemetry Authors |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package queued |
| 16 | + |
| 17 | +import ( |
| 18 | + "time" |
| 19 | + |
| 20 | + "github.com/open-telemetry/opentelemetry-service/consumer" |
| 21 | + "github.com/open-telemetry/opentelemetry-service/internal/configmodels" |
| 22 | + "github.com/open-telemetry/opentelemetry-service/internal/factories" |
| 23 | + "github.com/open-telemetry/opentelemetry-service/processor" |
| 24 | +) |
| 25 | + |
| 26 | +var _ = factories.RegisterProcessorFactory(&processorFactory{}) |
| 27 | + |
| 28 | +const ( |
| 29 | + // The value of "type" key in configuration. |
| 30 | + typeStr = "queued-retry" |
| 31 | +) |
| 32 | + |
| 33 | +// processorFactory is the factory for OpenCensus exporter. |
| 34 | +type processorFactory struct { |
| 35 | +} |
| 36 | + |
| 37 | +// Type gets the type of the Option config created by this factory. |
| 38 | +func (f *processorFactory) Type() string { |
| 39 | + return typeStr |
| 40 | +} |
| 41 | + |
| 42 | +// CreateDefaultConfig creates the default configuration for exporter. |
| 43 | +func (f *processorFactory) CreateDefaultConfig() configmodels.Processor { |
| 44 | + return &ConfigV2{ |
| 45 | + ProcessorSettings: configmodels.ProcessorSettings{ |
| 46 | + TypeVal: typeStr, |
| 47 | + }, |
| 48 | + NumWorkers: 10, |
| 49 | + QueueSize: 5000, |
| 50 | + RetryOnFailure: true, |
| 51 | + BackoffDelay: time.Second * 5, |
| 52 | + } |
| 53 | +} |
| 54 | + |
| 55 | +// CreateTraceProcessor creates a trace processor based on this config. |
| 56 | +func (f *processorFactory) CreateTraceProcessor( |
| 57 | + nextConsumer consumer.TraceConsumer, |
| 58 | + cfg configmodels.Processor, |
| 59 | +) (processor.TraceProcessor, error) { |
| 60 | + oCfg := cfg.(*ConfigV2) |
| 61 | + return NewQueuedSpanProcessor(nextConsumer, |
| 62 | + Options.WithNumWorkers(oCfg.NumWorkers), |
| 63 | + Options.WithQueueSize(oCfg.QueueSize), |
| 64 | + Options.WithRetryOnProcessingFailures(oCfg.RetryOnFailure), |
| 65 | + Options.WithBackoffDelay(oCfg.BackoffDelay), |
| 66 | + ), nil |
| 67 | +} |
| 68 | + |
| 69 | +// CreateMetricsProcessor creates a metrics processor based on this config. |
| 70 | +func (f *processorFactory) CreateMetricsProcessor( |
| 71 | + nextConsumer consumer.MetricsConsumer, |
| 72 | + cfg configmodels.Processor, |
| 73 | +) (processor.MetricsProcessor, error) { |
| 74 | + return nil, factories.ErrDataTypeIsNotSupported |
| 75 | +} |
0 commit comments