用途:配置 OpenTelemetry Collector,通过 Sentry Exporter 将 traces 和 logs 发送到 Sentry,并支持多项目路由与自动创建项目。
主要能力:检查现有 Collector 配置与版本;安装 otelcol-contrib(要求 v0.145.0 或更高,支持二进制或 Docker);写入 Collector 配置;配置 Sentry 项目自动创建(auto_create_projects,按 service.name 创建,需至少一个团队,创建期间可能丢数据);添加环境变量占位符(SENTRY_ORG_SLUG、SENTRY_AUTH_TOKEN);校验并运行 Collector;验证 traces/logs 是否在 60 秒内出现在 Sentry;为 Python、Ruby、Node.js 启用 OTLPIntegration 实现 trace connectedness。
使用方式:按清单逐步执行。先查找含 receivers: 的 YAML 或 otel-collector-config.、collector-config.、otelcol.* 文件,询问用户是修改现有配置还是新建。检查 which otelcol-contrib 或 ./otelcol-contrib 版本。二进制安装示例:curl -LO https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v<numeric_version>/otelcol-contrib_<numeric_version><os><arch>.tar.gz,随后 tar -xzf 并 chmod +x。Docker 安装:docker pull otel/opentelemetry-collector-contrib:<numeric_version>。配置模板取自 Sentry Exporter 文档的 example-config.yaml,凭据使用 ${env:SENTRY_ORG_SLUG}、${env:SENTRY_AUTH_TOKEN}。校验:set -a && source "<env_file>" && set +a && "<collector_path>" validate --config "<config_file>"。运行二进制:set -a && source "<env_file>" && set +a && "<collector_path>" --config "<config_file>"。Docker 运行需挂载配置并映射 4317、4318、13133 端口。
适用场景:需要把 OTel 遥测接入 Sentry 的团队,尤其是多项目路由、自动建项目,以及希望 OTel traces 与 Sentry 错误、日志、cron、指标关联的 Python/Ruby/Node.js 应用。
限制:Sentry Exporter 需 otelcol-contrib v0.145.0 及以上;自动创建项目需 Project:Write 权限且组织内至少有一个团队,新项目归入首个团队;OTLPIntegration 目前仅支持 Python、Ruby、Node.js;Node.js 使用 otlpIntegration 时不要设置 tracesSampleRate;Docker 挂载需绝对路径;凭据需用户自行填写,工具只添加占位符。其他平台与更多高级选项暂未提供。