← Back to Plugins
Tools

Open Claw Langsmith Trace

PosysBabi By PosysBabi ⭐ 1 stars 👁 5 views ▲ 0 votes

a langsmith trace intergrate plugin for OpenClaw

GitHub

Install

npm install --production

Configuration Example

{
  "plugins": {
    "entries": {
      "openclaw-langsmith-trace": {
        "enabled": true,
        "config": {
          "apiKey": "ls__your_api_key_here",
          "projectName": "your-project-name"
        }
      }
    }
  }
}

README

# OpenClaw LangSmith Trace Plugin

这是一个 OpenClaw 插件,用于通过 OpenTelemetry 协议将 OpenClaw 的执行链路(Traces)上报到 [LangSmith](https://smith.langchain.com/) 观测平台。

## 功能特性

- **自动链路追踪**:自动捕获 OpenClaw 的生命周期事件(网关启动、会话开始/结束、消息收发、LLM 调用、工具调用、Agent 执行等)。
- **LangSmith 集成**:原生支持 LangSmith OTLP 协议,无需额外部署 Collector。
- **配置灵活**:支持自定义项目名称、服务名称及上报频率。

## 安装与配置

### 步骤一:安装插件

```bash
# 克隆项目
git clone https://github.com/PosysBabi/open-claw-langsmith-trace.git
cd open-claw-langsmith-trace

# 安装运行时依赖 (这一步会生成 node_modules)
npm install --production

# 创建 OpenClaw 插件目录 (如果不存在)
mkdir -p ~/.openclaw/extensions/openclaw-langsmith-trace

# 复制插件文件和依赖项到 OpenClaw 扩展目录
cp -r dist/* ~/.openclaw/extensions/openclaw-langsmith-trace/
cp -r node_modules ~/.openclaw/extensions/openclaw-langsmith-trace/
```

### 步骤二:配置插件

编辑您的 OpenClaw 配置文件 `~/.openclaw/openclaw.json`,在 `plugins.entries` 部分添加或修改插件配置。

```json
{
  "plugins": {
    "entries": {
      "openclaw-langsmith-trace": {
        "enabled": true,
        "config": {
          "apiKey": "ls__your_api_key_here",
          "projectName": "your-project-name"
        }
      }
    }
  }
}
```

### 步骤三:重启生效

配置完成后,重启网关以应用插件和配置:
```bash
openclaw gateway restart
```
您可以通过 `openclaw plugins list` 命令查看插件状态,确保 `openclaw-langsmith-trace` 已成功加载 (loaded)。

## 配置项详解

| 配置项 | 类型 | 必填 | 默认值 | 说明 |
| :--- | :--- | :--- | :--- | :--- |
| `apiKey` | string | **是** | - | LangSmith API Key (通常以 `ls__` 开头) |
| `projectName` | string | 否 | `openclaw-project` | LangSmith 中的项目名称,数据将上报到该项目 |
| `endpoint` | string | 否 | (见说明) | OTLP 上报地址。**默认使用公网地址 `https://api.smith.langchain.com/v1/otel/v1/traces`**,通常无需配置此项。 |
| `serviceName` | string | 否 | `openclaw-agent` | 标识服务的名称 |
| `debug` | boolean | 否 | `false` | 是否开启调试日志,开启后会在控制台打印详细的 Span 信息 |
| `batchSize` | number | 否 | `10` | 批量上报的 Span 数量阈值 |
| `batchInterval` | number | 否 | `5000` | 批量上报的时间间隔(毫秒) |
| `enabledHooks` | array | 否 | (全部启用) | 指定需要监听的钩子列表,如 `["session_start", "llm_output"]` |

## 获取 LangSmith API Key

1. 登录 [LangSmith](https://smith.langchain.com/)。
2. 进入 Settings -> API Keys。
3. 点击 "Create API Key" 生成新的 Key。

## 本地开发与构建

```bash
# 安装依赖
npm install

# 构建项目
npm run build

# 监听模式构建
npm run dev
```

tools

Comments

Sign in to leave a comment

Loading comments...