Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/grafana-agent
Path: blob/main/pkg/traces/servicegraphprocessor/factory.go
4095 views
1
package servicegraphprocessor
2
3
import (
4
"context"
5
"time"
6
7
"go.opentelemetry.io/collector/component"
8
"go.opentelemetry.io/collector/config"
9
"go.opentelemetry.io/collector/consumer"
10
)
11
12
const (
13
// TypeStr is the unique identifier for the Prometheus service graph exporter.
14
TypeStr = "service_graphs"
15
16
// DefaultWait is the default value to wait for an edge to be completed
17
DefaultWait = time.Second * 10
18
// DefaultMaxItems is the default amount of edges that will be stored in the storeMap
19
DefaultMaxItems = 10_000
20
// DefaultWorkers is the default amount of workers that will be used to process the edges
21
DefaultWorkers = 10
22
)
23
24
// Config holds the configuration for the Prometheus service graph processor.
25
type Config struct {
26
config.ProcessorSettings `mapstructure:",squash"`
27
28
Wait time.Duration `mapstructure:"wait"`
29
MaxItems int `mapstructure:"max_items"`
30
31
Workers int `mapstructure:"workers"`
32
33
SuccessCodes *successCodes `mapstructure:"success_codes"`
34
}
35
36
type successCodes struct {
37
http []int64 `mapstructure:"http"`
38
grpc []int64 `mapstructure:"grpc"`
39
}
40
41
// NewFactory returns a new factory for the Prometheus service graph processor.
42
func NewFactory() component.ProcessorFactory {
43
return component.NewProcessorFactory(
44
TypeStr,
45
createDefaultConfig,
46
component.WithTracesProcessor(createTracesProcessor, component.StabilityLevelUndefined),
47
)
48
}
49
50
func createDefaultConfig() config.Processor {
51
return &Config{
52
ProcessorSettings: config.NewProcessorSettings(config.NewComponentIDWithName(TypeStr, TypeStr)),
53
}
54
}
55
56
func createTracesProcessor(
57
_ context.Context,
58
_ component.ProcessorCreateSettings,
59
cfg config.Processor,
60
nextConsumer consumer.Traces,
61
) (component.TracesProcessor, error) {
62
63
eCfg := cfg.(*Config)
64
return newProcessor(nextConsumer, eCfg), nil
65
}
66
67