Skip to content

Fix Add OTel Receiver After Config Apply & Fix Reload Monitoring Old Log #1057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 43 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f4e1d98
Moved Config parser to data source, stop instance watcher during conf…
aphralG Apr 23, 2025
975834b
Moved Config parser to data source, stop instance watcher during conf…
aphralG Apr 23, 2025
d54b145
change resource plugin to parse config
aphralG Apr 24, 2025
37c27b1
clean up
aphralG Apr 24, 2025
23feefa
move logger creation
aphralG Apr 24, 2025
f743035
added comments for context
aphralG Apr 24, 2025
2458c87
added comments for context
aphralG Apr 24, 2025
5e9d5e1
fix unit tests
aphralG Apr 24, 2025
d6532c3
try fix tests
aphralG Apr 24, 2025
65a1159
try fix tests
aphralG Apr 24, 2025
6698df9
fix test maybe
aphralG Apr 24, 2025
6ef74bc
fix tests
aphralG Apr 24, 2025
c219493
fix tests
aphralG Apr 24, 2025
2425def
fix tests
aphralG Apr 24, 2025
3d27ae0
fix tests
aphralG Apr 24, 2025
7537a1b
fix tests
aphralG Apr 24, 2025
606588b
fix tests
aphralG Apr 24, 2025
30b424f
fix tests
aphralG Apr 25, 2025
94f5438
fix tests
aphralG Apr 25, 2025
63eb2d1
fix tests
aphralG Apr 25, 2025
b50260e
fix tests
aphralG Apr 25, 2025
e6e65ce
fix tests
aphralG Apr 25, 2025
ba6f453
fix tests
aphralG Apr 25, 2025
b77f4e9
fix tests
aphralG Apr 25, 2025
18d3821
add plus file
aphralG Apr 25, 2025
725e59d
add plus conf file
aphralG Apr 25, 2025
78cd6d5
Merge branch 'v3' into dynamically-add-otel-receiver-after-config-apply
aphralG Apr 25, 2025
a7d896e
add plus conf file
aphralG Apr 25, 2025
a6e00f7
add plus conf file
aphralG Apr 25, 2025
1ecca95
add plus conf file
aphralG Apr 25, 2025
467b4b1
add plus conf file
aphralG Apr 25, 2025
59d5450
add plus conf file
aphralG Apr 25, 2025
9a8b38b
undo change
aphralG Apr 25, 2025
aa6c683
undo change
aphralG Apr 25, 2025
757168f
PR feedback
aphralG Apr 29, 2025
a58ddf8
Merge branch 'v3' into dynamically-add-otel-receiver-after-config-apply
aphralG Apr 29, 2025
3d6db7a
clean up
aphralG Apr 29, 2025
a662ad7
Pr feedback
aphralG Apr 29, 2025
7a94c34
pr feedback
aphralG Apr 29, 2025
dedec6b
merge v3
aphralG Apr 29, 2025
0cca25c
fix tests
aphralG Apr 29, 2025
262d353
fix tests
aphralG Apr 29, 2025
e4dc0d2
fix tests
aphralG Apr 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions internal/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/nginx/agent/v3/internal/bus"
"github.com/nginx/agent/v3/internal/config"
"github.com/nginx/agent/v3/internal/logger"
"github.com/nginx/agent/v3/internal/plugin"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -46,9 +45,6 @@ func (a *App) Run(ctx context.Context) error {
return
}

slogger := logger.New(*agentConfig.Log)
slog.SetDefault(slogger)

slog.InfoContext(ctx, "Starting NGINX Agent",
slog.String("version", a.version),
slog.String("commit", a.commit),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
)

type NginxStubStatusScraper struct {
logger *zap.Logger
httpClient *http.Client
client *client.NginxClient
cfg *config.Config
Expand All @@ -50,6 +51,7 @@ func NewScraper(
cfg: cfg,
mb: mb,
rb: rb,
logger: logger,
}
}

Expand All @@ -59,6 +61,7 @@ func (s *NginxStubStatusScraper) ID() component.ID {

// nolint: unparam
func (s *NginxStubStatusScraper) Start(_ context.Context, _ component.Host) error {
s.logger.Info("Starting NGINX stub status scraper")
httpClient := http.DefaultClient
httpClient.Timeout = s.cfg.ClientConfig.Timeout

Expand All @@ -74,7 +77,9 @@ func (s *NginxStubStatusScraper) Start(_ context.Context, _ component.Host) erro
return nil
}

// nolint: unparam
func (s *NginxStubStatusScraper) Shutdown(_ context.Context) error {
s.logger.Info("Shutting down NGINX stub status scraper")
return nil
}

Expand Down
8 changes: 7 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"strings"
"time"

"github.com/nginx/agent/v3/internal/logger"

"github.com/nginx/agent/v3/internal/datasource/file"

"github.com/goccy/go-yaml"
Expand Down Expand Up @@ -81,6 +83,10 @@ func ResolveConfig() (*Config, error) {
directories := viperInstance.GetStringSlice(AllowedDirectoriesKey)
allowedDirs := []string{AgentDirName}

log := resolveLog()
slogger := logger.New(log.Path, log.Level)
slog.SetDefault(slogger)

// Check directories in allowed_directories are valid
for _, dir := range directories {
if dir == "" || !filepath.IsAbs(dir) {
Expand Down Expand Up @@ -109,7 +115,7 @@ func ResolveConfig() (*Config, error) {
UUID: viperInstance.GetString(UUIDKey),
Version: viperInstance.GetString(VersionKey),
Path: viperInstance.GetString(ConfigPathKey),
Log: resolveLog(),
Log: log,
DataPlaneConfig: resolveDataPlaneConfig(),
Client: resolveClient(),
AllowedDirectories: allowedDirs,
Expand Down
121 changes: 121 additions & 0 deletions internal/datasource/config/configfakes/fake_config_parser.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading