Skip to main content
Loading navigation
Back to prompt library

Integrate Graphite for Observability

Linked challenge: Secure Personal Intelligence Agent with Google ADK & Gemini 2.5 Pro

Prompt source

implementation13 lines5 sectionsNo variables1 code block
Modify your Google ADK agent to send detailed traces and logs to Graphite for every tool call, LLM interaction, and decision point. Ensure that privacy-sensitive information is masked or omitted from logs. Your implementation should demonstrate how Graphite helps in debugging the agent's reasoning process and verifying data access decisions. 

```python
# from google_adk.tools import Tool
# from graphite import Client

# graphite_client = Client(api_key="YOUR_GRAPHITE_API_KEY")

# class TracedGmailReader(SimulatedGmailReader):
#    def call(self, user_id: str, consent_level: dict):
#        graphite_client.log_event("Gmail_Tool_Call_Start", {"user_id": user_id, "requested_access": "email"})
#        response = super().call(user_id, consent_level)
#        graphite_client.log_event("Gmail_Tool_Call_End", {"user_id": user_id, "response_status": "success" if "Access denied" not in response else "denied"})
#        return response

# (Then use TracedGmailReader in your agent)
```