Skip to content

feat: route telemetry directly to Azure Application Insights#37

Merged
kulvirgit merged 1 commit intomainfrom
feat/azure-appinsights-telemetry
Mar 4, 2026
Merged

feat: route telemetry directly to Azure Application Insights#37
kulvirgit merged 1 commit intomainfrom
feat/azure-appinsights-telemetry

Conversation

@kulvirgit
Copy link
Collaborator

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 customEventssession_start, generation, session_end all landed with correct customDimensions and customMeasurements
  • Verified session_Id standard column populated correctly from ai.session.id tag

Replace altimate-backend ingest with direct App Insights ingestion.
Instrumentation key is baked in so all npm installs report automatically
with no user configuration. `APPLICATIONINSIGHTS_CONNECTION_STRING` env
var overrides the default for dev/testing.

Events are mapped to App Insights custom event format:
- `customDimensions` — string fields (model_id, provider_id, etc.)
- `customMeasurements` — numeric fields (cost, duration_ms, token counts)
- `tokens.*` payload is flattened to `tokens_input`, `tokens_output`, etc.
- `ai.user.id` tag captures the authenticated user's email
@kulvirgit kulvirgit merged commit f269f3d into main Mar 4, 2026
3 of 4 checks passed
@kulvirgit kulvirgit deleted the feat/azure-appinsights-telemetry branch March 9, 2026 20:50
anandgupta42 pushed a commit that referenced this pull request Mar 17, 2026
feat: route telemetry directly to Azure Application Insights
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant