Skip to content

Commit

Permalink
[cmd/opampsupervisor]: update defult output paths for supervisor logg…
Browse files Browse the repository at this point in the history
…er (#36072)

Co-authored-by: Evan Bradley <[email protected]>
  • Loading branch information
srikanthccv and evan-bradley authored Nov 27, 2024
1 parent ea29673 commit e899e0c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 9 deletions.
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 @@ -255,7 +255,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 @@ -289,7 +289,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 @@ -387,7 +387,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 @@ -465,7 +465,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

0 comments on commit e899e0c

Please sign in to comment.