Path: blob/main/pkg/traces/servicegraphprocessor/factory.go
4095 views
package servicegraphprocessor12import (3"context"4"time"56"go.opentelemetry.io/collector/component"7"go.opentelemetry.io/collector/config"8"go.opentelemetry.io/collector/consumer"9)1011const (12// TypeStr is the unique identifier for the Prometheus service graph exporter.13TypeStr = "service_graphs"1415// DefaultWait is the default value to wait for an edge to be completed16DefaultWait = time.Second * 1017// DefaultMaxItems is the default amount of edges that will be stored in the storeMap18DefaultMaxItems = 10_00019// DefaultWorkers is the default amount of workers that will be used to process the edges20DefaultWorkers = 1021)2223// Config holds the configuration for the Prometheus service graph processor.24type Config struct {25config.ProcessorSettings `mapstructure:",squash"`2627Wait time.Duration `mapstructure:"wait"`28MaxItems int `mapstructure:"max_items"`2930Workers int `mapstructure:"workers"`3132SuccessCodes *successCodes `mapstructure:"success_codes"`33}3435type successCodes struct {36http []int64 `mapstructure:"http"`37grpc []int64 `mapstructure:"grpc"`38}3940// NewFactory returns a new factory for the Prometheus service graph processor.41func NewFactory() component.ProcessorFactory {42return component.NewProcessorFactory(43TypeStr,44createDefaultConfig,45component.WithTracesProcessor(createTracesProcessor, component.StabilityLevelUndefined),46)47}4849func createDefaultConfig() config.Processor {50return &Config{51ProcessorSettings: config.NewProcessorSettings(config.NewComponentIDWithName(TypeStr, TypeStr)),52}53}5455func createTracesProcessor(56_ context.Context,57_ component.ProcessorCreateSettings,58cfg config.Processor,59nextConsumer consumer.Traces,60) (component.TracesProcessor, error) {6162eCfg := cfg.(*Config)63return newProcessor(nextConsumer, eCfg), nil64}656667