Skip to content
27 changes: 27 additions & 0 deletions .chloggen/codeboten_log-stderr-to-error.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

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

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Update passthrough logging to use Error for stderr pipe.

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

# (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:

# 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/supervisor/commander/commander.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (c *Commander) startWithPassthroughLogging() error {
scanner := bufio.NewScanner(stderrPipe)
for scanner.Scan() {
line := scanner.Text()
colLogger.Info(line)
colLogger.Error(line)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this classification, although it will result in anyone using passthrough logs but not configuring the collector to use stdout and stderr appropriately to start seeing a bunch of error logs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not configuring the collector to use stdout and stderr appropriately

My understanding is that the Collector outputs to stdout for anything related to the CLI (e.g. the components command) and to stderr for application-level logs. How should users configure this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't totally understand this point either, but what comes to mind is if the user is configuring the collector's own telemetry output path to be just "stderr" like so:

service:
  telemetry:
    logs:
      level: DEBUG
      output_paths: ["stderr"]

Then DEBUG level and above collector logs would appear as errors in the supervisor's logs. Is this the kind of bad configuration we're talking about?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe by default the collector uses stderr when running for all logs: https://github.com/open-telemetry/opentelemetry-collector/blob/b1ce36b19f7f95fd2689af2038820cc12066310f/service/telemetry/factory.go#L95-L96

This can be changed like @dpaasman00 mentioned. So a user would do

service:
  telemetry:
    logs:
      output_paths: ["stdout"]
      error_output_paths: ["stderr"]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the info.

@codeboten would it be reasonable to add that config to the default configuration the Supervisor passes to the Collector as part of this change? I have the same concern as Tyler about the Supervisor printing error-level logs using non-error level logs from the Collector.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evan-bradley sure I can add the output paths to correctly send to stderr and stdout if left unset

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set defaults for output_paths to stdout and for error_output_paths to stderr, ptal

}
if err := scanner.Err(); err != nil {
c.logger.Error("Error reading agent stderr: %w", zap.Error(err))
Expand Down