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

[exporter/logging] Logging exporter logger does not honor telemetry logs configuration #5652

Closed
mx-psi opened this issue Jul 8, 2022 · 1 comment · Fixed by #5677
Closed
Labels
bug Something isn't working exporter/logging Logging exporter related issues

Comments

@mx-psi
Copy link
Member

mx-psi commented Jul 8, 2022

Describe the bug

The logging exporter does not honor telemetry logs configuration, since a new logger is created at startup which is completely independent from the Collector's logger.

func createLogger(cfg *Config) (*zap.Logger, error) {

I am not sure if this was intentional, but it is confusing to me :)

Steps to reproduce

Run the Collector with the following configuration:

receivers:
  hostmetrics:
    scrapers:
      load:
    collection_interval: 3s

exporters:
  logging:
    loglevel: debug

service:
  telemetry:
    logs:
      output_paths: [example.log]
  pipelines:
    metrics:
      receivers: [hostmetrics]
      exporters: [logging]

What did you expect to see?

I expected logging exporter logs to be logged to the example.log file, as this is where the rest of components will log.

What did you see instead?

All logs but the logging exporter's are logged to example.log. The logging exporter logs are logged to stderr.

What version did you use?
Version: v0.55.0

Additional context

This also makes this exporter less useful on context where the Collector is used as a library, since you effectively can't control where the logging exporter outputs.

This can be easily fixed if we take the core from the main logger and build a new core with sampling options to it, using zapcore.NewSamplingWithOptions. The level can also be managed with zapcore.NewIncreaseLevelCore, although in this case we lose the possibility of having a lower log level on the logging exporter than in the global one (IMO that's fine so long as we have a descriptive error).

@mx-psi mx-psi added bug Something isn't working exporter/logging Logging exporter related issues labels Jul 8, 2022
@mx-psi
Copy link
Member Author

mx-psi commented Jul 8, 2022

Originally the logging exporter used to output using the default logger, this changed in #257. It seems like the reason was to have independent control; however we can keep roughly the same level of independent control while using the same logger by building from the same core.

tigrannajaryan pushed a commit that referenced this issue Jul 15, 2022
…#5677)

Build the logger on the logging exporter's logger from the one on `TelemetrySettings`, so that the logger honors the configuration settings on `telemetry::logs` and the configuration options on `CollectorSettings.LoggingOptions`.

Depends on #5678

**Link to tracking Issue:** Fixes #5652

**Documentation:** Documented the feature gate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working exporter/logging Logging exporter related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant