Skip to content

8. Pipeline observability and reliability ​

Home · Full index

8.1 O01 · Record the tested commit and outcome ​

GitHub Actions · Steps fragment. Use as the last step of a job with a real verification step. The summary surfaces evidence in the run UI.

yaml
- name: Write job summary
  if: '!cancelled()'
  env:
    JOB_STATUS: ${{ job.status }}
  run: |
    {
      printf '## Test job\n\n'
      printf -- '- Commit: %s\n' "$GITHUB_SHA"
      printf -- '- Result: %s\n' "$JOB_STATUS"
    } >> "$GITHUB_STEP_SUMMARY"

Verify. In a scratch PR, check the summary on both a green and a failing run.

8.2 O02 · Bound a slow integration test ​

GitHub Actions · Job-level fragment. Requires uv, a committed lockfile and integration tests. Keep the checkout and uv setup steps from your existing job before the test step. Ubuntu provides GNU timeout.

yaml
timeout-minutes: 10
steps:
  # Keep checkout and dependency setup steps above the test.
  - name: Run integration tests with a deadline
    run: timeout --kill-after=10s 120s uv run --locked pytest -q tests/integration/

Verify. Use a deliberately slow local test. A normal test failure and a deadline exit give distinguishable logs. The job-level timeout also bounds time outside the test command.

8.3 O03 · Retry a bounded read-only check ​

Linux Bash · Script fragment. Requires curl and a lab-owned endpoint set in CHECK_URL. Use for a read-only health query with a known transient startup period.

bash
curl --fail --silent --show-error \
  --connect-timeout 2 --max-time 5 --retry 4 --retry-delay 2 \
  --retry-max-time 20 --retry-connrefused "$CHECK_URL"

Verify. Compare a late-starting service with a persistent failure. Retrying state-changing requests requires an idempotency strategy.

8.4 O04 · Capture cluster evidence after smoke-test failure ​

GitHub Actions · Steps fragment. Assumes kubectl has already been configured for the read-only staging operations below. Put this after a rollout or smoke-test step in that same job. If your deploy step removes a temporary kubeconfig on exit as in D02, run diagnostic commands inside that step before its cleanup or configure separate read-only credentials.

yaml
- name: Capture staging diagnostics
  if: failure()
  shell: bash
  run: |
    mkdir -p diagnostics
    kubectl -n staging get deployment health-api -o wide > diagnostics/deployment.txt 2>&1 || true
    kubectl -n staging get pods -l app=health-api -o wide > diagnostics/pods.txt 2>&1 || true
- name: Upload diagnostics
  if: failure()
  uses: actions/upload-artifact@v4
  with:
    name: staging-diagnostics
    path: diagnostics/*.txt
    if-no-files-found: warn
    retention-days: 3

Verify. Break a lab readiness check. The deployment job stays failed and the logs show which resources could be queried. Review and redact any application-specific output before putting it in shared artifacts.

8.5 O05 · Gate an inference endpoint on p95 latency ​

Python 3.12 · Full local script. Save as bench.py. Set INFERENCE_URL to a lab-owned OpenAI-compatible endpoint ending in /v1/chat/completions and MODEL_NAME to its loaded model. Set an optional INFERENCE_API_KEY and use HTTPS for remote credentials. Set MAX_P95_MS from a measured baseline for a fixed model and runner. The script sends 3 warmups and 30 sequential, non-streaming requests with a fixed prompt and output cap. It records end-to-end latency, which includes network, generation and response download time.

python
import json
import math
import os
import time
from urllib.request import Request, urlopen

payload = json.dumps({
    "model": os.environ["MODEL_NAME"],
    "messages": [{"role": "user", "content": "Name one benefit of batching."}],
    "max_tokens": 16,
    "temperature": 0,
    "stream": False,
}).encode()
url = os.environ["INFERENCE_URL"]
limit = float(os.environ["MAX_P95_MS"])
if not math.isfinite(limit) or limit <= 0:
    raise ValueError("MAX_P95_MS must be a positive finite number")

headers = {"Content-Type": "application/json"}
if token := os.environ.get("INFERENCE_API_KEY"):
    headers["Authorization"] = f"Bearer {token}"

samples_ms = []
for index in range(33):
    request = Request(url, data=payload, headers=headers)
    start = time.perf_counter()
    with urlopen(request, timeout=15) as response:
        body = json.load(response)
    if not body["choices"]:
        raise ValueError("Empty inference response")
    elapsed_ms = (time.perf_counter() - start) * 1_000
    if index >= 3:
        samples_ms.append(elapsed_ms)

p95_ms = sorted(samples_ms)[math.ceil(len(samples_ms) * 0.95) - 1]
print(json.dumps({"samples": len(samples_ms), "p95_ms": round(p95_ms, 2), "limit_ms": limit}))
if p95_ms > limit:
    raise SystemExit("Inference latency gate failed")

Verify. Run against an idle baseline and then lower the budget enough to fail intentionally. Keep server, model, prompt and request settings fixed for comparisons. Use a streaming client and different instrumentation to measure time to first token or inter-token latency.

Reference · GitHub job summaries, curl manual, Kubernetes Deployment diagnostics.