feat(metrics): harden metrics scripts and correct discovery-time docs#54
Open
Licenser wants to merge 5 commits into
Open
feat(metrics): harden metrics scripts and correct discovery-time docs#54Licenser wants to merge 5 commits into
Licenser wants to merge 5 commits into
Conversation
20f824c to
116b4aa
Compare
axiom-api: - Add --connect-timeout (10s) and --max-time (120s), overridable via AXIOM_CONNECT_TIMEOUT / AXIOM_MAX_TIME, so requests fail fast rather than hang. metrics-info: - URL-encode dataset, metric, and tag names plus time params (jq @uri) so OTel names and RFC3339 offsets survive reserved characters. - Accept relative --start/--end (now, now-<N>[smhdw]); resolved to RFC3339 UTC client-side because the info endpoints only parse RFC3339. - Fetch per-tag values concurrently in `describe`; collect, check all failures, then parse, so a failed fetch aborts instead of emitting partial JSON. - Propagate type-probe query failures instead of swallowing them, so a failed query is never misreported as the tag being "absent". query-metrics/SKILL.md: - Document the timeouts, single-quoting MPL, bounding `group by` cardinality, and 429 back-off. - Correct the relative-time docs: metrics-info handles only now / now-<N>[smhdw], while metrics-query forwards times to the server, which accepts a broader set (e.g. now-1y). Verified against the axiom deployment. Both metrics-info copies (query-metrics, building-dashboards) kept in sync. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render Axiom metrics query results (application/vnd.metrics.v3+json) as multi-series line charts. - Zero-dependency Python stdlib Unicode/braille renderer (default, works in any terminal/transcript/CI log) - Optional gnuplot backend for PNG/SVG/sixel; font/line weight scale with the canvas; non-ASCII (e.g. em dash) emitted as real UTF-8 - Series reduction: collapse near-overlapping lines, cap at top-N by peak, and report dropped counts in the legend - Local-time x-axis (--tz override), null points drawn as gaps, group_keys legends (e.g. "200 | GET"), units from response metadata - auto format: inline image on image-capable terminals; a PNG file plus an explicit "display this file" instruction when piped (AI agent harness); ASCII in a plain terminal or when gnuplot is absent - 35 unit tests (parser pinned to service/query/src/server/tests.rs goldens) - Registered in the repo README and given a per-skill README Co-authored-by: Claude <noreply@anthropic.com>
select_series caps with reps[:top_n], so --top 0 selected nothing and negatives dropped a suffix instead of limiting to N peaks, leaving an empty plot that crashes gnuplot on otherwise-valid JSON. Validate --top at the CLI boundary with a positive-int argparse type (exit 2 with a clear message) before any input is read. Add tests for the helper and main() integration, and note the >= 1 constraint in SKILL.md. Co-authored-by: Claude <noreply@anthropic.com>
collapse_overlapping short-circuited on rng == 0, merging every series whose values share a single number even when two series have no timestamps in common. The later series was dropped from the chart and legend despite never aligning with the kept line. _aligned_max_diff already returns +inf for series with no shared points, so the short-circuit was both wrong (merged disjoint lines) and redundant (identical overlapping flat lines still collapse, since 0 <= eps*0). No division by rng exists, so removing it carries no zero-division risk. Add regression tests for the disjoint and overlapping flat-line cases. Co-authored-by: Claude <noreply@anthropic.com>
bfd99ff to
c82aad1
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c82aad1. Configure here.
_tz_offset_seconds returned 0 for tz=None because a naive datetime's utcoffset() is None, so PNG/SVG/sixel charts labeled the x-axis in UTC while ASCII used local time. Attach the local zone when tz is None, and shift each epoch by the offset at its own instant so tick labels stay correct across a DST transition instead of using one offset from the first sample. Co-authored-by: pi <noreply@earendil.works>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Hardens the
query-metrics/building-dashboardsmetrics scripts and fixes a documentation claim that contradicted actual behavior. All changes were verified live against theaxiomdeployment.axiom-api--connect-timeout(10s) and--max-time(120s), overridable viaAXIOM_CONNECT_TIMEOUT/AXIOM_MAX_TIME. Requests now fail fast instead of hanging indefinitely.metrics-infojq @uri) across all endpoint paths, so OTel names (/,., spaces) and RFC3339+offsetsurvive reserved characters.--start/--end(now,now-<N>[smhdw]), resolved to RFC3339 UTC client-side because the info endpoints only parse RFC3339.describe: collect → check all failures → then parse, so a failed fetch aborts loudly instead of emitting partial JSON."absent".query-metrics/SKILL.mdgroup bycardinality, and 429 back-off.metrics-infoaccepts "the same relative forms asmetrics-query" — it does not.metrics-queryforwards times to the server unparsed (broader grammar, e.g.now-1y), whilemetrics-infoonly handlesnow/now-<N>[smhdw]client-side.Verification (against
axiomdeployment)metrics-query(server_mpl)metrics-infonow-7dnow-1yy)s/m/h/d/w)now-1mounexpected token "mo")Also confirmed accurate against the live API and left unchanged: the
{"code","message"}error shape + annotated MPL source-pointer, and the histogrambucket … using/ quantile / temporality spec wording.metrics-chart/SKILL.mdTest plan
bash -npasses on bothmetrics-infocopies andmetrics-querymetrics-infocopies remain byte-identicalnow-7dOK /now-1y400 in info;now-1yOK in query)🤖 Generated with Claude Code
Note
Low Risk
Mostly additive CLI/docs and local chart rendering; script changes improve URL safety and error handling without altering auth or query semantics.
Overview
Adds a new
metrics-chartskill that turns metrics v2/v3 JSON into multi-series line charts (stdlib braille ASCII by default, optional gnuplot PNG/SVG/sixel, series collapse/top-N, agent-friendly PNG handoff), plus examples and unit tests. The root README lists the skill.axiom-api(query-metrics and building-dashboards) now uses 10s connect / 120s total curl timeouts, overridable viaAXIOM_CONNECT_TIMEOUT/AXIOM_MAX_TIME.metrics-info(both skill copies) is hardened: URL-encoding for dataset/metric/tag names and time query params; client-sidenow/now-<N>[smhdw]normalization (narrower thanmetrics-query); parallel per-tag value fetches indescribewith fail-fast on errors; tag type probes exit on query failure instead of reporting"absent".query-metrics/SKILL.mddocuments MPL single-quoting, high-cardinalitygroup byrisk, histogrambucketguidance, corrected relative-time semantics formetrics-infovsmetrics-query, timeouts, and 429 backoff.Reviewed by Cursor Bugbot for commit d174ce6. Bugbot is set up for automated code reviews on this repo. Configure here.