dify/api/tests/unit_tests/core
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
..
agent/output_parser fix: code block syntax cannot be displayed correctly in react mode (#16904) 2025-03-31 16:27:29 +08:00
app revert: revert human input relevant code (#31766) 2026-01-30 19:18:49 +08:00
datasource fix: handle missing `credential_id` (#30051) 2025-12-24 11:21:51 +08:00
file fix: `File` model add known extra fields, fix issue about the tool of… (#27607) 2025-11-04 09:57:25 +08:00
helper feat(refactoring): Support Structured Logging (JSON) (#30170) 2026-01-04 11:46:46 +08:00
logging feat(refactoring): Support Structured Logging (JSON) (#30170) 2026-01-04 11:46:46 +08:00
mcp feat: implement RFC-compliant OAuth discovery with dynamic scope selection for MCP providers (#28294) 2025-11-20 11:18:16 +08:00
model_runtime fix: Drain non-stream plugin chunk iterator (#31564) 2026-01-30 16:54:56 +08:00
moderation Feat/ implement test script of content moderation (#28923) 2025-11-30 12:43:58 +08:00
ops refactor(telemetry): migrate to type-safe enum-based event routing with centralized enterprise filtering 2026-02-05 20:15:12 -08:00
plugin revert: revert human input relevant code (#31766) 2026-01-30 19:18:49 +08:00
prompt Feat/chat message image first for agent and advanced_chat APP (#23796) 2025-08-22 16:42:15 +08:00
rag fix: SSRF in WordExtractor URL download (credit to @EaEa0001 ) (#31678) 2026-01-29 14:01:21 +08:00
repositories revert: revert human input relevant code (#31766) 2026-01-30 19:18:49 +08:00
schemas feat: knowledge pipeline (#25360) 2025-09-18 12:49:10 +08:00
telemetry refactor(telemetry): simplify by eliminating TelemetryFacade 2026-02-05 22:41:09 -08:00
tools revert: revert human input relevant code (#31766) 2026-01-30 19:18:49 +08:00
variables refactor(variables): clarify base vs union type naming (#30634) 2026-01-13 23:39:34 +09:00
workflow revert: revert human input relevant code (#31766) 2026-01-30 19:18:49 +08:00
__init__.py FEAT: NEW WORKFLOW ENGINE (#3160) 2024-04-08 18:51:46 +08:00
test_file.py feat(llm_node): support order in text and files (#11837) 2024-12-20 14:12:50 +08:00
test_model_manager.py fix RetrievalMethod StrEnum (#26768) 2025-10-13 10:29:37 +08:00
test_provider_configuration.py chore: remove icon_large of models (#30466) 2026-01-03 02:35:17 +09:00
test_provider_manager.py more typed orm (#28519) 2025-11-24 10:50:20 +08:00
test_trigger_debug_event_selectors.py feat: introduce trigger functionality (#27644) 2025-11-12 17:59:37 +08:00