Monitor Gin performance with OpenTelemetry

OpenTelemetry Gin allows developers to easily add observability to their Gin applications, providing insights into application performance, behavior, and usage patterns.

Gin is one of the fastest full-featured web frameworks for Go. Gin allows you to build web applications and microservices in Go.

OpenTelemetry Gin can help developers monitor and diagnose issues with their Gin applications, and can provide valuable insights into the behavior of the applications in production.

What is OpenTelemetry?

OpenTelemetryopen in new window is an open source and vendor-neutral API for OpenTelemetry tracingopen in new window (including logs and errors) and OpenTelemetry metricsopen in new window.

Otel specifies how to collect and export telemetry data in a vendor agnostic way. With OpenTelemetry, you can instrument your application once and then add or change vendors without changing the instrumentation, for example, many open source tracing toolsopen in new window already support OpenTelemetry.

OpenTelemetry is available for most programming languages and provides interoperability across different languages and environments.

Gin instrumentation

OpenTelemetry Gin is be easy to use and provides a simple API for instrumenting Gin applications, making it possible for developers to quickly add observability to their applications without having to write a lot of code.

To install otelgin instrumentation:

go get


You can instrument Gin router by installing OpenTelemetry middleware:

import (

router := gin.Default()

Instrumenting templates rendering

To instrument templates rendering, use otelgin.HTML helper:

import ""

func exampleHandler(c *gin.Context) {
	otelgin.HTML(c, http.StatusOK, indexTmpl, gin.H{
		"foo": "bar",

What is Uptrace?

Uptrace is an open source APMopen in new window for OpenTelemetry that helps developers pinpoint failures and find performance bottlenecks. Uptrace can process billions of spans on a single server and allows to monitor your software at 10x lower cost.

You can get startedopen in new window with Uptrace by downloading a DEB/RPM package or a pre-compiled Go binary.

What's next?

Next, instrumentopen in new window more operations, for example, database queries, errors, and logs. You can also learn about OpenTelemetry Go Tracing APIopen in new window to create your own instrumentations.

Popular instrumentations:

See also:

Last Updated: