dify/api/core/ops
GareArc ff877ee39c
fix(telemetry): add resolved_trace_id property to eliminate trace_id inconsistencies
Add computed property to BaseTraceInfo that provides intelligent fallback:
1. External trace_id (from X-Trace-Id header)
2. workflow_run_id (for workflow-related traces)
3. message_id (as final fallback)

This ensures attribute dify.trace_id always matches log-level trace_id,
eliminating inconsistencies where attribute was null but log-level had value.

Changes:
- Add resolved_trace_id property to BaseTraceInfo (trace_entity.py)
- Replace 4 direct trace_id attribute assignments with resolved_trace_id
- Add trace_id_source parameter to 5 emit_metric_only_event calls

Fixes trace_id inconsistency found in MESSAGE_RUN, TOOL_EXECUTION,
MODERATION_CHECK, SUGGESTED_QUESTION_GENERATION, GENERATE_NAME_EXECUTION,
DATASET_RETRIEVAL, and PROMPT_GENERATION_EXECUTION events.

All 78 telemetry tests passing.
2026-02-28 20:32:15 -08:00
..
aliyun_trace fix: use Factory to create repository in Aliyun Trace (#30899) 2026-01-14 10:21:46 +08:00
arize_phoenix_trace fix(api): Populate Missing Attributes For Arize Phoenix Integration (#29526) 2025-12-15 11:15:18 +08:00
entities fix(telemetry): add resolved_trace_id property to eliminate trace_id inconsistencies 2026-02-28 20:32:15 -08:00
langfuse_trace feat(telemetry): add enterprise OTEL telemetry with gateway, traces, metrics, and logs 2026-02-05 23:10:30 -08:00
langsmith_trace feat(telemetry): add enterprise OTEL telemetry with gateway, traces, metrics, and logs 2026-02-05 23:10:30 -08:00
mlflow_trace feat: MLflow tracing (#26093) 2025-11-22 13:53:58 +08:00
opik_trace remove .value (#26633) 2025-10-11 09:08:29 +08:00
tencent_trace revert: "fix(ops): add streaming metrics and LLM span for agent-chat traces" (#29469) 2025-12-11 12:53:37 +08:00
weave_trace Fix duration displayed for workflow steps on Weave dashboard (#28289) 2025-11-20 11:37:01 +08:00
__init__.py feat: add ops trace (#5483) 2024-06-26 17:33:29 +08:00
base_trace_instance.py Migrate SQLAlchemy from 1.x to 2.0 with automated and manual adjustments (#23224) 2025-09-02 10:30:19 +08:00
ops_trace_manager.py refactor(telemetry): move gateway to core as stateless module-level functions 2026-02-28 19:27:24 -08:00
utils.py revert: revert human input relevant code (#31766) 2026-01-30 19:18:49 +08:00