You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .agents/skills/add-metrics/SKILL.md
+51Lines changed: 51 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,45 @@ name: add-metrics
3
3
description: "Add or change Prometheus metrics — cache WithLabelValues, hot path, cleanup, avoid high cardinality, naming, MustRegister, backward compatibility. From tikv/pd metrics PRs."
4
4
---
5
5
6
+
# Add Metrics
7
+
8
+
## Responsibility
9
+
10
+
Add or change Prometheus instrumentation in `tikv/pd` without regressing hot
11
+
paths, exploding label cardinality, or silently breaking dashboards and alerts.
12
+
13
+
## Inputs
14
+
15
+
- target package, file, or code path to instrument
16
+
- metric definition: namespace, subsystem, name, help text, type, unit, and
17
+
labels
18
+
- lifecycle context: where the entity is created, updated, and removed
19
+
- rollout context: existing metrics, dashboards, alerts, or compatibility
20
+
constraints that must remain stable
21
+
22
+
## Outputs
23
+
24
+
- a patch that updates metric definitions, registration, record sites, cleanup
25
+
sites, and related tests or docs when needed
26
+
- a short implementation note covering label choices, hot-path tradeoffs, and
27
+
backward-compatibility or migration impact
28
+
- if the requested metric is unsafe, a concrete alternative such as a lower
29
+
cardinality design or background aggregation
30
+
31
+
## Constraints
32
+
33
+
- cache `WithLabelValues(...)` results instead of recomputing them in hot paths
34
+
- avoid per-request or per-event metric creation on hot paths; prefer background
35
+
aggregation when feasible
36
+
- keep label cardinality bounded and add cleanup via `DeleteLabelValues(...)`
37
+
when entities disappear
38
+
- do not rename, remove, or change the type of an existing metric without an
39
+
explicit migration or rollout plan
40
+
- use `prometheus.MustRegister(...)` and keep dashboards, alerts, and docs
41
+
aligned with the final metric semantics
42
+
- if a metric is expensive, noisy, or experimental, prefer an existing toggle or
43
+
rollout gate instead of unconditional always-on instrumentation
44
+
6
45
## Principles (checklist + detail)
7
46
8
47
Before adding or changing metrics, ensure:
@@ -32,3 +71,15 @@ Before adding or changing metrics, ensure:
32
71
12.**Fix wrong metrics and document semantics** — If a metric measures the wrong thing (e.g. “processing time” including network), fix the measurement or add a new metric/version; do not silently change semantics.
33
72
34
73
13.**Instrument full lifecycle** — For gRPC streams or long-lived resources, add metrics for the full lifecycle and reflect cleanup/end so dashboards don’t show stuck or misleading series.
74
+
75
+
## Usage Examples
76
+
77
+
- Add a counter or histogram in a scheduler or API path, but cache
78
+
`WithLabelValues(...)` during init and only record the fast-path value in the
79
+
request handler.
80
+
- Add a gauge vector for long-lived resources such as streams, stores, or
81
+
groups, and pair creation with `DeleteLabelValues(...)` on teardown so old
82
+
series disappear.
83
+
- Replace or supplement an incorrect metric by introducing a new metric with the
84
+
right semantics while keeping the old metric stable until dashboards and
Copy file name to clipboardExpand all lines: .agents/skills/create-pr/SKILL.md
+43-11Lines changed: 43 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,50 @@ description: Push the current branch and create a pull request on tikv/pd follow
4
4
compatibility: Requires gh CLI authenticated with tikv/pd repo access. Must have local commits on a non-master branch.
5
5
---
6
6
7
-
# Persona & Goal
7
+
# Create PR
8
8
9
-
PD contributor assistant. Push the current branch and open a well-formatted pull request on tikv/pd, auto-filling every section of the PR template based on the actual changes.
9
+
## Responsibility
10
+
11
+
Push the current branch and open a pull request on `tikv/pd` that matches the
12
+
repository template and review expectations.
13
+
14
+
## Inputs
15
+
16
+
- current branch name, base branch, and committed diff to be submitted
17
+
- issue references and whether they should be `Close` or `ref`
18
+
-`.github/pull_request_template.md` plus
19
+
`references/pr-template.md` for the exact PR structure
20
+
- optional head repository or remote details when the PR comes from a fork
21
+
22
+
## Outputs
23
+
24
+
- a validated PR title and body draft shown to the user before submission
25
+
- a pushed branch with upstream tracking information
26
+
- a created PR URL, or a blocking error if push/auth/template validation fails
27
+
28
+
## Implementation Details
29
+
30
+
- Validation commands are `git status`, `git branch --show-current`,
31
+
`git log --oneline master..HEAD`, `git diff master...HEAD --stat`, and
32
+
`git diff master...HEAD`.
33
+
- PR content must be rendered from `.github/pull_request_template.md` and
34
+
`references/pr-template.md`, not improvised from memory.
35
+
- Push with `git push -u origin <branch-name>` unless the user specifies a
36
+
different remote or head repo.
37
+
- Create the PR with `gh pr create --repo tikv/pd ... --body-file -` so the
38
+
template formatting survives.
39
+
- Do not bypass local hooks with `--no-verify`; if a push hook or auth check
40
+
blocks the operation, surface the error instead of silently skipping it.
41
+
42
+
## Constraints
43
+
44
+
- Never force-push without user confirmation.
45
+
- Always show the PR content before submitting. User approval is required.
46
+
- Use `gh` for GitHub operations. Do not guess API URLs.
47
+
- Follow PD commit conventions when deriving the PR title.
48
+
- Ask for the issue number when it is unknown.
49
+
- Do not invent issue references.
50
+
- Do not modify code or rewrite commits as part of this skill.
10
51
11
52
# Reference Files
12
53
@@ -61,12 +102,3 @@ If the push or PR creation fails:
61
102
-**Push rejected**: Check if the remote branch exists; suggest force-push only if user confirms.
62
103
-**PR already exists**: Show the existing PR URL; offer to update it instead.
63
104
-**Auth failure**: Remind user to authenticate with `gh auth login`.
64
-
65
-
# Agent Constraints
66
-
67
-
-**Never force-push without user confirmation.**
68
-
-**Always show the PR content before submitting.** User must approve title and body.
69
-
-**Use `gh` CLI for GitHub operations.** Do not guess API URLs.
70
-
-**Follow PD commit conventions.**`pkg: message` format for title.
71
-
-**Do not modify code.** This skill only pushes and creates PRs.
72
-
-**Ask for issue number if unknown.** Do not invent issue references.
0 commit comments