发布

  • [OPIK-4112][OPIK-4630][OPIK-4117] PydanticAI integration fixes (#5432)

    frostbyte_neo 发布于 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 usage from parent spans when children spans also carry usage.
    • Updated LogfireMappingRules with a new rule for final_result to improve trace aggregation handling.
    • Refactored deduplication logic to filter spans during trace creation and aggregation processes.
    • [OPIK-4415] Add logfire.metrics mapping rule in LogfireMappingRules to 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_tokens when prompt_tokens and completion_tokens are available, but total_tokens is missing.
    • Ensured existing total_tokens values 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.
    下载附件