Skip to content

refactor(metrics): migrate metrics tiles and logsmap to cc-api-client#1755

Merged
pdesoyres-cc merged 6 commits into
masterfrom
metrics/warp10-migration-v4
Jun 2, 2026
Merged

refactor(metrics): migrate metrics tiles and logsmap to cc-api-client#1755
pdesoyres-cc merged 6 commits into
masterfrom
metrics/warp10-migration-v4

Conversation

@pdesoyres-cc
Copy link
Copy Markdown
Contributor

@pdesoyres-cc pdesoyres-cc commented May 28, 2026

Context

Continues the migration away from the legacy @clevercloud/client Warp 10 access path
toward the new typed cc-api-client. Once every consumer of sendToWarp is gone, we can
drop the Warpscript plumbing and the WARP_10_HOST config surface, which is what this
branch achieves for the metrics tiles and the logs map.

Changes

  • cc-tile-metrics: smart binding now uses GetMetricsCommand. The new response is
    already keyed by metric name with normalized timestamps, so the local extractMetric
    helper and the RawMetric type are gone. Doc fixed from /v4/metrics/... to
    /v4/stats/... to match the endpoint.
  • cc-tile-status-codes: replaces the two-step Warp 10 token + Warpscript exec with a
    single GetStatusCodeDistributionCommand. Client-side filtering of non-standard codes
    is dropped — the new client exposes excludeNonStandardStatusCodes.
  • cc-tile-requests: adds the smart binding it never had, backed by
    GetStatusCodeDistributionCommand, so it can be wired into the demo and console
    without going through Warpscript.
  • cc-logsmap: adds a smart binding using GetRequestsCommand for heatmap mode and
    StreamRequestsCommand for the live points mode.
  • send-to-api: removes sendToWarp, the Warp10ApiConfig type, and the
    WARP_10_HOST plumbing in the storybook auth plugin. The API config surface now only
    carries what is actually used.
  • Build: cc-api-client.js is added as a rollup main entry so consumers can import it
    without pulling in a specific component chunk.

Implementation notes

For cc-logsmap heatmap mode, the response is byte-identical within an hour-aligned
bucket, so the current hour is cached until the next hour boundary plus a 2-minute
margin — same cadence the previous Warpscript query had, but expressed at the client
level instead of inside the script.

For cc-tile-status-codes, dropping the local filter changes a subtle behavior: codes
outside the standard ranges used to be silently dropped after fetch. The new flag
asks the client to omit them upstream, so the tile shows exactly what the client returns.

How to review

  1. Start with src/lib/send-to-api.js and the storybook plugin to confirm nothing else
    in the tree still references sendToWarp / WARP_10_HOST.
  2. Then walk the four *.smart.js files in this order:
    cc-tile-metricscc-tile-status-codescc-tile-requestscc-logsmap.
    Each one is independent; reading them in that order matches increasing complexity
    (single command → two commands + streaming).
  3. The .smart.md docs next to each component were updated in lockstep — worth a pass
    to check the example payloads match the new command outputs.
  4. Local smoke test: run the storybook smart demos for the four components against a
    real account and confirm the tiles render the same data as on master.

1-2 approvals from anyone on the team.

@pdesoyres-cc pdesoyres-cc self-assigned this May 28, 2026
@pdesoyres-cc pdesoyres-cc added the enhancement New feature or request label May 28, 2026
@pdesoyres-cc pdesoyres-cc force-pushed the metrics/warp10-migration-v4 branch from 31bf4f7 to 66a30e9 Compare May 28, 2026 07:29
@github-actions
Copy link
Copy Markdown
Contributor

🔎 A preview has been automatically published : https://clever-components-preview.cellar-c2.services.clever-cloud.com/metrics/warp10-migration-v4/index.html.

This preview will be deleted once this PR is closed.

Copy link
Copy Markdown
Contributor

@florian-sanders-cc florian-sanders-cc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small fix but apart from that, LGTM! 👍

Comment thread src/components/cc-logsmap/cc-logsmap.smart.js
Comment thread src/components/cc-tile-requests/cc-tile-requests.smart.js Outdated
@pdesoyres-cc pdesoyres-cc force-pushed the metrics/warp10-migration-v4 branch 2 times, most recently from 09dcfd4 to fc77c0d Compare June 2, 2026 08:21
The shared `CcApiClient` utility now lives next to `i18n.js` and `smart-manager.js` as a top-level
library that components import directly. It needs to ship as its own entry in the published bundle
so consumers can import it without pulling in a specific component chunk.
Part of the migration away from the legacy clients toward the typed `cc-api-client` command
API. Swaps `getOrganisationApplicationMetrics` for `GetMetricsCommand`, which already returns
metrics keyed by name with normalized timestamps, removing the need for the local
`extractMetric` helper and the `RawMetric` type. Also fix the documentation from
`/v4/metrics/...` to `/v4/stats/...` to match the new API endpoint.
…-api-client

Part of the Warp10 → cc-api-client migration. Replaces the two-step Warp10 token fetch +
Warpscript execution with a single `GetStatusCodeDistributionCommand`, which also drops the
client-side filtering of non-standard status codes (the new client handles it via
`excludeNonStandardStatusCodes`).
Part of the Warp10 → cc-api-client migration. `cc-tile-requests` didn't expose a smart
binding yet; this adds one backed by `GetStatusCodeDistributionCommand` so the tile can
be wired into the demo and console without going through Warpscript.
Continues the Warp10 migration by wiring `cc-logsmap` to the new client: `GetHeatMapCommand` for
the `heatmap` mode and `StreamRequestsCommand` for the live `points` mode.

The heat map aggregates into hourly buckets, so its response is byte-identical for the rest of the
current hour — cached until the next hour boundary plus a 2-minute margin to absorb ingestion lag.
Now that cc-tile-metrics, cc-tile-status-codes, cc-tile-requests and cc-logsmap fetch their
data through the new cc-api-client, nothing in the repo still calls sendToWarp. Drop the
helper, the Warp10ApiConfig type, and the WARP_10_HOST plumbing in the storybook auth
plugin so the API config surface only carries what is actually used.
@pdesoyres-cc pdesoyres-cc force-pushed the metrics/warp10-migration-v4 branch from fc77c0d to 2b69684 Compare June 2, 2026 09:27
@pdesoyres-cc pdesoyres-cc merged commit f2ea139 into master Jun 2, 2026
7 checks passed
@pdesoyres-cc pdesoyres-cc deleted the metrics/warp10-migration-v4 branch June 2, 2026 09:43
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

🔎 The preview has been automatically deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants