@codeflyai/codefly 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +375 -0
  3. package/bundle/codefly.js +486433 -0
  4. package/bundle/docs/architecture.md +80 -0
  5. package/bundle/docs/assets/connected_devtools.png +0 -0
  6. package/bundle/docs/assets/gemini-screenshot.png +0 -0
  7. package/bundle/docs/assets/release_patch.png +0 -0
  8. package/bundle/docs/assets/theme-ansi-light.png +0 -0
  9. package/bundle/docs/assets/theme-ansi.png +0 -0
  10. package/bundle/docs/assets/theme-atom-one.png +0 -0
  11. package/bundle/docs/assets/theme-ayu-light.png +0 -0
  12. package/bundle/docs/assets/theme-ayu.png +0 -0
  13. package/bundle/docs/assets/theme-custom.png +0 -0
  14. package/bundle/docs/assets/theme-default-light.png +0 -0
  15. package/bundle/docs/assets/theme-default.png +0 -0
  16. package/bundle/docs/assets/theme-dracula.png +0 -0
  17. package/bundle/docs/assets/theme-github-light.png +0 -0
  18. package/bundle/docs/assets/theme-github.png +0 -0
  19. package/bundle/docs/assets/theme-google-light.png +0 -0
  20. package/bundle/docs/assets/theme-xcode-light.png +0 -0
  21. package/bundle/docs/changelogs/index.md +592 -0
  22. package/bundle/docs/changelogs/latest.md +225 -0
  23. package/bundle/docs/changelogs/preview.md +129 -0
  24. package/bundle/docs/changelogs/releases.md +896 -0
  25. package/bundle/docs/cli/authentication.md +3 -0
  26. package/bundle/docs/cli/checkpointing.md +94 -0
  27. package/bundle/docs/cli/codefly-ignore.md +71 -0
  28. package/bundle/docs/cli/codefly-md.md +109 -0
  29. package/bundle/docs/cli/commands.md +354 -0
  30. package/bundle/docs/cli/configuration.md +780 -0
  31. package/bundle/docs/cli/custom-commands.md +315 -0
  32. package/bundle/docs/cli/enterprise.md +565 -0
  33. package/bundle/docs/cli/generation-settings.md +210 -0
  34. package/bundle/docs/cli/headless.md +388 -0
  35. package/bundle/docs/cli/index.md +63 -0
  36. package/bundle/docs/cli/keyboard-shortcuts.md +143 -0
  37. package/bundle/docs/cli/model-routing.md +37 -0
  38. package/bundle/docs/cli/model.md +62 -0
  39. package/bundle/docs/cli/sandbox.md +171 -0
  40. package/bundle/docs/cli/session-management.md +158 -0
  41. package/bundle/docs/cli/settings.md +113 -0
  42. package/bundle/docs/cli/system-prompt.md +95 -0
  43. package/bundle/docs/cli/telemetry.md +792 -0
  44. package/bundle/docs/cli/themes.md +237 -0
  45. package/bundle/docs/cli/token-caching.md +20 -0
  46. package/bundle/docs/cli/trusted-folders.md +95 -0
  47. package/bundle/docs/cli/tutorials.md +83 -0
  48. package/bundle/docs/cli/uninstall.md +47 -0
  49. package/bundle/docs/core/index.md +101 -0
  50. package/bundle/docs/core/memport.md +244 -0
  51. package/bundle/docs/core/policy-engine.md +267 -0
  52. package/bundle/docs/core/tools-api.md +131 -0
  53. package/bundle/docs/examples/proxy-script.md +83 -0
  54. package/bundle/docs/extensions/extension-releasing.md +183 -0
  55. package/bundle/docs/extensions/getting-started-extensions.md +245 -0
  56. package/bundle/docs/extensions/index.md +293 -0
  57. package/bundle/docs/faq.md +154 -0
  58. package/bundle/docs/get-started/authentication.md +321 -0
  59. package/bundle/docs/get-started/configuration-v1.md +888 -0
  60. package/bundle/docs/get-started/configuration.md +1524 -0
  61. package/bundle/docs/get-started/deployment.md +143 -0
  62. package/bundle/docs/get-started/examples.md +219 -0
  63. package/bundle/docs/get-started/gemini-3.md +116 -0
  64. package/bundle/docs/get-started/index.md +71 -0
  65. package/bundle/docs/get-started/installation.md +141 -0
  66. package/bundle/docs/hooks/best-practices.md +856 -0
  67. package/bundle/docs/hooks/index.md +687 -0
  68. package/bundle/docs/hooks/reference.md +168 -0
  69. package/bundle/docs/hooks/writing-hooks.md +1026 -0
  70. package/bundle/docs/ide-integration/ide-companion-spec.md +267 -0
  71. package/bundle/docs/ide-integration/index.md +202 -0
  72. package/bundle/docs/index.md +147 -0
  73. package/bundle/docs/integration-tests.md +211 -0
  74. package/bundle/docs/issue-and-pr-automation.md +134 -0
  75. package/bundle/docs/local-development.md +128 -0
  76. package/bundle/docs/mermaid/context.mmd +103 -0
  77. package/bundle/docs/mermaid/render-path.mmd +64 -0
  78. package/bundle/docs/npm.md +62 -0
  79. package/bundle/docs/quota-and-pricing.md +158 -0
  80. package/bundle/docs/release-confidence.md +164 -0
  81. package/bundle/docs/releases.md +540 -0
  82. package/bundle/docs/sidebar.json +297 -0
  83. package/bundle/docs/tools/file-system.md +217 -0
  84. package/bundle/docs/tools/index.md +95 -0
  85. package/bundle/docs/tools/mcp-server.md +1044 -0
  86. package/bundle/docs/tools/memory.md +54 -0
  87. package/bundle/docs/tools/shell.md +260 -0
  88. package/bundle/docs/tools/todos.md +57 -0
  89. package/bundle/docs/tools/web-fetch.md +59 -0
  90. package/bundle/docs/tools/web-search.md +42 -0
  91. package/bundle/docs/tos-privacy.md +96 -0
  92. package/bundle/docs/troubleshooting.md +158 -0
  93. package/bundle/policies/agent.toml +31 -0
  94. package/bundle/policies/discovered.toml +8 -0
  95. package/bundle/policies/read-only.toml +61 -0
  96. package/bundle/policies/write.toml +78 -0
  97. package/bundle/policies/yolo.toml +31 -0
  98. package/bundle/sandbox-macos-permissive-closed.sb +32 -0
  99. package/bundle/sandbox-macos-permissive-open.sb +27 -0
  100. package/bundle/sandbox-macos-permissive-proxied.sb +37 -0
  101. package/bundle/sandbox-macos-restrictive-closed.sb +93 -0
  102. package/bundle/sandbox-macos-restrictive-open.sb +96 -0
  103. package/bundle/sandbox-macos-restrictive-proxied.sb +98 -0
  104. package/package.json +148 -0
@@ -0,0 +1,792 @@
1
+ # Observability with OpenTelemetry
2
+
3
+ Learn how to enable and setup OpenTelemetry for Gemini CLI.
4
+
5
+ - [Observability with OpenTelemetry](#observability-with-opentelemetry)
6
+ - [Key benefits](#key-benefits)
7
+ - [OpenTelemetry integration](#opentelemetry-integration)
8
+ - [Configuration](#configuration)
9
+ - [Google Cloud telemetry](#google-cloud-telemetry)
10
+ - [Prerequisites](#prerequisites)
11
+ - [Direct export (recommended)](#direct-export-recommended)
12
+ - [Collector-based export (advanced)](#collector-based-export-advanced)
13
+ - [Local telemetry](#local-telemetry)
14
+ - [File-based output (recommended)](#file-based-output-recommended)
15
+ - [Collector-based export (advanced)](#collector-based-export-advanced-1)
16
+ - [Logs and metrics](#logs-and-metrics)
17
+ - [Logs](#logs)
18
+ - [Sessions](#sessions)
19
+ - [Tools](#tools)
20
+ - [Files](#files)
21
+ - [API](#api)
22
+ - [Model routing](#model-routing)
23
+ - [Chat and streaming](#chat-and-streaming)
24
+ - [Resilience](#resilience)
25
+ - [Extensions](#extensions)
26
+ - [Agent runs](#agent-runs)
27
+ - [IDE](#ide)
28
+ - [UI](#ui)
29
+ - [Metrics](#metrics)
30
+ - [Custom](#custom)
31
+ - [Sessions](#sessions-1)
32
+ - [Tools](#tools-1)
33
+ - [API](#api-1)
34
+ - [Token usage](#token-usage)
35
+ - [Files](#files-1)
36
+ - [Chat and streaming](#chat-and-streaming-1)
37
+ - [Model routing](#model-routing-1)
38
+ - [Agent runs](#agent-runs-1)
39
+ - [UI](#ui-1)
40
+ - [Performance](#performance)
41
+ - [GenAI semantic convention](#genai-semantic-convention)
42
+
43
+ ## Key benefits
44
+
45
+ - **🔍 Usage analytics**: Understand interaction patterns and feature adoption
46
+ across your team
47
+ - **⚡ Performance monitoring**: Track response times, token consumption, and
48
+ resource utilization
49
+ - **🐛 Real-time debugging**: Identify bottlenecks, failures, and error patterns
50
+ as they occur
51
+ - **📊 Workflow optimization**: Make informed decisions to improve
52
+ configurations and processes
53
+ - **🏢 Enterprise governance**: Monitor usage across teams, track costs, ensure
54
+ compliance, and integrate with existing monitoring infrastructure
55
+
56
+ ## OpenTelemetry integration
57
+
58
+ Built on **[OpenTelemetry]** — the vendor-neutral, industry-standard
59
+ observability framework — Gemini CLI's observability system provides:
60
+
61
+ - **Universal compatibility**: Export to any OpenTelemetry backend (Google
62
+ Cloud, Jaeger, Prometheus, Datadog, etc.)
63
+ - **Standardized data**: Use consistent formats and collection methods across
64
+ your toolchain
65
+ - **Future-proof integration**: Connect with existing and future observability
66
+ infrastructure
67
+ - **No vendor lock-in**: Switch between backends without changing your
68
+ instrumentation
69
+
70
+ [OpenTelemetry]: https://opentelemetry.io/
71
+
72
+ ## Configuration
73
+
74
+ All telemetry behavior is controlled through your `.codefly/settings.json` file.
75
+ Environment variables can be used to override the settings in the file.
76
+
77
+ | Setting | Environment Variable | Description | Values | Default |
78
+ | -------------- | -------------------------------- | --------------------------------------------------- | ----------------- | ----------------------- |
79
+ | `enabled` | `GEMINI_TELEMETRY_ENABLED` | Enable or disable telemetry | `true`/`false` | `false` |
80
+ | `target` | `GEMINI_TELEMETRY_TARGET` | Where to send telemetry data | `"gcp"`/`"local"` | `"local"` |
81
+ | `otlpEndpoint` | `GEMINI_TELEMETRY_OTLP_ENDPOINT` | OTLP collector endpoint | URL string | `http://localhost:4317` |
82
+ | `otlpProtocol` | `GEMINI_TELEMETRY_OTLP_PROTOCOL` | OTLP transport protocol | `"grpc"`/`"http"` | `"grpc"` |
83
+ | `outfile` | `GEMINI_TELEMETRY_OUTFILE` | Save telemetry to file (overrides `otlpEndpoint`) | file path | - |
84
+ | `logPrompts` | `GEMINI_TELEMETRY_LOG_PROMPTS` | Include prompts in telemetry logs | `true`/`false` | `true` |
85
+ | `useCollector` | `GEMINI_TELEMETRY_USE_COLLECTOR` | Use external OTLP collector (advanced) | `true`/`false` | `false` |
86
+ | `useCliAuth` | `GEMINI_TELEMETRY_USE_CLI_AUTH` | Use CLI credentials for telemetry (GCP target only) | `true`/`false` | `false` |
87
+
88
+ **Note on boolean environment variables:** For the boolean settings (`enabled`,
89
+ `logPrompts`, `useCollector`), setting the corresponding environment variable to
90
+ `true` or `1` will enable the feature. Any other value will disable it.
91
+
92
+ For detailed information about all configuration options, see the
93
+ [Configuration guide](../get-started/configuration.md).
94
+
95
+ ## Google Cloud telemetry
96
+
97
+ ### Prerequisites
98
+
99
+ Before using either method below, complete these steps:
100
+
101
+ 1. Set your Google Cloud project ID:
102
+ - For telemetry in a separate project from inference:
103
+ ```bash
104
+ export OTLP_GOOGLE_CLOUD_PROJECT="your-telemetry-project-id"
105
+ ```
106
+ - For telemetry in the same project as inference:
107
+ ```bash
108
+ export GOOGLE_CLOUD_PROJECT="your-project-id"
109
+ ```
110
+
111
+ 2. Authenticate with Google Cloud:
112
+ - If using a user account:
113
+ ```bash
114
+ gcloud auth application-default login
115
+ ```
116
+ - If using a service account:
117
+ ```bash
118
+ export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/service-account.json"
119
+ ```
120
+ 3. Make sure your account or service account has these IAM roles:
121
+ - Cloud Trace Agent
122
+ - Monitoring Metric Writer
123
+ - Logs Writer
124
+
125
+ 4. Enable the required Google Cloud APIs (if not already enabled):
126
+ ```bash
127
+ gcloud services enable \
128
+ cloudtrace.googleapis.com \
129
+ monitoring.googleapis.com \
130
+ logging.googleapis.com \
131
+ --project="$OTLP_GOOGLE_CLOUD_PROJECT"
132
+ ```
133
+
134
+ ### Authenticating with CLI Credentials
135
+
136
+ By default, the telemetry collector for Google Cloud uses Application Default
137
+ Credentials (ADC). However, you can configure it to use the same OAuth
138
+ credentials that you use to log in to the Gemini CLI. This is useful in
139
+ environments where you don't have ADC set up.
140
+
141
+ To enable this, set the `useCliAuth` property in your `telemetry` settings to
142
+ `true`:
143
+
144
+ ```json
145
+ {
146
+ "telemetry": {
147
+ "enabled": true,
148
+ "target": "gcp",
149
+ "useCliAuth": true
150
+ }
151
+ }
152
+ ```
153
+
154
+ **Important:**
155
+
156
+ - This setting requires the use of **Direct Export** (in-process exporters).
157
+ - It **cannot** be used with `useCollector: true`. If you enable both, telemetry
158
+ will be disabled and an error will be logged.
159
+ - The CLI will automatically use your credentials to authenticate with Google
160
+ Cloud Trace, Metrics, and Logging APIs.
161
+
162
+ ### Direct export (recommended)
163
+
164
+ Sends telemetry directly to Google Cloud services. No collector needed.
165
+
166
+ 1. Enable telemetry in your `.codefly/settings.json`:
167
+ ```json
168
+ {
169
+ "telemetry": {
170
+ "enabled": true,
171
+ "target": "gcp"
172
+ }
173
+ }
174
+ ```
175
+ 2. Run Gemini CLI and send prompts.
176
+ 3. View logs and metrics:
177
+ - Open the Google Cloud Console in your browser after sending prompts:
178
+ - Logs: https://console.cloud.google.com/logs/
179
+ - Metrics: https://console.cloud.google.com/monitoring/metrics-explorer
180
+ - Traces: https://console.cloud.google.com/traces/list
181
+
182
+ ### Collector-based export (advanced)
183
+
184
+ For custom processing, filtering, or routing, use an OpenTelemetry collector to
185
+ forward data to Google Cloud.
186
+
187
+ 1. Configure your `.codefly/settings.json`:
188
+ ```json
189
+ {
190
+ "telemetry": {
191
+ "enabled": true,
192
+ "target": "gcp",
193
+ "useCollector": true
194
+ }
195
+ }
196
+ ```
197
+ 2. Run the automation script:
198
+ ```bash
199
+ npm run telemetry -- --target=gcp
200
+ ```
201
+ This will:
202
+ - Start a local OTEL collector that forwards to Google Cloud
203
+ - Configure your workspace
204
+ - Provide links to view traces, metrics, and logs in Google Cloud Console
205
+ - Save collector logs to
206
+ `~/.codefly/tmp/<projectHash>/otel/collector-gcp.log`
207
+ - Stop collector on exit (e.g. `Ctrl+C`)
208
+ 3. Run Gemini CLI and send prompts.
209
+ 4. View logs and metrics:
210
+ - Open the Google Cloud Console in your browser after sending prompts:
211
+ - Logs: https://console.cloud.google.com/logs/
212
+ - Metrics: https://console.cloud.google.com/monitoring/metrics-explorer
213
+ - Traces: https://console.cloud.google.com/traces/list
214
+ - Open `~/.codefly/tmp/<projectHash>/otel/collector-gcp.log` to view local
215
+ collector logs.
216
+
217
+ ## Local telemetry
218
+
219
+ For local development and debugging, you can capture telemetry data locally:
220
+
221
+ ### File-based output (recommended)
222
+
223
+ 1. Enable telemetry in your `.codefly/settings.json`:
224
+ ```json
225
+ {
226
+ "telemetry": {
227
+ "enabled": true,
228
+ "target": "local",
229
+ "otlpEndpoint": "",
230
+ "outfile": ".codefly/telemetry.log"
231
+ }
232
+ }
233
+ ```
234
+ 2. Run Gemini CLI and send prompts.
235
+ 3. View logs and metrics in the specified file (e.g., `.codefly/telemetry.log`).
236
+
237
+ ### Collector-based export (advanced)
238
+
239
+ 1. Run the automation script:
240
+ ```bash
241
+ npm run telemetry -- --target=local
242
+ ```
243
+ This will:
244
+ - Download and start Jaeger and OTEL collector
245
+ - Configure your workspace for local telemetry
246
+ - Provide a Jaeger UI at http://localhost:16686
247
+ - Save logs/metrics to `~/.codefly/tmp/<projectHash>/otel/collector.log`
248
+ - Stop collector on exit (e.g. `Ctrl+C`)
249
+ 2. Run Gemini CLI and send prompts.
250
+ 3. View traces at http://localhost:16686 and logs/metrics in the collector log
251
+ file.
252
+
253
+ ## Logs and metrics
254
+
255
+ The following section describes the structure of logs and metrics generated for
256
+ Gemini CLI.
257
+
258
+ The `session.id`, `installation.id`, and `user.email` (available only when
259
+ authenticated with a Google account) are included as common attributes on all
260
+ logs and metrics.
261
+
262
+ ### Logs
263
+
264
+ Logs are timestamped records of specific events. The following events are logged
265
+ for Gemini CLI, grouped by category.
266
+
267
+ #### Sessions
268
+
269
+ Captures startup configuration and user prompt submissions.
270
+
271
+ - `gemini_cli.config`: Emitted once at startup with the CLI configuration.
272
+ - **Attributes**:
273
+ - `model` (string)
274
+ - `embedding_model` (string)
275
+ - `sandbox_enabled` (boolean)
276
+ - `core_tools_enabled` (string)
277
+ - `approval_mode` (string)
278
+ - `api_key_enabled` (boolean)
279
+ - `vertex_ai_enabled` (boolean)
280
+ - `log_user_prompts_enabled` (boolean)
281
+ - `file_filtering_respect_git_ignore` (boolean)
282
+ - `debug_mode` (boolean)
283
+ - `mcp_servers` (string)
284
+ - `mcp_servers_count` (int)
285
+ - `extensions` (string)
286
+ - `extension_ids` (string)
287
+ - `extension_count` (int)
288
+ - `mcp_tools` (string, if applicable)
289
+ - `mcp_tools_count` (int, if applicable)
290
+ - `output_format` ("text", "json", or "stream-json")
291
+
292
+ - `gemini_cli.user_prompt`: Emitted when a user submits a prompt.
293
+ - **Attributes**:
294
+ - `prompt_length` (int)
295
+ - `prompt_id` (string)
296
+ - `prompt` (string; excluded if `telemetry.logPrompts` is `false`)
297
+ - `auth_type` (string)
298
+
299
+ #### Tools
300
+
301
+ Captures tool executions, output truncation, and Smart Edit behavior.
302
+
303
+ - `gemini_cli.tool_call`: Emitted for each tool (function) call.
304
+ - **Attributes**:
305
+ - `function_name`
306
+ - `function_args`
307
+ - `duration_ms`
308
+ - `success` (boolean)
309
+ - `decision` ("accept", "reject", "auto_accept", or "modify", if applicable)
310
+ - `error` (if applicable)
311
+ - `error_type` (if applicable)
312
+ - `prompt_id` (string)
313
+ - `tool_type` ("native" or "mcp")
314
+ - `mcp_server_name` (string, if applicable)
315
+ - `extension_name` (string, if applicable)
316
+ - `extension_id` (string, if applicable)
317
+ - `content_length` (int, if applicable)
318
+ - `metadata` (if applicable)
319
+
320
+ - `gemini_cli.tool_output_truncated`: Output of a tool call was truncated.
321
+ - **Attributes**:
322
+ - `tool_name` (string)
323
+ - `original_content_length` (int)
324
+ - `truncated_content_length` (int)
325
+ - `threshold` (int)
326
+ - `lines` (int)
327
+ - `prompt_id` (string)
328
+
329
+ - `gemini_cli.smart_edit_strategy`: Smart Edit strategy chosen.
330
+ - **Attributes**:
331
+ - `strategy` (string)
332
+
333
+ - `gemini_cli.smart_edit_correction`: Smart Edit correction result.
334
+ - **Attributes**:
335
+ - `correction` ("success" | "failure")
336
+
337
+ - `gen_ai.client.inference.operation.details`: This event provides detailed
338
+ information about the GenAI operation, aligned with [OpenTelemetry GenAI
339
+ semantic conventions for events].
340
+ - **Attributes**:
341
+ - `gen_ai.request.model` (string)
342
+ - `gen_ai.provider.name` (string)
343
+ - `gen_ai.operation.name` (string)
344
+ - `gen_ai.input.messages` (json string)
345
+ - `gen_ai.output.messages` (json string)
346
+ - `gen_ai.response.finish_reasons` (array of strings)
347
+ - `gen_ai.usage.input_tokens` (int)
348
+ - `gen_ai.usage.output_tokens` (int)
349
+ - `gen_ai.request.temperature` (float)
350
+ - `gen_ai.request.top_p` (float)
351
+ - `gen_ai.request.top_k` (int)
352
+ - `gen_ai.request.max_tokens` (int)
353
+ - `gen_ai.system_instructions` (json string)
354
+ - `server.address` (string)
355
+ - `server.port` (int)
356
+
357
+ #### Files
358
+
359
+ Tracks file operations performed by tools.
360
+
361
+ - `gemini_cli.file_operation`: Emitted for each file operation.
362
+ - **Attributes**:
363
+ - `tool_name` (string)
364
+ - `operation` ("create" | "read" | "update")
365
+ - `lines` (int, optional)
366
+ - `mimetype` (string, optional)
367
+ - `extension` (string, optional)
368
+ - `programming_language` (string, optional)
369
+
370
+ #### API
371
+
372
+ Captures Gemini API requests, responses, and errors.
373
+
374
+ - `gemini_cli.api_request`: Request sent to Gemini API.
375
+ - **Attributes**:
376
+ - `model` (string)
377
+ - `prompt_id` (string)
378
+ - `request_text` (string, optional)
379
+
380
+ - `gemini_cli.api_response`: Response received from Gemini API.
381
+ - **Attributes**:
382
+ - `model` (string)
383
+ - `status_code` (int|string)
384
+ - `duration_ms` (int)
385
+ - `input_token_count` (int)
386
+ - `output_token_count` (int)
387
+ - `cached_content_token_count` (int)
388
+ - `thoughts_token_count` (int)
389
+ - `tool_token_count` (int)
390
+ - `total_token_count` (int)
391
+ - `response_text` (string, optional)
392
+ - `prompt_id` (string)
393
+ - `auth_type` (string)
394
+ - `finish_reasons` (array of strings)
395
+
396
+ - `gemini_cli.api_error`: API request failed.
397
+ - **Attributes**:
398
+ - `model` (string)
399
+ - `error` (string)
400
+ - `error_type` (string)
401
+ - `status_code` (int|string)
402
+ - `duration_ms` (int)
403
+ - `prompt_id` (string)
404
+ - `auth_type` (string)
405
+
406
+ - `gemini_cli.malformed_json_response`: `generateJson` response could not be
407
+ parsed.
408
+ - **Attributes**:
409
+ - `model` (string)
410
+
411
+ #### Model routing
412
+
413
+ - `gemini_cli.slash_command`: A slash command was executed.
414
+ - **Attributes**:
415
+ - `command` (string)
416
+ - `subcommand` (string, optional)
417
+ - `status` ("success" | "error")
418
+
419
+ - `gemini_cli.slash_command.model`: Model was selected via slash command.
420
+ - **Attributes**:
421
+ - `model_name` (string)
422
+
423
+ - `gemini_cli.model_routing`: Model router made a decision.
424
+ - **Attributes**:
425
+ - `decision_model` (string)
426
+ - `decision_source` (string)
427
+ - `routing_latency_ms` (int)
428
+ - `reasoning` (string, optional)
429
+ - `failed` (boolean)
430
+ - `error_message` (string, optional)
431
+
432
+ #### Chat and streaming
433
+
434
+ - `gemini_cli.chat_compression`: Chat context was compressed.
435
+ - **Attributes**:
436
+ - `tokens_before` (int)
437
+ - `tokens_after` (int)
438
+
439
+ - `gemini_cli.chat.invalid_chunk`: Invalid chunk received from a stream.
440
+ - **Attributes**:
441
+ - `error.message` (string, optional)
442
+
443
+ - `gemini_cli.chat.content_retry`: Retry triggered due to a content error.
444
+ - **Attributes**:
445
+ - `attempt_number` (int)
446
+ - `error_type` (string)
447
+ - `retry_delay_ms` (int)
448
+ - `model` (string)
449
+
450
+ - `gemini_cli.chat.content_retry_failure`: All content retries failed.
451
+ - **Attributes**:
452
+ - `total_attempts` (int)
453
+ - `final_error_type` (string)
454
+ - `total_duration_ms` (int, optional)
455
+ - `model` (string)
456
+
457
+ - `gemini_cli.conversation_finished`: Conversation session ended.
458
+ - **Attributes**:
459
+ - `approvalMode` (string)
460
+ - `turnCount` (int)
461
+
462
+ - `gemini_cli.next_speaker_check`: Next speaker determination.
463
+ - **Attributes**:
464
+ - `prompt_id` (string)
465
+ - `finish_reason` (string)
466
+ - `result` (string)
467
+
468
+ #### Resilience
469
+
470
+ Records fallback mechanisms for models and network operations.
471
+
472
+ - `gemini_cli.flash_fallback`: Switched to a flash model as fallback.
473
+ - **Attributes**:
474
+ - `auth_type` (string)
475
+
476
+ - `gemini_cli.ripgrep_fallback`: Switched to grep as fallback for file search.
477
+ - **Attributes**:
478
+ - `error` (string, optional)
479
+
480
+ - `gemini_cli.web_fetch_fallback_attempt`: Attempted web-fetch fallback.
481
+ - **Attributes**:
482
+ - `reason` ("private_ip" | "primary_failed")
483
+
484
+ #### Extensions
485
+
486
+ Tracks extension lifecycle and settings changes.
487
+
488
+ - `gemini_cli.extension_install`: An extension was installed.
489
+ - **Attributes**:
490
+ - `extension_name` (string)
491
+ - `extension_version` (string)
492
+ - `extension_source` (string)
493
+ - `status` (string)
494
+
495
+ - `gemini_cli.extension_uninstall`: An extension was uninstalled.
496
+ - **Attributes**:
497
+ - `extension_name` (string)
498
+ - `status` (string)
499
+
500
+ - `gemini_cli.extension_enable`: An extension was enabled.
501
+ - **Attributes**:
502
+ - `extension_name` (string)
503
+ - `setting_scope` (string)
504
+
505
+ - `gemini_cli.extension_disable`: An extension was disabled.
506
+ - **Attributes**:
507
+ - `extension_name` (string)
508
+ - `setting_scope` (string)
509
+
510
+ - `gemini_cli.extension_update`: An extension was updated.
511
+ - **Attributes**:
512
+ - `extension_name` (string)
513
+ - `extension_version` (string)
514
+ - `extension_previous_version` (string)
515
+ - `extension_source` (string)
516
+ - `status` (string)
517
+
518
+ #### Agent runs
519
+
520
+ - `gemini_cli.agent.start`: Agent run started.
521
+ - **Attributes**:
522
+ - `agent_id` (string)
523
+ - `agent_name` (string)
524
+
525
+ - `gemini_cli.agent.finish`: Agent run finished.
526
+ - **Attributes**:
527
+ - `agent_id` (string)
528
+ - `agent_name` (string)
529
+ - `duration_ms` (int)
530
+ - `turn_count` (int)
531
+ - `terminate_reason` (string)
532
+
533
+ #### IDE
534
+
535
+ Captures IDE connectivity and conversation lifecycle events.
536
+
537
+ - `gemini_cli.ide_connection`: IDE companion connection.
538
+ - **Attributes**:
539
+ - `connection_type` (string)
540
+
541
+ #### UI
542
+
543
+ Tracks terminal rendering issues and related signals.
544
+
545
+ - `kitty_sequence_overflow`: Terminal kitty control sequence overflow.
546
+ - **Attributes**:
547
+ - `sequence_length` (int)
548
+ - `truncated_sequence` (string)
549
+
550
+ ### Metrics
551
+
552
+ Metrics are numerical measurements of behavior over time.
553
+
554
+ #### Custom
555
+
556
+ ##### Sessions
557
+
558
+ Counts CLI sessions at startup.
559
+
560
+ - `gemini_cli.session.count` (Counter, Int): Incremented once per CLI startup.
561
+
562
+ ##### Tools
563
+
564
+ Measures tool usage and latency.
565
+
566
+ - `gemini_cli.tool.call.count` (Counter, Int): Counts tool calls.
567
+ - **Attributes**:
568
+ - `function_name`
569
+ - `success` (boolean)
570
+ - `decision` (string: "accept", "reject", "modify", or "auto_accept", if
571
+ applicable)
572
+ - `tool_type` (string: "mcp" or "native", if applicable)
573
+
574
+ - `gemini_cli.tool.call.latency` (Histogram, ms): Measures tool call latency.
575
+ - **Attributes**:
576
+ - `function_name`
577
+
578
+ ##### API
579
+
580
+ Tracks API request volume and latency.
581
+
582
+ - `gemini_cli.api.request.count` (Counter, Int): Counts all API requests.
583
+ - **Attributes**:
584
+ - `model`
585
+ - `status_code`
586
+ - `error_type` (if applicable)
587
+
588
+ - `gemini_cli.api.request.latency` (Histogram, ms): Measures API request
589
+ latency.
590
+ - **Attributes**:
591
+ - `model`
592
+ - Note: Overlaps with `gen_ai.client.operation.duration` (GenAI conventions).
593
+
594
+ ##### Token usage
595
+
596
+ Tracks tokens used by model and type.
597
+
598
+ - `gemini_cli.token.usage` (Counter, Int): Counts tokens used.
599
+ - **Attributes**:
600
+ - `model`
601
+ - `type` ("input", "output", "thought", "cache", or "tool")
602
+ - Note: Overlaps with `gen_ai.client.token.usage` for `input`/`output`.
603
+
604
+ ##### Files
605
+
606
+ Counts file operations with basic context.
607
+
608
+ - `gemini_cli.file.operation.count` (Counter, Int): Counts file operations.
609
+ - **Attributes**:
610
+ - `operation` ("create", "read", "update")
611
+ - `lines` (Int, optional)
612
+ - `mimetype` (string, optional)
613
+ - `extension` (string, optional)
614
+ - `programming_language` (string, optional)
615
+
616
+ - `gemini_cli.lines.changed` (Counter, Int): Number of lines changed (from file
617
+ diffs).
618
+ - **Attributes**:
619
+ - `function_name`
620
+ - `type` ("added" or "removed")
621
+
622
+ ##### Chat and streaming
623
+
624
+ Resilience counters for compression, invalid chunks, and retries.
625
+
626
+ - `gemini_cli.chat_compression` (Counter, Int): Counts chat compression
627
+ operations.
628
+ - **Attributes**:
629
+ - `tokens_before` (Int)
630
+ - `tokens_after` (Int)
631
+
632
+ - `gemini_cli.chat.invalid_chunk.count` (Counter, Int): Counts invalid chunks
633
+ from streams.
634
+
635
+ - `gemini_cli.chat.content_retry.count` (Counter, Int): Counts retries due to
636
+ content errors.
637
+
638
+ - `gemini_cli.chat.content_retry_failure.count` (Counter, Int): Counts requests
639
+ where all content retries failed.
640
+
641
+ ##### Model routing
642
+
643
+ Routing latency/failures and slash-command selections.
644
+
645
+ - `gemini_cli.slash_command.model.call_count` (Counter, Int): Counts model
646
+ selections via slash command.
647
+ - **Attributes**:
648
+ - `slash_command.model.model_name` (string)
649
+
650
+ - `gemini_cli.model_routing.latency` (Histogram, ms): Model routing decision
651
+ latency.
652
+ - **Attributes**:
653
+ - `routing.decision_model` (string)
654
+ - `routing.decision_source` (string)
655
+
656
+ - `gemini_cli.model_routing.failure.count` (Counter, Int): Counts model routing
657
+ failures.
658
+ - **Attributes**:
659
+ - `routing.decision_source` (string)
660
+ - `routing.error_message` (string)
661
+
662
+ ##### Agent runs
663
+
664
+ Agent lifecycle metrics: runs, durations, and turns.
665
+
666
+ - `gemini_cli.agent.run.count` (Counter, Int): Counts agent runs.
667
+ - **Attributes**:
668
+ - `agent_name` (string)
669
+ - `terminate_reason` (string)
670
+
671
+ - `gemini_cli.agent.duration` (Histogram, ms): Agent run durations.
672
+ - **Attributes**:
673
+ - `agent_name` (string)
674
+
675
+ - `gemini_cli.agent.turns` (Histogram, turns): Turns taken per agent run.
676
+ - **Attributes**:
677
+ - `agent_name` (string)
678
+
679
+ ##### UI
680
+
681
+ UI stability signals such as flicker count.
682
+
683
+ - `gemini_cli.ui.flicker.count` (Counter, Int): Counts UI frames that flicker
684
+ (render taller than terminal).
685
+
686
+ ##### Performance
687
+
688
+ Optional performance monitoring for startup, CPU/memory, and phase timing.
689
+
690
+ - `gemini_cli.startup.duration` (Histogram, ms): CLI startup time by phase.
691
+ - **Attributes**:
692
+ - `phase` (string)
693
+ - `details` (map, optional)
694
+
695
+ - `gemini_cli.memory.usage` (Histogram, bytes): Memory usage.
696
+ - **Attributes**:
697
+ - `memory_type` ("heap_used", "heap_total", "external", "rss")
698
+ - `component` (string, optional)
699
+
700
+ - `gemini_cli.cpu.usage` (Histogram, percent): CPU usage percentage.
701
+ - **Attributes**:
702
+ - `component` (string, optional)
703
+
704
+ - `gemini_cli.tool.queue.depth` (Histogram, count): Number of tools in the
705
+ execution queue.
706
+
707
+ - `gemini_cli.tool.execution.breakdown` (Histogram, ms): Tool time by phase.
708
+ - **Attributes**:
709
+ - `function_name` (string)
710
+ - `phase` ("validation", "preparation", "execution", "result_processing")
711
+
712
+ - `gemini_cli.api.request.breakdown` (Histogram, ms): API request time by phase.
713
+ - **Attributes**:
714
+ - `model` (string)
715
+ - `phase` ("request_preparation", "network_latency", "response_processing",
716
+ "token_processing")
717
+
718
+ - `gemini_cli.token.efficiency` (Histogram, ratio): Token efficiency metrics.
719
+ - **Attributes**:
720
+ - `model` (string)
721
+ - `metric` (string)
722
+ - `context` (string, optional)
723
+
724
+ - `gemini_cli.performance.score` (Histogram, score): Composite performance
725
+ score.
726
+ - **Attributes**:
727
+ - `category` (string)
728
+ - `baseline` (number, optional)
729
+
730
+ - `gemini_cli.performance.regression` (Counter, Int): Regression detection
731
+ events.
732
+ - **Attributes**:
733
+ - `metric` (string)
734
+ - `severity` ("low", "medium", "high")
735
+ - `current_value` (number)
736
+ - `baseline_value` (number)
737
+
738
+ - `gemini_cli.performance.regression.percentage_change` (Histogram, percent):
739
+ Percent change from baseline when regression detected.
740
+ - **Attributes**:
741
+ - `metric` (string)
742
+ - `severity` ("low", "medium", "high")
743
+ - `current_value` (number)
744
+ - `baseline_value` (number)
745
+
746
+ - `gemini_cli.performance.baseline.comparison` (Histogram, percent): Comparison
747
+ to baseline.
748
+ - **Attributes**:
749
+ - `metric` (string)
750
+ - `category` (string)
751
+ - `current_value` (number)
752
+ - `baseline_value` (number)
753
+
754
+ #### GenAI semantic convention
755
+
756
+ The following metrics comply with [OpenTelemetry GenAI semantic conventions] for
757
+ standardized observability across GenAI applications:
758
+
759
+ - `gen_ai.client.token.usage` (Histogram, token): Number of input and output
760
+ tokens used per operation.
761
+ - **Attributes**:
762
+ - `gen_ai.operation.name` (string): The operation type (e.g.,
763
+ "generate_content", "chat")
764
+ - `gen_ai.provider.name` (string): The GenAI provider ("gcp.gen_ai" or
765
+ "gcp.vertex_ai")
766
+ - `gen_ai.token.type` (string): The token type ("input" or "output")
767
+ - `gen_ai.request.model` (string, optional): The model name used for the
768
+ request
769
+ - `gen_ai.response.model` (string, optional): The model name that generated
770
+ the response
771
+ - `server.address` (string, optional): GenAI server address
772
+ - `server.port` (int, optional): GenAI server port
773
+
774
+ - `gen_ai.client.operation.duration` (Histogram, s): GenAI operation duration in
775
+ seconds.
776
+ - **Attributes**:
777
+ - `gen_ai.operation.name` (string): The operation type (e.g.,
778
+ "generate_content", "chat")
779
+ - `gen_ai.provider.name` (string): The GenAI provider ("gcp.gen_ai" or
780
+ "gcp.vertex_ai")
781
+ - `gen_ai.request.model` (string, optional): The model name used for the
782
+ request
783
+ - `gen_ai.response.model` (string, optional): The model name that generated
784
+ the response
785
+ - `server.address` (string, optional): GenAI server address
786
+ - `server.port` (int, optional): GenAI server port
787
+ - `error.type` (string, optional): Error type if the operation failed
788
+
789
+ [OpenTelemetry GenAI semantic conventions]:
790
+ https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/gen-ai-metrics.md
791
+ [OpenTelemetry GenAI semantic conventions for events]:
792
+ https://github.com/open-telemetry/semantic-conventions/blob/8b4f210f43136e57c1f6f47292eb6d38e3bf30bb/docs/gen-ai/gen-ai-events.md