|
| 1 | +// Copyright The 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 sumologicsyslogprocessor |
| 16 | + |
| 17 | +import ( |
| 18 | + "context" |
| 19 | + |
| 20 | + "go.opentelemetry.io/collector/component" |
| 21 | + "go.opentelemetry.io/collector/config" |
| 22 | + "go.opentelemetry.io/collector/consumer" |
| 23 | + "go.opentelemetry.io/collector/processor/processorhelper" |
| 24 | +) |
| 25 | + |
| 26 | +const ( |
| 27 | + // The value of "type" Tail Sampling in configuration. |
| 28 | + typeStr = "sumologic_syslog" |
| 29 | +) |
| 30 | + |
| 31 | +var processorCapabilities = component.ProcessorCapabilities{MutatesConsumedData: true} |
| 32 | + |
| 33 | +// NewFactory returns a new factory for the Tail Sampling processor. |
| 34 | +func NewFactory() component.ProcessorFactory { |
| 35 | + return processorhelper.NewFactory( |
| 36 | + typeStr, |
| 37 | + createDefaultConfig, |
| 38 | + processorhelper.WithLogs(createLogProcessor)) |
| 39 | +} |
| 40 | + |
| 41 | +func createDefaultConfig() config.Processor { |
| 42 | + return &Config{ |
| 43 | + ProcessorSettings: config.NewProcessorSettings(typeStr), |
| 44 | + FacilityAttr: defaultFacilityAttr, |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +func createLogProcessor( |
| 49 | + _ context.Context, |
| 50 | + params component.ProcessorCreateParams, |
| 51 | + cfg config.Processor, |
| 52 | + nextConsumer consumer.Logs, |
| 53 | +) (component.LogsProcessor, error) { |
| 54 | + tCfg := cfg.(*Config) |
| 55 | + |
| 56 | + return processorhelper.NewLogsProcessor( |
| 57 | + cfg, |
| 58 | + nextConsumer, |
| 59 | + newSumologicSyslogProcessor(tCfg), |
| 60 | + processorhelper.WithCapabilities(processorCapabilities)) |
| 61 | +} |
0 commit comments