feat: route telemetry directly to Azure Application Insights

Merged
KU
7mo ago
+136-124

Summary

  • Telemetry: Migrates from posting batches to altimate-backend /api/observability/ingest to posting directly to Azure Application Insights (/v2/track), eliminating backend dependency and auth complexity
  • ID module: Replaces hand-rolled timestamp+base62 generator with the ulid npm package, using monotonicFactory() to preserve same-millisecond ordering guarantees

Code Review Fixes (8-model review)

  • id.ts: Use monotonicFactory() instead of plain ulid() — fixes non-deterministic ordering of IDs generated within the same millisecond
  • id.ts: timestamp() now throws a clear error on descending IDs instead of a cryptic DEC_TIME_MALFORMED library error
  • telemetry/index.ts: clearTimeout moved to finally block to prevent timer leak
  • telemetry/index.ts: Log log.debug on non-2xx HTTP responses for debuggability
  • telemetry/index.ts: Use JSON.stringify for object values instead of String(v) to prevent [object Object] in customDimensions
  • config.ts: Add telemetry.disabled config field — opt-out via ~/.config/altimate-code/config.json ("telemetry": { "disabled": true })

Test Plan

  • Built binary and ran altimate-code run "say hello in one sentence"
  • Queried Azure App Insights customEvents — session_start, generation, session_end all landed with correct customDimensions and customMeasurements
  • Verified session_Id standard column populated correctly from ai.session.id tag