You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
@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. 🚀
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, supportssyslog
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 existingpkg/infra/log.Logger
into aHandler
(https://pkg.go.dev/log/slog#Handler) forslog
. We could also inject a Handler through Wire and/or make global slog logger to use our custom Handler. This would allow services to useslog
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
The text was updated successfully, but these errors were encountered: