Skip to content

Commit f0e2a50

Browse files
committed
clean up agent config settings
1 parent 9b02bed commit f0e2a50

File tree

14 files changed

+61
-32
lines changed

14 files changed

+61
-32
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The following packages need to be installed:
2424
```
2525
git clone https://github.com/open-telemetry/opentelemetry-collector.git
2626
cd opentelemetry-collector
27-
git checkout v0.114.0
27+
git checkout v0.124.0
2828
cd cmd/mdatagen
2929
go install
3030
```

internal/collector/nginxossreceiver/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ status:
77
beta: [metrics]
88
distributions: [contrib]
99
codeowners:
10-
active: [aphralG, dhurley, craigell, sean-breen, Rashmiti, CVanF5]
10+
active: [ aphralG, dhurley, craigell, sean-breen, CVanF5 ]
1111

1212
resource_attributes:
1313
instance.id:

internal/collector/nginxplusreceiver/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ status:
77
beta: [metrics]
88
distributions: [contrib]
99
codeowners:
10-
active: [apgralG, dhurley, craigell, sean-breen, Rashmiti, CVanF5]
10+
active: [ aphralG, dhurley, craigell, sean-breen, CVanF5 ]
1111

1212
resource_attributes:
1313
instance.id:

internal/collector/otel_collector_plugin.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ import (
2626
)
2727

2828
const (
29-
maxTimeToWaitForShutdown = 30 * time.Second
30-
filePermission = 0o600
29+
maxTimeToWaitForShutdown = 30 * time.Second
30+
defaultCollectionInterval = 1 * time.Minute
31+
filePermission = 0o600
3132
// To conform to the rfc3164 spec the timestamp in the logs need to be formatted correctly.
3233
// Here are some examples of what the timestamp conversions look like.
3334
// Notice how if the day begins with a zero that the zero is replaced with an empty space.
@@ -405,6 +406,7 @@ func (oc *Collector) checkForNewReceivers(nginxConfigContext *model.NginxConfigC
405406
Listen: nginxConfigContext.PlusAPI.Listen,
406407
Location: nginxConfigContext.PlusAPI.Location,
407408
},
409+
CollectionInterval: defaultCollectionInterval,
408410
},
409411
)
410412

@@ -438,7 +440,8 @@ func (oc *Collector) addNginxOssReceiver(nginxConfigContext *model.NginxConfigCo
438440
Listen: nginxConfigContext.StubStatus.Listen,
439441
Location: nginxConfigContext.StubStatus.Location,
440442
},
441-
AccessLogs: toConfigAccessLog(nginxConfigContext.AccessLogs),
443+
AccessLogs: toConfigAccessLog(nginxConfigContext.AccessLogs),
444+
CollectionInterval: defaultCollectionInterval,
442445
},
443446
)
444447

internal/collector/otel_collector_plugin_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ func TestCollector_ProcessNginxConfigUpdateTopic(t *testing.T) {
184184
Listen: "",
185185
Location: "",
186186
},
187+
CollectionInterval: defaultCollectionInterval,
187188
},
188189
},
189190
},
@@ -229,6 +230,7 @@ func TestCollector_ProcessNginxConfigUpdateTopic(t *testing.T) {
229230
LogFormat: "$$remote_addr - $$remote_user [$$time_local] \\\"$$request\\\"",
230231
},
231232
},
233+
CollectionInterval: defaultCollectionInterval,
232234
},
233235
},
234236
},

internal/collector/otelcol.tmpl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ receivers:
7575
url: "{{- .StubStatus.URL -}}"
7676
listen: "{{- .StubStatus.Listen -}}"
7777
location: "{{- .StubStatus.Location -}}"
78-
collection_interval: 10s
78+
{{- if .CollectionInterval }}
79+
collection_interval: {{ .CollectionInterval }}
80+
{{- end }}
7981
{{- if gt (len .AccessLogs) 0 }}
8082
access_logs:
8183
{{- range .AccessLogs }}
@@ -90,7 +92,9 @@ receivers:
9092
url: "{{- .PlusAPI.URL -}}"
9193
listen: "{{- .PlusAPI.Listen -}}"
9294
location: "{{- .PlusAPI.Location -}}"
93-
collection_interval: 10s
95+
{{- if .CollectionInterval }}
96+
collection_interval: {{ .CollectionInterval }}
97+
{{- end }}
9498
{{- end }}
9599
{{- range $index, $tcplogReceiver := .Receivers.TcplogReceivers }}
96100
tcplog/{{$index}}:

internal/collector/settings.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func createFile(confPath string) error {
9191

9292
// Generates a OTel Collector config to a file by injecting the Metrics Config to a Go template.
9393
func writeCollectorConfig(conf *config.Collector) error {
94+
slog.Info("Writing collector config")
9495
otelcolTemplate, err := template.New(otelTemplatePath).Parse(otelcolTemplate)
9596
if err != nil {
9697
return err

internal/collector/settings_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func TestTemplateWrite(t *testing.T) {
9393
Location: "",
9494
Listen: "",
9595
},
96+
CollectionInterval: 30 * time.Second,
9697
AccessLogs: []config.AccessLog{
9798
{
9899
LogFormat: accessLogFormat,

internal/config/config_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"testing"
1313
"time"
1414

15+
"github.com/nginx/agent/v3/pkg/config"
16+
1517
"github.com/nginx/agent/v3/test/helpers"
1618

1719
"github.com/stretchr/testify/require"
@@ -882,11 +884,13 @@ func createConfig() *Config {
882884
FilePath: "/var/log/nginx/access-custom.conf",
883885
},
884886
},
887+
CollectionInterval: 30 * time.Second,
885888
},
886889
},
887890
NginxPlusReceivers: []NginxPlusReceiver{
888891
{
889-
InstanceID: "cd7b8911-c2c5-4daf-b311-dbead151d939",
892+
InstanceID: "cd7b8911-c2c5-4daf-b311-dbead151d939",
893+
CollectionInterval: 30 * time.Second,
890894
},
891895
},
892896
HostMetrics: &HostMetrics{
@@ -966,5 +970,9 @@ func createConfig() *Config {
966970
"label2": "new-value",
967971
"label3": 123,
968972
},
973+
Features: []string{
974+
config.FeatureCertificates, config.FeatureFileWatcher, config.FeatureMetrics,
975+
config.FeatureAPIAction, config.FeatureLogsNap,
976+
},
969977
}
970978
}

internal/config/defaults.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const (
4444
DefBackoffInitialInterval = 500 * time.Millisecond
4545
DefBackoffRandomizationFactor = 0.5 // the value is 0 <= and < 1
4646
DefBackoffMultiplier = 1.5
47-
DefBackoffMaxInterval = 5 * time.Second
47+
DefBackoffMaxInterval = 10 * time.Minute
4848
DefBackoffMaxElapsedTime = 30 * time.Second
4949

5050
// Watcher defaults

0 commit comments

Comments
 (0)