File tree Expand file tree Collapse file tree
apps/sim/lib/copilot/request Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ describe('recordSimToolMetric', () => {
2929 } )
3030
3131 it . each ( [ 'main' , 'workflow' ] ) (
32- 'attributes call counts to the registered %s agent without adding it to duration ' ,
32+ 'attributes call counts and duration to the registered %s agent' ,
3333 ( agentId ) => {
3434 recordSimToolMetric ( 'read' , agentId , 'success' , 125 )
3535
@@ -42,7 +42,10 @@ describe('recordSimToolMetric', () => {
4242 ...baseAttributes ,
4343 [ TraceAttr . GenAiAgentName ] : agentId ,
4444 } )
45- expect ( toolDurationRecord ) . toHaveBeenCalledWith ( 125 , baseAttributes )
45+ expect ( toolDurationRecord ) . toHaveBeenCalledWith ( 125 , {
46+ ...baseAttributes ,
47+ [ TraceAttr . GenAiAgentName ] : agentId ,
48+ } )
4649 }
4750 )
4851
@@ -58,6 +61,9 @@ describe('recordSimToolMetric', () => {
5861 ...baseAttributes ,
5962 [ TraceAttr . GenAiAgentName ] : 'other' ,
6063 } )
61- expect ( toolDurationRecord ) . toHaveBeenCalledWith ( 125 , baseAttributes )
64+ expect ( toolDurationRecord ) . toHaveBeenCalledWith ( 125 , {
65+ ...baseAttributes ,
66+ [ TraceAttr . GenAiAgentName ] : 'other' ,
67+ } )
6268 } )
6369} )
Original file line number Diff line number Diff line change 55// contracts/metrics_v1.go) so the Go∪Sim union is queryable as one series set
66// — e.g. `copilot.tool.duration` split by `tool.executor` (go|client|sim).
77//
8- // Bounded cardinality only: tool.name is capped to the shared tool catalog
9- // (else "other"); vfs phase / file-read outcome are bounded sets. NEVER a
10- // user/chat/request id (those explode Prometheus series).
8+ // Bounded cardinality only: tool.name and gen_ai.agent.name are capped to the
9+ // shared catalogs (else "other"); vfs phase / file-read outcome are bounded
10+ // sets. NEVER a user/chat/request id (those explode Prometheus series).
1111import { type Counter , type Histogram , metrics } from '@opentelemetry/api'
1212import { Metric } from '@/lib/copilot/generated/metrics-v1'
1313import { TOOL_CATALOG } from '@/lib/copilot/generated/tool-catalog-v1'
@@ -91,11 +91,9 @@ export function recordSimToolMetric(
9191 [ TraceAttr . ToolName ] : cappedToolName ( name ) ,
9292 [ TraceAttr . ToolExecutor ] : 'sim' ,
9393 [ TraceAttr . ToolOutcome ] : outcome ,
94- }
95- toolCalls . add ( 1 , {
96- ...baseAttrs ,
9794 [ TraceAttr . GenAiAgentName ] : cappedAgentId ( agentId ) ,
98- } )
95+ }
96+ toolCalls . add ( 1 , baseAttrs )
9997 if ( durationMs >= 0 ) toolDuration . record ( durationMs , baseAttrs )
10098}
10199
You can’t perform that action at this time.
0 commit comments