Skip to main content
Version: 2.8.x(Latest)

After gaining a preliminary understanding of the concept of OpenTelemetry, we will use Jaeger as an example to demonstrate how to implement tracing in a program.

Jaeger

Jaeger \ˈyā-gər\ is Uber's open-source distributed tracing system and one of the systems that support OpenTelemetry. It is also a CNCF project. In this article, we will use Jaeger to demonstrate how to introduce distributed tracing into a system. Below is the architecture diagram for Opentracing+Jaeger, which also applies to using OpenTelemetry.

Preparation

Jaeger offers an all-in-one image, which allows us to quickly start testing:

docker run --rm --name jaeger \
-e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 5778:5778 \
-p 16686:16686 \
-p 4317:4317 \
-p 4318:4318 \
-p 14250:14250 \
-p 14268:14268 \
-p 14269:14269 \
-p 9411:9411 \
jaegertracing/all-in-one:1.55

If pulling the docker image is too slow, you can try modifying the image address of the docker pull site, such as: http://mirrors.ustc.edu.cn/help/dockerhub.html?highlight=docker

After the image starts, you can open the Jaeger UI via http://localhost:16686.

Sample Code Address

Our sample code is in the gf main repository, located at: https://github.com/gogf/gf/tree/master/example/trace

Encapsulated Jaeger Registration (to be removed in version 2.6.0)

For developers' convenience, we have encapsulated the initialization logic for jaeger through a community module, code address: https://github.com/gogf/gf/tree/master/contrib/trace/jaeger

OTLP HTTP Encapsulation

For developers' convenience, we have encapsulated the initialization logic for otelhttp through a community module, code address: https://github.com/gogf/gf/tree/master/contrib/trace/otlphttp

OTLP GRPC Encapsulation

For developers' convenience, we have encapsulated the initialization logic for otelgrpc through a community module, code address: https://github.com/gogf/gf/tree/master/contrib/trace/otlpgrpc