Join us
@uptrace ・ Dec 23,2022 ・ 2 min read ・ 1947 views ・ Originally posted on uptrace.dev
Still using Jaeger/Sentry? Uptrace is an OpenTelemetry tracing tool that stores data in extremely efficient ClickHouse database and provides powerful filtering and grouping.
OpenTelemetry is a vendor-neutral API for distributed traces and metrics. You can use OpenTelemetry to collect traces, errors, and logs. Uptrace stores that data, aggregates and processes it to help you pinpoint failures and find performance bottlenecks.
Uptrace is an open source and blazingly fast distributed tracing tool powered by OpenTelemetry and ClickHouse. It is a popular alternative to Jaeger and can be installed by downloading a DEB/RPM package or a pre-compiled binary.
OpenTelemetry Tracing allows you to see how a request progresses through different services and components, timings of every operation, any logs and errors as they occur. In a distributed environment, tracing also helps you understand relationships and interactions between distributed micro-services and systems.
Using tracing, you can break down requests into spans. Span is an operation (unit of work) your app performs handling a request, for example, a database query or a
network call.
Trace is a tree of spans that shows the path that a request makes through an app. Root span is the first span in a trace.
To learn more about tracing, see Distributed tracing using OpenTelemetry.
You can create spans using OpenTelemetry Go API like this:
In this tutorial, you will be instrumenting a toy app that uses Gin router and GORM database client. You can retrieve the source code with the following command:
Uptrace provides OpenTelemetry Go distro that configures OpenTelemetry SDK for you. To install the distro:
Then you need to initialize the distro whenever you app is started:
See OpenTelemetry Go for details.
You can instrument Gin router using otelgin instrumentation provided by OpenTelemetry:
otelgin instrumentation will save the active span in the Go context.Context
. You can retrieve the context from the http.Request
, extract the span from it, and use the span to record attributes:
After the database is instrumented, you should use WithContext
method to propagate the active trace context:
You can also record log messages using otelzap instrumentation for Zap logging library:
And then start the app passing Uptrace DSN as an env variable:
The app should be serving requests on http://localhost:9999
and should render a link to Uptrace UI. After opening the link, you should see this:
Next, you can learn about OpenTelemetry Go Tracing to create your own instrumentations or browse existing OpenTelemetry instrumentations provided by the community.
Popular Go instrumentations:
Join other developers and claim your FAUN account now!
Influence
Total Hits
Posts
Only registered users can post comments. Please, login or signup.