-
Notifications
You must be signed in to change notification settings - Fork 3
Add TaskLogger dependency
#25
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
Conversation
src/docket/dependencies.py
Outdated
| "task.key": execution.key, | ||
| "task.attempt": execution.attempt, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
task.*? execution.*? task.execution.*?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the OTEL stuff I used execution.key, and execution.attempt because I thought the task could refer to the function itself and the execution could refer to this one instance of running the function
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #25 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 21 21
Lines 1160 1182 +22
Branches 51 51
=========================================
+ Hits 1160 1182 +22 ☔ View full report in Codecov by Sentry. |
src/docket/dependencies.py
Outdated
| def __call__( | ||
| self, docket: Docket, worker: Worker, execution: Execution | ||
| ) -> logging.LoggerAdapter: | ||
| logger = logging.getLogger(f"docket.task.{execution.key}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make this configurable but I kind of feel like we always want the logger to be the task identifier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this should be "docket.task.{execution.function.__name__}"? The key is unique to each time a task runs, so if we made that the logger name, it might be pretty hard to filter it in logging tools? These also form like a hierarchical tree inside of the logging module so it might get bogged down if there are tons of unique ones (not totally sure about that)
chrisguidry
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it! I feel like we should do something really sparkly with logging in Docket but I don't know what it is yet :D #23 is aspirational
src/docket/dependencies.py
Outdated
| def __call__( | ||
| self, docket: Docket, worker: Worker, execution: Execution | ||
| ) -> logging.LoggerAdapter: | ||
| logger = logging.getLogger(f"docket.task.{execution.key}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this should be "docket.task.{execution.function.__name__}"? The key is unique to each time a task runs, so if we made that the logger name, it might be pretty hard to filter it in logging tools? These also form like a hierarchical tree inside of the logging module so it might get bogged down if there are tons of unique ones (not totally sure about that)
src/docket/dependencies.py
Outdated
| "task.key": execution.key, | ||
| "task.attempt": execution.attempt, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the OTEL stuff I used execution.key, and execution.attempt because I thought the task could refer to the function itself and the execution could refer to this one instance of running the function
tests/test_fundamentals.py
Outdated
| assert called | ||
| assert "Task is running" in caplog.text | ||
| assert "docket.task.my-cool-task:123" in caplog.text | ||
| print(caplog.text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray?
Closes #9
This PR adds a new dependency
TaskLogger. I'm not exactly sure if this is what was intended so happy to make adjustments!