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 DDOGTracer to work with AsyncDriver #1236

Closed
rwhitten577 opened this issue Nov 21, 2024 · 2 comments · Fixed by #1247
Closed

Update DDOGTracer to work with AsyncDriver #1236

rwhitten577 opened this issue Nov 21, 2024 · 2 comments · Fixed by #1247

Comments

@rwhitten577
Copy link
Contributor

Is your feature request related to a problem? Please describe.
The current DDOGTracer with AsyncDriver creates a span for each Hamilton function/node when it creates a coroutine, but doesn't track when the function actually runs. It would be great to have it track timing of the actual function body execution for more accurate metrics.

Also when using Hamilton in a FastAPI app, the FastAPI middleware tracer is not correlating the Hamilton trace as a child, i.e. 2 separate traces appear in DataDog. Ideally the Hamilton trace uses the current FastAPI request trace as its parent.

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
Open to using the OTel adapter instead of DDog if it's any easier to implement these changes.

Additional context
Slack thread: https://hamilton-opensource.slack.com/archives/C03M33QB4M8/p1731597046007369

@elijahbenizzy
Copy link
Collaborator

So this should be pretty easy. The approach:

  1. Create an async version of this class
  2. Change the superclasses -- see note below. We'd want to make them async.
  3. Add the right (same) code (pretty sure the same thing is what you want)?
  4. Ensure the state we keep is async-friendly (pretty sure it'll work)

Regarding (2) -- currently this subclasses three user-facing classes lifecycle.NodeExecutionHook, lifecycle.GraphExecutionHook, lifecycle.TaskExecutionHook. We don't have asynchronous version sof these, so we could either (1) subclass the right async hooks directly, or (2) create the user-facing versions of them (an equivalent class).

Note we could also do something clever by sharing code between the two, or at least having helper functions.

Otherwise, it's the same exact process as OTel (see this class), although I'd be curious if we'll run into async issues there (I assume it just works but we'd need to verify).

@rwhitten577 rwhitten577 mentioned this issue Dec 2, 2024
7 tasks
@rwhitten577
Copy link
Contributor Author

I got an async ddog version working in #1247. Tried the OTel adapter and didn't spend too much time debugging, but it seemed to add some overhead and/or block the event loop. Focused instead on getting ddog to work with async.

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 a pull request may close this issue.

2 participants