Improve logs for `GET /tasks/:guid`
Nothing is logged when the details of a Task are requested. Instead, it would be nice to log something like this:
{"timestamp":"...","level":"info","source":"api","message":"get-task.started","data":{"session":"218"}}
{"timestamp":"...","level":"info","source":"api","message":"get-task.listing-jobs","data":{"session":"218", "label-selector": "..."}}
{"timestamp":"...","level":"info","source":"api","message":"get-task.ended","data":{"session":"218", "response-code": 200}}
Let's also make sure that any errors are logged correctly and only once. Refer to #177562455 for details about how we want to log errors.
Dev Notes
Ensure logs are correlated using lager session IDs. This requires using the logger.Session method and passing the logger through method calls. It will not work if the logger is stored in a struct.
Logger can be passed as an explicit method argument, or might also be passed as part of the context object that is already passed around (see the https://github.com/cloudfoundry/lager/tree/master/lagerctx package, and note in this story). With lagerctx, there is the risk of accidentally and unknowingly using the fallback discard logger if the original context is somehow lost while passing through methods. So explicitly passing both context and logger as separate method parameters throughout might be the safest option, giving compile-time guarantees of having logging correctly propagated.