Skip to content

Commit 9853bf6

Browse files
authored
Get rid of deprecated internal.{Duration,Size,Number} (influxdata#8969)
1 parent c66ccee commit 9853bf6

File tree

194 files changed

+1563
-1540
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+1563
-1540
lines changed

agent/agent.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ type outputUnit struct {
9898
func (a *Agent) Run(ctx context.Context) error {
9999
log.Printf("I! [agent] Config: Interval:%s, Quiet:%#v, Hostname:%#v, "+
100100
"Flush Interval:%s",
101-
a.Config.Agent.Interval.Duration, a.Config.Agent.Quiet,
102-
a.Config.Agent.Hostname, a.Config.Agent.FlushInterval.Duration)
101+
time.Duration(a.Config.Agent.Interval), a.Config.Agent.Quiet,
102+
a.Config.Agent.Hostname, time.Duration(a.Config.Agent.FlushInterval))
103103

104104
log.Printf("D! [agent] Initializing plugins")
105105
err := a.initPlugins()
@@ -274,19 +274,19 @@ func (a *Agent) runInputs(
274274
var wg sync.WaitGroup
275275
for _, input := range unit.inputs {
276276
// Overwrite agent interval if this plugin has its own.
277-
interval := a.Config.Agent.Interval.Duration
277+
interval := time.Duration(a.Config.Agent.Interval)
278278
if input.Config.Interval != 0 {
279279
interval = input.Config.Interval
280280
}
281281

282282
// Overwrite agent precision if this plugin has its own.
283-
precision := a.Config.Agent.Precision.Duration
283+
precision := time.Duration(a.Config.Agent.Precision)
284284
if input.Config.Precision != 0 {
285285
precision = input.Config.Precision
286286
}
287287

288288
// Overwrite agent collection_jitter if this plugin has its own.
289-
jitter := a.Config.Agent.CollectionJitter.Duration
289+
jitter := time.Duration(a.Config.Agent.CollectionJitter)
290290
if input.Config.CollectionJitter != 0 {
291291
jitter = input.Config.CollectionJitter
292292
}
@@ -373,13 +373,13 @@ func (a *Agent) testRunInputs(
373373
defer wg.Done()
374374

375375
// Overwrite agent interval if this plugin has its own.
376-
interval := a.Config.Agent.Interval.Duration
376+
interval := time.Duration(a.Config.Agent.Interval)
377377
if input.Config.Interval != 0 {
378378
interval = input.Config.Interval
379379
}
380380

381381
// Overwrite agent precision if this plugin has its own.
382-
precision := a.Config.Agent.Precision.Duration
382+
precision := time.Duration(a.Config.Agent.Precision)
383383
if input.Config.Precision != 0 {
384384
precision = input.Config.Precision
385385
}
@@ -611,8 +611,8 @@ func (a *Agent) runAggregators(
611611
go func(agg *models.RunningAggregator) {
612612
defer wg.Done()
613613

614-
interval := a.Config.Agent.Interval.Duration
615-
precision := a.Config.Agent.Precision.Duration
614+
interval := time.Duration(a.Config.Agent.Interval)
615+
precision := time.Duration(a.Config.Agent.Precision)
616616

617617
acc := NewAccumulator(agg, unit.aggC)
618618
acc.SetPrecision(getPrecision(precision, interval))
@@ -723,8 +723,8 @@ func (a *Agent) runOutputs(
723723
var wg sync.WaitGroup
724724

725725
// Start flush loop
726-
interval := a.Config.Agent.FlushInterval.Duration
727-
jitter := a.Config.Agent.FlushJitter.Duration
726+
interval := time.Duration(a.Config.Agent.FlushInterval)
727+
jitter := time.Duration(a.Config.Agent.FlushJitter)
728728

729729
ctx, cancel := context.WithCancel(context.Background())
730730

cmd/telegraf/telegraf.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,12 @@ func runAgent(ctx context.Context,
151151
return errors.New("Error: no inputs found, did you provide a valid config file?")
152152
}
153153

154-
if int64(c.Agent.Interval.Duration) <= 0 {
155-
return fmt.Errorf("Agent interval must be positive, found %s",
156-
c.Agent.Interval.Duration)
154+
if int64(c.Agent.Interval) <= 0 {
155+
return fmt.Errorf("Agent interval must be positive, found %v", c.Agent.Interval)
157156
}
158157

159-
if int64(c.Agent.FlushInterval.Duration) <= 0 {
160-
return fmt.Errorf("Agent flush_interval must be positive; found %s",
161-
c.Agent.Interval.Duration)
158+
if int64(c.Agent.FlushInterval) <= 0 {
159+
return fmt.Errorf("Agent flush_interval must be positive; found %v", c.Agent.Interval)
162160
}
163161

164162
ag, err := agent.NewAgent(c)

config/config.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ func NewConfig() *Config {
8282

8383
// Agent defaults:
8484
Agent: &AgentConfig{
85-
Interval: internal.Duration{Duration: 10 * time.Second},
85+
Interval: Duration(10 * time.Second),
8686
RoundInterval: true,
87-
FlushInterval: internal.Duration{Duration: 10 * time.Second},
87+
FlushInterval: Duration(10 * time.Second),
8888
LogTarget: "file",
8989
LogfileRotationMaxArchives: 5,
9090
},
@@ -111,7 +111,7 @@ func NewConfig() *Config {
111111
// AgentConfig defines configuration that will be used by the Telegraf agent
112112
type AgentConfig struct {
113113
// Interval at which to gather information
114-
Interval internal.Duration
114+
Interval Duration
115115

116116
// RoundInterval rounds collection interval to 'interval'.
117117
// ie, if Interval=10s then always collect on :00, :10, :20, etc.
@@ -123,22 +123,22 @@ type AgentConfig struct {
123123
// when interval = "250ms", precision will be "1ms"
124124
// Precision will NOT be used for service inputs. It is up to each individual
125125
// service input to set the timestamp at the appropriate precision.
126-
Precision internal.Duration
126+
Precision Duration
127127

128128
// CollectionJitter is used to jitter the collection by a random amount.
129129
// Each plugin will sleep for a random time within jitter before collecting.
130130
// This can be used to avoid many plugins querying things like sysfs at the
131131
// same time, which can have a measurable effect on the system.
132-
CollectionJitter internal.Duration
132+
CollectionJitter Duration
133133

134134
// FlushInterval is the Interval at which to flush data
135-
FlushInterval internal.Duration
135+
FlushInterval Duration
136136

137137
// FlushJitter Jitters the flush interval by a random amount.
138138
// This is primarily to avoid large write spikes for users running a large
139139
// number of telegraf instances.
140140
// ie, a jitter of 5s and interval 10s means flushes will happen every 10-15s
141-
FlushJitter internal.Duration
141+
FlushJitter Duration
142142

143143
// MetricBatchSize is the maximum number of metrics that is wrote to an
144144
// output plugin in one call.
@@ -178,11 +178,11 @@ type AgentConfig struct {
178178

179179
// The file will be rotated after the time interval specified. When set
180180
// to 0 no time based rotation is performed.
181-
LogfileRotationInterval internal.Duration `toml:"logfile_rotation_interval"`
181+
LogfileRotationInterval Duration `toml:"logfile_rotation_interval"`
182182

183183
// The logfile will be rotated when it becomes larger than the specified
184184
// size. When set to 0 no size based rotation is performed.
185-
LogfileRotationMaxSize internal.Size `toml:"logfile_rotation_max_size"`
185+
LogfileRotationMaxSize Size `toml:"logfile_rotation_max_size"`
186186

187187
// Maximum number of rotated archives to keep, any older logs are deleted.
188188
// If set to -1, no archives are removed.

0 commit comments

Comments
 (0)