Skip to content

Commit 734a31a

Browse files
committed
Bench(refactor[lgtm]): Move the otel scripts into the stack they belong to
`scripts/lgtm/` holds the observability stack -- its compose files, dashboard generator, telemetry wiring, and load driver. The smoke run and the acceptance check sat outside it under an `otel_` prefix, though they are the two entry points that stack exists to serve: `acceptance.py` already documented itself in terms of `scripts.lgtm.generate_dashboards`, and `generate_dashboards` returns the reference. scripts/otel_smoke.py -> scripts/lgtm/smoke.py scripts/otel_acceptance.py -> scripts/lgtm/acceptance.py Inside the directory the prefix was saying what the directory already says, so it goes, matching `identity.py`, `telemetry.py`, and `load_tmux.py` beside them. Moving one level deeper broke two paths that had been counting directories, both silently: - `acceptance.py` derived the repository root with `parent.parent`, which now lands on `scripts/`, pointing every dashboard and helper lookup one level wrong. - `smoke.py` put `__file__.parent / "lgtm"` on `sys.path` to import `telemetry`; from inside `lgtm/` that names a directory that does not exist. It now adds its own directory, the idiom `load_tmux.py` already uses. `--help` used to say `otel_smoke.py`, which told a reader where to look. Bare `smoke.py` does not, so both parsers name their path, as the orchestration scripts do. Verified: both run under the invocation their `just` recipes use, every derived path resolves, and the lgtm tests pass.
1 parent d03a3a1 commit 734a31a

8 files changed

Lines changed: 20 additions & 18 deletions

File tree

CHANGES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ engine instrumentation seam, so the exporters are ordinary sinks and libtmux
286286
itself gains no OpenTelemetry dependency.
287287

288288
The Grafana dashboards under `scripts/lgtm/dashboards/` are generated rather
289-
than hand-edited, and `scripts/otel_acceptance.py` runs each panel's own query
289+
than hand-edited, and `scripts/lgtm/acceptance.py` runs each panel's own query
290290
and fails naming any panel that came back empty. See `scripts/lgtm/README.md`.
291291

292292
Every run is stamped with its branch, revision, repository, worktree, and an

justfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,17 @@ otel-dashboards:
173173
# Drive a real tmux workload through the engine seam into LGTM
174174
[group: 'otel']
175175
otel-smoke *args:
176-
uv run --group otel python scripts/otel_smoke.py {{ args }}
176+
uv run --group otel python scripts/lgtm/smoke.py {{ args }}
177177

178178
# Verify every dashboard panel's own queries return data
179179
[group: 'otel']
180180
otel-acceptance *args:
181-
uv run --group otel python scripts/otel_acceptance.py {{ args }}
181+
uv run --group otel python scripts/lgtm/acceptance.py {{ args }}
182182

183183
# Start the stack, run the workload, then verify every panel end to end
184184
[group: 'otel']
185185
otel-verify:
186-
uv run --group otel python scripts/otel_acceptance.py --start-stack --smoke
186+
uv run --group otel python scripts/lgtm/acceptance.py --start-stack --smoke
187187

188188
# Drive the engines under a load shape (ramping arrival rate) via rampa
189189
[group: 'otel']

scripts/lgtm/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ $ just otel-ports
8282

8383
## What the workload emits
8484

85-
`scripts/otel_smoke.py` runs every transport — subprocess and control mode,
85+
`scripts/lgtm/smoke.py` runs every transport — subprocess and control mode,
8686
sync and async — against a throwaway tmux server, and emits four signals:
8787

8888
Metrics are `tmux_requests_total`, `tmux_commands_total`, `tmux_inlined_total`,
@@ -273,7 +273,7 @@ mid-run -- `destroy-unattached off` only survives *detach*.
273273
A dashboard that renders is not a dashboard that works. A panel whose query
274274
returns nothing looks exactly like a panel reporting a healthy zero.
275275

276-
`scripts/otel_acceptance.py` reads the generated JSON, expands the template
276+
`scripts/lgtm/acceptance.py` reads the generated JSON, expands the template
277277
variables the way Grafana would, runs every panel's own query against
278278
Prometheus, Loki, Tempo, or Pyroscope, and fails naming any panel that returned
279279
nothing. Because it reads the dashboards themselves, a panel added to the
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import urllib.parse
2929
import urllib.request
3030

31-
ROOT = pathlib.Path(__file__).resolve().parent.parent
31+
ROOT = pathlib.Path(__file__).resolve().parents[2]
3232
DASHBOARDS = ROOT / "scripts" / "lgtm" / "dashboards"
3333
SERVICE = "libtmux-engines"
3434

@@ -327,7 +327,9 @@ def check_until(endpoints: Endpoints, timeout: float, poll: float) -> list[Resul
327327

328328
def main(argv: list[str] | None = None) -> int:
329329
"""Run the acceptance sweep and print a per-panel report."""
330-
parser = argparse.ArgumentParser(description=__doc__)
330+
parser = argparse.ArgumentParser(
331+
prog="scripts/lgtm/acceptance.py", description=__doc__
332+
)
331333
parser.add_argument("--prometheus", default="http://127.0.0.1:9099")
332334
parser.add_argument("--loki", default="http://127.0.0.1:3100")
333335
parser.add_argument("--tempo", default="http://127.0.0.1:3200")
@@ -336,7 +338,7 @@ def main(argv: list[str] | None = None) -> int:
336338
"--start-stack", action="store_true", help="run scripts/lgtm/up.sh first"
337339
)
338340
parser.add_argument(
339-
"--smoke", action="store_true", help="run scripts/otel_smoke.py first"
341+
"--smoke", action="store_true", help="run scripts/lgtm/smoke.py first"
340342
)
341343
parser.add_argument(
342344
"--settle",
@@ -362,7 +364,7 @@ def main(argv: list[str] | None = None) -> int:
362364
subprocess.run([str(ROOT / "scripts" / "lgtm" / "up.sh")], check=True)
363365
if args.smoke:
364366
subprocess.run(
365-
[sys.executable, str(ROOT / "scripts" / "otel_smoke.py")], check=True
367+
[sys.executable, str(ROOT / "scripts" / "lgtm" / "smoke.py")], check=True
366368
)
367369
if args.start_stack or args.smoke:
368370
time.sleep(args.settle)

scripts/lgtm/generate_dashboards.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
start and ``tests/test_lgtm_dashboards.py`` fails if the committed copy differs,
1010
so the two cannot silently diverge.
1111
12-
Every panel must be backed by telemetry ``scripts/otel_smoke.py`` actually
13-
emits. ``scripts/otel_acceptance.py`` executes each panel's own queries and
12+
Every panel must be backed by telemetry ``scripts/lgtm/smoke.py`` actually
13+
emits. ``scripts/lgtm/acceptance.py`` executes each panel's own queries and
1414
fails on any that returns nothing, which is what keeps a board honest.
1515
"""
1616

scripts/lgtm/load_tmux.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Load-shape the tmux engines with rampa, and export the result to LGTM.
22
3-
``otel_smoke.py`` answers "does telemetry flow" by running flat out for a fixed
3+
``smoke.py`` answers "does telemetry flow" by running flat out for a fixed
44
duration. That is the wrong shape for asking where a transport stops keeping
55
up, because a closed loop of N workers slows down with the system: offered load
66
falls as latency rises, and the graph bends politely instead of breaking.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import typing as t
2929
import uuid
3030

31-
sys.path.insert(0, str(pathlib.Path(__file__).parent / "lgtm"))
31+
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
3232

3333
import telemetry
3434

@@ -46,7 +46,7 @@
4646
from libtmux.experimental.engines.instrumentation import CountingSink
4747
from libtmux.server import Server
4848

49-
logger = logging.getLogger("libtmux.otel_smoke")
49+
logger = logging.getLogger("libtmux.lgtm.smoke")
5050

5151
PLAIN = CommandRequest.from_args("list-panes", "-a", "-F", "#{pane_id}")
5252
LISTING = CommandRequest.from_args("list-windows", "-a", "-F", "#{window_id}")
@@ -253,7 +253,7 @@ def lane_totals(counts: CountingSink) -> dict[str, int]:
253253

254254
def main(argv: list[str] | None = None) -> int:
255255
"""Run every lane under full telemetry and print the local counts."""
256-
parser = argparse.ArgumentParser(description=__doc__)
256+
parser = argparse.ArgumentParser(prog="scripts/lgtm/smoke.py", description=__doc__)
257257
parser.add_argument("--run-id", default=f"smoke-{uuid.uuid4().hex[:8]}")
258258
parser.add_argument(
259259
"--spike",

tests/test_lgtm_dashboards.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Structural contracts for the generated Grafana dashboards.
22
33
These run offline. They cannot tell whether a panel has data -- that is
4-
``scripts/otel_acceptance.py`` against a live stack -- but they do keep the
4+
``scripts/lgtm/acceptance.py`` against a live stack -- but they do keep the
55
committed JSON honest about its generator and about the datasources it binds
66
to, which is where a board rots silently.
77
"""
@@ -135,7 +135,7 @@ def test_acceptance_expands_every_template_variable() -> None:
135135
through as text and match nothing.
136136
"""
137137
spec = importlib.util.spec_from_file_location(
138-
"otel_acceptance", _ROOT / "scripts" / "otel_acceptance.py"
138+
"lgtm_acceptance", _ROOT / "scripts" / "lgtm" / "acceptance.py"
139139
)
140140
assert spec is not None
141141
assert spec.loader is not None

0 commit comments

Comments
 (0)