Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/grafana-agent
Path: blob/main/component/otelcol/config_retry.go
4095 views
1
package otelcol
2
3
import (
4
"time"
5
6
"github.com/grafana/agent/pkg/river"
7
otelexporterhelper "go.opentelemetry.io/collector/exporter/exporterhelper"
8
)
9
10
// RetryArguments holds shared settings for components which can retry
11
// requests.
12
type RetryArguments struct {
13
Enabled bool `river:"enabled,attr,optional"`
14
InitialInterval time.Duration `river:"initial_interval,attr,optional"`
15
MaxInterval time.Duration `river:"max_interval,attr,optional"`
16
MaxElapsedTime time.Duration `river:"max_elapsed_time,attr,optional"`
17
}
18
19
var _ river.Unmarshaler = (*RetryArguments)(nil)
20
21
// DefaultRetryArguments holds default settings for RetryArguments.
22
var DefaultRetryArguments = RetryArguments{
23
Enabled: true,
24
InitialInterval: 5 * time.Second,
25
MaxInterval: 30 * time.Second,
26
MaxElapsedTime: 5 * time.Minute,
27
}
28
29
// UnmarshalRiver implements river.Unmarshaler.
30
func (args *RetryArguments) UnmarshalRiver(f func(interface{}) error) error {
31
*args = DefaultRetryArguments
32
type arguments RetryArguments
33
return f((*arguments)(args))
34
}
35
36
// Convert converts args into the upstream type.
37
func (args *RetryArguments) Convert() *otelexporterhelper.RetrySettings {
38
if args == nil {
39
return nil
40
}
41
42
return &otelexporterhelper.RetrySettings{
43
Enabled: args.Enabled,
44
InitialInterval: args.InitialInterval,
45
MaxInterval: args.MaxInterval,
46
MaxElapsedTime: args.MaxElapsedTime,
47
}
48
}
49
50