Skip to content

Loongsuite Go Agent provides an automatic solution for Golang applications that want to leverage OpenTelemetry to enable effective observability. No code changes are required in the target application, the instrumentation is done at compile time. Simply adding otel prefix to go build to get started 🚀

Installation

Prebuilt Binaries

  • Download
  • Download
  • Download
  • Download
  • Download

This is the recommended way to install the tool.

Install via Bash

For Linux and MacOS users, the following script will install otel in /usr/local/bin/otel by default:

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

Build from Source

bash
$ make         # build only
$ make install # build and install

Getting Started

Make sure the tool is installed:

bash
$ # You may use "otel-linux-amd64" instead of "otel"
$ otel version

Just adding otel prefix to go build to build your project:

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

That's the whole process! The tool will automatically instrument your code with OpenTelemetry, and you can start to observe your application. 🔭

The detailed usage of otel tool can be found in Usage.

NOTE

If you find any compilation failures while go build works, it's likely a bug. Please feel free to file a bug at GitHub Issues to help us enhance this project.

Examples

  • demo - End-to-end example with OpenTelemetry tracing and metrics
  • zap logging - Auto-instrumentation for github.com/uber-go/zap logging
  • benchmark - Performance testing and overhead measurement
  • sql injection - Custom code injection for SQL injection detection
  • nethttp - HTTP monitoring with request/response instrumentation
  • kratos-demo - Integration with the Kratos framework

Supported Libraries

List of Supported Libraries
LibraryRepository UrlMin VersionMax Version
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

We are progressively open-sourcing the libraries we have supported, and your contributions are Very Welcome

IMPORTANT

The framework you expected is not in the list? Don't worry, you can easily inject your code into any frameworks/libraries that are not officially supported.

Please refer to this document to get started.

Community

We are looking forward to your feedback and suggestions. You can join our DingTalk group to engage with us.

DingTalkStar History