npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@monocle.sh/adonisjs-agent

v1.0.0

Published

Monocle agent for AdonisJS - sends telemetry to Monocle cloud

Readme

@monocle.sh/adonisjs-agent

Monocle agent for AdonisJS - sends telemetry to Monocle cloud.

Installation

npm install @monocle.sh/adonisjs-agent
# or
yarn add @monocle.sh/adonisjs-agent
# or
pnpm add @monocle.sh/adonisjs-agent

Configuration

Run the configure command to set up the agent automatically:

node ace configure @monocle.sh/adonisjs-agent

This will:

  1. Create config/monocle.ts configuration file
  2. Create otel.ts initialization file at project root
  3. Add the otel.ts import as the first import in bin/server.ts
  4. Register the Monocle provider in adonisrc.ts
  5. Register the Monocle middleware as the first router middleware
  6. Add required environment variables to .env and start/env.ts

After configuration, add your API key to .env:

MONOCLE_API_KEY=mk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

User Identification

To associate telemetry data with authenticated users, add Monocle.setUser() in your authentication middleware:

import type { NextFn } from '@adonisjs/core/types/http'
import type { HttpContext } from '@adonisjs/core/http'
import { Monocle } from '@monocle.sh/adonisjs-agent'

export default class SilentAuthMiddleware {
  async handle(ctx: HttpContext, next: NextFn) {
    await ctx.auth.check()

    if (ctx.auth.user) Monocle.setUser(ctx.auth.user)

    return next()
  }
}

Exception Tracking

Exceptions are automatically recorded in spans when thrown during a request. The agent hooks into AdonisJS's ExceptionHandler.report() method to capture exceptions with their stack traces.

If you want to manually capture exceptions in custom code:

import { Monocle } from '@monocle.sh/adonisjs-agent'

try {
  // your code
} catch (error) {
  Monocle.captureException(error, {
    user: { id: '123', email: '[email protected]' },
    tags: { component: 'payment' },
    extra: { orderId: 456 },
  })
  throw error
}

Configuration Options

The config/monocle.ts file supports the following options:

import { defineConfig, destinations } from '@monocle.sh/adonisjs-agent'
import env from '#start/env'

export default defineConfig({
  // Optional: Your Monocle API key
  apiKey: env.get('MONOCLE_API_KEY'),

  // Optional: Custom ingestion endpoint (for development)
  // endpoint: 'http://localhost:4318',

  // Service identification
  serviceName: env.get('APP_NAME'),
  serviceVersion: env.get('APP_VERSION'),
  environment: env.get('APP_ENV'),

  // Additional OTLP destinations (Monocle is always injected automatically)
  destinations: {
    grafana: destinations.otlp({
      endpoint: env.get('GRAFANA_OTLP_ENDPOINT'),
      signals: 'all',
    }),
  },

  // Host metrics (CPU, Memory, Network, etc.)
  // Set to false to disable
  hostMetrics: {
    enabled: true,
  },

  // CLI command tracing
  cli: {
    enabled: false,
    exclude: ['make:*', 'generate:*', 'queue:work', 'queue:listen'],
  },

  // Trace/log batching configuration for Monocle destination
  batch: {
    maxExportBatchSize: 512,
    scheduledDelayMillis: 5000,
  },

  // Enable gzip compression for Monocle destination (default: true)
  compression: true,
})

Environment Variables

| Variable | Description | Required | | ----------------- | ------------------------------------------------------ | -------- | | MONOCLE_API_KEY | Your Monocle API key | No | | APP_NAME | Service name for identification | Yes | | APP_VERSION | Service version (e.g., git sha, semver) | Yes | | APP_ENV | Environment: development, staging, or production | Yes |

License

ISC