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

docs: make a small set of examples for logger best practices #2041

Open
dshemetov opened this issue Aug 29, 2024 · 1 comment
Open

docs: make a small set of examples for logger best practices #2041

dshemetov opened this issue Aug 29, 2024 · 1 comment

Comments

@dshemetov
Copy link
Contributor

dshemetov commented Aug 29, 2024

Ah I didn't know that! Do we have a space/documentation/reference for best practices like these?

Originally posted by @aysim319 in #2025 (comment)

I'm thinking we can just show a couple templates and a couple of the features of structlog.

@melange396
Copy link
Contributor

There are many existing instances of good logging in our repositories that you could choose from for this. However, i don't think examples alone will be able to fully demonstrate all of the necessary principles;

The following comment (modified from the initial description of #2025) is worth adding before the simple logger examples in

and in the top docstring of the logger module itself1:

"""

To make our structured logging as useful as it can be, particularly within the context of how we use logs in Elastic, the event argument (typically the first unnamed arg) should be a static string (to make filtering easier), and each dynamic/varying value should be specified in an individual meaningfully- and consistently-named argument to the logger call (for use in filtering, thresholding, grouping, visualization, etc).

"""

Footnotes

  1. while editing that docstring we should also remove these now-outdated instructions: https://github.com/cmu-delphi/covidcast-indicators/blob/d52dcd5a6b84083fb5cbca4164ebdd8429ac81d3/_delphi_utils_python/delphi_utils/logger.py#L5-L8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants