Skip to content
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

Merged
merged 23 commits into from
Sep 6, 2024
Merged

Update logger structure #981

merged 23 commits into from
Sep 6, 2024

Conversation

ricardoMogg
Copy link
Collaborator

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

Copy link

vercel bot commented Sep 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
base-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 6, 2024 4:48pm
web-base-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 6, 2024 4:48pm

@cb-heimdall
Copy link
Collaborator

cb-heimdall commented Sep 6, 2024

✅ Heimdall Review Status

Requirement Status More Info
Reviews 1/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

dneilroth
dneilroth previously approved these changes Sep 6, 2024
//TODO: initialice ddTrace through dd-tracer
if (ddTrace) {
// Access trace information server-side
const currentSpan = ddTrace?.scope().active();
Copy link
Collaborator

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

Copy link
Collaborator Author

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;
Copy link
Collaborator

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.

Copy link
Collaborator Author

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

} else {
console.log(`[${this.service}] ${message}`, meta);
console.log(JSON.stringify(logEntry));
Copy link
Collaborator

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?

Copy link
Collaborator

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));
}

?

Copy link
Collaborator Author

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.

@cb-heimdall cb-heimdall dismissed dneilroth’s stale review September 6, 2024 16:37

Approved review 2286700462 from dneilroth is now dismissed due to new commit. Re-request for approval.

dneilroth
dneilroth previously approved these changes Sep 6, 2024
@cb-heimdall cb-heimdall dismissed dneilroth’s stale review September 6, 2024 16:42

Approved review 2286724283 from dneilroth is now dismissed due to new commit. Re-request for approval.

@ricardoMogg ricardoMogg merged commit 67add19 into master Sep 6, 2024
7 checks passed
@ricardoMogg ricardoMogg deleted the update_logger_structure branch September 6, 2024 16:51
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.

3 participants