DEV Community

Cover image for OpenTelemetry Beego monitoring [otelbeego]
Alexandr Bandurchin for Uptrace

Posted on • Originally published at uptrace.dev

OpenTelemetry Beego monitoring [otelbeego]

OpenTelemetry Beego is an OpenTelemetry instrumentation for the Beego web framework, a popular open-source web framework for building web applications in Go.

This article will teach you how to monitor Beego performance using OpenTelemetry observability framework.

What is Beego?

Beego is an open source web framework written in Go. It follows the Model-View-Controller (MVC) architectural pattern and provides a set of tools and features for rapidly building web applications and APIs. Beego focuses on simplicity, scalability, and modularity.

What is OpenTelemetry?

OpenTelemetry is an open-source observability framework that aims to standardize and simplify the collection, processing, and export of telemetry data from applications and systems.

OpenTelemetry supports multiple programming languages and platforms, making it suitable for a wide range of applications and environments.

OpenTelemetry enables developers to instrument their code and collect telemetry data, which can then be exported to various OpenTelemetry backends or observability platforms for analysis and visualization. The OpenTelemetry Collector acts as a central component for receiving, processing, and exporting telemetry data, providing advanced capabilities like batching, filtering, and routing.

OpenTelemetry Beego

OpenTelemetry Beego allows developers to monitor the performance and behavior of their Beego applications, providing insights into application usage patterns, resource utilization, and performance bottlenecks.

To install otelbeego OpenTelemetry instrumentation:

go get go.opentelemetry.io/contrib/instrumentation/github.com/astaxie/beego/otelbeego
Enter fullscreen mode Exit fullscreen mode

Usage

To integrate OpenTelemetry with Beego, you can use the OpenTelemetry Go SDK to instrument your Beego application and collect telemetry data. By adding OpenTelemetry instrumentation to your application, you can collect distributed traces, metrics, and logs, adding observability to your Beego-based web application.

You can instrument Beego by installing with OpenTelemetry middleware:

import (
    "github.com/astaxie/beego"
    "go.opentelemetry.io/contrib/instrumentation/github.com/astaxie/beego/otelbeego"
)

mware := otelbeego.NewOTelBeegoMiddleWare("service-name")
beego.RunWithMiddleWares(":7777", mware)
Enter fullscreen mode Exit fullscreen mode

Instrumenting templates rendering

To instrument templates rendering, disable autorender and use helpers from otelbeego package:

import "go.opentelemetry.io/contrib/instrumentation/github.com/astaxie/beego/otelbeego"

beego.BConfig.WebConfig.AutoRender = false

err := otelbeego.Render(&c.Controller)
Enter fullscreen mode Exit fullscreen mode

See the example and the reference:

What is Uptrace?

Uptrace is an open source APM for OpenTelemetry that supports distributed tracing, metrics, and logs. You can use it to monitor applications and troubleshoot issues. For more details, see the OpenTelemetry Go guide and compare with top APM tools.

Uptrace Overview

Uptrace comes with an intuitive query builder, rich dashboards, alerting rules, notifications, and integrations for most languages and frameworks.

Uptrace can process billions of spans and metrics on a single server and allows you to monitor your applications at 10x lower cost.

In just a few minutes, you can try Uptrace by visiting the cloud demo (no login required) or running it locally with Docker. The source code is available on GitHub.

What's next?

By using OpenTelemetry with Beego, you can leverage the capabilities of both frameworks to build scalable, observable, and high-performance web applications.

Next, instrument more operations to get a more detailed picture. Try to prioritize network calls, disk operations, database queries, errors, and logs.

You can also create your own instrumentations using OpenTelemetry Go Tracing API.

Top comments (0)