add more telemetry data

This commit is contained in:
Senko Rasic
2024-06-13 13:52:15 +02:00
parent 4379e0498d
commit df287ffb00
5 changed files with 43 additions and 9 deletions

View File

@@ -196,7 +196,14 @@ class Developer(BaseAgent):
self.next_state.modified_files = {}
self.set_next_steps(response, source)
self.next_state.action = f"Task #{current_task_index + 1} start"
await telemetry.trace_code_event("task-start", {"task-num": current_task_index + 1})
await telemetry.trace_code_event(
"task-start",
{
"task_index": current_task_index + 1,
"num_tasks": len(self.current_state.tasks),
"num_epics": len(self.current_state.epics),
},
)
return AgentResponse.done(self)
async def get_relevant_files(

View File

@@ -27,7 +27,13 @@ class TaskCompleter(BaseAgent):
tasks,
)
await telemetry.trace_code_event(
"task-end", {"task-num": current_task_index1, "num-iterations": len(self.current_state.iterations)}
"task-end",
{
"task_index": current_task_index1,
"num_tasks": len(self.current_state.tasks),
"num_epics": len(self.current_state.epics),
"num_iterations": len(self.current_state.iterations),
},
)
return AgentResponse.done(self)

View File

@@ -155,7 +155,13 @@ class TechLead(BaseAgent):
}
for task in response.plan
]
await telemetry.trace_code_event("development-plan", {"num-tasks": len(response.plan)})
await telemetry.trace_code_event(
"development-plan",
{
"num_tasks": len(self.current_state.tasks),
"num_epics": len(self.current_state.epics),
},
)
return AgentResponse.done(self)
async def update_epic(self) -> AgentResponse:

View File

@@ -182,7 +182,21 @@ class Troubleshooter(IterationPromptMixin, BaseAgent):
return False, False, ""
if user_response.button == "loop":
await telemetry.trace_code_event("stuck-in-loop", {"clicked": True})
await telemetry.trace_code_event(
"stuck-in-loop",
{
"clicked": True,
"task_index": self.current_state.tasks.index(self.current_state.current_task) + 1,
"num_tasks": len(self.current_state.tasks),
"num_epics": len(self.current_state.epics),
"num_iterations": len(self.current_state.iterations),
"num_steps": len(self.current_state.steps),
"architecture": {
"system_dependencies": self.current_state.specification.system_dependencies,
"app_dependencies": self.current_state.specification.package_dependencies,
},
},
)
return True, True, ""
return True, False, user_response.text

View File

@@ -368,8 +368,9 @@ class Telemetry:
if not self.enabled or getenv("DISABLE_TELEMETRY"):
return
if not data.get("app_id") and self.data["app_id"]:
data = {**data, "app_id": self.data["app_id"]}
data = deepcopy(data)
for item in ["app_id", "user_contact", "platform", "pilot_version", "model"]:
data[item] = self.data[item]
payload = {
"pathId": self.telemetry_id,
@@ -377,13 +378,13 @@ class Telemetry:
"data": data,
}
log.debug(f"Sending trace event {name} to {self.endpoint}")
log.debug(f"Sending trace event {name} to {self.endpoint}: {repr(payload)}")
try:
async with httpx.AsyncClient() as client:
await client.post(self.endpoint, json=payload)
except httpx.RequestError:
pass
except httpx.RequestError as e:
log.error(f"Failed to send trace event {name}: {e}", exc_info=True)
async def trace_loop(self, name: str, task_with_loop: dict):
payload = deepcopy(self.data)