主题
在服务器日志中包含 HTTP 请求头
出于隐私原因,Agent Server 默认会在服务器日志中省略 HTTP 请求头。然而,记录请求 ID 和关联 ID 可以帮助你调试问题,并在分布式系统中追踪请求。你可以通过修改 langgraph.json 文件中的 logging_headers 部分,选择为所有 API 调用记录请求头。
json
{
"$schema": "https://langgra.ph/schema.json",
"http": {
"logging_headers": {
"includes": ["request-id", "x-purchase-id", "*-trace-*"],
"excludes": ["authorization", "x-api-key", "x-organization-id", "x-user-id"]
}
}
}includes 和 excludes 列表接受精确的请求头名称,或使用 * 作为通配符以匹配任意数量字符的 glob 模式(不区分大小写)。出于安全考虑,不支持其他类型的模式。
请注意,排除优先于包含。例如,如果你包含 *-id 但排除 x-user-id,那么 x-user-id 请求头将不会被记录。