8000 Improve nodejs asyncID tracking by grcevski · Pull Request #1800 · grafana/beyla · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve nodejs asyncID tracking #1800

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

Merged
merged 9 commits into from
Apr 7, 2025

Conversation

grcevski
Copy link
Contributor
@grcevski grcevski commented Apr 4, 2025

In certain situations, for example, when the await keyword is used in JavaScript, the asyncID may be incremented outside of the NodeJS runtime, e.g. by the interpreted JavaScript code. In this case we'll have gaps in the NodeJS chain of async event parent child relationship. This PR introduces a loop to look for neighbouring child asyncIDs for the request/client call chains for NodeJS, in case we cannot find the parent information directly.

TODO:

  • Integration tests
  • Clean up unguarded prints

@grcevski grcevski requested a review from a team as a code owner April 4, 2025 21:18
@@ -216,7 +216,7 @@ debug:
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -mod vendor -gcflags "-N -l" -ldflags="-X '$(BUILDINFO_PKG).Version=$(RELEASE_VERSION)' -X '$(BUILDINFO_PKG).Revision=$(RELEASE_REVISION)'" -a -o bin/$(CMD) $(MAIN_GO_FILE)

.PHONY: dev
dev: prereqs docker-generate compile-for-coverage
dev: prereqs generate compile-for-coverage
Copy link
Contributor Author

Choose a reason for hiding this comment

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

for development, I think we should just use the local development clang/llvm for speed purposes, rather than having to use the docker generate.

Copy link
codecov bot commented Apr 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.35%. Comparing base (a2c0758) to head (004a7f3).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1800      +/-   ##
==========================================
- Coverage   67.23%   65.35%   -1.89%     
==========================================
  Files         219      203      -16     
  Lines       22605    20884    -1721     
==========================================
- Hits        15199    13648    -1551     
+ Misses       6634     6363     -271     
- Partials      772      873     +101     
Flag Coverage Δ
integration-test 54.67% <ø> (-0.27%) ⬇️
k8s-integration-test 53.18% <ø> (+0.11%) ⬆️
oats-test 34.30% <ø> (ø)
unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor
@rafaelroquetto rafaelroquetto left a comment

Choose a reason for hiding this comment

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

Impressive!

@@ -119,7 +119,7 @@ static __always_inline tp_info_pid_t *find_parent_trace(const pid_connection_inf
}

attempts++;
} while (attempts < 3); // Up to 3 levels of thread nesting allowed
} while (attempts < 5); // Up to 5 levels of thread nesting allowed
Copy link
Contributor

Choose a reason for hiding this comment

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

if this 5 needs to be in sync with the one in the for inside runtime.h, perhaps we should use a constant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are technically different, one is how many times we go up the child->parent chain (this one in runtime) and the other is how many times we decrement the current async_id until we find one matching.

@grcevski grcevski merged commit f16a225 into grafana:main Apr 7, 2025
15 checks passed
@grcevski grcevski deleted the improve_nodejs_tracking branch April 7, 2025 17:50
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.

2 participants
0