@@ -2,20 +2,24 @@ import '@sim/testing/mocks/executor'
22
33import { beforeEach , describe , expect , it , vi } from 'vitest'
44
5- const { recordSimToolMetric, setAttribute } = vi . hoisted ( ( ) => ( {
6- recordSimToolMetric : vi . fn ( ) ,
7- setAttribute : vi . fn ( ) ,
8- } ) )
5+ const { recordSimToolMetric, setAttribute, withCopilotToolSpan } = vi . hoisted ( ( ) => {
6+ const setAttribute = vi . fn ( )
7+ return {
8+ recordSimToolMetric : vi . fn ( ) ,
9+ setAttribute,
10+ withCopilotToolSpan : vi . fn (
11+ ( _input : unknown , fn : ( span : { setAttribute : typeof setAttribute } ) => Promise < unknown > ) =>
12+ fn ( { setAttribute } )
13+ ) ,
14+ }
15+ } )
916
1017vi . mock ( '@/lib/copilot/request/metrics' , ( ) => ( {
1118 recordSimToolMetric,
1219} ) )
1320
1421vi . mock ( '@/lib/copilot/request/otel' , ( ) => ( {
15- withCopilotToolSpan : (
16- _input : unknown ,
17- fn : ( span : { setAttribute : typeof setAttribute } ) => Promise < unknown >
18- ) => fn ( { setAttribute } ) ,
22+ withCopilotToolSpan,
1923} ) )
2024
2125import { TOOL_WATCHDOG_DEFAULT_MS , TOOL_WATCHDOG_LONG_RUNNING_MS } from '@/lib/copilot/constants'
@@ -110,6 +114,10 @@ describe('executeToolAndReport metrics', () => {
110114 MothershipStreamV1ToolOutcome . success ,
111115 expect . any ( Number )
112116 )
117+ expect ( withCopilotToolSpan ) . toHaveBeenCalledWith (
118+ expect . objectContaining ( { agentName : 'workflow' } ) ,
119+ expect . any ( Function )
120+ )
113121 } )
114122
115123 it . each ( [
@@ -138,6 +146,10 @@ describe('executeToolAndReport metrics', () => {
138146 MothershipStreamV1ToolOutcome . error ,
139147 expect . any ( Number )
140148 )
149+ expect ( withCopilotToolSpan ) . toHaveBeenCalledWith (
150+ expect . objectContaining ( { agentName : expectedAgentId } ) ,
151+ expect . any ( Function )
152+ )
141153 }
142154 )
143155} )
0 commit comments