Install mosaicstack-telemetry in Coordinator #370

Closed
opened 2026-02-15 05:28:05 +00:00 by jason.woltje · 1 comment
Owner

Summary

Add the mosaicstack-telemetry Python SDK to apps/coordinator so the coordinator can track task completions it dispatches to coding harnesses.

Requirements

Package Installation

  • Install mosaicstack-telemetry from Gitea PyPI registry
  • Add to pyproject.toml dependencies
  • Configure pip index URL: https://git.mosaicstack.dev/api/packages/mosaic/pypi/simple/

Integration Pattern (async lifespan)

from mosaicstack_telemetry import TelemetryClient, TelemetryConfig

@asynccontextmanager
async def lifespan(app: FastAPI):
    config = TelemetryConfig()  # Reads from env vars automatically
    async with TelemetryClient(config) as client:
        app.state.telemetry = client
        await client.start_async()
        yield
        await client.stop_async()

app = FastAPI(lifespan=lifespan)

Environment Variables (auto-read by Python SDK)

MOSAIC_TELEMETRY_ENABLED=true
MOSAIC_TELEMETRY_SERVER_URL=https://tel-api.mosaicstack.dev
MOSAIC_TELEMETRY_API_KEY=<64-char hex>
MOSAIC_TELEMETRY_INSTANCE_ID=<uuid>

Key SDK Details

  • Dual sync/async support (use async for coordinator)
  • Uses httpx.AsyncClient for HTTP, pydantic for validation
  • Thread-safe event queue, async context manager
  • EventBuilder with fluent API for constructing events
  • Never throws — errors logged via logging.getLogger("mosaicstack_telemetry")

What the Coordinator Tracks

The coordinator dispatches tasks to coding harnesses (Claude Code, Codex CLI, OpenCode). After each task completes, it should build a TaskCompletionEvent capturing:

  • Which harness was used
  • Which model/provider
  • Task duration
  • Token usage (from harness output)
  • Quality gate results (build, lint, test, typecheck, security)
  • Outcome (success/failure/partial/timeout)
  • Retry count
  • Context compactions/rotations

Acceptance Criteria

  • Package installed and importable
  • Telemetry client starts/stops with coordinator lifecycle
  • Async context manager for clean shutdown
  • Disabled mode works (no HTTP calls)
  • Unit tests for initialization
## Summary Add the `mosaicstack-telemetry` Python SDK to `apps/coordinator` so the coordinator can track task completions it dispatches to coding harnesses. ## Requirements ### Package Installation - Install `mosaicstack-telemetry` from Gitea PyPI registry - Add to `pyproject.toml` dependencies - Configure pip index URL: `https://git.mosaicstack.dev/api/packages/mosaic/pypi/simple/` ### Integration Pattern (async lifespan) ```python from mosaicstack_telemetry import TelemetryClient, TelemetryConfig @asynccontextmanager async def lifespan(app: FastAPI): config = TelemetryConfig() # Reads from env vars automatically async with TelemetryClient(config) as client: app.state.telemetry = client await client.start_async() yield await client.stop_async() app = FastAPI(lifespan=lifespan) ``` ### Environment Variables (auto-read by Python SDK) ``` MOSAIC_TELEMETRY_ENABLED=true MOSAIC_TELEMETRY_SERVER_URL=https://tel-api.mosaicstack.dev MOSAIC_TELEMETRY_API_KEY=<64-char hex> MOSAIC_TELEMETRY_INSTANCE_ID=<uuid> ``` ### Key SDK Details - Dual sync/async support (use async for coordinator) - Uses `httpx.AsyncClient` for HTTP, `pydantic` for validation - Thread-safe event queue, async context manager - `EventBuilder` with fluent API for constructing events - Never throws — errors logged via `logging.getLogger("mosaicstack_telemetry")` ### What the Coordinator Tracks The coordinator dispatches tasks to coding harnesses (Claude Code, Codex CLI, OpenCode). After each task completes, it should build a `TaskCompletionEvent` capturing: - Which harness was used - Which model/provider - Task duration - Token usage (from harness output) - Quality gate results (build, lint, test, typecheck, security) - Outcome (success/failure/partial/timeout) - Retry count - Context compactions/rotations ## Acceptance Criteria - [ ] Package installed and importable - [ ] Telemetry client starts/stops with coordinator lifecycle - [ ] Async context manager for clean shutdown - [ ] Disabled mode works (no HTTP calls) - [ ] Unit tests for initialization
jason.woltje added the orchestrator label 2026-02-15 05:28:05 +00:00
jason.woltje added this to the M10-Telemetry (0.0.10) milestone 2026-02-15 05:31:19 +00:00
Author
Owner

Completed in commit 83d0cbe on feature/m10-telemetry. Installed mosaicstack-telemetry in coordinator, integrated TelemetryClient into FastAPI lifespan, created mosaic_telemetry.py helpers. 28 unit tests.

Completed in commit 83d0cbe on feature/m10-telemetry. Installed mosaicstack-telemetry in coordinator, integrated TelemetryClient into FastAPI lifespan, created mosaic_telemetry.py helpers. 28 unit tests.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mosaic/stack#370