Collector Configuration

Customize the port, database path, and startup behavior of the collector.

Architecture

Agent (SDK)
POST /events
Collector
SSE /stream
Dashboard
Collector
SQLite

CLI flags

npx @useaop/collector start [options]
FlagDefaultDescription
--port4317Port to listen on for events, SSE stream, and dashboard
--db-path~/.aop/events.dbPath to the SQLite database file
--no-openopens browserDisable auto-opening the dashboard in the browser on start

Examples

# Run on a custom port
npx @useaop/collector start --port 9090

# Use a project-local database
npx @useaop/collector start --db-path ./aop-events.db

# Headless mode (no browser)
npx @useaop/collector start --no-open

# Combine options
npx @useaop/collector start --port 9090 --db-path ./data/aop.db --no-open

Programmatic usage

Import and call startCollector() to embed the collector in your own Node.js process:

import { startCollector } from '@useaop/collector'

const server = await startCollector({
  port: 4317,          // Port to listen on
  dbPath: '~/.aop/events.db',  // SQLite database path
  openBrowser: true    // Auto-open dashboard in browser
})

Options

OptionTypeDefaultDescription
portnumber4317Port to listen on
dbPathstring~/.aop/events.dbPath to the SQLite database file
openBrowserbooleantrueWhether to open the dashboard in the default browser on start

Server object

The returned server object exposes:

server.close()   // Gracefully shut down the collector
server.port      // The actual port the server is listening on
server.dbPath    // The resolved database path

Environment variables

You can also configure the collector via environment variables. CLI flags take precedence.

AOP_PORT=9090
AOP_DB_PATH=./my-events.db
AOP_NO_OPEN=true

Related