Skip to content

Commit 51c5847

Browse files
committed
PR feedback
1 parent ee804c8 commit 51c5847

File tree

8 files changed

+27
-26
lines changed

8 files changed

+27
-26
lines changed

api/grpc/mpi/v1/command.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/grpc/mpi/v1/common.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/grpc/mpi/v1/files.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/collector/otel_collector_plugin.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const (
4545
`? (let utcTime = ` +
4646
`date(timestamp).UTC(); utcTime.Format("Jan 2 15:04:05")) : date(timestamp).Format("Jan 02 15:04:05"); ` +
4747
`split(body, ">")[0] + ">" + newTimestamp + " " + split(body, " ", 2)[1])'`
48+
debugOTelConfigPath = "/var/lib/nginx-agent/opentelemetry-collector-agent-debug.yaml"
4849
)
4950

5051
type (
@@ -388,7 +389,7 @@ func (oc *Collector) updateHeadersSetterExtension(
388389

389390
func (oc *Collector) writeRunningConfig(ctx context.Context, settings otelcol.CollectorSettings) error {
390391
slog.DebugContext(ctx, "Writing running OTel collector config", "path",
391-
"/var/lib/nginx-agent/opentelemetry-collector-agent-debug.yaml")
392+
debugOTelConfigPath)
392393
resolver, err := confmap.NewResolver(settings.ConfigProviderSettings.ResolverSettings)
393394
if err != nil {
394395
return fmt.Errorf("unable to create resolver: %w", err)
@@ -403,7 +404,7 @@ func (oc *Collector) writeRunningConfig(ctx context.Context, settings otelcol.Co
403404
return fmt.Errorf("error while marshaling to YAML: %w", err)
404405
}
405406

406-
writeErr := os.WriteFile("/var/lib/nginx-agent/opentelemetry-collector-agent-debug.yaml", b, filePermission)
407+
writeErr := os.WriteFile(debugOTelConfigPath, b, filePermission)
407408
if writeErr != nil {
408409
return fmt.Errorf("error while writing debug config: %w", err)
409410
}

internal/collector/settings.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ func createConverterFactories() []confmap.ConverterFactory {
7272

7373
func createURIs(cfg *config.Config) []string {
7474
configFiles := []string{cfg.Collector.ConfigPath}
75-
configFiles = slices.Concat(configFiles, cfg.Collector.AdditionalPaths)
76-
slog.Info("Additional config files:", "", configFiles)
75+
configFiles = slices.Concat(configFiles, cfg.Collector.AdditionalConfigPaths)
76+
slog.Info("Merging additional OTel config files", "config_files", configFiles)
7777

7878
return configFiles
7979
}

internal/config/config.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,14 +1061,14 @@ func resolveCollector(allowedDirs []string) (*Collector, error) {
10611061
}
10621062

10631063
col := &Collector{
1064-
ConfigPath: viperInstance.GetString(CollectorConfigPathKey),
1065-
AdditionalPaths: viperInstance.GetStringSlice(CollectorAdditionalConfigPathsKey),
1066-
Exporters: exporters,
1067-
Processors: resolveProcessors(),
1068-
Receivers: receivers,
1069-
Extensions: resolveExtensions(),
1070-
Log: resolveCollectorLog(),
1071-
Pipelines: resolvePipelines(),
1064+
ConfigPath: viperInstance.GetString(CollectorConfigPathKey),
1065+
AdditionalConfigPaths: viperInstance.GetStringSlice(CollectorAdditionalConfigPathsKey),
1066+
Exporters: exporters,
1067+
Processors: resolveProcessors(),
1068+
Receivers: receivers,
1069+
Extensions: resolveExtensions(),
1070+
Log: resolveCollectorLog(),
1071+
Pipelines: resolvePipelines(),
10721072
}
10731073

10741074
// Check for self-signed certificate true in Agent conf

internal/config/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,8 +1112,8 @@ func createConfig() *Config {
11121112
},
11131113
},
11141114
Collector: &Collector{
1115-
ConfigPath: "/etc/nginx-agent/nginx-agent-otelcol.yaml",
1116-
AdditionalPaths: []string{"/configs/my_config.yaml", "/etc/nginx-agent/nginx-agent-otelcol.yaml"},
1115+
ConfigPath: "/etc/nginx-agent/nginx-agent-otelcol.yaml",
1116+
AdditionalConfigPaths: []string{"/configs/my_config.yaml", "/etc/nginx-agent/nginx-agent-otelcol.yaml"},
11171117
Exporters: Exporters{
11181118
OtlpExporters: map[string]*OtlpExporter{
11191119
"default": {

internal/config/types.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ type (
105105
}
106106

107107
Collector struct {
108-
ConfigPath string `yaml:"config_path" mapstructure:"config_path"`
109-
AdditionalPaths []string `yaml:"additional_config_paths" mapstructure:"additional_config_paths"`
110-
Log *Log `yaml:"log" mapstructure:"log"`
111-
Exporters Exporters `yaml:"exporters" mapstructure:"exporters"`
112-
Extensions Extensions `yaml:"extensions" mapstructure:"extensions"`
113-
Processors Processors `yaml:"processors" mapstructure:"processors"`
114-
Pipelines Pipelines `yaml:"pipelines" mapstructure:"pipelines"`
115-
Receivers Receivers `yaml:"receivers" mapstructure:"receivers"`
108+
ConfigPath string `yaml:"config_path" mapstructure:"config_path"`
109+
AdditionalConfigPaths []string `yaml:"additional_config_paths" mapstructure:"additional_config_paths"`
110+
Log *Log `yaml:"log" mapstructure:"log"`
111+
Exporters Exporters `yaml:"exporters" mapstructure:"exporters"`
112+
Extensions Extensions `yaml:"extensions" mapstructure:"extensions"`
113+
Processors Processors `yaml:"processors" mapstructure:"processors"`
114+
Pipelines Pipelines `yaml:"pipelines" mapstructure:"pipelines"`
115+
Receivers Receivers `yaml:"receivers" mapstructure:"receivers"`
116116
}
117117

118118
Pipelines struct {
@@ -365,7 +365,7 @@ func (col *Collector) Validate(allowedDirectories []string) error {
365365
err = errors.Join(err, nginxReceiver.Validate(allowedDirectories))
366366
}
367367

368-
for _, path := range col.AdditionalPaths {
368+
for _, path := range col.AdditionalConfigPaths {
369369
cleanPath := filepath.Clean(path)
370370
pathAllowed := isAllowedDir(cleanPath, allowedDirectories)
371371
if !pathAllowed {

0 commit comments

Comments
 (0)