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

Wrapper for slog #86499

Open
9 of 13 tasks
leonorfmartins opened this issue Apr 18, 2024 · 1 comment
Open
9 of 13 tasks

Wrapper for slog #86499

leonorfmartins opened this issue Apr 18, 2024 · 1 comment
Labels
area/backend internal for issues made by grafanistas type/chore

Comments

@leonorfmartins
Copy link
Contributor

leonorfmartins commented Apr 18, 2024

What is the chore?:
Problem 1: there are different log packages in the grafana codebase, we should just stick to one.
Problem 2: direct dependencies on pkg/infra/log (which in its turn has plenty of dependencies) makes it difficult to decompose the backend into independent modules.

Proposal:

pkg/infra/log is still useful (and we should not make incompatible changes to the logger output). It handles various per-service logging levels, supports syslog and colourised logs and a few other things. Its interface is fairly standard (4 levels + key value attributes + context).

However, Go now comes with slog in its standard library. We should be able to convert existing pkg/infra/log.Logger into a Handler (https://pkg.go.dev/log/slog#Handler) for slog. We could also inject a Handler through Wire and/or make global slog logger to use our custom Handler. This would allow services to use slog APIs for logging without worrying what kind of a logging backend they are using.

As a positive side effect it also breaks the dependency graph and loosens the connections to pkg/infra.

(We could do the same thing for traces and use OTEL interface everywhere as well) - however here I'd suggest to focus only on logging topic.

Related PR: #87000

Explore

Implement

Finish

@grafanabot
Copy link
Contributor

@leonorfmartins please add one or more appropriate labels. Here are some tips:

  • if you are making an issue, TODO, or reminder for yourself or your team, please add one label that best describes the product or feature area. Please also add the issue to your project board. 🚀

  • if you are making an issue for any other reason (docs typo, you found a bug, etc), please add at least one label that best describes the product or feature that you are discussing (e.g. area/alerting, datasource/loki, type/docs, type/bug, etc). Our issue triage doc also provides additional guidance on labeling. 🚀

Thank you! ❤️

@grafanabot grafanabot added the internal for issues made by grafanistas label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/backend internal for issues made by grafanistas type/chore
Projects
None yet
Development

No branches or pull requests

3 participants