Skip to content

Commit 10481f2

Browse files
test(otel): cover orchestration span timing helpers
Add unit tests for stampOrchestrationStartTime and resolveOrchestrationSpanBounds used by the backfilled orchestration span export path in #9794. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent d128026 commit 10481f2

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
'use strict'
2+
3+
const assert = require('node:assert/strict')
4+
5+
const { describe, it } = require('mocha')
6+
7+
const {
8+
resolveOrchestrationSpanBounds,
9+
} = require('../../src/helpers/otel-orchestration-export')
10+
const {
11+
stampOrchestrationStartTime,
12+
} = require('../../src/helpers/otel-orchestration-store')
13+
14+
describe('otel orchestration span timing', () => {
15+
describe('stampOrchestrationStartTime', () => {
16+
it('stamps the first orchestration turn once', () => {
17+
const seeded = {
18+
traceId: 'abc',
19+
spanId: 'def',
20+
pendingStart: true,
21+
}
22+
23+
const first = stampOrchestrationStartTime(seeded, 'PizzaOrderOrchestration')
24+
assert.ok(first.startTime)
25+
assert.strictEqual(first.pendingStart, undefined)
26+
27+
const second = stampOrchestrationStartTime(first, 'PizzaOrderOrchestration')
28+
assert.strictEqual(second.startTime, first.startTime)
29+
})
30+
})
31+
32+
describe('resolveOrchestrationSpanBounds', () => {
33+
it('spans the full instance window from first turn through completion', () => {
34+
const bounds = resolveOrchestrationSpanBounds({ startTime: 100 }, 350)
35+
36+
assert.strictEqual(bounds.startTime, 100)
37+
assert.strictEqual(bounds.endTime, 350)
38+
})
39+
40+
it('clamps start time when it would exceed the end time', () => {
41+
const bounds = resolveOrchestrationSpanBounds({ startTime: 400 }, 350)
42+
43+
assert.strictEqual(bounds.startTime, 350)
44+
assert.strictEqual(bounds.endTime, 350)
45+
})
46+
})
47+
})

0 commit comments

Comments
 (0)