Skip to content

Commit 2ab48a0

Browse files
committed
setting default collection interval to -1
1 parent d705a03 commit 2ab48a0

File tree

8 files changed

+34
-27
lines changed

8 files changed

+34
-27
lines changed

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ replace (
4242
replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor => github.com/amazon-contributing/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.0.0-20250717174233-f514045fc484
4343

4444
replace (
45-
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver => github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.0.0-20250717174233-f514045fc484
46-
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightskueuereceiver => github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightskueuereceiver v0.0.0-20250717174233-f514045fc484
45+
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver => github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.0.0-20250721131320-b5bbe3bd1873
46+
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightskueuereceiver => github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightskueuereceiver v0.0.0-20250721131320-b5bbe3bd1873
4747
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsxrayreceiver => github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awsxrayreceiver v0.0.0-20250717174233-f514045fc484
4848
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jmxreceiver => github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/jmxreceiver v0.0.0-20250717174233-f514045fc484
49-
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver => github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.0.0-20250717174233-f514045fc484
49+
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver => github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.0.0-20250721131320-b5bbe3bd1873
5050
)
5151

5252
// Temporary fix, pending PR https://github.com/shirou/gopsutil/pull/957

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,16 +229,16 @@ github.com/amazon-contributing/opentelemetry-collector-contrib/pkg/translator/pr
229229
github.com/amazon-contributing/opentelemetry-collector-contrib/pkg/translator/prometheus v0.0.0-20250717174233-f514045fc484/go.mod h1:7prJseoHF7mXXAPdU+q1zoZdVOclFZsgNhoBriqBIp0=
230230
github.com/amazon-contributing/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.0.0-20250717174233-f514045fc484 h1:cFRXqozAwclrrSJD/1fwrrebwNNVL8sAPvewZSmYl0k=
231231
github.com/amazon-contributing/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.0.0-20250717174233-f514045fc484/go.mod h1:K8inysgi51ecddal8W6MPqrYcjh65wm1PsVDV+zgCEA=
232-
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.0.0-20250717174233-f514045fc484 h1:KkQR49FSmepOqBfze1zNBmAi06DUUSQzOS+lzQkSPTY=
233-
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.0.0-20250717174233-f514045fc484/go.mod h1:78qZtZnv6jO7K56d1OUMtgTcH0rPcb4N8Zp4/EiMJ0o=
234-
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightskueuereceiver v0.0.0-20250717174233-f514045fc484 h1:NqDlh14x1674xIAnLC3iCvEmaLeGEorAzzWopMKAW9o=
235-
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightskueuereceiver v0.0.0-20250717174233-f514045fc484/go.mod h1:GipgrS7Hgv0MgjQ6c2CrEti5kWKsXSaqB+E2XrHmiy4=
232+
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.0.0-20250721131320-b5bbe3bd1873 h1:8SriTFa1DpZ1O+SA4UN5poiWBzswE5HZASo5KmIloDo=
233+
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.0.0-20250721131320-b5bbe3bd1873/go.mod h1:78qZtZnv6jO7K56d1OUMtgTcH0rPcb4N8Zp4/EiMJ0o=
234+
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightskueuereceiver v0.0.0-20250721131320-b5bbe3bd1873 h1:FtH0ZsoPsGoN2wePoIOY/sybhbvo9nyS01NhqpbXoys=
235+
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightskueuereceiver v0.0.0-20250721131320-b5bbe3bd1873/go.mod h1:GipgrS7Hgv0MgjQ6c2CrEti5kWKsXSaqB+E2XrHmiy4=
236236
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awsxrayreceiver v0.0.0-20250717174233-f514045fc484 h1:7Eq8GHafdPwuj/zruhctXzYyhtXUmp0FVAcsHX0V6Co=
237237
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awsxrayreceiver v0.0.0-20250717174233-f514045fc484/go.mod h1:iNL2C4bugyDA/nYSAu4O68xD859BudOWGd0+03+lWVs=
238238
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/jmxreceiver v0.0.0-20250717174233-f514045fc484 h1:ot2Q8zo4EQBwhCIOht3XkuRYkBsJhddWBQrng37LFWQ=
239239
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/jmxreceiver v0.0.0-20250717174233-f514045fc484/go.mod h1:tEB7CZP8f7qVEWH9y3F2sbI5EcvICSW3sZOFwXRge5U=
240-
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.0.0-20250717174233-f514045fc484 h1:hh+kKCO1UBFIvDIF4pxiwSbixO3AfbjOc36z6uuXujE=
241-
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.0.0-20250717174233-f514045fc484/go.mod h1:Tc/PSUfe91PN6BoGKEHFo6V0gb23gxp7QLTdsrK2meI=
240+
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.0.0-20250721131320-b5bbe3bd1873 h1:sY5RiiJU7o3mEApYF6bwhtZoeZ3NNhxxxqs6n1Pv4QA=
241+
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.0.0-20250721131320-b5bbe3bd1873/go.mod h1:Tc/PSUfe91PN6BoGKEHFo6V0gb23gxp7QLTdsrK2meI=
242242
github.com/amir/raidman v0.0.0-20170415203553-1ccc43bfb9c9 h1:FXrPTd8Rdlc94dKccl7KPmdmIbVh/OjelJ8/vgMRzcQ=
243243
github.com/amir/raidman v0.0.0-20170415203553-1ccc43bfb9c9/go.mod h1:eliMa/PW+RDr2QLWRmLH1R1ZA4RInpmvOzDDXtaIZkc=
244244
github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=

translator/translate/otel/common/common.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,16 @@ func GetOrDefaultNumber(conf *confmap.Conf, key string, defaultVal float64) floa
395395
return value
396396
}
397397

398+
// GetOrDefaultCollectionInterval gets the collection interval from the configuration.
399+
// If the interval is not specified or is <= 0, it returns the component's default interval.
400+
func GetOrDefaultCollectionInterval(conf *confmap.Conf, key string, componentDefault time.Duration) time.Duration {
401+
interval, ok := GetDuration(conf, key)
402+
if !ok || interval <= 0 {
403+
return componentDefault
404+
}
405+
return interval
406+
}
407+
398408
// GetDuration gets the value for the key and calls ParseDuration on it.
399409
// If the key is missing, it is unable to parse the duration, or the
400410
// duration is set to 0, then the returned bool will be false.

translator/translate/otel/receiver/adapter/translator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ type translator struct {
2424
// See otel.ConfigKey.
2525
cfgKey string
2626

27-
// preferMetricCollectionInterval is an option to using the preferaable metric collection interval before
27+
// preferMetricCollectionInterval is an option to using the preferable metric collection interval before
2828
// using the interval key chain and defaultMetricCollectionInterval
2929
preferMetricCollectionInterval time.Duration
3030

31-
// defaultMetricCollectionInterval is the fallback interval if it
31+
// defaultMetricCollectionInterval is the fallback interval if
3232
// it is not present in the interval keychain.
3333
defaultMetricCollectionInterval time.Duration
3434
}

translator/translate/otel/receiver/awscontainerinsight/translator.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"fmt"
99
"os"
1010
"strings"
11-
"time"
1211

1312
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver"
1413
"go.opentelemetry.io/collector/component"
@@ -32,7 +31,7 @@ const (
3231
ecs = "ecs"
3332
eks = "eks"
3433

35-
defaultMetricsCollectionInterval = time.Minute
34+
defaultMetricsCollectionInterval = -1 // default to -1 to use default value defined in receiver
3635
defaultLeaderLockName = "cwagent-clusterleader" // To maintain backwards compatability with https://github.com/aws/amazon-cloudwatch-agent/blob/2dd89abaab4590cffbbc31ef89319b62809b09d1/plugins/inputs/k8sapiserver/k8sapiserver.go#L30
3736
)
3837

translator/translate/otel/receiver/awscontainerinsight/translator_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestTranslator(t *testing.T) {
4343
},
4444
want: &awscontainerinsightreceiver.Config{
4545
ContainerOrchestrator: ecs,
46-
CollectionInterval: time.Minute,
46+
CollectionInterval: defaultMetricsCollectionInterval,
4747
LeaderLockName: "otel-container-insight-clusterleader",
4848
TagService: true,
4949
},
@@ -130,7 +130,7 @@ func TestTranslator(t *testing.T) {
130130
},
131131
want: &awscontainerinsightreceiver.Config{
132132
ContainerOrchestrator: eks,
133-
CollectionInterval: 60 * time.Second,
133+
CollectionInterval: defaultMetricsCollectionInterval,
134134
TagService: false,
135135
LeaderLockName: defaultLeaderLockName,
136136
LeaderLockUsingConfigMapOnly: true,
@@ -153,7 +153,7 @@ func TestTranslator(t *testing.T) {
153153
},
154154
want: &awscontainerinsightreceiver.Config{
155155
ContainerOrchestrator: eks,
156-
CollectionInterval: 60 * time.Second,
156+
CollectionInterval: defaultMetricsCollectionInterval,
157157
CollectionRole: awscontainerinsightreceiver.LEADER,
158158
TagService: true,
159159
LeaderLockName: defaultLeaderLockName,
@@ -177,7 +177,7 @@ func TestTranslator(t *testing.T) {
177177
},
178178
want: &awscontainerinsightreceiver.Config{
179179
ContainerOrchestrator: eks,
180-
CollectionInterval: 60 * time.Second,
180+
CollectionInterval: defaultMetricsCollectionInterval,
181181
CollectionRole: awscontainerinsightreceiver.NODE,
182182
TagService: true,
183183
LeaderLockName: defaultLeaderLockName,
@@ -199,7 +199,7 @@ func TestTranslator(t *testing.T) {
199199
},
200200
want: &awscontainerinsightreceiver.Config{
201201
ContainerOrchestrator: eks,
202-
CollectionInterval: 60 * time.Second,
202+
CollectionInterval: defaultMetricsCollectionInterval,
203203
PrefFullPodName: true,
204204
LeaderLockName: defaultLeaderLockName,
205205
LeaderLockUsingConfigMapOnly: true,
@@ -224,7 +224,7 @@ func TestTranslator(t *testing.T) {
224224
},
225225
want: &awscontainerinsightreceiver.Config{
226226
ContainerOrchestrator: eks,
227-
CollectionInterval: 60 * time.Second,
227+
CollectionInterval: defaultMetricsCollectionInterval,
228228
LeaderLockName: defaultLeaderLockName,
229229
LeaderLockUsingConfigMapOnly: true,
230230
ClusterName: "TestCluster",
@@ -248,7 +248,7 @@ func TestTranslator(t *testing.T) {
248248
},
249249
want: &awscontainerinsightreceiver.Config{
250250
ContainerOrchestrator: eks,
251-
CollectionInterval: 60 * time.Second,
251+
CollectionInterval: defaultMetricsCollectionInterval,
252252
PrefFullPodName: true,
253253
LeaderLockName: defaultLeaderLockName,
254254
LeaderLockUsingConfigMapOnly: true,
@@ -273,7 +273,7 @@ func TestTranslator(t *testing.T) {
273273
},
274274
want: &awscontainerinsightreceiver.Config{
275275
ContainerOrchestrator: eks,
276-
CollectionInterval: 60 * time.Second,
276+
CollectionInterval: defaultMetricsCollectionInterval,
277277
PrefFullPodName: true,
278278
LeaderLockName: defaultLeaderLockName,
279279
LeaderLockUsingConfigMapOnly: true,
@@ -322,7 +322,7 @@ func TestTranslator(t *testing.T) {
322322
isSystemd: true,
323323
want: &awscontainerinsightreceiver.Config{
324324
ContainerOrchestrator: eks,
325-
CollectionInterval: 60 * time.Second,
325+
CollectionInterval: defaultMetricsCollectionInterval,
326326
PrefFullPodName: false,
327327
LeaderLockName: defaultLeaderLockName,
328328
LeaderLockUsingConfigMapOnly: true,

translator/translate/otel/receiver/awscontainerinsightskueue/translator.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ package awscontainerinsightskueue
55

66
import (
77
"errors"
8-
"time"
9-
108
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightskueuereceiver"
119
"go.opentelemetry.io/collector/component"
1210
"go.opentelemetry.io/collector/confmap"
@@ -16,7 +14,7 @@ import (
1614
)
1715

1816
const (
19-
defaultMetricsCollectionInterval = time.Minute
17+
defaultMetricsCollectionInterval = -1 // default to -1 to use default value defined in receiver
2018
)
2119

2220
type translator struct {
@@ -42,7 +40,7 @@ func (t *translator) ID() component.ID {
4240
return component.NewIDWithName(t.factory.Type(), t.name)
4341
}
4442

45-
// Translate creates an aws container insights receiver config if either
43+
// Translate creates an aws container insights kueue receiver config if either
4644
// of the sections defined in the services exist.
4745
func (t *translator) Translate(conf *confmap.Conf) (component.Config, error) {
4846
cfg := t.factory.CreateDefaultConfig().(*awscontainerinsightskueuereceiver.Config)

translator/translate/otel/receiver/awscontainerinsightskueue/translator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestTranslator(t *testing.T) {
3636
},
3737
isSystemd: true,
3838
want: &awscontainerinsightskueuereceiver.Config{
39-
CollectionInterval: 60 * time.Second,
39+
CollectionInterval: defaultMetricsCollectionInterval,
4040
ClusterName: "TestCluster",
4141
},
4242
},

0 commit comments

Comments
 (0)