Skip to content

Conversation

@jakekaplan
Copy link
Collaborator

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!

Comment on lines 66 to 67
"task.key": execution.key,
"task.attempt": execution.attempt,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

task.*? execution.*? task.execution.*?

Copy link
Owner

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-commenter
Copy link

codecov-commenter commented Mar 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (d822753) to head (6037997).

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.
📢 Have feedback on the report? Share it here.

def __call__(
self, docket: Docket, worker: Worker, execution: Execution
) -> logging.LoggerAdapter:
logger = logging.getLogger(f"docket.task.{execution.key}")
Copy link
Collaborator Author

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?

Copy link
Owner

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)

Copy link
Owner

@chrisguidry chrisguidry left a 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

def __call__(
self, docket: Docket, worker: Worker, execution: Execution
) -> logging.LoggerAdapter:
logger = logging.getLogger(f"docket.task.{execution.key}")
Copy link
Owner

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)

Comment on lines 66 to 67
"task.key": execution.key,
"task.attempt": execution.attempt,
Copy link
Owner

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

assert called
assert "Task is running" in caplog.text
assert "docket.task.my-cool-task:123" in caplog.text
print(caplog.text)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray?

@jakekaplan jakekaplan merged commit cad61a5 into main Mar 3, 2025
4 checks passed
@chrisguidry chrisguidry deleted the task-logger branch March 26, 2025 13:26
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

Successfully merging this pull request may close these issues.

Logger dependency?

4 participants