Skip to content

Commit ff1b659

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

File tree

8 files changed

+35
-29
lines changed

8 files changed

+35
-29
lines changed

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ replace (
1919

2020
replace (
2121
github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil => github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/awsutil v0.0.0-20250717174233-f514045fc484
22-
github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/containerinsight => github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/containerinsight v0.0.0-20250717174233-f514045fc484
22+
github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/containerinsight => github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/containerinsight v0.0.0-20250722193355-2e41d3b81be3
2323
github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/cwlogs => github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/cwlogs v0.0.0-20250717174233-f514045fc484
2424
github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/k8s => github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/k8s v0.0.0-20250717174233-f514045fc484
2525
github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/metrics => github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/metrics v0.0.0-20250717174233-f514045fc484
@@ -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-20250722193355-2e41d3b81be3
46+
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightskueuereceiver => github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightskueuereceiver v0.0.0-20250722193355-2e41d3b81be3
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-20250722193355-2e41d3b81be3
5050
)
5151

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

go.sum

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,6 @@ github.com/amazon-contributing/opentelemetry-collector-contrib/extension/awsprox
199199
github.com/amazon-contributing/opentelemetry-collector-contrib/extension/awsproxy v0.0.0-20250717174233-f514045fc484/go.mod h1:IaVVx5+2dXba7dDVfnCAZkqBc3fE7XX5UnehsGmf+mw=
200200
github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/awsutil v0.0.0-20250717174233-f514045fc484 h1:34a19sMva8wCzo9OMMMdK26woQy5WKG3wKGe4Xt6tYM=
201201
github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/awsutil v0.0.0-20250717174233-f514045fc484/go.mod h1:AbdplNaM4g1LnEbDczU5tDqnF1xhzlgBvpB1xwEUlhg=
202-
github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/containerinsight v0.0.0-20250717174233-f514045fc484 h1:gs9fAS213niCP4k2sPeqsEfOgSrXI6eDsn2REPeKDJw=
203-
github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/containerinsight v0.0.0-20250717174233-f514045fc484/go.mod h1:9bL/kFVrHh9yDtTUQwxkVl7gRA0PfTmt87CBzC/ihBM=
204202
github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/cwlogs v0.0.0-20250717174233-f514045fc484 h1:cRB7SfM84zjadY92D1s2ywEAsO7+YKAFBDXUlpveh10=
205203
github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/cwlogs v0.0.0-20250717174233-f514045fc484/go.mod h1:XK8ww4E/9UaVR0wz3mS1HRr+qFEfA/FBZoSRZjVnJRs=
206204
github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/k8s v0.0.0-20250717174233-f514045fc484 h1:36mpJBt/c/mZYE7R2+z2anERw0vmc7tf22SJ9FkRJf8=
@@ -229,16 +227,16 @@ github.com/amazon-contributing/opentelemetry-collector-contrib/pkg/translator/pr
229227
github.com/amazon-contributing/opentelemetry-collector-contrib/pkg/translator/prometheus v0.0.0-20250717174233-f514045fc484/go.mod h1:7prJseoHF7mXXAPdU+q1zoZdVOclFZsgNhoBriqBIp0=
230228
github.com/amazon-contributing/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.0.0-20250717174233-f514045fc484 h1:cFRXqozAwclrrSJD/1fwrrebwNNVL8sAPvewZSmYl0k=
231229
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=
230+
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.0.0-20250722185957-5561c58c81fd h1:Vg8NFRXprGAgmLvsrxP5etgVgTFT4aKluPOGWFRB+b8=
231+
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver v0.0.0-20250722185957-5561c58c81fd/go.mod h1:78qZtZnv6jO7K56d1OUMtgTcH0rPcb4N8Zp4/EiMJ0o=
232+
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightskueuereceiver v0.0.0-20250722185957-5561c58c81fd h1:nwrxRfSQ3wQ5udVCh+vEQsW8i5cYWWUZOA7kCQsXDG0=
233+
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightskueuereceiver v0.0.0-20250722185957-5561c58c81fd/go.mod h1:GipgrS7Hgv0MgjQ6c2CrEti5kWKsXSaqB+E2XrHmiy4=
236234
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awsxrayreceiver v0.0.0-20250717174233-f514045fc484 h1:7Eq8GHafdPwuj/zruhctXzYyhtXUmp0FVAcsHX0V6Co=
237235
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awsxrayreceiver v0.0.0-20250717174233-f514045fc484/go.mod h1:iNL2C4bugyDA/nYSAu4O68xD859BudOWGd0+03+lWVs=
238236
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/jmxreceiver v0.0.0-20250717174233-f514045fc484 h1:ot2Q8zo4EQBwhCIOht3XkuRYkBsJhddWBQrng37LFWQ=
239237
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=
238+
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.0.0-20250722185957-5561c58c81fd h1:O8ea/g1SGPLV34xU5rRMW5XYTvAvP9BHvKrzJhhqXVI=
239+
github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.0.0-20250722185957-5561c58c81fd/go.mod h1:Tc/PSUfe91PN6BoGKEHFo6V0gb23gxp7QLTdsrK2meI=
242240
github.com/amir/raidman v0.0.0-20170415203553-1ccc43bfb9c9 h1:FXrPTd8Rdlc94dKccl7KPmdmIbVh/OjelJ8/vgMRzcQ=
243241
github.com/amir/raidman v0.0.0-20170415203553-1ccc43bfb9c9/go.mod h1:eliMa/PW+RDr2QLWRmLH1R1ZA4RInpmvOzDDXtaIZkc=
244242
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package awscontainerinsightskueue
55

66
import (
77
"errors"
8-
"time"
98

109
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightskueuereceiver"
1110
"go.opentelemetry.io/collector/component"
@@ -16,7 +15,7 @@ import (
1615
)
1716

1817
const (
19-
defaultMetricsCollectionInterval = time.Minute
18+
defaultMetricsCollectionInterval = -1 // default to -1 to use default value defined in receiver
2019
)
2120

2221
type translator struct {
@@ -42,7 +41,7 @@ func (t *translator) ID() component.ID {
4241
return component.NewIDWithName(t.factory.Type(), t.name)
4342
}
4443

45-
// Translate creates an aws container insights receiver config if either
44+
// Translate creates an aws container insights kueue receiver config if either
4645
// of the sections defined in the services exist.
4746
func (t *translator) Translate(conf *confmap.Conf) (component.Config, error) {
4847
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)