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