Skip to content

Conversation

@adv-11
Copy link

@adv-11 adv-11 commented Dec 11, 2025

As discussed on PR #358 and PR #353 :

Add DataDog integration example

Shows how to plug Agent-Lightning into DataDog APM for production monitoring.

What it does:

  • Custom tracer sends all agent spans to DataDog
  • Multi-signal rewards (correctness + speed + cost)
  • Debug mode for quick testing
  • Clean reference implementation.

self.span_start_time: float = 0.0
print(f"[DataDogTracer] Initialized for service: {service}")

def start_span(self, name: str, **attributes) -> Any:
Copy link
Contributor

Choose a reason for hiding this comment

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

Who is responsible for calling this method?

Copy link
Author

Choose a reason for hiding this comment

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

Agent-Lightning's Runner calls this automatically.

The call flow is:

  1. Runner.step() begins → calls tracer.start_span()
  2. Agent executes and calls agl.emit_reward()→ triggers tracer.add_event()
  3. Runner.step()` completes → calls tracer.end_span()

Copy link
Contributor

Choose a reason for hiding this comment

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

The runner doesn't call those methods automatically as far as I can remember.

Copy link
Author

Choose a reason for hiding this comment

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

youre right - the tracer methods aren't called automatically by Runner.

Looking at the existing examples (apo, calc_x, etc.), I see the pattern now:

The tracer is passed to LitAgentRunner and used within runner.run_context(). The Runner manages the tracer lifecycle during runner.step() calls.

Let me revise the DataDog example to follow the correct pattern shown in apo_debug.py and calc_agent.py

‘’’
runner = agl.LitAgentRunner(DataDogTracer())
with runner.run_context(agent=my_agent, store=store):
await runner.step(task, resources=resources)
‘’’

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