@lanterna-profiler/detectors
v2.3.0
Published
Lanterna default detector pack — CPU, memory & experimental async detectors, thresholds, attribution helpers, plugin types
Readme
@lanterna-profiler/detectors
Default detector pack for Lanterna — agent-first Node.js CPU, memory & experimental async profiler.
This package contains the built-in CPU, memory, and async detectors, thresholds, attribution helpers, and kind factories that pre-wire those detectors. The CPU pack includes both pattern-specific rules (sync-crypto, blocking-io, json-on-hot-path, dependency hotspots, require-on-hot-path) and the generic cpu-hotspot:* fallback for plain user-code CPU that needs a concrete file/line or caller lead. Capture orchestration and KindScopedDetector itself live in @lanterna-profiler/core.
Install
npm install @lanterna-profiler/core @lanterna-profiler/detectorsUsage
import { runProfile } from '@lanterna-profiler/core';
import {
createCpuProfileKindWithBuiltInDetectors,
createMemoryProfileKindWithBuiltInDetectors,
} from '@lanterna-profiler/detectors';
const report = await runProfile({
command: ['node', 'app.js'],
durationMs: 30_000,
pretty: false,
kinds: [
createCpuProfileKindWithBuiltInDetectors({
readStderrSoFar: () => '',
sampleIntervalMicros: 1000,
deep: false,
}),
createMemoryProfileKindWithBuiltInDetectors({}),
],
});Documentation
- Writing a detector — plugin contract,
KindScopedDetector, attribution helpers, full Prisma example. - Writing a profile kind — author a brand-new measurement axis.
- Loading plugins —
--detectorsand.lanterna.json. - Built-in finding catalog — every detector grouped by kind.
Related packages
@lanterna-profiler/core— capture orchestration, profile kinds, pipeline, kind-scoped detector seam, and report APIs.@lanterna-profiler/cli—lanternabinary built on top of this package.
