Skip to content

Proposal: add possibility to get reconcileID from context #2055

@zbindenren

Description

@zbindenren

Currently the context is added to the log message as follows:

log := c.LogConstructor(&req)

log = log.WithValues("reconcileID", uuid.NewUUID())
ctx = logf.IntoContext(ctx, log)

There is no easy way to get the reconcileID.

Sometimes it would be great when you have access to the reconcile ID. For example: when communicating with third party services, it would be nice if we could send the corresponding reconsileID in order to add the possibility to match a request with a specific reconcileID.

I propose to introduce method like:

func ReconcileID(ctx context.Context) string {
...
}

to get the reconcileID from the current context. In order that this works, we had to change the above code to something like:

log := c.LogConstructor(&req)

reconcileID := uuid.NewUUID()
log = log.WithValues("reconcileID", reconcileID)

reconcileIDToContext(ctx, reconcileID)

ctx = logf.IntoContext(ctx, log)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions