mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-23 17:05:28 +08:00
refactor: remove beta diagnostics collection and reporting (#2616)
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from langbot.pkg.telemetry import diagnostics
|
||||
|
||||
import copy
|
||||
import json
|
||||
import time
|
||||
@@ -94,7 +92,6 @@ class InteractionManager:
|
||||
self.ap = ap
|
||||
self.store = store or InteractionStore(ap.persistence_mgr.get_db_engine())
|
||||
|
||||
@diagnostics.observe('interaction', 'interaction.request', source='agent', stage='execute')
|
||||
async def handle_result(
|
||||
self,
|
||||
*,
|
||||
@@ -208,7 +205,6 @@ class InteractionManager:
|
||||
except Exception as exc:
|
||||
await self.store.mark_delivery_failed(run_id, request.interaction_id, str(exc))
|
||||
raise
|
||||
diagnostics.set_outcome('waiting', reason_code='waiting')
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
@@ -255,14 +251,12 @@ class InteractionManager:
|
||||
except pydantic.ValidationError:
|
||||
return
|
||||
|
||||
@diagnostics.observe('interaction', 'interaction.acknowledge', source='platform', stage='ack')
|
||||
async def acknowledge_submission(self, record: dict[str, typing.Any], adapter: typing.Any) -> None:
|
||||
"""Best-effort transition of submitted controls into a read-only state."""
|
||||
delivery_result = record.get('delivery_result')
|
||||
if not isinstance(delivery_result, dict) or not self._supports_platform_api(
|
||||
adapter, INTERACTION_ACKNOWLEDGE_API
|
||||
):
|
||||
diagnostics.set_outcome('skipped')
|
||||
return
|
||||
try:
|
||||
delivery_result = await adapter.call_platform_api(
|
||||
@@ -280,8 +274,6 @@ class InteractionManager:
|
||||
delivery_result,
|
||||
)
|
||||
except Exception as exc:
|
||||
diagnostics.set_outcome('failed', reason_code='response_error')
|
||||
diagnostics.annotate(error=exc)
|
||||
self._warning(f'Failed to acknowledge interaction submission: {exc}')
|
||||
|
||||
async def _find_update_target(
|
||||
@@ -332,7 +324,6 @@ class InteractionManager:
|
||||
f'interaction field {field.id} has duplicate option values',
|
||||
)
|
||||
|
||||
@diagnostics.observe('interaction', 'interaction.consume', source='platform', stage='dispatch')
|
||||
async def consume_callback(
|
||||
self,
|
||||
*,
|
||||
|
||||
@@ -10,8 +10,6 @@ from langbot_plugin.api.entities.builtin.provider import message as provider_mes
|
||||
from langbot_plugin.api.entities.builtin.pipeline import query as pipeline_query
|
||||
|
||||
from langbot_plugin.entities.io.actions.enums import PluginToRuntimeAction
|
||||
|
||||
from ...telemetry import diagnostics as diagnostics
|
||||
from .reply_stream import ReplyStreamSession
|
||||
from ...core import app
|
||||
from ...api.http.context import ExecutionContext
|
||||
@@ -80,7 +78,6 @@ class AgentRunOrchestrator:
|
||||
self.journal = AgentRunJournal(ap)
|
||||
self._session_registry = get_session_registry()
|
||||
|
||||
@diagnostics.observe('run', 'runner.run', source='agent', stage='prepare')
|
||||
async def run(
|
||||
self,
|
||||
event: AgentEventEnvelope,
|
||||
@@ -106,8 +103,6 @@ class AgentRunOrchestrator:
|
||||
runner_id,
|
||||
bound_plugins,
|
||||
)
|
||||
|
||||
diagnostics.runner_metadata(self.ap, descriptor, binding.processor_type)
|
||||
usage = 'event' if binding.processor_type == 'event_processor' else 'agent'
|
||||
if usage not in descriptor.usages:
|
||||
raise ValueError(f'The selected Runner does not support {usage} usage')
|
||||
@@ -177,7 +172,6 @@ class AgentRunOrchestrator:
|
||||
|
||||
state_context = build_state_context(event, binding, descriptor)
|
||||
run_id = context['run_id']
|
||||
diagnostics.annotate(run_id=run_id, stage='execute')
|
||||
context['context']['available_apis']['reply_stream'] = hasattr(PluginToRuntimeAction, 'REPLY_STREAM') and any(
|
||||
tool.get('tool_name') == 'event_reply' and tool.get('tool_type') == 'platform'
|
||||
for tool in resources.get('tools', [])
|
||||
@@ -188,7 +182,6 @@ class AgentRunOrchestrator:
|
||||
source=(adapter_context or {}).get('_platform_event')
|
||||
or getattr((adapter_context or {}).get('_query'), 'message_event', None),
|
||||
)
|
||||
reply_streams.diagnostics = getattr(self.ap, 'diagnostics', None)
|
||||
available_apis = context.get('context', {}).get('available_apis')
|
||||
run_authorization = {
|
||||
'runner_id': descriptor.id,
|
||||
@@ -390,12 +383,6 @@ class AgentRunOrchestrator:
|
||||
terminal_status = 'cancelled'
|
||||
terminal_reason = run_snapshot.get('status_reason') or 'cancel_requested'
|
||||
break
|
||||
diagnostics.set_outcome(
|
||||
{'completed': 'succeeded', 'failed': 'failed', 'cancelled': 'cancelled'}.get(
|
||||
terminal_status, 'succeeded'
|
||||
),
|
||||
reason_code='runner_failed' if terminal_status == 'failed' else '',
|
||||
)
|
||||
await self.journal.finalize_run(
|
||||
run_id=run_id,
|
||||
status=terminal_status or 'completed',
|
||||
@@ -403,7 +390,6 @@ class AgentRunOrchestrator:
|
||||
usage=terminal_usage,
|
||||
)
|
||||
except Exception as exc:
|
||||
diagnostics.set_outcome('timeout' if self._is_deadline_exhausted(context) else 'failed')
|
||||
failed_usage = terminal_usage
|
||||
await self.journal.finalize_run(
|
||||
run_id=run_id,
|
||||
@@ -432,7 +418,6 @@ class AgentRunOrchestrator:
|
||||
exc_info=True,
|
||||
)
|
||||
|
||||
@diagnostics.observe('lifecycle', 'runner.query_prepare', source='pipeline', stage='prepare')
|
||||
async def run_from_query(
|
||||
self,
|
||||
query: pipeline_query.Query,
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from ...telemetry import diagnostics
|
||||
|
||||
import copy
|
||||
import fnmatch
|
||||
import typing
|
||||
@@ -669,7 +667,6 @@ def resolve_platform_api_call(session, bot_uuid, action, params, context_tool=No
|
||||
raise ValueError(f'Platform API {action} or its target is not authorized for this run')
|
||||
|
||||
|
||||
@diagnostics.observe('api', 'host.platform_tool', source='agent')
|
||||
async def execute_platform_tool(
|
||||
ap: typing.Any,
|
||||
execution_context: typing.Any,
|
||||
@@ -689,7 +686,6 @@ async def execute_platform_tool(
|
||||
normalized = _event_params(definition, context, normalized)
|
||||
# This flag is frozen by the Host from the synthetic debug envelope, not tool arguments.
|
||||
if delivery.get('surface') == 'webui' and (delivery.get('platform_capabilities') or {}).get('debug_mock') is True:
|
||||
diagnostics.annotate(source='webui_debug', attributes={'synthetic': True})
|
||||
result = _execute_mock_platform_tool(definition, context, normalized)
|
||||
if message_chain is not None:
|
||||
result['parameters']['message'] = message_chain.model_dump(mode='json')
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from ...telemetry import diagnostics
|
||||
|
||||
import typing
|
||||
import asyncio
|
||||
|
||||
@@ -138,9 +136,6 @@ class RunnerRegistry:
|
||||
permissions=typed_manifest.permissions,
|
||||
raw_manifest=manifest,
|
||||
)
|
||||
manager = getattr(self.ap, 'diagnostics', None)
|
||||
if isinstance(manager, diagnostics.DiagnosticsManager) and manager.enabled:
|
||||
diagnostics.declare_runner(descriptor)
|
||||
return descriptor
|
||||
|
||||
async def refresh(self, context: TenantContext) -> None:
|
||||
|
||||
@@ -7,8 +7,6 @@ from dataclasses import dataclass, field
|
||||
from typing import Literal
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
from ...telemetry import diagnostics
|
||||
|
||||
import pydantic
|
||||
from langbot_plugin.api.entities.builtin.platform import events, message
|
||||
from langbot_plugin.api.entities.builtin.provider import message as provider_message
|
||||
@@ -56,9 +54,6 @@ class ReplyStreamSession:
|
||||
self._closed = False
|
||||
self._active: set[asyncio.Task] = set()
|
||||
|
||||
@diagnostics.observe(
|
||||
'delivery', 'reply_stream.apply', source='agent', fields=lambda b: {'attributes': {'stream': True}}
|
||||
)
|
||||
async def apply(self, request: ReplyStreamRequest) -> dict:
|
||||
task = asyncio.create_task(self._apply(request))
|
||||
self._active.add(task)
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from ...telemetry import diagnostics
|
||||
|
||||
import asyncio
|
||||
import copy
|
||||
import typing
|
||||
@@ -172,7 +170,6 @@ class AgentRunSessionRegistry:
|
||||
'query_id': query_id,
|
||||
'execution_query': execution_query,
|
||||
'reply_streams': reply_streams,
|
||||
'_diagnostic_context': diagnostics.capture_context(),
|
||||
'plugin_identity': plugin_identity,
|
||||
'authorization': authorization,
|
||||
'status': {
|
||||
|
||||
Reference in New Issue
Block a user