Monitor Labstack Echo with OpenTelemetry

Echo is a high performance, extensible, minimalist web framework for Go. It features a highly optimized HTTP router with zero dynamic memory allocations.

In this article you will learn how to monitor and optimize Echo performance using OpenTelemetry observability framework.

What is OpenTelemetry?

OpenTelemetryopen in new window is an open-source observability framework hosted by Cloud Native Computing Foundation. It is a merger of OpenCensus and OpenTracing projects.

OpenTelemetry aims to provide a single standard across all types of observability signals such as tracesopen in new window, logsopen in new window, and metricsopen in new window.

OpenTelemetry specifies how to collect and send telemetry data to backend platforms. With OpenTelemetry, you can instrument your application once and then add or change vendors without changing the instrumentation.

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

Installation

To install Echo OpenTelemetry instrumentation:

go get go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho

Usage

You can instrument Gin router by installing OpenTelemetry middleware:

import (
	"github.com/labstack/echo/v4"
	"go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho"
)

router := echo.New()
router.Use(otelecho.Middleware("service-name"))

What is Uptrace?

Need a backend to store telemetry data collected by OpenTelemetry instrumentations?

Uptrace is an open source APM for OpenTelemetry with an intuitive query builder, rich dashboards, automatic alerts, and integrations for most languages and frameworks.

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, instrument more operations, for example, database queries, errors, and logs. You can also learn about OpenTelemetry Go Tracing API to create your own instrumentations.

Popular instrumentations:

See also:

Last Updated: