Skip to content

Commit c965580

Browse files
chore(sentry-instrument): regenerate semantics weekly
Run the semantics generator every Monday and commit changed references to main. Keep the instrument skill's domain links synchronized as categories change. Co-Authored-By: Evan Purkhiser <evan.purkhiser@sentry.io>
1 parent c1aab39 commit c965580

3 files changed

Lines changed: 93 additions & 1 deletion

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Refresh the generated Sentry semantic-convention references once a week.
2+
# The release App token is required because this workflow commits directly to
3+
# main and GITHUB_TOKEN pushes do not trigger the normal push workflows.
4+
5+
name: Regenerate semantic conventions
6+
7+
on:
8+
schedule:
9+
- cron: "17 13 * * 1"
10+
workflow_dispatch:
11+
12+
permissions: {}
13+
14+
concurrency:
15+
group: regenerate-semantic-conventions
16+
cancel-in-progress: false
17+
18+
jobs:
19+
regenerate:
20+
if: github.repository == 'getsentry/sentry-for-ai'
21+
runs-on: ubuntu-24.04
22+
timeout-minutes: 10
23+
permissions:
24+
contents: read
25+
steps:
26+
- name: Get auth token
27+
id: token
28+
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
29+
with:
30+
client-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }}
31+
private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }}
32+
33+
- name: Checkout main
34+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
35+
with:
36+
ref: main
37+
token: ${{ steps.token.outputs.token }}
38+
39+
- name: Install uv
40+
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
41+
42+
- name: Regenerate references
43+
run: |
44+
set -euo pipefail
45+
python3 scripts/gen-semantics.py
46+
47+
# flowmark exits non-zero when it rewrites files. Run it once to
48+
# apply fixes, then again to prove the generated tree is stable.
49+
./scripts/lint.sh run flowmark --files \
50+
src/references/semantics/*.md \
51+
src/skills/sentry-instrument/SKILL.md || true
52+
./scripts/lint.sh run flowmark --files \
53+
src/references/semantics/*.md \
54+
src/skills/sentry-instrument/SKILL.md
55+
./scripts/lint.sh run built-links
56+
57+
- name: Commit changes
58+
run: |
59+
set -euo pipefail
60+
61+
if git diff --quiet -- src/references/semantics src/skills/sentry-instrument/SKILL.md; then
62+
echo "No semantic-convention changes."
63+
exit 0
64+
fi
65+
66+
git config user.name "github-actions[bot]"
67+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
68+
git add src/references/semantics src/skills/sentry-instrument/SKILL.md
69+
git commit -m "chore(sentry-instrument): regenerate semantic conventions"
70+
git push origin HEAD:main

scripts/gen-semantics.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
SOURCE_URL = "https://getsentry.github.io/sentry-conventions/api/attributes.json"
1717
REPO_ROOT = Path(__file__).resolve().parents[1]
1818
OUT_DIR = REPO_ROOT / "src" / "references" / "semantics"
19+
SKILL_PATH = REPO_ROOT / "src" / "skills" / "sentry-instrument" / "SKILL.md"
20+
TOC_START = "<!-- semantics-toc:start -->"
21+
TOC_END = "<!-- semantics-toc:end -->"
1922

2023
# One-line domain intros shown at the top of each file. Keep these about the
2124
# domain, not about how the file was generated.
@@ -157,7 +160,24 @@ def main() -> None:
157160
lines.append("")
158161
(OUT_DIR / f"{cat}.md").write_text("\n".join(lines), encoding="utf-8")
159162

160-
print(f"wrote {len(by_cat)} domain files ({len(stable)} stable attrs) -> {OUT_DIR.relative_to(REPO_ROOT)}")
163+
skill = SKILL_PATH.read_text(encoding="utf-8")
164+
before, marker, tail = skill.partition(TOC_START)
165+
if not marker:
166+
raise RuntimeError(f"missing {TOC_START} in {SKILL_PATH}")
167+
_, marker, after = tail.partition(TOC_END)
168+
if not marker:
169+
raise RuntimeError(f"missing {TOC_END} in {SKILL_PATH}")
170+
links = "\n".join(
171+
f"- [`{cat}`](references/semantics/{cat}.md)" for cat in sorted(by_cat)
172+
)
173+
SKILL_PATH.write_text(
174+
f"{before}{TOC_START}\n{links}\n{TOC_END}{after}", encoding="utf-8"
175+
)
176+
177+
print(
178+
f"wrote {len(by_cat)} domain files ({len(stable)} stable attrs) and refreshed "
179+
f"{SKILL_PATH.relative_to(REPO_ROOT)}"
180+
)
161181

162182

163183
if __name__ == "__main__":

src/skills/sentry-instrument/SKILL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ When naming custom span or log attributes, open **only** the matching domain ref
101101
below. Prefer these stable keys over invented names.
102102
Deprecated attributes are omitted.
103103

104+
<!-- semantics-toc:start -->
104105
- [`angular`](references/semantics/angular.md)
105106
- [`app`](references/semantics/app.md)
106107
- [`art`](references/semantics/art.md)
@@ -159,6 +160,7 @@ Deprecated attributes are omitted.
159160
- [`user`](references/semantics/user.md)
160161
- [`user_agent`](references/semantics/user_agent.md)
161162
- [`vercel`](references/semantics/vercel.md)
163+
<!-- semantics-toc:end -->
162164

163165
## Step 4 — Verify it landed
164166

0 commit comments

Comments
 (0)