Skip to content
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

[cmd/opampsupervisor]: update defult output paths for supervisor logger #36072

Merged
merged 6 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions .chloggen/opamp_supervisor_default_output_paths.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: cmd/opampsupervisor

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Update default logger output paths to stderr

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [36072]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: |
The default output paths for the opamp supervisor logger have been updated to stderr from [stdout, stderr].
# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
2 changes: 1 addition & 1 deletion cmd/opampsupervisor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func runInteractive() error {
return fmt.Errorf("failed to create logger: %w", err)
}

supervisor, err := supervisor.NewSupervisor(logger, cfg)
supervisor, err := supervisor.NewSupervisor(logger.Named("supervisor"), cfg)
if err != nil {
return fmt.Errorf("failed to create supervisor: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/opampsupervisor/supervisor/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func DefaultSupervisor() Supervisor {
Telemetry: Telemetry{
Logs: Logs{
Level: zapcore.InfoLevel,
OutputPaths: []string{"stdout", "stderr"},
OutputPaths: []string{"stderr"},
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/opampsupervisor/supervisor/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ func (o *opAMPLogger) Errorf(_ context.Context, format string, v ...any) {
o.l.Errorf(format, v...)
}

func newLoggerFromZap(l *zap.Logger) types.Logger {
func newLoggerFromZap(l *zap.Logger, name string) types.Logger {
return &opAMPLogger{
l: l.Sugar(),
l: l.Sugar().Named(name),
}
}
6 changes: 3 additions & 3 deletions cmd/opampsupervisor/supervisor/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (s *Supervisor) getBootstrapInfo() (err error) {
return fmt.Errorf("failed to write agent config: %w", err)
}

srv := server.New(newLoggerFromZap(s.logger))
srv := server.New(newLoggerFromZap(s.logger, "opamp-server"))

done := make(chan error, 1)
var connected atomic.Bool
Expand Down Expand Up @@ -388,7 +388,7 @@ func (s *Supervisor) startOpAMP() error {
}

func (s *Supervisor) startOpAMPClient() error {
s.opampClient = client.NewWebSocket(newLoggerFromZap(s.logger))
s.opampClient = client.NewWebSocket(newLoggerFromZap(s.logger, "opamp-client"))

// determine if we need to load a TLS config or not
var tlsConfig *tls.Config
Expand Down Expand Up @@ -466,7 +466,7 @@ func (s *Supervisor) startOpAMPClient() error {
// depending on information received by the Supervisor from the remote
// OpAMP server.
func (s *Supervisor) startOpAMPServer() error {
s.opampServer = server.New(newLoggerFromZap(s.logger))
s.opampServer = server.New(newLoggerFromZap(s.logger, "opamp-server"))

var err error
s.opampServerPort, err = s.getSupervisorOpAMPServerPort()
Expand Down
4 changes: 2 additions & 2 deletions cmd/opampsupervisor/supervisor/supervisor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func Test_onMessage(t *testing.T) {
cfgState: &atomic.Value{},
effectiveConfig: &atomic.Value{},
agentHealthCheckEndpoint: "localhost:8000",
opampClient: client.NewHTTP(newLoggerFromZap(zap.NewNop())),
opampClient: client.NewHTTP(newLoggerFromZap(zap.NewNop(), "opamp-client")),
}
require.NoError(t, s.createTemplates())

Expand Down Expand Up @@ -339,7 +339,7 @@ func Test_onMessage(t *testing.T) {
cfgState: &atomic.Value{},
effectiveConfig: &atomic.Value{},
agentHealthCheckEndpoint: "localhost:8000",
opampClient: client.NewHTTP(newLoggerFromZap(zap.NewNop())),
opampClient: client.NewHTTP(newLoggerFromZap(zap.NewNop(), "opamp-client")),
}
require.NoError(t, s.createTemplates())

Expand Down
Loading