fix(telemetry): patch memory leak and enforce logPrompts privacy (#23281)

This commit is contained in:
Spencer
2026-03-23 19:58:06 -04:00
committed by GitHub
parent f784e192fa
commit fcd190b8b1
15 changed files with 184 additions and 74 deletions
@@ -38,7 +38,6 @@ const runInDevTraceSpan = vi.hoisted(() =>
const metadata = { attributes: opts.attributes || {} };
return fn({
metadata,
endSpan: vi.fn(),
});
}),
);
@@ -205,7 +204,7 @@ describe('SubAgentInvocation', () => {
// Verify metadata was set on the span
const spanCallback = vi.mocked(runInDevTraceSpan).mock.calls[0][1];
const mockMetadata = { input: undefined, output: undefined };
const mockSpan = { metadata: mockMetadata, endSpan: vi.fn() };
const mockSpan = { metadata: mockMetadata };
await spanCallback(mockSpan as Parameters<typeof spanCallback>[0]);
expect(mockMetadata.input).toBe(params);
expect(mockMetadata.output).toBe(mockResult);
@@ -181,6 +181,7 @@ class SubAgentInvocation extends BaseToolInvocation<AgentInputs, ToolResult> {
return runInDevTraceSpan(
{
operation: GeminiCliOperation.AgentCall,
logPrompts: this.context.config.getTelemetryLogPromptsEnabled(),
attributes: {
[GEN_AI_AGENT_NAME]: this.definition.name,
[GEN_AI_AGENT_DESCRIPTION]: this.definition.description,