How to use @adonisjs/profiler - 5 common examples

To help you get started, we’ve selected a few @adonisjs/profiler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adonisjs / adonis-framework / test / exception-handler.spec.ts View on Github external
test('ignore http status inside the ignore list', (assert) => {
    class AppHandler extends HttpExceptionHandler {
      protected ignoreStatuses = [500]
      protected dontReport = []
    }

    const logger = new FakeLogger(loggerConfig)
    const handler = new AppHandler(logger)

    const ctx = HttpContext.create('/', {}, logger, new Profiler({}).create(''), encryption)
    handler.report(new Exception('bad request', 500, 'E_BAD_REQUEST'), ctx)

    assert.deepEqual(logger.logs, [])
  })
github adonisjs / adonis-lucid / test / orm / base-model-options.spec.ts View on Github external
test('pass profiler to the client when defined explicitly', async (assert) => {
    class User extends BaseModel {
      public static $table = 'users'

      @column({ primary: true })
      public id: number

      @column()
      public username: string
    }

    await db.insertQuery().table('users').insert({ username: 'virk' })
    const profiler = new Profiler({})

    const user = await User.query({ profiler }).first()
    assert.equal(user!.$options!.connection, 'primary')
    assert.deepEqual(user!.$options!.profiler, profiler)
  })
github adonisjs / adonis-lucid / test-helpers / index.ts View on Github external
export function getProfiler () {
  return new Profiler({ enabled: false })
}
github adonisjs / adonis-framework / test / cors.spec.ts View on Github external
const server = createServer(async (req, res) => {
        const cors = new Cors(fixture.configureOptions())
        const logger = new Logger({ name: 'adonis', enabled: false, level: 'trace' })

        fixture.configureRequest(req)
        const ctx = HttpContext.create('/', {}, logger, new Profiler({}).create(''), encryption, req, res)
        await cors.handle(ctx)

        if (!ctx.response.hasLazyBody) {
          ctx.response.send(null)
        }

        ctx.response.finish()
      })
github adonisjs / adonis-framework / packages / core / src / Ignitor / index.ts View on Github external
private _instantiateProfiler () {
    const profiler = new Profiler(this._getProfilerConfig())
    this.ioc.singleton('Adonis/Src/Profiler', () => profiler)
    this.ioc.alias('Adonis/Src/Profiler', 'Profiler')

    /**
     * Attach subscriber if exists
     */
    if (this._profilerSubscriber) {
      profiler.subscribe(this._profilerSubscriber)
    }

    this._bootstrapper = profiler.create('bootstrap', { intent: this._intent })
  }

@adonisjs/profiler

Profiler to time function calls in AdonisJs with context

MIT
Latest version published 3 years ago

Package Health Score

57 / 100
Full package analysis