File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { trace } from '@opentelemetry/api'
12import { createLogger } from '@sim/logger'
23import { toError } from '@sim/utils/errors'
34import { sleep } from '@sim/utils/helpers'
45import { backoffWithJitter } from '@sim/utils/retry'
56import { foldDocsIndexPath } from '@/lib/copilot/docs/docs-path'
67import { DOCS_MANIFEST } from '@/lib/copilot/generated/docs-manifest'
8+ import { TraceAttr } from '@/lib/copilot/generated/trace-attributes-v1'
79import type { GrepCountEntry , GrepMatch , GrepOptions } from '@/lib/copilot/vfs/operations'
810import { glob as globPaths , grep , grepReadResult } from '@/lib/copilot/vfs/operations'
911import { 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
Original file line number Diff line number Diff line change @@ -279,6 +279,7 @@ export const TraceAttr = {
279279 CopilotVfsFileMediaType : 'copilot.vfs.file.media_type' ,
280280 CopilotVfsFileName : 'copilot.vfs.file.name' ,
281281 CopilotVfsFileSizeBytes : 'copilot.vfs.file.size_bytes' ,
282+ CopilotVfsGrepDocsPageCount : 'copilot.vfs.grep.docs_page_count' ,
282283 CopilotVfsHasAlpha : 'copilot.vfs.has_alpha' ,
283284 CopilotVfsInputBytes : 'copilot.vfs.input.bytes' ,
284285 CopilotVfsInputHeight : 'copilot.vfs.input.height' ,
@@ -924,6 +925,7 @@ export const TraceAttrValues: readonly TraceAttrValue[] = [
924925 'copilot.vfs.file.media_type' ,
925926 'copilot.vfs.file.name' ,
926927 'copilot.vfs.file.size_bytes' ,
928+ 'copilot.vfs.grep.docs_page_count' ,
927929 'copilot.vfs.has_alpha' ,
928930 'copilot.vfs.input.bytes' ,
929931 'copilot.vfs.input.height' ,
You can’t perform that action at this time.
0 commit comments