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. |
||
|---|---|---|
| .. | ||
| __init__.py | ||