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

Improve Jaeger Python traces (more spans/snapshot tag). #1845

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pyodide/internal/python.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export async function uploadArtifacts() {
* Used for tracing via Jaeger.
*/

export async function enterJaegerSpan(span, callback) {
export function enterJaegerSpan(span, callback) {
if (!internalJaeger.traceId) {
// Jaeger tracing not enabled or traceId is not present in request.
return callback();
Expand Down
18 changes: 10 additions & 8 deletions src/pyodide/python-entrypoint-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,17 @@ function getPyodide() {

let mainModulePromise;
function getMainModule() {
if (mainModulePromise) {
return enterJaegerSpan("get_main_module", async () => {
if (mainModulePromise) {
return mainModulePromise;
}
mainModulePromise = (async function () {
const pyodide = await getPyodide();
await setupPackages(pyodide);
return enterJaegerSpan("pyimport_main_module", () => pyimportMainModule(pyodide));
})();
return mainModulePromise;
}
mainModulePromise = (async function () {
const pyodide = await getPyodide();
await setupPackages(pyodide);
return pyimportMainModule(pyodide);
})();
return mainModulePromise;
});
}

// Do not setup anything to do with Python in the global scope when tracing. The Jaeger tracing
Expand Down
4 changes: 4 additions & 0 deletions src/workerd/api/pyodide/pyodide.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ class ArtifactBundler : public jsg::Object {
return uploadMemorySnapshotCb != kj::none;
}

bool hasMemorySnapshot() {
return existingSnapshot != kj::none;
}

static jsg::Ref<ArtifactBundler> makeDisabledBundler() {
return jsg::alloc<ArtifactBundler>();
}
Expand Down
Loading