Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/developers/development/telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ These settings can be overridden by environment variables or CLI flags.
| `outfile` | `QWEN_TELEMETRY_OUTFILE` | `--telemetry-outfile <path>` | Save telemetry to file (overrides `otlpEndpoint`) | file path | - |
| `logPrompts` | `QWEN_TELEMETRY_LOG_PROMPTS` | `--telemetry-log-prompts` / `--no-telemetry-log-prompts` | Include prompts in telemetry logs | `true`/`false` | `true` |
| `includeSensitiveSpanAttributes` | `QWEN_TELEMETRY_INCLUDE_SENSITIVE_SPAN_ATTRIBUTES` | - | Include sensitive attributes in log-to-span bridge spans | `true`/`false` | `false` |
| `useCollector` | `QWEN_TELEMETRY_USE_COLLECTOR` | - | Use external OTLP collector (advanced) | `true`/`false` | `false` |

**Note on boolean environment variables:** For the boolean settings (`enabled`,
`logPrompts`, `includeSensitiveSpanAttributes`, `useCollector`), setting the
`logPrompts`, `includeSensitiveSpanAttributes`), setting the
corresponding environment variable to `true` or `1` will enable the feature. Any
other value will disable it.

Expand Down
2 changes: 0 additions & 2 deletions docs/users/configuration/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,6 @@ Configures logging and metrics collection for Qwen Code. For more information, s
| `telemetry.logPrompts` | boolean | Whether or not to include the content of user prompts in the logs. | |
| `telemetry.includeSensitiveSpanAttributes` | boolean | Whether to include `prompt`, `function_args`, and `response_text` in spans created by the log-to-span bridge. Only controls bridge spans; OTel logs and other telemetry sinks may still receive `response_text`. | `false` |
| `telemetry.outfile` | string | The file to write telemetry to when `target` is `local`. | |
| `telemetry.useCollector` | boolean | Whether to use an external OTLP collector. | |

### Example `settings.json`

Expand Down Expand Up @@ -579,7 +578,6 @@ For authentication-related variables (like `OPENAI_*`) and the recommended `.qwe
| `QWEN_TELEMETRY_LOG_PROMPTS` | Set to `true` or `1` to enable or disable logging of user prompts. Any other value is treated as disabling it. | Overrides the `telemetry.logPrompts` setting. |
| `QWEN_TELEMETRY_INCLUDE_SENSITIVE_SPAN_ATTRIBUTES` | Set to `true` or `1` to include `prompt`, `function_args`, and `response_text` in spans created by the log-to-span bridge. Any other value disables it. | Overrides the `telemetry.includeSensitiveSpanAttributes` setting. Only controls bridge spans; OTel logs and other telemetry sinks may still receive `response_text`. |
| `QWEN_TELEMETRY_OUTFILE` | Sets the file path to write telemetry to when the target is `local`. | Overrides the `telemetry.outfile` setting. |
| `QWEN_TELEMETRY_USE_COLLECTOR` | Set to `true` or `1` to enable or disable using an external OTLP collector. Any other value is treated as disabling it. | Overrides the `telemetry.useCollector` setting. |
| `QWEN_SANDBOX` | Alternative to the `sandbox` setting in `settings.json`. | Accepts `true`, `false`, `docker`, `podman`, or a custom command string. |
| `QWEN_SANDBOX_IMAGE` | Overrides sandbox image selection for Docker/Podman. | Takes precedence over `tools.sandboxImage`. |
| `SEATBELT_PROFILE` | (macOS specific) Switches the Seatbelt (`sandbox-exec`) profile on macOS. | `permissive-open`: (Default) Restricts writes to the project folder (and a few other folders, see `packages/cli/src/utils/sandbox-macos-permissive-open.sb`) but allows other operations. `strict`: Uses a strict profile that declines operations by default. `<profile_name>`: Uses a custom profile. To define a custom profile, create a file named `sandbox-macos-<profile_name>.sb` in your project's `.qwen/` directory (e.g., `my-project/.qwen/sandbox-macos-custom.sb`). |
Expand Down
9 changes: 0 additions & 9 deletions packages/cli/src/config/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2893,15 +2893,6 @@ describe('Telemetry configuration via environment variables', () => {
expect(config.getTelemetryOutfile()).toBe('/gemini/env/telemetry.log');
});

it('should prioritize QWEN_TELEMETRY_USE_COLLECTOR over settings', async () => {
vi.stubEnv('QWEN_TELEMETRY_USE_COLLECTOR', 'true');
process.argv = ['node', 'script.js'];
const argv = await parseArguments();
const settings: Settings = { telemetry: { useCollector: false } };
const config = await loadCliConfig(settings, argv, undefined, []);
expect(config.getTelemetryUseCollector()).toBe(true);
});

it('should use settings value when QWEN_TELEMETRY_ENABLED is not set', async () => {
vi.stubEnv('QWEN_TELEMETRY_ENABLED', undefined);
process.argv = ['node', 'script.js'];
Expand Down
27 changes: 0 additions & 27 deletions packages/core/src/config/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -974,33 +974,6 @@ describe('Server Config (config.ts)', () => {
expect(config.getTelemetryEnabled()).toBe(TELEMETRY_SETTINGS.enabled);
});

it('Config constructor should set telemetry useCollector to true when provided', () => {
const paramsWithTelemetry: ConfigParameters = {
...baseParams,
telemetry: { enabled: true, useCollector: true },
};
const config = new Config(paramsWithTelemetry);
expect(config.getTelemetryUseCollector()).toBe(true);
});

it('Config constructor should set telemetry useCollector to false when provided', () => {
const paramsWithTelemetry: ConfigParameters = {
...baseParams,
telemetry: { enabled: true, useCollector: false },
};
const config = new Config(paramsWithTelemetry);
expect(config.getTelemetryUseCollector()).toBe(false);
});

it('Config constructor should default telemetry useCollector to false if not provided', () => {
const paramsWithTelemetry: ConfigParameters = {
...baseParams,
telemetry: { enabled: true },
};
const config = new Config(paramsWithTelemetry);
expect(config.getTelemetryUseCollector()).toBe(false);
});

it('should have a getFileService method that returns FileDiscoveryService', () => {
const config = new Config(baseParams);
const fileService = config.getFileService();
Expand Down
6 changes: 0 additions & 6 deletions packages/core/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ export interface TelemetrySettings {
logPrompts?: boolean;
includeSensitiveSpanAttributes?: boolean;
outfile?: string;
useCollector?: boolean;
}

export interface OutputSettings {
Expand Down Expand Up @@ -860,7 +859,6 @@ export class Config {
includeSensitiveSpanAttributes:
params.telemetry?.includeSensitiveSpanAttributes ?? false,
outfile: params.telemetry?.outfile,
useCollector: params.telemetry?.useCollector,
};
this.gitCoAuthor = {
...normalizeGitCoAuthor(params.gitCoAuthor),
Expand Down Expand Up @@ -2207,10 +2205,6 @@ export class Config {
return this.gitCoAuthor;
}

getTelemetryUseCollector(): boolean {
return this.telemetrySettings.useCollector ?? false;
}

getGeminiClient(): GeminiClient {
return this.geminiClient;
}
Expand Down
5 changes: 0 additions & 5 deletions packages/core/src/telemetry/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ describe('telemetry/config helpers', () => {
logPrompts: false,
includeSensitiveSpanAttributes: true,
outfile: 'settings.log',
useCollector: false,
};
const resolved = await resolveTelemetrySettings({ settings });
expect(resolved).toEqual({
Expand All @@ -83,7 +82,6 @@ describe('telemetry/config helpers', () => {
logPrompts: false,
includeSensitiveSpanAttributes: false,
outfile: 'settings.log',
useCollector: false,
};
const env = {
QWEN_TELEMETRY_ENABLED: '1',
Expand All @@ -93,7 +91,6 @@ describe('telemetry/config helpers', () => {
QWEN_TELEMETRY_LOG_PROMPTS: 'true',
QWEN_TELEMETRY_INCLUDE_SENSITIVE_SPAN_ATTRIBUTES: 'true',
QWEN_TELEMETRY_OUTFILE: 'env.log',
QWEN_TELEMETRY_USE_COLLECTOR: 'true',
} as Record<string, string>;
const argv = {
telemetry: false,
Expand All @@ -116,7 +113,6 @@ describe('telemetry/config helpers', () => {
logPrompts: true,
includeSensitiveSpanAttributes: true,
outfile: 'env.log',
useCollector: true,
});

const resolvedArgv = await resolveTelemetrySettings({
Expand All @@ -135,7 +131,6 @@ describe('telemetry/config helpers', () => {
logPrompts: false,
includeSensitiveSpanAttributes: true,
outfile: 'argv.log',
useCollector: true, // from env as no argv option
});
});

Expand Down
5 changes: 0 additions & 5 deletions packages/core/src/telemetry/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ export async function resolveTelemetrySettings(options: {
const outfile =
argv.telemetryOutfile ?? env['QWEN_TELEMETRY_OUTFILE'] ?? settings.outfile;

const useCollector =
parseBooleanEnvFlag(env['QWEN_TELEMETRY_USE_COLLECTOR']) ??
settings.useCollector;

// Per-signal endpoint overrides (HTTP only).
// Priority: QWEN_ env var > standard OTEL_ env var > settings.json
const otlpTracesEndpoint =
Expand Down Expand Up @@ -141,6 +137,5 @@ export async function resolveTelemetrySettings(options: {
logPrompts,
includeSensitiveSpanAttributes,
outfile,
useCollector,
};
}
1 change: 0 additions & 1 deletion packages/core/src/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
export enum TelemetryTarget {
GCP = 'gcp',
LOCAL = 'local',
Comment thread
doudouOUC marked this conversation as resolved.
QWEN = 'qwen',
}

const DEFAULT_TELEMETRY_TARGET = TelemetryTarget.LOCAL;
Expand Down
25 changes: 0 additions & 25 deletions packages/core/src/telemetry/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { OTLPTraceExporter as OTLPTraceExporterHttp } from '@opentelemetry/expor
import { OTLPLogExporter as OTLPLogExporterHttp } from '@opentelemetry/exporter-logs-otlp-http';
import { OTLPMetricExporter as OTLPMetricExporterHttp } from '@opentelemetry/exporter-metrics-otlp-http';
import { NodeSDK } from '@opentelemetry/sdk-node';
import { TelemetryTarget } from './index.js';

import * as os from 'node:os';
import * as path from 'node:path';
Expand Down Expand Up @@ -136,7 +135,6 @@ describe('Telemetry SDK', () => {
getTelemetryOtlpLogsEndpoint: () => undefined,
getTelemetryOtlpMetricsEndpoint: () => undefined,
getTelemetryTarget: () => 'local',
getTelemetryUseCollector: () => false,
getTelemetryOutfile: () => undefined,
getTelemetryIncludeSensitiveSpanAttributes: () => false,
getDebugMode: () => false,
Expand Down Expand Up @@ -382,28 +380,6 @@ describe('Telemetry SDK', () => {
}
});

it('should use OTLP exporters when target is gcp but useCollector is true', () => {
vi.spyOn(mockConfig, 'getTelemetryTarget').mockReturnValue(
TelemetryTarget.GCP,
);
vi.spyOn(mockConfig, 'getTelemetryUseCollector').mockReturnValue(true);

initializeTelemetry(mockConfig);

expect(OTLPTraceExporter).toHaveBeenCalledWith({
url: 'http://localhost:4317',
compression: 'gzip',
});
expect(OTLPLogExporter).toHaveBeenCalledWith({
url: 'http://localhost:4317',
compression: 'gzip',
});
expect(OTLPMetricExporter).toHaveBeenCalledWith({
url: 'http://localhost:4317',
compression: 'gzip',
});
});

it('should not use OTLP exporters when telemetryOutfile is set', () => {
vi.spyOn(mockConfig, 'getTelemetryOutfile').mockReturnValue(
path.join(os.tmpdir(), 'test.log'),
Expand Down Expand Up @@ -551,7 +527,6 @@ describe('refreshSessionContext', () => {
getTelemetryOtlpLogsEndpoint: () => undefined,
getTelemetryOtlpMetricsEndpoint: () => undefined,
getTelemetryTarget: () => 'local',
getTelemetryUseCollector: () => false,
getTelemetryOutfile: () => undefined,
getDebugMode: () => false,
getSessionId: () => 'test-session',
Expand Down
Loading