main
1// Issue #67: every ply span of a /v1 request is a Workers span under the request span (src/edge-trace.ts).
2// The pinned smoke sends one single-file find/replace edit, `edit-traced` (scripts/cd/lifecycle.ts), with the version
3// override. This check finds that request's span events in Workers Observability (`$metadata.type = span`, joined on
4// the smoke's cf-ray, then on the traceId those events carry) and requires ply's span names among them.
5//
6// pass every expected name is in the edit's trace
7// worker the edit's trace was ingested (its spans are there) and a ply span is not: the regression in #67
8// harness_fault no span event joins to the edit after polling, or the smoke has no edit-traced request: unevaluable
9import { asRecord } from './json.ts'
10import { TRACED_EDIT_STEP } from './lifecycle.ts'
11import { rayIdOf, sameRay, spanNameOf, traceIdOf, type SmokeRequest } from './telemetry.ts'
13export { TRACED_EDIT_STEP }
15/** Span names ply records for that edit (ply's span contract; test/worker-spans.test.js sees the same under workerd). */
16export const TRACED_EDIT_SPANS = ['git.edit', 'git.edit.tree', 'git.edit.blob', 'git.upload-pack fetch', 'git.receive-pack'] as const
18export type SpanCheck =
19 | { readonly kind: 'pass'; readonly line: string; readonly traceIds: readonly string[]; readonly names: readonly string[] }
20 | { readonly kind: 'worker'; readonly line: string; readonly traceIds: readonly string[]; readonly names: readonly string[]; readonly missing: readonly string[] }
21 | { readonly kind: 'harness_fault'; readonly line: string }
23const PREFIX = 'spans:'
25function sorted(values: Iterable<string>): string[] {
26 return [...new Set(values)].sort()
27}
29/** Judge the span events of one window for the smoke's edit-traced request. Pure: the caller queries and polls. */
30export function checkEditSpans(requests: readonly SmokeRequest[], spanEvents: readonly unknown[]): SpanCheck {
31 const request = requests.find(row => row.step === TRACED_EDIT_STEP)
32 if (!request) return { kind: 'harness_fault', line: `${PREFIX} the smoke report has no ${TRACED_EDIT_STEP} request; cannot check ply spans (#67)` }
33 const ray = request.ray
34 if (!ray) return { kind: 'harness_fault', line: `${PREFIX} ${TRACED_EDIT_STEP} ${request.id} has no cf-ray to join span events on; cannot check ply spans (#67)` }
35 const records = spanEvents.map(asRecord).filter((rec): rec is Record<string, unknown> => rec !== null)
36 const traceIds = new Set<string>()
37 for (const rec of records) {
38 const eventRay = rayIdOf(rec)
39 const traceId = traceIdOf(rec)
40 if (eventRay && traceId && sameRay(eventRay, ray)) traceIds.add(traceId)
41 }
42 const joined = records.filter(rec => {
43 const eventRay = rayIdOf(rec)
44 if (eventRay && sameRay(eventRay, ray)) return true
45 const traceId = traceIdOf(rec)
46 return traceId !== null && traceIds.has(traceId)
47 })
48 if (joined.length === 0) {
49 return { kind: 'harness_fault', line: `${PREFIX} no span event joined to ${TRACED_EDIT_STEP} ${request.id} (cf-ray ${ray}); Workers Observability has not ingested its trace, so ply spans cannot be checked (#67)` }
50 }
51 const names = sorted(joined.map(spanNameOf).filter((name): name is string => name !== null))
52 const missing = TRACED_EDIT_SPANS.filter(name => !names.includes(name))
53 const traces = sorted(traceIds)
54 const where = `${TRACED_EDIT_STEP} ${request.id} trace ${traces.join(',') || '-'}`
55 if (missing.length > 0) {
56 return {
57 kind: 'worker',
58 line: `${PREFIX} ${where} is missing ply spans ${missing.join(', ')}; saw ${names.join(', ') || 'none'} (#67: ply spans are not reaching Workers tracing)`,
59 traceIds: traces,
60 names,
61 missing,
62 }
63 }
64 return { kind: 'pass', line: `${PREFIX} ${where} has ${TRACED_EDIT_SPANS.join(', ')} (${joined.length} span events)`, traceIds: traces, names }
65}
67export type SpanPoll = {
68 /** One span-events query over the window. Throws when telemetry is unavailable. */
69 readonly query: () => Promise<readonly unknown[]>
70 readonly sleep: (ms: number) => Promise<void>
71 readonly now: () => number
72 /** Waits between queries; the last repeats. */
73 readonly pollsMs: readonly number[]
74 /** Stop polling once this much time has passed since the first query. */
75 readonly waitMs: number
76}
78/**
79 * Query, judge, and query again while the edit's spans are not all there yet: span events of one trace are ingested
80 * independently, so an early page can hold the fetch spans and not ply's. The verdict is the last query's.
81 */
82export async function pollEditSpans(requests: readonly SmokeRequest[], poll: SpanPoll): Promise<SpanCheck> {
83 const started = poll.now()
84 for (let attempt = 0; ; attempt++) {
85 const check = checkEditSpans(requests, await poll.query())
86 const waited = poll.now() - started
87 if (check.kind === 'pass' || waited >= poll.waitMs || !requests.some(row => row.step === TRACED_EDIT_STEP && row.ray)) return check
88 const pause = poll.pollsMs[Math.min(attempt, poll.pollsMs.length - 1)]
89 await poll.sleep(Math.min(typeof pause === 'number' ? pause : poll.waitMs, poll.waitMs - waited))
90 }
91}
Diagnostics4 git calls · 55 ms
CallStatusSizeTime055 ms
discover200152 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200145 B · hit3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=145 git.response.cache=HIT git.response.duration_ms=3 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=145 git.pkt.payload.max=76 git.ls_refs.count=2 git.ls_refs.head=refs/heads/main
fetchblob:none · deepen 1020040 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=41349 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=526b305930b8ef382f2d7a1f9c0238730a585921 git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=6 git.pkt.data=4 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=41349 git.pkt.payload.max=41254 git.sideband.band1.bytes=41253 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=61 git.pack.bytes=41253 git.pack.ofs_delta=0 git.pack.ref_delta=0 git.pack.chain.max=0 git.pack.trailer=ab60efef4b7243678c75de64a4386986ee885c1c git.pack.full=61Open pack map
fetch2001.9 KiB · hit50 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=50 git.response.bytes=1973 git.response.cache=HIT git.response.duration_ms=50 git.fetch.wants=4308859ddcde04fbec2ed0ffcd01ed3bad6ed771 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=1973 git.pkt.payload.max=1952 git.sideband.band1.bytes=1951 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/ply-web.git
- Ref
- refs/heads/main
- Commit
- 526b305930b8ef382f2d7a1f9c0238730a585921
- cf-ray
- a5e2ddee4cb72308
- Request
- ce386757…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format