components/otelopscol/processor/modifyscopeprocessor/factory.go (41 lines of code) (raw):

// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package modifyscopeprocessor import ( "context" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/processor" "go.opentelemetry.io/collector/processor/processorhelper" ) // The value of "type" key in configuration. var componentType component.Type = component.MustNewType("modifyscope") func NewFactory() processor.Factory { return processor.NewFactory( componentType, createDefaultConfig, processor.WithMetrics(createMetricsProcessor, component.StabilityLevelBeta)) } func createDefaultConfig() component.Config { return &Config{} } var processorCapabilities = consumer.Capabilities{MutatesData: true} func createMetricsProcessor( ctx context.Context, params processor.Settings, cfg component.Config, nextConsumer consumer.Metrics, ) (processor.Metrics, error) { oCfg := cfg.(*Config) if err := validateConfiguration(oCfg); err != nil { return nil, err } metricsProcessor := newModifyScopeProcessor(params.Logger, oCfg) return processorhelper.NewMetrics( ctx, params, cfg, nextConsumer, metricsProcessor.ProcessMetrics, processorhelper.WithCapabilities(processorCapabilities)) } // validateConfiguration validates the input configuration has all of the required fields for the processor // An error is returned if there are any invalid inputs. func validateConfiguration(_ *Config) error { return nil }