{"componentChunkName":"component---src-templates-acg-portal-new-template-tsx","path":"/Mms8r66bk","result":{"data":{"markdownRemark":{"html":"<h2 id=\"codex-通过-langfuse-插件接入百度-llm\"><a href=\"#codex-%E9%80%9A%E8%BF%87-langfuse-%E6%8F%92%E4%BB%B6%E6%8E%A5%E5%85%A5%E7%99%BE%E5%BA%A6-llm\" aria-label=\"codex 通过 langfuse 插件接入百度 llm permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Codex 通过 Langfuse 插件接入百度 LLM</h2>\n<p>通过 <strong>Langfuse Codex Observability Plugin</strong> 将 Codex 的对话 Trace 上报至<strong>BCM-> LLM应用性能监控</strong>。该插件以 Codex Stop Hook 机制运行，每次 Codex turn 完成后读取会话记录，转换为 Langfuse 格式的 Trace 并上报。接入后，Codex 的每次对话会在 <strong>LLM应用性能监控</strong> 中展示为一条 Trace，包含 LLM 调用、工具执行、子 Agent 等完整调用链。可参考 <a href=\"https://langfuse.com/integrations/developer-tools/codex\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">langfuse官方文档</a> 了解插件的完整功能和配置选项。</p>\n<h3 id=\"前提条件\"><a href=\"#%E5%89%8D%E6%8F%90%E6%9D%A1%E4%BB%B6\" aria-label=\"前提条件 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>前提条件</h3>\n<ul>\n<li>Codex 版本 ≥ 0.128</li>\n<li>Node.js ≥ 22</li>\n<li>百度 LLM 接入点与 Token（见步骤1）</li>\n</ul>\n<h3 id=\"步骤1：获取接入点与-token\"><a href=\"#%E6%AD%A5%E9%AA%A41%EF%BC%9A%E8%8E%B7%E5%8F%96%E6%8E%A5%E5%85%A5%E7%82%B9%E4%B8%8E-token\" aria-label=\"步骤1：获取接入点与 token permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>步骤1：获取接入点与 Token</h3>\n<p>注：该信息因地域和用户而异，可在控制台“接入应用”页面获取，下方为示例</p>\n<ul>\n<li><strong>接入点：</strong><a href=\"http://apm-collector.bj.baidubce.com\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">http://apm-collector.bj.baidubce.com</a></li>\n<li><strong>Authentication：</strong>UFSpMM<strong>***</strong>lnFrVBqtPDK</li>\n</ul>\n<h3 id=\"步骤2：安装-langfuse-插件\"><a href=\"#%E6%AD%A5%E9%AA%A42%EF%BC%9A%E5%AE%89%E8%A3%85-langfuse-%E6%8F%92%E4%BB%B6\" aria-label=\"步骤2：安装 langfuse 插件 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>步骤2：安装 Langfuse 插件</h3>\n\n    <div class=\"code-block-wrapper\">\n        <div class=\"code-block\">\n            <div class=\"code-block-header\">\n                <span class=\"code-block-name\">Bash</span>\n                <button class=\"code-copy-btn\" data-tooltip-text=\"\">\n                    <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\"> <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M5.57894 3.45614C5.57894 3.38832 5.63392 3.33333 5.70175 3.33333H12.5439C12.6117 3.33333 12.6667 3.38832 12.6667 3.45614V10.2982C12.6667 10.3661 12.6117 10.4211 12.5439 10.4211H11.7544V5.70175C11.7544 4.89754 11.1025 4.24561 10.2982 4.24561H5.57894V3.45614ZM4.24561 4.24561V3.45614C4.24561 2.65194 4.89754 2 5.70175 2H12.5439C13.3481 2 14 2.65194 14 3.45614V10.2982C14 11.1025 13.3481 11.7544 12.5439 11.7544H11.7544V12.5439C11.7544 13.3481 11.1025 14 10.2982 14H3.45614C2.65194 14 2 13.3481 2 12.5439V5.70175C2 4.89754 2.65194 4.24561 3.45614 4.24561H4.24561ZM3.33333 5.70175C3.33333 5.63392 3.38832 5.57894 3.45614 5.57894H10.2982C10.3661 5.57894 10.4211 5.63392 10.4211 5.70175V12.5439C10.4211 12.6117 10.3661 12.6667 10.2982 12.6667H3.45614C3.38832 12.6667 3.33333 12.6117 3.33333 12.5439V5.70175Z\" fill=\"currentColor\"></path> </svg>\n                    复制\n                </button>\n            </div>\n            <div class=\"code-block-content\">\n                <pre class=\"language-bash\"><code><span class=\"line-number\">1</span>codex plugin marketplace <span class=\"token function\">add</span> langfuse/codex-observability-plugin</code></pre>\n            </div>\n        </div>\n    </div>\n  \n<h3 id=\"步骤3：启用插件\"><a href=\"#%E6%AD%A5%E9%AA%A43%EF%BC%9A%E5%90%AF%E7%94%A8%E6%8F%92%E4%BB%B6\" aria-label=\"步骤3：启用插件 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>步骤3：启用插件</h3>\n<p>在 ~/.codex/config.toml 中启用：（注意自己实际运行的CodeX的目录）</p>\n\n    <div class=\"code-block-wrapper\">\n        <div class=\"code-block\">\n            <div class=\"code-block-header\">\n                <span class=\"code-block-name\">TOML</span>\n                <button class=\"code-copy-btn\" data-tooltip-text=\"\">\n                    <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\"> <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M5.57894 3.45614C5.57894 3.38832 5.63392 3.33333 5.70175 3.33333H12.5439C12.6117 3.33333 12.6667 3.38832 12.6667 3.45614V10.2982C12.6667 10.3661 12.6117 10.4211 12.5439 10.4211H11.7544V5.70175C11.7544 4.89754 11.1025 4.24561 10.2982 4.24561H5.57894V3.45614ZM4.24561 4.24561V3.45614C4.24561 2.65194 4.89754 2 5.70175 2H12.5439C13.3481 2 14 2.65194 14 3.45614V10.2982C14 11.1025 13.3481 11.7544 12.5439 11.7544H11.7544V12.5439C11.7544 13.3481 11.1025 14 10.2982 14H3.45614C2.65194 14 2 13.3481 2 12.5439V5.70175C2 4.89754 2.65194 4.24561 3.45614 4.24561H4.24561ZM3.33333 5.70175C3.33333 5.63392 3.38832 5.57894 3.45614 5.57894H10.2982C10.3661 5.57894 10.4211 5.63392 10.4211 5.70175V12.5439C10.4211 12.6117 10.3661 12.6667 10.2982 12.6667H3.45614C3.38832 12.6667 3.33333 12.6117 3.33333 12.5439V5.70175Z\" fill=\"currentColor\"></path> </svg>\n                    复制\n                </button>\n            </div>\n            <div class=\"code-block-content\">\n                <pre class=\"language-text\"><code><span class=\"line-number\">1</span>[features]\n<span class=\"line-number\">2</span>plugin_hooks = true\n<span class=\"line-number\">3</span>\n<span class=\"line-number\">4</span>[plugins.&quot;tracing@codex-observability-plugin&quot;]\n<span class=\"line-number\">5</span>enabled = true</code></pre>\n            </div>\n        </div>\n    </div>\n  \n<h3 id=\"步骤4：配置接入凭证\"><a href=\"#%E6%AD%A5%E9%AA%A44%EF%BC%9A%E9%85%8D%E7%BD%AE%E6%8E%A5%E5%85%A5%E5%87%AD%E8%AF%81\" aria-label=\"步骤4：配置接入凭证 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>步骤4：配置接入凭证</h3>\n<p>在 ~/.codex/langfuse.json 中配置：</p>\n\n    <div class=\"code-block-wrapper\">\n        <div class=\"code-block\">\n            <div class=\"code-block-header\">\n                <span class=\"code-block-name\">JSON</span>\n                <button class=\"code-copy-btn\" data-tooltip-text=\"\">\n                    <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\"> <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M5.57894 3.45614C5.57894 3.38832 5.63392 3.33333 5.70175 3.33333H12.5439C12.6117 3.33333 12.6667 3.38832 12.6667 3.45614V10.2982C12.6667 10.3661 12.6117 10.4211 12.5439 10.4211H11.7544V5.70175C11.7544 4.89754 11.1025 4.24561 10.2982 4.24561H5.57894V3.45614ZM4.24561 4.24561V3.45614C4.24561 2.65194 4.89754 2 5.70175 2H12.5439C13.3481 2 14 2.65194 14 3.45614V10.2982C14 11.1025 13.3481 11.7544 12.5439 11.7544H11.7544V12.5439C11.7544 13.3481 11.1025 14 10.2982 14H3.45614C2.65194 14 2 13.3481 2 12.5439V5.70175C2 4.89754 2.65194 4.24561 3.45614 4.24561H4.24561ZM3.33333 5.70175C3.33333 5.63392 3.38832 5.57894 3.45614 5.57894H10.2982C10.3661 5.57894 10.4211 5.63392 10.4211 5.70175V12.5439C10.4211 12.6117 10.3661 12.6667 10.2982 12.6667H3.45614C3.38832 12.6667 3.33333 12.6117 3.33333 12.5439V5.70175Z\" fill=\"currentColor\"></path> </svg>\n                    复制\n                </button>\n            </div>\n            <div class=\"code-block-content\">\n                <pre class=\"language-json\"><code><span class=\"line-number\">1</span><span class=\"token punctuation\">{</span>\n<span class=\"line-number\">2</span>  <span class=\"token property\">\"enabled\"</span><span class=\"token operator\">:</span> <span class=\"token boolean\">true</span><span class=\"token punctuation\">,</span>\n<span class=\"line-number\">3</span>  <span class=\"token property\">\"public_key\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"&lt;Authentication>\"</span><span class=\"token punctuation\">,</span>\n<span class=\"line-number\">4</span>  <span class=\"token property\">\"secret_key\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"sk-placeholder\"</span><span class=\"token punctuation\">,</span>\n<span class=\"line-number\">5</span>  <span class=\"token property\">\"base_url\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"http://apm-collector.bj.baidubce.com\"</span>\n<span class=\"line-number\">6</span><span class=\"token punctuation\">}</span></code></pre>\n            </div>\n        </div>\n    </div>\n  \n<p>对应的字段说明如下：</p>\n<table>\n<thead>\n<tr>\n<th>参数</th>\n<th>描述</th>\n<th>示例</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>public_key></code></td>\n<td>步骤1获取的鉴权 Token</td>\n<td><code>UFSpMM*******lnFrVBqtPDK</code></td>\n</tr>\n<tr>\n<td><code>&#x3C;secret_key></code></td>\n<td>任意非空字符串，服务端不校验，但必须非空</td>\n<td><code>sk-placeholder</code></td>\n</tr>\n<tr>\n<td><code>&#x3C;endpoint></code></td>\n<td>任意非空字符串，服务端不校验，但必须非空</td>\n<td><code>http://apm-collector.bj.baidubce.com</code></td>\n</tr>\n<tr>\n<td><code>&#x3C;base_url></code></td>\n<td>百度 APM 接入点</td>\n<td><code>http://apm-collector.bj.baidubce.com</code></td>\n</tr>\n</tbody>\n</table>\n<p>也可以使用环境变量配置：</p>\n\n    <div class=\"code-block-wrapper\">\n        <div class=\"code-block\">\n            <div class=\"code-block-header\">\n                <span class=\"code-block-name\">Bash</span>\n                <button class=\"code-copy-btn\" data-tooltip-text=\"\">\n                    <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\"> <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M5.57894 3.45614C5.57894 3.38832 5.63392 3.33333 5.70175 3.33333H12.5439C12.6117 3.33333 12.6667 3.38832 12.6667 3.45614V10.2982C12.6667 10.3661 12.6117 10.4211 12.5439 10.4211H11.7544V5.70175C11.7544 4.89754 11.1025 4.24561 10.2982 4.24561H5.57894V3.45614ZM4.24561 4.24561V3.45614C4.24561 2.65194 4.89754 2 5.70175 2H12.5439C13.3481 2 14 2.65194 14 3.45614V10.2982C14 11.1025 13.3481 11.7544 12.5439 11.7544H11.7544V12.5439C11.7544 13.3481 11.1025 14 10.2982 14H3.45614C2.65194 14 2 13.3481 2 12.5439V5.70175C2 4.89754 2.65194 4.24561 3.45614 4.24561H4.24561ZM3.33333 5.70175C3.33333 5.63392 3.38832 5.57894 3.45614 5.57894H10.2982C10.3661 5.57894 10.4211 5.63392 10.4211 5.70175V12.5439C10.4211 12.6117 10.3661 12.6667 10.2982 12.6667H3.45614C3.38832 12.6667 3.33333 12.6117 3.33333 12.5439V5.70175Z\" fill=\"currentColor\"></path> </svg>\n                    复制\n                </button>\n            </div>\n            <div class=\"code-block-content\">\n                <pre class=\"language-bash\"><code><span class=\"line-number\">1</span><span class=\"token builtin class-name\">export</span> <span class=\"token assign-left variable\">TRACE_TO_LANGFUSE</span><span class=\"token operator\">=</span>true\n<span class=\"line-number\">2</span><span class=\"token builtin class-name\">export</span> <span class=\"token assign-left variable\">LANGFUSE_PUBLIC_KEY</span><span class=\"token operator\">=</span><span class=\"token string\">\"&lt;Authentication>\"</span>\n<span class=\"line-number\">3</span><span class=\"token builtin class-name\">export</span> <span class=\"token assign-left variable\">LANGFUSE_SECRET_KEY</span><span class=\"token operator\">=</span><span class=\"token string\">\"sk-placeholder\"</span>\n<span class=\"line-number\">4</span><span class=\"token builtin class-name\">export</span> <span class=\"token assign-left variable\">LANGFUSE_BASE_URL</span><span class=\"token operator\">=</span><span class=\"token string\">\"http://apm-collector.bj.baidubce.com\"</span></code></pre>\n            </div>\n        </div>\n    </div>\n  \n<h3 id=\"步骤5：设置-servicename-和-hostname（可选）\"><a href=\"#%E6%AD%A5%E9%AA%A45%EF%BC%9A%E8%AE%BE%E7%BD%AE-servicename-%E5%92%8C-hostname%EF%BC%88%E5%8F%AF%E9%80%89%EF%BC%89\" aria-label=\"步骤5：设置 servicename 和 hostname（可选） permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>步骤5：设置 service.name 和 host.name（可选）</h3>\n<blockquote>\n<p>⚠️ Langfuse 插件 v0.1.0 使用 NodeTracerProvider 时未传入 resource 参数，导致 OTel SDK 使用 defaultResource() 硬编码 service.name = unknown_service:node，且不读取 OTEL_SERVICE_NAME、OTEL_RESOURCE_ATTRIBUTES 等标准环境变量。host.name 同理需手动注入。</p>\n</blockquote>\n<p><strong>解决方式</strong>： 设置以下环境变量，同时修改插件 bundle。</p>\n\n    <div class=\"code-block-wrapper\">\n        <div class=\"code-block\">\n            <div class=\"code-block-header\">\n                <span class=\"code-block-name\">Bash</span>\n                <button class=\"code-copy-btn\" data-tooltip-text=\"\">\n                    <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\"> <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M5.57894 3.45614C5.57894 3.38832 5.63392 3.33333 5.70175 3.33333H12.5439C12.6117 3.33333 12.6667 3.38832 12.6667 3.45614V10.2982C12.6667 10.3661 12.6117 10.4211 12.5439 10.4211H11.7544V5.70175C11.7544 4.89754 11.1025 4.24561 10.2982 4.24561H5.57894V3.45614ZM4.24561 4.24561V3.45614C4.24561 2.65194 4.89754 2 5.70175 2H12.5439C13.3481 2 14 2.65194 14 3.45614V10.2982C14 11.1025 13.3481 11.7544 12.5439 11.7544H11.7544V12.5439C11.7544 13.3481 11.1025 14 10.2982 14H3.45614C2.65194 14 2 13.3481 2 12.5439V5.70175C2 4.89754 2.65194 4.24561 3.45614 4.24561H4.24561ZM3.33333 5.70175C3.33333 5.63392 3.38832 5.57894 3.45614 5.57894H10.2982C10.3661 5.57894 10.4211 5.63392 10.4211 5.70175V12.5439C10.4211 12.6117 10.3661 12.6667 10.2982 12.6667H3.45614C3.38832 12.6667 3.33333 12.6117 3.33333 12.5439V5.70175Z\" fill=\"currentColor\"></path> </svg>\n                    复制\n                </button>\n            </div>\n            <div class=\"code-block-content\">\n                <pre class=\"language-bash\"><code><span class=\"line-number\">1</span><span class=\"token builtin class-name\">export</span> <span class=\"token assign-left variable\">OTEL_SERVICE_NAME</span><span class=\"token operator\">=</span><span class=\"token string\">\"&lt;应用名>\"</span>\n<span class=\"line-number\">2</span><span class=\"token builtin class-name\">export</span> <span class=\"token assign-left variable\">OTEL_RESOURCE_ATTRIBUTES</span><span class=\"token operator\">=</span><span class=\"token string\">\"host.name=&lt;主机名>\"</span></code></pre>\n            </div>\n        </div>\n    </div>\n  \n<p>编辑以下两个文件（相同修改）：</p>\n<table>\n<thead>\n<tr>\n<th>文件</th>\n<th>描述</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>marketplace 源</td>\n<td><code>~/.codex/.tmp/marketplaces/codex-observability-plugin/plugins/tracing/dist/index.mjs</code></td>\n</tr>\n<tr>\n<td>运行时缓存</td>\n<td><code>~/.codex/plugins/cache/codex-observability-plugin/tracing/&#x3C;版本号>/dist/index.mjs</code></td>\n</tr>\n</tbody>\n</table>\n<p>在 setupInstrumentation 函数中，将：</p>\n\n    <div class=\"code-block-wrapper\">\n        <div class=\"code-block\">\n            <div class=\"code-block-header\">\n                <span class=\"code-block-name\">JavaScript</span>\n                <button class=\"code-copy-btn\" data-tooltip-text=\"\">\n                    <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\"> <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M5.57894 3.45614C5.57894 3.38832 5.63392 3.33333 5.70175 3.33333H12.5439C12.6117 3.33333 12.6667 3.38832 12.6667 3.45614V10.2982C12.6667 10.3661 12.6117 10.4211 12.5439 10.4211H11.7544V5.70175C11.7544 4.89754 11.1025 4.24561 10.2982 4.24561H5.57894V3.45614ZM4.24561 4.24561V3.45614C4.24561 2.65194 4.89754 2 5.70175 2H12.5439C13.3481 2 14 2.65194 14 3.45614V10.2982C14 11.1025 13.3481 11.7544 12.5439 11.7544H11.7544V12.5439C11.7544 13.3481 11.1025 14 10.2982 14H3.45614C2.65194 14 2 13.3481 2 12.5439V5.70175C2 4.89754 2.65194 4.24561 3.45614 4.24561H4.24561ZM3.33333 5.70175C3.33333 5.63392 3.38832 5.57894 3.45614 5.57894H10.2982C10.3661 5.57894 10.4211 5.63392 10.4211 5.70175V12.5439C10.4211 12.6117 10.3661 12.6667 10.2982 12.6667H3.45614C3.38832 12.6667 3.33333 12.6117 3.33333 12.5439V5.70175Z\" fill=\"currentColor\"></path> </svg>\n                    复制\n                </button>\n            </div>\n            <div class=\"code-block-content\">\n                <pre class=\"language-text\"><code><span class=\"line-number\">1</span>const provider = new import_src.NodeTracerProvider({ spanProcessors: [spanProcessor] });</code></pre>\n            </div>\n        </div>\n    </div>\n  \n<p>改为：</p>\n\n    <div class=\"code-block-wrapper\">\n        <div class=\"code-block\">\n            <div class=\"code-block-header\">\n                <span class=\"code-block-name\">JavaScript</span>\n                <button class=\"code-copy-btn\" data-tooltip-text=\"\">\n                    <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\"> <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M5.57894 3.45614C5.57894 3.38832 5.63392 3.33333 5.70175 3.33333H12.5439C12.6117 3.33333 12.6667 3.38832 12.6667 3.45614V10.2982C12.6667 10.3661 12.6117 10.4211 12.5439 10.4211H11.7544V5.70175C11.7544 4.89754 11.1025 4.24561 10.2982 4.24561H5.57894V3.45614ZM4.24561 4.24561V3.45614C4.24561 2.65194 4.89754 2 5.70175 2H12.5439C13.3481 2 14 2.65194 14 3.45614V10.2982C14 11.1025 13.3481 11.7544 12.5439 11.7544H11.7544V12.5439C11.7544 13.3481 11.1025 14 10.2982 14H3.45614C2.65194 14 2 13.3481 2 12.5439V5.70175C2 4.89754 2.65194 4.24561 3.45614 4.24561H4.24561ZM3.33333 5.70175C3.33333 5.63392 3.38832 5.57894 3.45614 5.57894H10.2982C10.3661 5.57894 10.4211 5.63392 10.4211 5.70175V12.5439C10.4211 12.6117 10.3661 12.6667 10.2982 12.6667H3.45614C3.38832 12.6667 3.33333 12.6117 3.33333 12.5439V5.70175Z\" fill=\"currentColor\"></path> </svg>\n                    复制\n                </button>\n            </div>\n            <div class=\"code-block-content\">\n                <pre class=\"language-text\"><code><span class=\"line-number\">1</span>const attrs = { &quot;service.name&quot;: process.env.OTEL_SERVICE_NAME || &quot;codex&quot; };\n<span class=\"line-number\">2</span>if (process.env.OTEL_RESOURCE_ATTRIBUTES) {\n<span class=\"line-number\">3</span>  process.env.OTEL_RESOURCE_ATTRIBUTES.split(&quot;,&quot;).forEach(pair =&gt; {\n<span class=\"line-number\">4</span>    const [k, ...v] = pair.trim().split(&quot;=&quot;);\n<span class=\"line-number\">5</span>    if (k) attrs[k.trim()] = v.join(&quot;=&quot;).trim();\n<span class=\"line-number\">6</span>  });\n<span class=\"line-number\">7</span>}\n<span class=\"line-number\">8</span>const provider = new import_src.NodeTracerProvider({\n<span class=\"line-number\">9</span>  spanProcessors: [spanProcessor],\n<span class=\"line-number\">10</span>  resource: require_src$3().defaultResource().merge(\n<span class=\"line-number\">11</span>    require_src$3().resourceFromAttributes(attrs)\n<span class=\"line-number\">12</span>  )\n<span class=\"line-number\">13</span>});</code></pre>\n            </div>\n        </div>\n    </div>\n  \n<h3 id=\"步骤6：验证接入\"><a href=\"#%E6%AD%A5%E9%AA%A46%EF%BC%9A%E9%AA%8C%E8%AF%81%E6%8E%A5%E5%85%A5\" aria-label=\"步骤6：验证接入 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>步骤6：验证接入</h3>\n<p>重启 Codex 后发起一次对话，插件会在每个 turn 完成后触发。查看本地日志确认导出成功：</p>\n\n    <div class=\"code-block-wrapper\">\n        <div class=\"code-block\">\n            <div class=\"code-block-header\">\n                <span class=\"code-block-name\">Bash</span>\n                <button class=\"code-copy-btn\" data-tooltip-text=\"\">\n                    <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\"> <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M5.57894 3.45614C5.57894 3.38832 5.63392 3.33333 5.70175 3.33333H12.5439C12.6117 3.33333 12.6667 3.38832 12.6667 3.45614V10.2982C12.6667 10.3661 12.6117 10.4211 12.5439 10.4211H11.7544V5.70175C11.7544 4.89754 11.1025 4.24561 10.2982 4.24561H5.57894V3.45614ZM4.24561 4.24561V3.45614C4.24561 2.65194 4.89754 2 5.70175 2H12.5439C13.3481 2 14 2.65194 14 3.45614V10.2982C14 11.1025 13.3481 11.7544 12.5439 11.7544H11.7544V12.5439C11.7544 13.3481 11.1025 14 10.2982 14H3.45614C2.65194 14 2 13.3481 2 12.5439V5.70175C2 4.89754 2.65194 4.24561 3.45614 4.24561H4.24561ZM3.33333 5.70175C3.33333 5.63392 3.38832 5.57894 3.45614 5.57894H10.2982C10.3661 5.57894 10.4211 5.63392 10.4211 5.70175V12.5439C10.4211 12.6117 10.3661 12.6667 10.2982 12.6667H3.45614C3.38832 12.6667 3.33333 12.6117 3.33333 12.5439V5.70175Z\" fill=\"currentColor\"></path> </svg>\n                    复制\n                </button>\n            </div>\n            <div class=\"code-block-content\">\n                <pre class=\"language-bash\"><code><span class=\"line-number\">1</span>sqlite3 ~/.codex/logs_2.sqlite <span class=\"token string\">\"\n<span class=\"line-number\">2</span>SELECT ts, level, feedback_log_body\n<span class=\"line-number\">3</span>FROM logs\n<span class=\"line-number\">4</span>WHERE feedback_log_body LIKE '%ExportSucceeded%'\n<span class=\"line-number\">5</span>ORDER BY ts DESC LIMIT 5;\"</span></code></pre>\n            </div>\n        </div>\n    </div>\n  \n<p>看到 <code>HttpMetricsClient.ExportSucceeded</code> 或类似记录说明导出成功。\n然后到 <strong>LLM应用性能监控</strong> 搜索 <code>service.name = &#x3C;你设置的应用名></code> 查看 Trace 数据。由于数据的处理存在一定延时，如果接入后在控制台没有查询到应用，请等待 30 秒左右。</p>","fields":{"slug":"Mms8r66bk","title":"CodeX 通过 Langfuse 插件接入百度 LLM","date":"2026-08-03","extractedHeadings":[]},"headings":[{"value":"Codex 通过 Langfuse 插件接入百度 LLM","depth":2},{"value":"前提条件","depth":3},{"value":"步骤1：获取接入点与 Token","depth":3},{"value":"步骤2：安装 Langfuse 插件","depth":3},{"value":"步骤3：启用插件","depth":3},{"value":"步骤4：配置接入凭证","depth":3},{"value":"步骤5：设置 service.name 和 host.name（可选）","depth":3},{"value":"步骤6：验证接入","depth":3}]}},"pageContext":{"isCreatedByStatefulCreatePages":false,"slug":"Mms8r66bk","prev":{"id":"Vmoy30f2b","name":"APM与Grafana Tempo兼容","path":"Vmoy30f2b","filePath":"典型实践/APM和LLM最佳实践/APM与Grafana Tempo兼容.md","seo":null,"parentIds":["Okx7b5erv","Lmfz2ortv"],"parents":[{"id":"Okx7b5erv","documentId":"81554908-8e82-4013-8002-8672c96eb3cf","name":"典型实践","repoName":"BCM","filePath":"典型实践","disabled":false,"path":"Okx7b5erv","lastMergeTime":null,"isApiDoc":null,"httpMethod":null,"seo":null,"sourceOrgName":null,"sourceRepoName":null,"sourceDocumentId":null},{"id":"Lmfz2ortv","documentId":"09d2f373-be54-4061-8681-f91b6df2f07c","name":"APM和LLM最佳实践","repoName":"BCM","filePath":"典型实践/APM和LLM最佳实践","disabled":false,"path":"Lmfz2ortv","lastMergeTime":null,"isApiDoc":null,"httpMethod":null,"seo":null,"sourceOrgName":null,"sourceRepoName":null,"sourceDocumentId":null}]},"next":{"id":"Fme9l2djx","name":"服务等级协议SLA","path":"Fme9l2djx","filePath":"服务等级协议SLA/APM和LLM应用性能监控服务等级协议SLA.md","seo":null,"parentIds":["aldi7w3wd"],"parents":[{"id":"aldi7w3wd","documentId":"97a5b397-14e3-47a2-94d2-97bbe80870a9","name":"服务等级协议SLA","repoName":"BCM","filePath":"服务等级协议SLA","disabled":false,"path":"aldi7w3wd","lastMergeTime":null,"isApiDoc":null,"httpMethod":null,"seo":null,"sourceOrgName":null,"sourceRepoName":null,"sourceDocumentId":null}]},"parents":[{"id":"Okx7b5erv","documentId":"81554908-8e82-4013-8002-8672c96eb3cf","name":"典型实践","repoName":"BCM","filePath":"典型实践","disabled":false,"path":"Okx7b5erv","lastMergeTime":null,"isApiDoc":null,"httpMethod":null,"seo":null,"sourceOrgName":null,"sourceRepoName":null,"sourceDocumentId":null},{"id":"Lmfz2ortv","documentId":"09d2f373-be54-4061-8681-f91b6df2f07c","name":"APM和LLM最佳实践","repoName":"BCM","filePath":"典型实践/APM和LLM最佳实践","disabled":false,"path":"Lmfz2ortv","lastMergeTime":null,"isApiDoc":null,"httpMethod":null,"seo":null,"sourceOrgName":null,"sourceRepoName":null,"sourceDocumentId":null}],"specificSeo":null}}}