MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / New

Function New

monitoring/monitoring.go:43–88  ·  view source on GitHub ↗

New creates a new Monitoring instance

(ctx context.Context, config *Config, workersNumber int)

Source from the content-addressed store, hash-verified

41
42// New creates a new Monitoring instance
43func New(ctx context.Context, config *Config, workersNumber int) (*Monitoring, error) {
44 if err := config.Validate(); err != nil {
45 return nil, err
46 }
47
48 st := stats.New(workersNumber)
49 monitors := make([]monitor, 0)
50
51 if m, err := prometheus.New(&config.Prometheus, st); err != nil {
52 return nil, err
53 } else if m != nil {
54 monitors = append(monitors, m)
55 }
56
57 if m, err := newrelic.New(&config.NewRelic, st); err != nil {
58 return nil, err
59 } else if m != nil {
60 monitors = append(monitors, m)
61 }
62
63 if m, err := datadog.New(&config.DataDog, st); err != nil {
64 return nil, err
65 } else if m != nil {
66 monitors = append(monitors, m)
67 }
68
69 if m, err := otel.New(&config.OpenTelemetry, st); err != nil {
70 return nil, err
71 } else if m != nil {
72 monitors = append(monitors, m)
73 }
74
75 if m, err := cloudwatch.New(ctx, &config.CloudWatch, st); err != nil {
76 return nil, err
77 } else if m != nil {
78 monitors = append(monitors, m)
79 }
80
81 m := &Monitoring{
82 config: config,
83 stats: st,
84 monitors: monitors,
85 }
86
87 return m, nil
88}
89
90// Enabled returns true if at least one monitoring service is enabled
91func (m *Monitoring) Enabled() bool {

Callers 4

NewFunction · 0.92
SetupSuiteMethod · 0.92
SetupSuiteMethod · 0.92
SetupTestMethod · 0.92

Calls 7

NewFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
ValidateMethod · 0.45

Tested by 3

SetupSuiteMethod · 0.74
SetupSuiteMethod · 0.74
SetupTestMethod · 0.74