-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Enable per-reconcile logger customization #1811
Comments
/cc @alvaroaleman @fabriziopandini @vincepri |
Additional note about the trace use case: I think we won't be able to create the traceID at that point when we actually use tracing, because we have to create a trace span like this: ctx, span := tracer.Start(ctx, "Reconcile")
defer span.End() This has to be inside of the Reconcile function because of the defer. As we don't want to pull the traceID out of the logger we've customized before, we have to create the span in Reconcile and then add the TraceID to the logger there. But I think the use case about Is there potentially a way to make the error logging after reconcile optional (enabled per default)? (https://github.com/kubernetes-sigs/controller-runtime/blob/master/pkg/internal/controller/controller.go#L317) It would be really great if we would be able to log the error in our Reconcile func with the full log context, without ending up with the error logged twice. |
Could we consider starting the trace within Controller Runtime (other folks might want to use this as well) and inject it into the context? |
I think that is reasonable. Although I would like to think about tracing specifically a bit more before proposing that and then open a new separate issue. But I think it should be fine to treat tracing as a separate topic and focus here on the log customization as it's (at least in my opinion) still a reasonable improvement independent of tracing. |
I'll open a new with an alternative proposal, i.e. just changing the logging in CR vs. making it customizable. Let's hold this issue for now. |
/close |
@sbueringer: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
It would be great if it would be possible to modify loggers for individual reconciles.
Some context:
pkg/builder.Builder
today you can set a logger which is later adjusted:The name and the k/v pair are added on top of either the logger provided in the builder or on top of
mgr.GetLogger()
.We would like to be able to customize the logger according to our requirements. Concrete this means we would like to add a "traceID" and "<kind>": "<namespace>/<name>" k/v pair to the logger (more background info below). We could do this during the
Reconcile
call, but then the error logged by controller-runtime wouldn't have this context (this one).As I'm pretty sure there are different opinions about what the name of a logger should look like and which k/v pairs should or shouldn't be added, I would propose to add a "hook" so that folks are able to customize the logger in the way they want.
Also e.g. dropping the current "name"/"namespace" k/v pairs would be a breaking change in controller-runtime.
Background info about "traceID" and "<kind>": "<namespace>/<name>"
I just wanted to provide this as background information. I think the discussion if this is a good or bad idea is out-of-scope (and still TBD in the CAPI project). But I think it should illustrate that it's worth making the logger customizable, so it's possible to accommodate requirements like this.
I've opened the following PR to illustrate how a solution could look like:
The text was updated successfully, but these errors were encountered: