SuperAPI AI 工具集

sentry-otel-exporter-setup

部署与运维

查看项目

更新于 10-15 21:51

技能介绍

用途:配置 OpenTelemetry Collector,通过 Sentry Exporter 把 traces 和 logs 发送到 Sentry,并支持多项目路由与自动创建项目。

主要能力:检查并复用已有 Collector 配置;校验 Collector 版本(Sentry Exporter 需 otelcol-contrib v0.145.0 或更高);以二进制或 Docker 方式安装运行;写入 Collector 配置并加入 Sentry Exporter;可选开启 auto_create_projects(按 service.name 创建项目,需组织内至少有一个 team,新项目归入找到的第一个 team,创建期间初始数据可能被丢弃);可加 debug exporter 排查问题;验证配置并检查日志与 Sentry 中是否出现遥测数据。

使用方式:按清单逐步执行。先查找含 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 的服务;使用 Python、Ruby 或 Node.js Sentry SDK 时,可启用 OTLPIntegration 实现 trace connectedness,例如 Python 安装 pip install "sentry-sdk[opentelemetry-otlp]",collector_url 默认 http://localhost:4318/v1/traces。

限制:自动创建项目需 Project:Write 权限与已有 team;token 须为 Internal Integration token;Docker 挂载需绝对路径;使用 otlpIntegration 时不要设置 tracesSampleRate;OTLPIntegration 目前仅支持 Python、Ruby、Node.js。