feat(o11y): track ingest version in session metrics + type safety and test coverage#57
Merged
feat(o11y): track ingest version in session metrics + type safety and test coverage#57
Conversation
Add ingestVersion field to session metrics to track which version of the ingestion system processed each session. The version is persisted in the SessionIngestDO metadata and included in all metrics emissions. - Add ingestVersion to SessionMetricsParams schema - Store ingestVersion in ingest_meta table during session initialization - Pass ingestVersion through to metrics emission - Map ingestVersion to double11 in Analytics Engine - Update tests to include ingestVersion field
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an ingestVersion field to emitted session metrics so downstream Analytics Engine data points can be attributed to the ingest version that processed the session.
Changes:
- Add
ingestVersionto the o11y RPC/session metrics schema and AE datapoint mapping (double11). - Persist
ingestVersioninSessionIngestDOmetadata and include it in metrics emission (including alarm recovery). - Update o11y unit tests to include/assert the additional
double.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| cloudflare-session-ingest/src/o11y-binding.d.ts | Extends the service binding RPC param type with ingestVersion. |
| cloudflare-session-ingest/src/dos/SessionIngestDO.ts | Persists ingestVersion in ingest_meta and passes it through to ingestSessionMetrics. |
| cloudflare-o11y/src/session-metrics-schema.ts | Adds ingestVersion to the validated session metrics payload schema. |
| cloudflare-o11y/src/session-metrics-analytics.ts | Appends ingestVersion into the AE doubles array as double11. |
| cloudflare-o11y/test/index.spec.ts | Updates test fixtures and expected AE datapoint doubles to include ingestVersion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…Changed types Expand IngestMetaKey to cover all 9 keys stored in ingest_meta table, introduce ExtractableMetaKey for the 4 item-extracted keys, and narrow writeIngestMetaIfChanged to reject undefined values and require typed keys.
Export and test computeBurnRate, dimensionKey, rowsToMap, and effectiveSeverity — pure functions that were previously module-private and untested.
Cover extractNormalizedTitleFromItem, extractNormalizedParentIdFromItem, extractNormalizedPlatformFromItem, and extractNormalizedOrgIdFromItem including normalization edge cases (empty, whitespace, null, non-string).
Cover all 8 item types and the unknown-type error path.
Cover empty input, session info, message ordering, part attachment, buffered parts arriving before their message, mixed ordering, and silently ignored item types.
Cover first-try success, retryable error with eventual success, fresh stub per attempt, all attempts exhausted, non-retryable immediate throw, non-Error wrapping, and maxAttempts config.
Cover negative duration clamping, undefined timeToFirstResponseMs when only user or only assistant messages exist, last-wins for multiple kilo_meta and session items, and TTFR clamping when assistant precedes user.
pandemicsyn
approved these changes
Feb 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ingestVersionfield to session metrics to track which version of the ingestion system processed each sessionIngestMetaKeyandwriteIngestMetaIfChangedtypes for compile-time safetycloudflare-o11yandcloudflare-session-ingestworkersChanges
Feature: ingest version tracking
ingestVersiontoSessionMetricsParamsSchemaingestVersioniningest_metatable during session initializationingestVersionthrough to metrics emissioningestVersiontodouble11in Analytics EngineRolling deploy safety
ingestVersiondefaults to0in the Zod schema so oldercloudflare-session-ingestworkers that don't send the field won't fail RPC validation whencloudflare-o11yis deployed firstRefactor:
IngestMetaKeytype safetyIngestMetaKeyto be the authoritative union of all 9 keys in theingest_metatableExtractableMetaKeyfor the 4 item-extracted metadata keys (title, parentId, platform, orgId)writeIngestMetaIfChangedto requirekey: IngestMetaKeyandincomingValue: string | null(no moreundefined)undefinedvalues at call sites before invoking the helperTests added
computeBurnRate,dimensionKey,rowsToMap,effectiveSeverity(exported and tested)ingestVersiondefaults to0when omitted from RPC paramsgetItemIdentity(all 8 item types + unknown type error)buildSharedSessionSnapshot(empty input, message ordering, part buffering)withDORetry(success, retryable/non-retryable errors, fresh stubs, exhaustion)computeSessionMetricsedge cases (negative duration clamping, TTFR with missing messages, last-wins semantics)