mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-28 14:04:41 -07:00
feat(telemetry) Instrument traces with more attributes and make them available to OTEL users (#20237)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Jerop Kipruto <jerop@google.com> Co-authored-by: MD. MOHIBUR RAHMAN <35300157+mrpmohiburrahman@users.noreply.github.com> Co-authored-by: Jeffrey Ying <jeffrey.ying86@live.com> Co-authored-by: Bryan Morgan <bryanmorgan@google.com> Co-authored-by: joshualitt <joshualitt@google.com> Co-authored-by: Dev Randalpura <devrandalpura@google.com> Co-authored-by: Google Admin <github-admin@google.com> Co-authored-by: Ben Knutson <benknutson@google.com>
This commit is contained in:
@@ -20,10 +20,18 @@ vi.mock('node:crypto', () => ({
|
||||
randomUUID: vi.fn(),
|
||||
}));
|
||||
|
||||
const runInDevTraceSpan = vi.hoisted(() =>
|
||||
vi.fn(async (opts, fn) => {
|
||||
const metadata = { attributes: opts.attributes || {} };
|
||||
return fn({
|
||||
metadata,
|
||||
endSpan: vi.fn(),
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
vi.mock('../telemetry/trace.js', () => ({
|
||||
runInDevTraceSpan: vi.fn(async (_opts, fn) =>
|
||||
fn({ metadata: { input: {}, output: {} } }),
|
||||
),
|
||||
runInDevTraceSpan,
|
||||
}));
|
||||
|
||||
import { logToolCall } from '../telemetry/loggers.js';
|
||||
@@ -81,6 +89,7 @@ import type {
|
||||
} from './types.js';
|
||||
import { CoreToolCallStatus, ROOT_SCHEDULER_ID } from './types.js';
|
||||
import { ToolErrorType } from '../tools/tool-error.js';
|
||||
import { GeminiCliOperation } from '../telemetry/constants.js';
|
||||
import * as ToolUtils from '../utils/tool-utils.js';
|
||||
import type { EditorType } from '../utils/editor.js';
|
||||
import {
|
||||
@@ -366,6 +375,21 @@ describe('Scheduler (Orchestrator)', () => {
|
||||
}),
|
||||
]),
|
||||
);
|
||||
|
||||
expect(runInDevTraceSpan).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
operation: GeminiCliOperation.ScheduleToolCalls,
|
||||
}),
|
||||
expect.any(Function),
|
||||
);
|
||||
|
||||
const spanArgs = vi.mocked(runInDevTraceSpan).mock.calls[0];
|
||||
const fn = spanArgs[1];
|
||||
const metadata = { attributes: {} };
|
||||
await fn({ metadata, endSpan: vi.fn() });
|
||||
expect(metadata).toMatchObject({
|
||||
input: [req1],
|
||||
});
|
||||
});
|
||||
|
||||
it('should set approvalMode to PLAN when config returns PLAN', async () => {
|
||||
|
||||
Reference in New Issue
Block a user