feat: 关闭 Datadog 日志发送

This commit is contained in:
claude-code-best
2026-04-03 09:49:59 +08:00
parent e32c159f35
commit 78144b4dba
3 changed files with 36 additions and 4 deletions

View File

@@ -9,9 +9,17 @@ import { MODEL_COSTS } from '../../utils/modelCost.js'
import { isAnalyticsDisabled } from './config.js'
import { getEventMetadata } from './metadata.js'
/**
* Datadog endpoint and token are configurable via environment variables.
* If neither is set, Datadog logging is disabled entirely (no data sent).
*
* DATADOG_LOGS_ENDPOINT=https://http-intake.logs.datadoghq.com/api/v2/logs
* DATADOG_API_KEY=<your-key>
*/
const DATADOG_LOGS_ENDPOINT =
'https://http-intake.logs.us5.datadoghq.com/api/v2/logs'
const DATADOG_CLIENT_TOKEN = 'pubbbf48e6d78dae54bceaa4acf463299bf'
process.env.DATADOG_LOGS_ENDPOINT ?? ''
const DATADOG_CLIENT_TOKEN =
process.env.DATADOG_API_KEY ?? ''
const DEFAULT_FLUSH_INTERVAL_MS = 15000
const MAX_BATCH_SIZE = 100
const NETWORK_TIMEOUT_MS = 5000
@@ -133,6 +141,12 @@ export const initializeDatadog = memoize(async (): Promise<boolean> => {
return false
}
// No custom endpoint configured — skip Datadog entirely
if (!DATADOG_LOGS_ENDPOINT || !DATADOG_CLIENT_TOKEN) {
datadogInitialized = false
return false
}
try {
datadogInitialized = true
return true