Closed
Bug 1212925
Opened 9 years ago
Closed 7 years ago
structured logging library
Categories
(Taskcluster :: Services, defect)
Taskcluster
Services
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: jhford, Assigned: jhford)
References
Details
Attachments
(2 files, 1 obsolete file)
We should have structured logging in our components for lots of reasons, including alerting and talking to security aggregation systems.
This should be implemented as a library which components can use. There must be an easy transition path for components using the debug module.
Assignee | ||
Comment 1•9 years ago
|
||
https://github.com/taskcluster/taskcluster-logging is where I'm working, on the master branch.
Assignee | ||
Comment 2•9 years ago
|
||
This is the patch required to move the aws provisioner to using bunyan without the nice structured logging bits. Please let me know what you think!
Assignee: nobody → jhford
Status: NEW → ASSIGNED
Flags: needinfo?(pmoore)
Flags: needinfo?(jopsen)
Flags: needinfo?(garndt)
Comment 3•9 years ago
|
||
Is there a reason why this is call it debugCompat rather than just debug?
Assignee | ||
Comment 4•9 years ago
|
||
oh, and the log.js file is:
module.exports = require('taskcluster-logging')({name: 'aws-provisioner'});
Assignee | ||
Comment 5•9 years ago
|
||
(In reply to Greg Arndt [:garndt] from comment #3)
> Is there a reason why this is call it debugCompat rather than just debug?
yes, because then we'd be overwriting the .debug method (in the .info, .warn, .fatal, .error, and .trace family). Then we'd be unable to log debug messages.
Assignee | ||
Comment 6•9 years ago
|
||
so to be clear, debugCompat is called once to return a debug function, not the call you have to make each time you want to interface with the old debug module.
Comment 8•9 years ago
|
||
Looks like this would be simple enough to convert where we're using debug. nice!
Comment 9•9 years ago
|
||
@jhford,
So basically I would be allowed to do the following:
let log = require('../lib/log');
let debug = log.debugCompat("...");
// In my code
log.info("la lal al al ");
log.error({what: "bad-thing", why: "who knows?", blame: "any one but me"});
debug("la la la"); // legacy debug statement
That seems nice...
@jhford, can we rename taskcluster-logging to taskcluster-lib-log or something like that.
More importantly, how does this work with modules?
Ie. I have cases where base.API logs something, how does it do that?
What if they use different versions of the logging library? (perhaps even different bunyan versions?)
@jhford, ^ I think that is my last concern, do I give base.API an instance of log from my app or?
Flags: needinfo?(jopsen) → needinfo?(jhford)
Comment 10•9 years ago
|
||
FYI, I don't mind the horrible name debugCompat, it encourages us to move on :)
Assignee | ||
Comment 11•9 years ago
|
||
(In reply to Jonas Finnemann Jensen (:jonasfj) from comment #9)
> @jhford,
> That seems nice...
Heh, yep!
> @jhford, can we rename taskcluster-logging to taskcluster-lib-log or
> something like that.
Yah, I can rename it.
> @jhford, ^ I think that is my last concern, do I give base.API an instance
> of log from my app or?
I think that we should have a small lib/log.js per library... if we do that, we could filter logging to ignore certain things. Passing around log objects feels like a really bad idea to me. I'd like to avoid it wherever it makes sense to. There are going to be some child loggers that get passed around I suspect, like in the case:
for x in y:
l = log.child({x: x})
for i in j:
ll = l.child({i: i})
print x, i
If we were to split the loops into their own functions, we'd have to pass a log object around, but it'd likely be only for smaller internal only functions where the API isn't totally screwed up by having to pass in a log object.
Flags: needinfo?(jhford)
Assignee | ||
Comment 12•9 years ago
|
||
Assignee | ||
Comment 14•9 years ago
|
||
Here's the Pull Request. I'll upload a sample of how I converted the provisioner to this library using the compatibility stuff.
Attachment #8677443 -
Flags: review?(jopsen)
Attachment #8677443 -
Flags: feedback?(pmoore)
Attachment #8677443 -
Flags: feedback?(garndt)
Assignee | ||
Comment 15•9 years ago
|
||
Attachment #8673662 -
Attachment is obsolete: true
Comment 16•9 years ago
|
||
Comment on attachment 8677443 [details] [review]
first review
Okay, the code looks sane.
I'm just confused about how to use the library.
So the r- is related to a need for better docs.
Preferably shorter, more concise, and clear focus on how this is different
from raw bunyan, and what is and is not global.
Do I or do I not pass around a log object and create childs of it?
What is name and what is module, what is required?
Should I use this in libraries (do I pass a log object around?).
Note: I'm fine with either solutions, even not using it in libraries as most
libraires should throw errors rather an logging stuff
(maybe we have a few exceptions, like base.API).
Attachment #8677443 -
Flags: review?(jopsen) → review-
Comment 17•9 years ago
|
||
Comment on attachment 8677443 [details] [review]
first review
Feeling a bit out of my depth here - I think I'll leave it to Greg and Jonas, as I'm not really actively developing in node. Thanks for checking with me though.
Attachment #8677443 -
Flags: feedback?(pmoore)
Comment 18•9 years ago
|
||
Comment on attachment 8677443 [details] [review]
first review
Looks like I forgot to remove this flag, but I think my initial comments are similar to Jonas'. Also my immediate need for this library has taken a back seat as we are replacing docker-worker with a Go replacement.
Attachment #8677443 -
Flags: feedback?(garndt)
Updated•8 years ago
|
Component: Platform Libraries → Platform and Services
Updated•7 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Updated•6 years ago
|
Component: Platform and Services → Services
You need to log in
before you can comment on or make changes to this bug.
Description
•