Docs
Core Concepts
Logging and Monitoring

Logging and Monitoring

Learn how Pylon enhances visibility into your application's performance and behavior with its integrated monitoring capabilities, ensuring smooth operations and rapid issue resolution.

Overview

Pylon integrates robust error monitoring capabilities to help you maintain and monitor your web services effectively. In this section, we'll explore how to set up error monitoring with Sentry.

Error Monitoring with Sentry

Pylon supports automatic integration with Sentry, a popular error tracking and monitoring service. To enable this integration, you need to set the SENTRY_DSN environment variable. Once this is configured, all logs and errors are automatically sent to your Sentry project.

Setting Up Sentry

  1. Get your Sentry DSN: Sign up for a Sentry account and create a new project. Obtain the DSN (Data Source Name) for your project.

  2. Set the SENTRY_DSN Environment Variable: Configure the SENTRY_DSN in your environment. This can typically be done in your project's environment configuration file or through your deployment pipeline.

SENTRY_DSN=https://[email protected]/project-id
  1. Deploy your Pylon service: With the SENTRY_DSN environment variable set, deploy your Pylon service. Logs and errors will now be automatically sent to Sentry.

Example

import {app} from '@getcronit/pylon'
 
export const graphql = {
  Mutation: {
    divide: (a: number, b: number) => {
      if (b === 0) {
        console.error('Attempt to divide by zero')
        throw new Error('Division by zero is not allowed')
      }
      console.info(`Dividing ${a} by ${b}`)
      return a / b
    }
  }
}
 
export default app

In this example, any errors or logs generated by the sum and divide operations will be captured and sent to Sentry if the SENTRY_DSN is configured.

Conclusion

By integrating Sentry for error monitoring, Pylon provides a comprehensive solution to track and manage the health and performance of your web services. Ensure that your SENTRY_DSN is set up correctly to take full advantage of these powerful tools, enabling you to maintain a robust and reliable application.

For more details, refer to the official documentation: