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

Adding diagnostics channels to Fetch #2701

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

crysmags
Copy link

@crysmags crysmags commented Feb 5, 2024

This relates to...

This is a follow up to a previous PR [Added diagnostics channels on fetch] (#2210) , this includes [proposed changes] (#2210 (comment)) to emit the start event synchronously at the beginning of the function, and emit the end event right before returning, on all paths.

Rationale

We added five diagnostics channels on fetch to trace the same information as would tracingChannel.tracePromise. Some channels won't make perfect sense but we want to stay consistent with TracingChannel as we want to use it to trace fetch and maybe other functions when TracingChannel become available in the most commonly used versions of node.js. The descriptions of each channel and what gets published to them are detailed in DiagnosticsChannel.md

Use case: enable APM tools to trace fetch

Changes

Added diagnostics channel to fetch
Added tests to diagnostics channel for fetch

Status

Copy link
Member

@KhafraDev KhafraDev left a comment

Choose a reason for hiding this comment

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

Could you please undo the indent changes please

@crysmags
Copy link
Author

crysmags commented Feb 5, 2024

Could you please undo the indent changes please

With the addition of the try block the indentations were necessary, excluding them the commit will result in lint errors.

Copy link
Member

@KhafraDev KhafraDev left a comment

Choose a reason for hiding this comment

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

I missed that.. why is the extra try block needed? Wouldn't it be possible to add a .finally() to the p.promise instead?

lib/fetch/index.js Outdated Show resolved Hide resolved
lib/fetch/index.js Outdated Show resolved Hide resolved
lib/fetch/index.js Outdated Show resolved Hide resolved
lib/fetch/index.js Outdated Show resolved Hide resolved
lib/fetch/index.js Outdated Show resolved Hide resolved
lib/fetch/index.js Outdated Show resolved Hide resolved
benchmarks/benchmark.js Outdated Show resolved Hide resolved
@crysmags
Copy link
Author

crysmags commented Feb 6, 2024

I missed that.. why is the extra try block needed? Wouldn't it be possible to add a .finally() to the p.promise instead?

Yes, I can add the finally to the promise, though the initial start event is placed in the first try block

Copy link
Member

@metcoder95 metcoder95 left a comment

Choose a reason for hiding this comment

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

lgtm

lib/core/diagnostics.js Outdated Show resolved Hide resolved
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

Good job. Some nits.

lib/fetch/index.js Outdated Show resolved Hide resolved
lib/fetch/index.js Outdated Show resolved Hide resolved
lib/fetch/index.js Outdated Show resolved Hide resolved
lib/fetch/index.js Outdated Show resolved Hide resolved
lib/fetch/index.js Outdated Show resolved Hide resolved
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina
Copy link
Member

Can you resolve the conflicts with main?

@crysmags
Copy link
Author

@mcollina conflicts have been resolved 👍🏼

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina
Copy link
Member

Since your work started, we have migrated the tests to node:test. Could you converT?

@Uzlopak
Copy link
Contributor

Uzlopak commented Feb 14, 2024

My proposed suggestion would migrate the test from tap to node:test ;)

@crysmags
Copy link
Author

@Uzlopak committed the changes, thanks for that!

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

cc @metcoder95

@Uzlopak
Copy link
Contributor

Uzlopak commented Feb 14, 2024

Interesting. The unit fests found a valid bug.

@Uzlopak

This comment was marked as outdated.

lib/core/diagnostics.js Outdated Show resolved Hide resolved
lib/core/diagnostics.js Outdated Show resolved Hide resolved
lib/core/diagnostics.js Outdated Show resolved Hide resolved
lib/core/diagnostics.js Outdated Show resolved Hide resolved
lib/core/diagnostics.js Outdated Show resolved Hide resolved
lib/core/diagnostics.js Outdated Show resolved Hide resolved
@Uzlopak

This comment was marked as outdated.

Copy link
Member

@metcoder95 metcoder95 left a comment

Choose a reason for hiding this comment

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

Minor detail, and LGTM 👍

lib/core/diagnostics.js Outdated Show resolved Hide resolved
@mcollina
Copy link
Member

Thanks for the great work and keeping up with us!

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina
Copy link
Member

@Uzlopak @KhafraDev ptal

Copy link
Member

@KhafraDev KhafraDev left a comment

Choose a reason for hiding this comment

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

One small thing

@@ -114,6 +122,75 @@ if (undiciDebugLog.enabled || fetchDebuglog.enabled) {
isClientSet = true
}

// Track fetch requests
if (fetchDebuglog.enabled) {
Copy link
Member

Choose a reason for hiding this comment

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

This needs to check for the existence of tracing channel

@Uzlopak
Copy link
Contributor

Uzlopak commented Apr 1, 2024

I promise, i will have a look at it tonight (german time).

Sorry for the delays. I was the last three weeks busy with taking care of administrative stuff.

@crysmags
Copy link
Author

crysmags commented Apr 2, 2024

We have made additional updates to the start/end/error publish events, we are now calling runStores with these events. We have extracted all the diagnostic channel events code to a function which wraps the body of fetch.

@rochdev
Copy link

rochdev commented Apr 10, 2024

@Uzlopak @KhafraDev Any other concerns with the PR?

Copy link
Member

@KhafraDev KhafraDev left a comment

Choose a reason for hiding this comment

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

I don't have time to do a full review (finals), but after skimming it over nothing stands out.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina
Copy link
Member

tests seems to be failing, plus there is a conflict now

@mcollina
Copy link
Member

mcollina commented May 6, 2024

@Uzlopak ping

@Uzlopak Uzlopak closed this May 6, 2024
@Uzlopak Uzlopak reopened this May 6, 2024
Copy link
Contributor

@Uzlopak Uzlopak left a comment

Choose a reason for hiding this comment

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

RSLGTM

@Uzlopak
Copy link
Contributor

Uzlopak commented May 6, 2024

Sry for the mess. Accidently closed the PR with my fat fingers. My approval is just a rubberstamp, as a sign that i am not oposing this PR.

@tsctx
Copy link
Contributor

tsctx commented May 6, 2024

Documentation has not been updated and does not match current behavior.

Copy link
Member

@metcoder95 metcoder95 left a comment

Choose a reason for hiding this comment

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

Seconding @tsctx, it seems we expanded the debuglog but we haven't document that, can we expand the documentation?

lib/web/fetch/index.js Outdated Show resolved Hide resolved
lib/web/fetch/index.js Outdated Show resolved Hide resolved
lib/web/fetch/index.js Outdated Show resolved Hide resolved
@@ -135,114 +191,115 @@ function fetch (input, init = undefined) {
try {
requestObject = new Request(input, init)
} catch (e) {
p.reject(e)
return p.promise
return Promise.reject(e)
Copy link
Contributor

Choose a reason for hiding this comment

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

1 microtask delayed.

lib/web/fetch/index.js Outdated Show resolved Hide resolved
lib/web/fetch/index.js Outdated Show resolved Hide resolved
lib/web/fetch/index.js Outdated Show resolved Hide resolved
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.

None yet