Skip to content

Fix async method tracing#1

Merged
half0wl merged 1 commit into
mainfrom
rc/fix-async-tracing
Mar 17, 2026
Merged

Fix async method tracing#1
half0wl merged 1 commit into
mainfrom
rc/fix-async-tracing

Conversation

@half0wl
Copy link
Copy Markdown
Owner

@half0wl half0wl commented Mar 17, 2026

With @Service({ trace: true }), async methods were not getting traced correctly.

wrapWithTracing is passing a sync callback () => original.apply(this, args) to the trace function for all methods, including async ones. Some tracer fns (e.g. DD APM's tracer.trace) closes the span immediately when the callback returns synchronously even if the retval is a Promise.

This fixes it by detecting AsyncFunction methods and pass async () => original.apply(this, args) so tracing libraries that inspect the callback's constructor (DD APM, OpenTelemetry) keep the span open until the promise settles.

@railway-app railway-app Bot temporarily deployed to ray.cat / container-pr-1 March 17, 2026 17:09 Destroyed
@railway-app
Copy link
Copy Markdown

railway-app Bot commented Mar 17, 2026

🚅 Deployed to the container-pr-1 environment in 😸 ray.cat

Service Status Web Updated (UTC)
container.lib.ray.cat 🕗 Deploying (View Logs) Web Mar 17, 2026 at 5:10 pm

@half0wl half0wl merged commit 8d72ef6 into main Mar 17, 2026
1 of 2 checks passed
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.

1 participant