Skip to content

龙蜥Go-Agent 为希望利用OpenTelemetry实现有效可观察性的Golang应用程序提供了一个自动化的解决方案。目标应用程序无需更改代码,埋点在编译时完成。只需在go build前加上otel前缀即可开始使用 🚀

安装

预编译二进制文件

  • 下载
  • 下载
  • 下载
  • 下载
  • 下载

这是安装该工具的推荐方法。

通过Bash安装

对于Linux和MacOS用户,以下脚本默认会将otel安装在/usr/local/bin/otel

bash
$ sudo curl -fsSL https://cdn.jsdelivr.net/gh/alibaba/loongsuite-go-agent@main/install.sh | sudo bash

从源码构建

bash
$ make         # 仅构建
$ make install # 构建并安装

快速开始

确保工具已安装:

bash
$ # 你也可以使用 "otel-linux-amd64" 代替 "otel"
$ otel version

只需在go build前加上otel前缀来构建你的项目:

bash
$ otel go build
$ otel go build -o app cmd/app
$ otel go build -gcflags="-m" cmd/app

整个过程就是这样!该工具将自动为你的代码注入OpenTelemetry,你就可以开始观察你的应用程序了。 🔭

otel工具的详细用法可以在用法中找到。

NOTE

如果你在go build能正常工作的情况下发现任何编译失败,这很可能是一个bug。 请随时在GitHub Issues上提交一个bug 来帮助我们改进这个项目。

示例

  • demo - 带有OpenTelemetry追踪和指标的端到端示例
  • zap logging - github.com/uber-go/zap日志记录的自动埋点
  • benchmark - 性能测试和开销测量
  • sql injection - 用于SQL注入检测的自定义代码注入
  • nethttp - 带有请求/响应埋点的HTTP监控
  • kratos-demo - 与Kratos框架的集成

支持的库

支持的库列表
仓库地址最低版本最高版本
database/sqlhttps://pkg.go.dev/database/sql--
dubbo-gohttps://github.com/apache/dubbo-gov3.3.0-
echohttps://github.com/labstack/echov4.0.0v4.12.0
einohttps://github.com/cloudwego/einov0.3.51-
elasticsearchhttps://github.com/elastic/go-elasticsearchv8.4.0v8.15.0
fasthttphttps://github.com/valyala/fasthttpv1.45.0v1.63.0
fiberhttps://github.com/gofiber/fiberv2.43.0v2.52.8
ginhttps://github.com/gin-gonic/ginv1.7.0v1.10.0
go-redishttps://github.com/redis/go-redisv9.0.5v9.5.1
go-redis v8https://github.com/redis/go-redisv8.11.0v8.11.5
gomicrohttps://github.com/micro/go-microv5.0.0v5.3.0
gorestfulhttps://github.com/emicklei/go-restfulv3.7.0v3.12.1
gormhttps://github.com/go-gorm/gormv1.22.0v1.25.9
grpchttps://google.golang.org/grpcv1.44.0-
hertzhttps://github.com/cloudwego/hertzv0.8.0-
irishttps://github.com/kataras/irisv12.2.0v12.2.11
client-gohttps://github.com/kubernetes/client-gov0.33.3-
kitexhttps://github.com/cloudwego/kitexv0.5.1v0.11.3
kratoshttps://github.com/go-kratos/kratosv2.6.3v2.8.4
langchaingohttps://github.com/tmc/langchaingov0.1.13v0.1.13
loghttps://pkg.go.dev/log--
logrushttps://github.com/sirupsen/logrusv1.5.0v1.9.3
mongodbhttps://github.com/mongodb/mongo-go-driverv1.11.1v1.15.1
muxhttps://github.com/gorilla/muxv1.3.0v1.8.1
nacoshttps://github.com/nacos-group/nacos-sdk-go/v2v2.0.0v2.2.7
net/httphttps://pkg.go.dev/net/http--
ollamahttps://github.com/ollama/ollamav0.3.14-
redigohttps://github.com/gomodule/redigov1.9.0v1.9.2
sentinelhttps://github.com/alibaba/sentinel-golangv1.0.4-
sloghttps://pkg.go.dev/log/slog--
trpc-gohttps://github.com/trpc-group/trpc-gov1.0.0v1.0.3
zaphttps://github.com/uber-go/zapv1.20.0v1.27.0
zerologhttps://github.com/rs/zerologv1.10.0v1.33.0
go-kit/loghttps://github.com/go-kit/logv0.1.0v0.2.1
pghttps://github.com/go-pg/pgv1.10.0v1.14.0
gocqlhttps://github.com/gocql/gocqlv1.3.0v1.7.0
sqlxhttps://github.com/jmoiron/sqlxv1.3.0v1.4.0

我们正在逐步开源我们支持的库,非常欢迎您的贡献。

IMPORTANT

你期望的框架不在列表中?别担心,你可以轻松地将你的代码注入任何未正式支持的框架/库。

请参考此文档开始。

社区

我们期待您的反馈和建议。您可以加入我们的钉钉群与我们交流。

钉钉Star历史