Skip to content

feat(logs-sampling-rule): manage logs sampling rules as code - #97

Open
pl wants to merge 3 commits into
pl/spec-migrationfrom
pl/resource-logs-sampling-rules
Open

feat(logs-sampling-rule): manage logs sampling rules as code#97
pl wants to merge 3 commits into
pl/spec-migrationfrom
pl/resource-logs-sampling-rules

Conversation

@pl

@pl pl commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Adds logs sampling rules (projects/{id}/logs/sampling_rules) as a managed resource — the campaign's first order-sensitive collection.

Design

  • Identity carrier: trailing HTML-comment marker in name (subscriptions pattern; maxLength 255, guarded). No tags/descriptionname is the only free-text field; description/tags are silently dropped by the create serializer (live-verified).
  • Ordering (the order-aware bit): priority (lower first, first-match-wins) is a settable AND PATCH-updatable field that round-trips, so ordering is handled as a normal hashed field — a priority change is a real, pushable diff. No reorder-endpoint machinery and no generic pipeline extension were needed; the order-awareness is the hash projection including priority. Live-verified: priority 10→42 → single update → clean no-op.
  • Round-trip: config (type-specific passthrough bag), enabled, rule_type, and scope fields round-trip. Real PATCH (200) and real DELETE (204).

Verification (dev project 806)

create → no-op re-apply → edit config → single update → no-op → priority-only change → single update → no-op (order-aware) → orphan left untouched → hand-built rule (no marker) invisible to plan/orphans (safety invariant) → scoped prune via direct pruneLogsSamplingRule. All rows cleaned up. Gates: typecheck / typecheck:examples / lint / test (303) all pass. Smoke seed verified in isolation (seed→apply→pull --all-rows→tag-back→dry-run no-op→cleanup).

Stacking

Stacks on #81 (pl/spec-migration, codegen-only base). Retarget to master when #81 merges. First commit is the codegen regen (skippable in review); docs/resources.md Logs rows are provisional ahead of the full matrix refresh (#78).

🤖 Generated with Claude Code

pl and others added 3 commits July 24, 2026 01:39
Add logs_sampling_rules list/create/retrieve/partial_update/destroy to the
openapi-filter allowlist and regenerate src/generated/api.d.ts. The reorder
endpoint is intentionally omitted — ordering is controlled via the settable,
PATCH-updatable `priority` field.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Manage logs sampling rules (projects/{id}/logs/sampling_rules) as code — the
campaign's first order-sensitive collection. Identity rides a trailing
HTML-comment marker in `name` (subscriptions pattern; maxLength 255, guarded).

Ordering: `priority` (lower first, first-match-wins) is a settable AND
PATCH-updatable field that round-trips, so order is handled as a normal hashed
field — a priority change is a real, pushable diff. No reorder-endpoint
machinery or generic pipeline extension needed; the order-awareness is the hash
projection including `priority`. `config` is a type-specific passthrough bag;
`enabled`/`rule_type`/scope fields round-trip; `description`/`tags` are dropped
by the create serializer (live-verified). Real PATCH update + real DELETE (204).

Includes pull codegen, unit tests (incl. the priority-change diff), two
examples with explicit priorities, README scope (logs:read/write), resources.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Seed one disabled logs sampling rule per smoke run, add logs-sampling-rules to
SMOKE_KINDS, and wire --logs-sampling-rule=<key> into smoke-cleanup.ts. Verified
in isolation: seed -> apply -> pull --all-rows -> tag-back -> dry-run no-op ->
cleanup. (Full `pnpm smoke` is blocked upstream of this resource by a
pre-existing gap: `actions` is in SMOKE_KINDS but has no pull codegen on
pl/spec-migration, so pull fails at args validation.)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
pl added a commit that referenced this pull request Jul 24, 2026
Logs sampling rules (#97), warehouse saved queries (#99), and batch
exports (#100) complete the buildable surface. Logs alerts/metric rules,
warehouse tables/view links deferred; group types excluded; notebooks
parked. Adds a status section with the post-merge follow-up list.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant