Skip to content

Conversation

@pull
Copy link

@pull pull bot commented Nov 28, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

)

* Add PostHog telemetry tracing for LLM assistant operations

This commit adds comprehensive PostHog telemetry integration to track
and analyze LLM assistant operations including:

- uDSPy module execution (ChainOfThought, ReAct, Predict)
- LLM API calls with automatic generation tracking
- Tool invocations
- Performance metrics (latency, token usage)
- Error tracking with exception messages

The telemetry system:
- Captures hierarchical span relationships for nested operations
- Patches OpenAI client for automatic generation event tracking
- Handles errors gracefully without breaking assistant execution
- Respects POSTHOG_ENABLED setting
- Adds workspace and user context to all events

Run the telemetry test suite:
```bash
just pytest -k test_telemetry
```

All 8 tests should pass, covering:
- Trace context manager (success and exception paths)
- Module execution tracing (ChainOfThought, ReAct, Predict)
- LM callback enrichment
- Tool execution tracing
- Exception handling (module and tool failures)
- Telemetry disabled state

To test manually:
1. Ensure POSTHOG_ENABLED=True in settings
2. Set up PostHog project credentials
3. Use the assistant and verify events appear in PostHog
4. Check for $ai_trace, $ai_span, and $ai_generation events
5. Verify span hierarchy and context propagation

* Fix issue when POSTHOG_PROJECT_API_KEY is not set

* Fix tests; capture all spans; add trace input and output

* Bump udspy version
@pull pull bot locked and limited conversation to collaborators Nov 28, 2025
@pull pull bot added the ⤵️ pull label Nov 28, 2025
@pull pull bot merged commit cf44d1b into code:develop Nov 28, 2025
2 of 4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant