@keqin/adonis-sentry
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

Adonis-Sentry

Installation

npm i @keqin/adonis-sentry
node ace configure @keqin/adonis-sentry
  1. Set Env SENTRY_DSN=
  2. call Sentry.captureException in app/Exceptions/Handler.ts
  3. Add types for ENV in env.ts
SENTRY_DSN: Env.schema.string.optional({ format: 'url' }),
SENTRY_TRACES_SAMPLE_RATE: Env.schema.string.optional(),
SENTRY_DEBUG: Env.schema.boolean.optional(),

Test Sentry DSN

node ace sentry:ping

Performance monitoring

  • set a env variable SENTRY_TRACES_SAMPLE_RATE between 0 to 1 as tracesSampleRate. we suggest set it to 1 in dev/testing environment.

  • regisitry middleware in kernel.ts

    Server.middleware.register([
        () => import('@keqin/adonis-sentry/build/TracingHandler')
    ])

    it would startTransaction in a http request, and inject sentry/sentryTrx to ctx

  • Optional: create span in a request

import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'

export default class Controller {
    public async index({ sentry, sentryTrx }: HttpContextContract) {
        const span = sentryTrx.startChild({
            op: 'query',
            description: "more specific details"
        })
        // to do something
        span.finish()
    }
}

Example

import Sentry from '@ioc:Adonis/Addons/Sentry'

Sentry.captureMessage('Hello World')

Debug mode

set SENTRY_DEBUG as true to turn debug mode on

License

The MIT License

Readme

Keywords

none

Package Sidebar

Install

npm i @keqin/adonis-sentry

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

15.7 kB

Total Files

21

Last publish

Collaborators

  • keqin-tech
  • shiny
  • daijie