Skip to content

Commit dac3284

Browse files
j15zclaude
andcommitted
improvement(copilot): stamp docs grep fan-out size on the grep span
A directory-scoped docs grep now records copilot.vfs.grep.docs_page_count (pages fetched from the live site) on the active tool span, mirroring the new contract attribute. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 7199a89 commit dac3284

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

apps/sim/lib/copilot/docs/docs-corpus.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import { trace } from '@opentelemetry/api'
12
import { createLogger } from '@sim/logger'
23
import { toError } from '@sim/utils/errors'
34
import { sleep } from '@sim/utils/helpers'
45
import { backoffWithJitter } from '@sim/utils/retry'
56
import { foldDocsIndexPath } from '@/lib/copilot/docs/docs-path'
67
import { DOCS_MANIFEST } from '@/lib/copilot/generated/docs-manifest'
8+
import { TraceAttr } from '@/lib/copilot/generated/trace-attributes-v1'
79
import type { GrepCountEntry, GrepMatch, GrepOptions } from '@/lib/copilot/vfs/operations'
810
import { glob as globPaths, grep, grepReadResult } from '@/lib/copilot/vfs/operations'
911
import { mapWithConcurrency } from '@/lib/core/utils/concurrency'
@@ -212,6 +214,7 @@ export async function grepDocs(
212214
}
213215
const dir = `${key}/`
214216
const pages = [...docsKeyView.keys()].filter((pageKey) => pageKey.startsWith(dir))
217+
trace.getActiveSpan()?.setAttribute(TraceAttr.CopilotVfsGrepDocsPageCount, pages.length)
215218
let unreachable = 0
216219
const results = await mapWithConcurrency(pages, GREP_FETCH_CONCURRENCY, async (pageKey) => {
217220
// Once any page is unreachable the grep is going to fail — skip the

apps/sim/lib/copilot/generated/trace-attributes-v1.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ export const TraceAttr = {
278278
CopilotVfsFileMediaType: 'copilot.vfs.file.media_type',
279279
CopilotVfsFileName: 'copilot.vfs.file.name',
280280
CopilotVfsFileSizeBytes: 'copilot.vfs.file.size_bytes',
281+
CopilotVfsGrepDocsPageCount: 'copilot.vfs.grep.docs_page_count',
281282
CopilotVfsHasAlpha: 'copilot.vfs.has_alpha',
282283
CopilotVfsInputBytes: 'copilot.vfs.input.bytes',
283284
CopilotVfsInputHeight: 'copilot.vfs.input.height',
@@ -922,6 +923,7 @@ export const TraceAttrValues: readonly TraceAttrValue[] = [
922923
'copilot.vfs.file.media_type',
923924
'copilot.vfs.file.name',
924925
'copilot.vfs.file.size_bytes',
926+
'copilot.vfs.grep.docs_page_count',
925927
'copilot.vfs.has_alpha',
926928
'copilot.vfs.input.bytes',
927929
'copilot.vfs.input.height',

0 commit comments

Comments
 (0)