-
[OPIK-4112][OPIK-4630][OPIK-4117] PydanticAI integration fixes (#5432)
发布于
2026-02-27 17:03:11 +00:00 - [OPIK-4112] Deduplicate token usage in OpenTelemetry spans with hierarchical structure
- Added logic to avoid double-counting tokens by clearing
usagefrom parent spans when children spans also carryusage. - Updated
LogfireMappingRuleswith a new rule forfinal_resultto improve trace aggregation handling. - Refactored deduplication logic to filter spans during trace creation and aggregation processes.
-
[OPIK-4415] Add
logfire.metricsmapping rule inLogfireMappingRulesto drop unused metrics -
[OPIK-4112] Add unit tests to validate token deduplication logic for hierarchical OpenTelemetry spans
- Added tests covering parent-child span structures to ensure accurate token usage deduplication.
- Verified scenarios with usage in both parent and child spans, only parent spans, and multiple child spans.
- [OPIK-4117] Add token computation logic and corresponding unit tests for OpenTelemetry spans
- Added logic to compute
total_tokenswhenprompt_tokensandcompletion_tokensare available, buttotal_tokensis missing. - Ensured existing
total_tokensvalues are not overwritten if present. - Introduced new unit tests to validate the scenarios, including edge cases where only one token component is provided.
- [OPIK-4117] Removed whitespace.
下载附件