Monitoring Errors Across Multiple Stacks with Sentry

Introduction

In the world of software, there’s a famous saying: “If you haven’t experienced an error, you haven’t written any code”. As our apps grow, so do their complexities and potential error points. This is where Sentry comes into play, an open-source error tracking tool that integrates with a variety of platforms. In this blog post, we’ll explore how to use Sentry for error monitoring with stack tracing for multiple parts of the stack – from PHP with Symfony to Javascript/Typescript in a Vue.js frontend and even Python.

 

What is Sentry ?

Sentry provides real-time error tracking for your applications, allowing you to identify, fix, and monitor issues in your codebase. With its rich stack tracing feature, you can drill down to the exact line of code that caused the issue, helping teams to swiftly diagnose and resolve problems.

 

Setting up Sentry

Whether you decide to use the cloud-based version or the on-premise solution (more on the difference below), Sentry’s setup process is straightforward.

Cloud Installation:

  1. Sign up on the Sentry website.
  2. After signing in, create a new project and select the platform you’re working on (e.g., PHP, Javascript, Python).

On-Premise Installation:

  1. Clone the Sentry On-Premise repository.
  2. Follow the detailed setup instructions from the README.

 

Integrating Sentry With Various Stacks

PHP with Symfony :

     1. Install the sentry/sentry-symfony package using composer:

				
					composer require sentry/sentry-symfony
				
			

     2. Add your DSN to the config/packages/sentry.yaml file:

				
					
sentry:
    dsn: "YOUR_DSN_HERE"
				
			

     3. Capture errors automatically! The bundle will hook into the Symfony error handler.

 

Javascript/Typescript (with vue.js as example) :

     1. Install the Sentry SDK via npm or yarn:

				
					npm install @sentry/browser @sentry/integrations
				
			

     2. Initialize Sentry at the beginning of your app:

				
					import Vue from 'vue';
import * as Sentry from '@sentry/browser';
import { Vue as VueIntegration } from '@sentry/integrations';

Sentry.init({
  dsn: "YOUR_DSN_HERE",
  integrations: [new VueIntegration({Vue, attachProps: true})],
});

				
			

     3. This captures both Vue and general Javascript errors.

Python :

     1. Install the Sentry SDK:

				
					pip install sentry-sdk
				
			

     2. Integrate Sentry with your application:

				
					import sentry_sdk

sentry_sdk.init(
    "YOUR_DSN_HERE"
)

				
			

Comparing Cloud vs On-Premise

Cloud:

  • Pros:
    • Quick setup
    • Automatic updates
    • Managed infrastructure (reducing operational overhead)
  • Cons:
    • Recurring costs based on event volume and retention
    • Less control over data (a concern for sensitive applications)

On-Premise:

  • Pros:
    • Full control over your data
    • More flexibility in terms of customization
    • One-time setup costs
  • Cons:
    • Requires dedicated infrastructure and maintenance
    • You’re responsible for updates and patches
    • Potential for higher initial costs (hardware, maintenance team)
 

What does it look like ?

A PHP stack trace :

 

Breadcrumbs of events :

Sending alerts, syncing, etc.

Sentry features a whole range of integrations, such as :

  • Jira integration to easily create tickets from events
  • Slack integration to post new events in specific channels (with each Sentry project in a separate channel)
  • Github and Gitlab for easy tracking of which commit or release caused which error
  • Well over 50 other integrations

 

How we use Sentry at Cu.be

We’ve been using Sentry for over 5 years across projects using PHP, Javascript, Python. Each project automatically alerts any new issues (or issues that mysteriously resurface) to Slack in the right channel, so developers and project managers are immediately aware.

Jira issues are created either from within Sentry or Slack and enter the backlog or (if critical) assigned to an engineer for handling.

On top of pure code based issues, we also use Sentry to create alerts on processes related to infrastructure, such as disk space slowly filling up, docker container issues, and so on.

Centralizing our monitoring is key to ensuring everyone is aware of what’s going on in production, staging and test environments which are all key to ensuring a successful software delivery.

 

Wrapping Up

Sentry is an invaluable tool for teams looking to improve their applications’ reliability and user experience. Whether you’re running a small project or a massive enterprise application, integrating Sentry can save countless hours of debugging, leading to quicker resolutions and happier users. The choice between cloud and on-premise installations depends largely on your team’s needs, resources, and data sensitivity concerns. Regardless of your choice, Sentry ensures that you’re always aware of, and prepared for, any hiccups in your application.

Picture of Wim Godden

Wim Godden

Tag Post :
Share This :

Are you looking for a reliable partner who understands you and your business?

No big words, endless planning or months of searching.