Skip to content

Add a RestateTracer and RestateTracerProvider for AI observability#187

Merged
igalshilman merged 4 commits intomainfrom
langfuse
Mar 31, 2026
Merged

Add a RestateTracer and RestateTracerProvider for AI observability#187
igalshilman merged 4 commits intomainfrom
langfuse

Conversation

@gvdongen
Copy link
Copy Markdown
Contributor

@gvdongen gvdongen commented Mar 31, 2026

This PR adds a RestateTracer and RestateTracerProvider that can be used to enable exporting Agent SDK traces to AI observability platforms like LangFuse, LogFire, and Arize.

It does two things:

  • Makes sure all Agent SDK spans get attached to the Restate parent trace
  • Fixes the nesting of spans to appear nicely together with the Restate-server-generated spans

Tested for: LangFuse + Google ADK/OpenAI Agents SDK/Pydantic AI, and LogFire + Pydantic AI

A few files weren't formatted correctly it seems

@gvdongen gvdongen requested a review from igalshilman March 31, 2026 07:01
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 31, 2026

Test Results

  7 files  ±0    7 suites  ±0   3m 11s ⏱️ -19s
 49 tests ±0   49 ✅ ±0  0 💤 ±0  0 ❌ ±0 
210 runs  ±0  210 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 3f2e541. ± Comparison against base commit 35b109c.

♻️ This comment has been updated with latest results.

Comment on lines +30 to +31
def __init__(self):
self._spans = []
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do you really need to collect spans like this? if you create the parent span for hte invocation attempt, and close that one, all the child spans should be closed as well.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@gvdongen worth to double check if this creates an issues?

root = self._get_root_context()
if root is not None:
context = root
span = self._tracer.start_span(name, context=context, **kwargs)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we need to standardize a bit across SDKs some span attributes. Standardizing across them makes easy to sort/correlate.

In the runtime we already use some conventions, like restate.invocation.id and restate.invocation.target.

I'll add a comment to this issue restatedev/restate#4530 with the ones we know and use already.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

@igalshilman igalshilman left a comment

Choose a reason for hiding this comment

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

Looks good! it would be nice if we can align the property names as @slinkydeveloper suggested.

Comment on lines +30 to +31
def __init__(self):
self._spans = []
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@gvdongen worth to double check if this creates an issues?

@igalshilman igalshilman merged commit 7da5236 into main Mar 31, 2026
8 checks passed
@igalshilman igalshilman deleted the langfuse branch March 31, 2026 16:38
@github-actions github-actions bot locked and limited conversation to collaborators Mar 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants