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

Add consistent (typed) log metadata #549

Open
rjferguson21 opened this issue Jul 8, 2024 · 1 comment
Open

Add consistent (typed) log metadata #549

rjferguson21 opened this issue Jul 8, 2024 · 1 comment
Labels
enhancement New feature or request operator Issues pertaining to the UDS Operator (Pepr)

Comments

@rjferguson21
Copy link
Contributor

With the addition of #533, we will be using child loggers which allow adding metadata to each log line which is very useful for filtering by a particular uds-operator component in Loki (or other log parsers).

It would also be beneficial to try to standardize the objects that we are logging using pino so that we can go a step further and potentially filter by other metadata for example showing all operator reconcile logs related to a particular Package.

The change would end up taking log lines that looked like:

 log.info(
    `Processing Package ${namespace}/${name}, status.phase: ${pkg.status?.phase}, observedGeneration: ${pkg.status?.observedGeneration}, retryAttempt: ${pkg.status?.retryAttempt}`,
  );

and converting them to something like:

// note this is K8s Metadata but it could include anything
type UDSReconcileLogMetadata = {
 name: string;
 namespace: string;
};

log.info<UDSReconcileLogMetadata>(
 { name, namespace },
 `Processing Package ${namespace}/${name}, status.phase: ${pkg.status?.phase}, observedGeneration: ${pkg.status?.observedGeneration}, retryAttempt: ${pkg.status?.retryAttempt}`,
);

The value of this would be that instead of you could consistently search for logs relating to a particular Package without relying on the log message alone.

@UnicornChance
Copy link
Contributor

also worth capturing in this issue could be the confusing nature of the pepr policies and the naming conventions there. The /policies/index.ts logs are under the policies component but technically refer to the operator.exemptions, maybe a restructuring of the files or renaming the components.

@mjnagel mjnagel added enhancement New feature or request operator Issues pertaining to the UDS Operator (Pepr) labels Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request operator Issues pertaining to the UDS Operator (Pepr)
Projects
None yet
Development

No branches or pull requests

3 participants