dify/api/core/app/apps
GareArc 4a9b74f86b
refactor(telemetry): simplify by eliminating TelemetryFacade
**Problem:**
The telemetry system had unnecessary abstraction layers and bad practices
from the last 3 commits introducing the gateway implementation:
- TelemetryFacade class wrapper around emit() function
- String literals instead of SignalType enum
- Dictionary mapping enum → string instead of enum → enum
- Unnecessary ENTERPRISE_TELEMETRY_GATEWAY_ENABLED feature flag
- Duplicate guard checks scattered across files
- Non-thread-safe TelemetryGateway singleton pattern
- Missing guard in ops_trace_task.py causing RuntimeError spam

**Solution:**
1. Deleted TelemetryFacade - replaced with thin emit() function in core/telemetry/__init__.py
2. Added SignalType enum ('trace' | 'metric_log') to enterprise/telemetry/contracts.py
3. Replaced CASE_TO_TRACE_TASK_NAME dict with CASE_TO_TRACE_TASK: dict[TelemetryCase, TraceTaskName]
4. Deleted is_gateway_enabled() and _emit_legacy() - using existing ENTERPRISE_ENABLED + ENTERPRISE_TELEMETRY_ENABLED instead
5. Extracted _should_drop_ee_only_event() helper to eliminate duplicate checks
6. Moved TelemetryGateway singleton to ext_enterprise_telemetry.py:
   - Init once in init_app() for thread-safety
   - Access via get_gateway() function
7. Re-added guard to ops_trace_task.py to prevent RuntimeError when EE=OFF but CE tracing enabled
8. Updated 11 caller files to import 'emit as telemetry_emit' instead of 'TelemetryFacade'

**Result:**
- 322 net lines deleted (533 removed, 211 added)
- All 91 tests pass
- Thread-safe singleton pattern
- Cleaner API surface: from TelemetryFacade.emit() to telemetry_emit()
- Proper enum usage throughout
- No RuntimeError spam in EE=OFF + CE=ON scenario
2026-02-05 22:41:09 -08:00
..
advanced_chat refactor(telemetry): simplify by eliminating TelemetryFacade 2026-02-05 22:41:09 -08:00
agent_chat feat: chatflow support multimodal (#31293) 2026-01-27 00:24:48 +08:00
chat feat: chatflow support multimodal (#31293) 2026-01-27 00:24:48 +08:00
common refactor(typing): use enum types for workflow status fields (#31792) 2026-02-02 09:41:34 +08:00
completion feat: chatflow support multimodal (#31293) 2026-01-27 00:24:48 +08:00
pipeline refactor: port api/controllers/console/datasets/datasets_document.py api/controllers/service_api/app/annotation.py api/core/app/app_config/easy_ui_based_app/agent/manager.py api/core/app/apps/pipeline/pipeline_generator.py api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py to match case (#31832) 2026-02-02 19:07:30 +09:00
workflow feat: Add parent trace context propagation for workflow-as-tool hierarchy 2026-02-05 20:19:29 -08:00
__init__.py FEAT: NEW WORKFLOW ENGINE (#3160) 2024-04-08 18:51:46 +08:00
base_app_generate_response_converter.py feat: Add summary index for knowledge. (#31625) 2026-01-29 13:47:35 +08:00
base_app_generator.py fix: fix object value is optional should skip validate (#30894) 2026-01-13 15:21:06 +08:00
base_app_queue_manager.py fix: release graph_runtime_state reference to prevent memory leak under high load (#30236) 2025-12-29 10:35:47 +08:00
base_app_runner.py feat: chatflow support multimodal (#31293) 2026-01-27 00:24:48 +08:00
exc.py refactor: decouple Node and NodeData (#22581) 2025-07-18 10:08:51 +08:00
message_based_app_generator.py revert: revert human input relevant code (#31766) 2026-01-30 19:18:49 +08:00
message_based_app_queue_manager.py remove bare list, dict, Sequence, None, Any (#25058) 2025-09-06 03:32:23 +08:00
workflow_app_runner.py revert: revert human input relevant code (#31766) 2026-01-30 19:18:49 +08:00