发布

  • [OPIK-7373] [FE][BE] fix: populate usage metrics for multi-project dashboard widgets (#7578)

    frostbyte_neo 发布于 2026-08-03 09:50:38 +00:00

    • [OPIK-7373] [FE][BE] fix: populate usage metrics for multi-project dashboard widgets

    The time-series widget editor sourced its "Usage metrics" dropdown from the
    per-project token-usage/names endpoint, using one representative project for a
    multi-project / "all projects" selection. When that project had no span token
    usage, the list came back empty ("No data") and group-by stayed disabled, even
    though the workspace had usage data.

    Add a workspace-scoped POST /v1/private/workspaces/token-usage/names endpoint
    (distinct usage keys across the resolved project set, all-time) mirroring the
    per-project one, and point the editor at it in multi-project mode via a
    useTokenUsageNames dispatcher. Also seed the options with the selected values
    and default to total_tokens on entering multi-project mode so the control never
    renders empty and group-by is immediately usable.

    Implements OPIK-7373: Cannot select usage metrics when creating multi-project
    dashboard widget.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • fix(dashboards): hide project selector on project-pinned dashboards

    When a dashboard is scoped to a single project (runtime context, e.g. the
    project-level Dashboards page), the widget's project scope is fixed to that
    project. Hide the whole "Project" block (the disabled "All projects in the
    workspace" checkbox and the disabled project selector) in the Time series and
    Single metric widget editors, since none of it is actionable there.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • refactor(dashboards): address PR review on token-usage widget
    • Do not seed total_tokens on entering multi-project mode: the chart filters
      series by usageMetrics, so a key absent from the data rendered an empty chart.
      Leave it empty (= all usage series) and let the user pick one for group-by.
    • Share the token-usage-names SQL between per-project and workspace queries via
      SpanMetricsQueries.tokenUsageNames(projectPredicate) so they can't drift.
    • Extract the token-usage fetch + option derivation into useUsageMetricOptions.
    • Cover the explicit empty project_ids path in WorkspacesResourceTest.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com


    Co-authored-by: Claude Opus 4.8 (1M context) noreply@anthropic.com

    下载附件