mirror of https://github.com/langgenius/dify.git
- Add TokenMetricLabels BaseModel to enforce consistent label structure - All dify.token.* metrics now use identical 6-label structure: * tenant_id, app_id, operation_type, model_provider, model_name, node_type - Pydantic validation ensures runtime enforcement (extra='forbid', frozen=True) - Enables filtering by operation_type to avoid double-counting: * workflow: aggregated workflow-level tokens * node_execution: individual node-level tokens * message: direct message tokens * rule_generate/code_generate: prompt generation tokens Previously, inconsistent label cardinality made aggregation impossible: - WORKFLOW: 3 labels - NODE_EXECUTION: 6 labels - MESSAGE: 5 labels - PROMPT_GENERATION: 5 labels Now all use the same 6-label structure for consistent querying. |
||
|---|---|---|
| .. | ||
| entities | ||
| __init__.py | ||
| contracts.py | ||
| draft_trace.py | ||
| enterprise_trace.py | ||
| event_handlers.py | ||
| exporter.py | ||
| gateway.py | ||
| id_generator.py | ||
| metric_handler.py | ||
| telemetry_log.py | ||