-
Notifications
You must be signed in to change notification settings - Fork 281
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
Update logger structure #981
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
✅ Heimdall Review Status
|
5bcb278
to
7e63215
Compare
apps/web/src/utils/logger.ts
Outdated
//TODO: initialice ddTrace through dd-tracer | ||
if (ddTrace) { | ||
// Access trace information server-side | ||
const currentSpan = ddTrace?.scope().active(); |
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.
nit: should this be ddTrace.scope()?.active();
? namely ddTrace?
shouldn't be needed since we check above
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.
yeah this is true
// Access trace information server-side | ||
const currentSpan = ddTrace?.scope().active(); | ||
traceId = currentSpan?.context().toTraceId() ?? undefined; | ||
spanId = currentSpan?.context().toSpanId() ?? undefined; |
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.
similarly here currentSpan?.context()?.toSpanId()
? if context() is null or undefined we'll get an error.
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.
context() shouldn't be nil, since it is part of the definition of the object itself
apps/web/src/utils/logger.ts
Outdated
} else { | ||
console.log(`[${this.service}] ${message}`, meta); | ||
console.log(JSON.stringify(logEntry)); |
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.
do we not want to use console.error()
or console.warn()
when those are the levels?
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.
otherwise can we structure this as
if (typeof console[level] === 'function') {
console[level](JSON.stringify(logEntry));
else {
console.log(JSON.stringify(logEntry));
}
?
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'm using the previous condition for that. there is a warn and error function so it will be going to that. This else in particular is kind of overkill, everything should fall between the first other 2 conditions.
Approved review 2286700462 from dneilroth is now dismissed due to new commit. Re-request for approval.
Approved review 2286724283 from dneilroth is now dismissed due to new commit. Re-request for approval.
What changed? Why?
Update logger structure so that it is compatible with datadog. This will make errors look better in the logs explorer
Notes to reviewers
How has it been tested?
tested locally and in dev