Skip to main content
Version: 6.x (latest)

N|Solid JS API

The N|Solid Agent exposes a JavaScript API that you can use to trigger its observability features from your code or extend them with additional information. This page is a reference for every method and property of the nsolid module.

You don't need the API for normal operation: N|Solid works without any changes to your application.

The nsolid module is a singleton, so you get the same reference to the N|Solid Agent wherever you require it:

const nsolid = require('nsolid')
info

Assets such as CPU profiles, heap profiles, heap samples, and heap snapshots that you trigger from the API are sent to the N|Solid Console. If grpc or saas is configured, they are sent over gRPC; otherwise they are sent over the ZeroMQ (command) connection.


nsolid.start()​

Starts and configures the N|Solid Agent. For example, if a configuration management system or database knows the address of your Console, you can look it up and then call nsolid.start() to connect and begin reporting metrics. You can start the agent at any time.

The keys are the same as the package.json nsolid configuration keys (see the configuration reference), with one difference:

  • The application version is specified as appVersion.
nsolid.start({
command: 'nsolid-command-host.local:9001',
tags: ['experiment-4a', 'Auth service'],
app: 'nsolid-awesome',
appVersion: '1.0.0'
})

nsolid.start() returns the nsolid object. If the agent is already running, the keys you pass are merged into its current configuration.

note

Call nsolid.start() from the main thread. In worker threads it does nothing.


nsolid.appName / nsolid.app​

Gets the N|Solid app name. The two properties are aliases.

> nsolid.appName
'nsolid-awesome'
> nsolid.app
'nsolid-awesome'

nsolid.appVersion​

Gets the application version string, if it's defined in package.json or passed to nsolid.start().

> nsolid.appVersion
'1.0.0'

nsolid.assetsEnabled​

Whether the agent currently allows collecting assets (CPU profiles, heap profiles, heap samples, and heap snapshots). Defaults to true. You can control it with NSOLID_ASSETS_ENABLED, the assetsEnabled key in package.json or nsolid.start(), nsolid.enableAssets() and nsolid.disableAssets(), or remotely from the N|Solid Console.

> nsolid.assetsEnabled
true

nsolid.clearFatalError()​

Clears an error previously stored with nsolid.saveFatalError().

process.on('uncaughtException', (err) => {
nsolid.clearFatalError()
nsolid.saveFatalError(err)
shutdownApp(() => process.exit(1))
})

nsolid.config​

Gets the N|Solid configuration as loaded by the agent. The configuration can change at runtime, either when you call nsolid.start() again with new settings or when a connected N|Solid Console sends a configuration change.

> nsolid.config
{
app: 'docs',
appVersion: '1.0.0',
assetsEnabled: true,
blockedLoopThreshold: 200,
contCpuProfile: false,
contCpuProfileInterval: 30000,
disablePackageScan: false,
env: 'prod',
hostname: 'my-host',
iisNode: false,
interval: 5000,
pauseMetrics: false,
promiseTracking: false,
pubkey: ' ... ',
statsdBucket: 'nsolid.${env}.${app}.${hostname}.${shortId}',
tags: [ 'beta-service', 'experiment-4a' ],
traceSampleRate: 1,
tracingEnabled: false,
tracingModulesBlacklist: 0,
trackGlobalPackages: false
}

Settings that aren't configured (such as command or statsd) don't appear in the object.


nsolid.enableAssets() / nsolid.disableAssets()​

Enables or disables asset collection at runtime. While assets are disabled, calls such as nsolid.profile(), nsolid.heapProfile(), nsolid.heapSampling(), nsolid.snapshot(), nsolid.heapProfileStream(), and nsolid.heapSamplingStream() fail, and continuous CPU profiling stops.

nsolid.disableAssets()
nsolid.assetsEnabled // false
nsolid.enableAssets()
nsolid.assetsEnabled // true

nsolid.enableTraces() / nsolid.disableTraces()​

Turns span generation on or off at runtime. This is equivalent to setting tracingEnabled with nsolid.start().

nsolid.enableTraces()
nsolid.tracingEnabled // true
nsolid.disableTraces()
nsolid.tracingEnabled // false

nsolid.getThreadName()​

Gets the name of the current thread, as set with nsolid.setThreadName(). Thread names label worker threads in the N|Solid Console for easier identification, and all metrics payloads include the name if it's set.

const { Worker, isMainThread } = require('node:worker_threads')
const { getThreadName, setThreadName } = require('nsolid')

if (!isMainThread) {
console.log(getThreadName()) // ''
setThreadName('worker-parser')
console.log(getThreadName()) // worker-parser
setTimeout(() => {}, 1000)
} else {
const worker = new Worker(__filename)
}

nsolid.heapProfile([duration][, trackAllocations][, callback])​

Starts a heap profile of the current thread. When it finishes, the profile is sent to the N|Solid Console. Read more in Memory leaks.

  • duration: duration in milliseconds. Defaults to 600000 (10 minutes).
  • trackAllocations: true to enable allocation tracking. Defaults to false.
  • callback: called with an error if the profile couldn't be started. If you don't supply a callback, the error is thrown.
// Two-minute heap profile with allocation tracking
nsolid.heapProfile(120000, true, (err) => {
if (err) {
console.error('The heap profile could not be started', err)
}
})

nsolid.heapProfileEnd([callback])​

Stops an ongoing heap profile on this thread before its duration ends. The callback receives an error if there was no active heap profile to stop. If you don't supply a callback, the error is thrown. The resulting heap profile is still sent to the N|Solid Console.

nsolid.heapProfileEnd((err) => {
if (err) {
console.error('No heap profile to stop')
}
})

nsolid.heapProfileStream(threadId, duration, trackAllocations)​

Collects a heap profile from any thread and returns it to your application as a readable stream, without sending it to the N|Solid Console. Use it to save heap profiles locally. See more about heap profiling in Memory leaks.

  • threadId: the integer ID of the thread to profile. The main thread is 0, and you must pass it even if there are no worker threads.
  • duration: duration in milliseconds.
  • trackAllocations: true to enable allocation tracking.
let profile = ''
const profileStream = nsolid.heapProfileStream(0, 20000, true)
profileStream.on('data', (data) => {
profile += data
})
profileStream.on('end', () => {
// `profile` now holds the JSON contents of the heap profile
})
profileStream.on('error', (err) => {
console.error('Heap profile failed', err)
})

If assets are disabled (assetsEnabled is false), heapProfileStream() throws ERR_NSOLID_HEAP_PROFILE_START immediately. Errors after the profile starts are emitted as 'error' events on the stream. If redactSnapshots is enabled, string values are redacted from the profile.


nsolid.heapSampling([duration][, options][, callback])​

Starts a sampling heap profile of the current thread and sends it to the N|Solid Console. Sampling is a lighter-weight heap profile: it provides higher-level statistics with less impact on your application.

  • duration: duration in milliseconds. Defaults to 600000 (10 minutes).
  • options: an object that controls how sampling is performed:
    • sampleInterval (default 512 * 1024): the heap is sampled every sampleInterval bytes. Use a smaller number for higher resolution but more overhead.
    • stackDepth (default 16): the maximum stack depth to capture for each sampled allocation.
    • flags (default 0): V8 sampling flags that enable additional collection options. The flags can be combined:
      • Force garbage collection
      • Include objects collected during a major GC
      • Include objects collected during a minor GC
  • callback: called with an error if sampling couldn't be started. If you don't supply a callback, the error is thrown.

The flags are bit flags. Here is one way to use them:

const SamplingFlags = {
noFlags: 0,
forceGC: 1 << 0,
includeObjectsCollectedByMajorGC: 1 << 1,
includeObjectsCollectedByMinorGC: 1 << 2,
}

const myFlags = SamplingFlags.forceGC | SamplingFlags.includeObjectsCollectedByMajorGC

nsolid.heapSampling(20000, { flags: myFlags })

nsolid.heapSamplingEnd([callback])​

Stops ongoing heap sampling on this thread before its duration ends. The callback receives an error if there was no active heap sampling to stop. If you don't supply a callback, the error is thrown. The resulting heap sample is still sent to the N|Solid Console.

nsolid.heapSamplingEnd((err) => {
if (err) {
console.error('No heap sampling to stop')
}
})

nsolid.heapSamplingStream(threadId, duration[, options])​

Collects a sampling heap profile from any thread and returns it to your application as a readable stream, without sending it to the N|Solid Console. Use it to save heap samples locally. See more about heap sampling in Memory leaks.

  • threadId: the integer ID of the thread to sample. The main thread is 0, and you must pass it even if there are no worker threads.
  • duration: duration in milliseconds (at least 1).
  • options: an optional object with the same fields as nsolid.heapSampling() (sampleInterval, stackDepth, flags).
let profile = ''
const profileStream = nsolid.heapSamplingStream(0, 20000, {})
profileStream.on('data', (data) => {
profile += data
})
profileStream.on('end', () => {
// `profile` now holds the JSON contents of the heap sample
})
profileStream.on('error', (err) => {
console.error('Heap sampling failed', err)
})

If assets are disabled, heapSamplingStream() throws ERR_NSOLID_HEAP_SAMPLING_START immediately. Errors after sampling starts are emitted as 'error' events on the stream.


nsolid.id​

Gets the N|Solid agent ID. N|Solid treats it as a unique identifier for this process.

> nsolid.id
'9964df10bd45350092a8064727ea4c009bee1d91'

nsolid.info()​

Returns identifying and static information about the process, host machine, and platform.

> nsolid.info()
{
app: 'docs',
appVersion: '1.0.0',
arch: 'x64',
cpuCores: 12,
cpuModel: 'AMD Ryzen 5 2600 Six-Core Processor',
execPath: '/usr/bin/nsolid',
hostname: 'my-host',
id: '797d1fa9fafd62002af42f919ab79900a455150d',
kernelVersion: 394240,
main: '/home/user/my-app/index.js',
nodeEnv: 'prod',
pid: 422446,
platform: 'linux',
processStart: 1716511183845,
tags: [ 'beta-service', 'experiment-4a' ],
totalMem: 8295538688,
versions: {
acorn: '8.16.0',
ada: '3.4.4',
amaro: '1.1.8',
ares: '1.34.6',
brotli: '1.2.0',
cldr: '48.0',
curl: '8.18.0',
grpc: '1.76.0',
icu: '78.2',
llhttp: '9.3.1',
merve: '1.2.2',
modules: '137',
napi: '10',
nbytes: '0.1.3',
ncrypto: '0.0.1',
nghttp2: '1.68.0',
nlohmann: '3.12.0',
node: '24.15.0',
nsolid: '6.2.4',
openssl: '3.5.5',
opentelemetry: '1.23.0',
protobuf: '6.33.2',
simdjson: '4.5.0',
simdutf: '6.4.0',
sodium: '1.0.21',
sqlite: '3.51.3',
tz: '2026a',
undici: '7.24.4',
unicode: '17.0',
uv: '1.51.0',
uvwasi: '0.0.23',
v8: '13.6.233.17-node.48',
zlib: '1.3.1-e00f703',
zmq: '4.3.5',
zstd: '1.5.7'
}
}

kernelVersion is the Linux kernel version encoded as a number (0 on other platforms). When iisNode is enabled, the object also includes iisNodeMain, the absolute path of the real main script.

You can also call nsolid.info() asynchronously:

nsolid.info((err, info) => {
// ...
})

nsolid.logger​

Sends log records through the N|Solid Agent. With a gRPC connection (NSOLID_GRPC or NSOLID_SAAS), the records are exported to the N|Solid Console as OpenTelemetry log records. Other connection types don't forward log records. Non-string values are converted with JSON.stringify().

MethodOpenTelemetry severity number
nsolid.logger.debug(msg)5 (DEBUG)
nsolid.logger.info(msg)9 (INFO)
nsolid.logger.warn(msg)13 (WARN)
nsolid.logger.error(msg)17 (ERROR)
nsolid.logger.fatal(msg)21 (FATAL)
nsolid.logger.info('Cache warmed')
nsolid.logger.error({ msg: 'Payment failed', orderId: 1234 })

nsolid.metrics()​

Returns the latest recorded metrics for the calling thread, plus process-wide metrics. It isn't the full per-thread set sent to connected endpoints.

> nsolid.metrics()
{
threadName: '',
threadId: 0,
timestamp: 1716511535286,
activeHandles: 1,
activeRequests: 0,
heapTotal: 6000640,
totalHeapSizeExecutable: 524288,
totalPhysicalSize: 5976064,
totalAvailableSize: 2193381512,
heapUsed: 5351112,
heapSizeLimit: 2197815296,
mallocedMemory: 147552,
externalMem: 2256629,
peakMallocedMemory: 521312,
numberOfNativeContexts: 2,
numberOfDetachedContexts: 0,
gcCount: 7,
gcForcedCount: 0,
gcFullCount: 0,
gcMajorCount: 4,
dnsCount: 0,
httpClientAbortCount: 0,
httpClientCount: 0,
httpServerAbortCount: 0,
httpServerCount: 0,
loopIdleTime: 351289699466,
loopIterations: 222,
loopIterWithEvents: 160,
eventsProcessed: 215,
eventsWaiting: 160,
providerDelay: 64084249,
processingDelay: 0,
loopTotalCount: 222,
pipeServerCreatedCount: 0,
pipeServerDestroyedCount: 0,
pipeSocketCreatedCount: 0,
pipeSocketDestroyedCount: 0,
tcpServerCreatedCount: 0,
tcpServerDestroyedCount: 0,
tcpSocketCreatedCount: 0,
tcpSocketDestroyedCount: 0,
udpSocketCreatedCount: 0,
udpSocketDestroyedCount: 0,
promiseCreatedCount: 0,
promiseResolvedCount: 0,
fsHandlesOpenedCount: 3,
fsHandlesClosedCount: 2,
gcDurUs99Ptile: 0,
gcDurUsMedian: 0,
dns99Ptile: 0,
dnsMedian: 0,
httpClient99Ptile: 0,
httpClientMedian: 0,
httpServer99Ptile: 0,
httpServerMedian: 0,
loopUtilization: 0.000395,
res5s: 0.001525,
res1m: 0.000173,
res5m: 0.000096,
res15m: 0.000053,
loopAvgTasks: 0,
loopEstimatedLag: 0.000056,
loopIdlePercent: 99.96048,
title: 'nsolid',
user: 'appuser',
uptime: 351,
systemUptime: 65463,
freeMem: 4299878400,
totalMem: 8295538688,
blockInputOpCount: 0,
blockOutputOpCount: 32,
ctxSwitchInvoluntaryCount: 0,
ctxSwitchVoluntaryCount: 4024,
ipcReceivedCount: 0,
ipcSentCount: 0,
pageFaultHardCount: 0,
pageFaultSoftCount: 4337,
signalCount: 0,
swapCount: 0,
rss: 56938496,
load1m: 0,
load5m: 0.03,
load15m: 0.06,
cpuUserPercent: 0.066668,
cpuSystemPercent: 0.01117,
cpuPercent: 0.077838,
cpu: 0.077838
}

If you pass a callback, the metrics are returned asynchronously:

nsolid.metrics((err, metrics) => {
// ...
})
tip

See Metrics in detail for a description of each metric.


nsolid.metricsPaused​

Whether metrics collection is currently paused. Use nsolid.pauseMetrics() and nsolid.resumeMetrics() to change it.

> nsolid.metricsPaused
false
> nsolid.pauseMetrics()
undefined
> nsolid.metricsPaused
true
> nsolid.resumeMetrics()
undefined
> nsolid.metricsPaused
false

nsolid.on(customCommand, handler)​

Registers a handler for a custom command. The handler runs when that custom command is sent to the process from the N|Solid Console or with nsolid-cli custom.

customCommand must be a non-empty string. There is only one handler per command: registering a second handler for the same name replaces the first.

The handler receives a request object:

FieldDescription
valueThe data sent with the custom command, parsed as JSON.
returnFunction that completes the custom command successfully and sends its argument back as the result.
throwFunction that completes the custom command with an error and sends its argument back.

Your handler must call either request.return() or request.throw().

warning

Custom commands are only delivered over the ZeroMQ (NSOLID_COMMAND) connection. They aren't available when you connect with NSOLID_GRPC or NSOLID_SAAS.

danger

A custom command handler can run any JavaScript. Use caution.

nsolid.on('my_command', (request) => {
console.log(`Value: ${request.value}`)
request.return({ ok: true })
})

nsolid.otel​

An object with the register() and registerInstrumentations() methods, for use with the OpenTelemetry JavaScript API package, @opentelemetry/api.

note

Your application must have tracing enabled for these examples to produce spans. Start your application with NSOLID_TRACING_ENABLED=1, or enable tracing in the N|Solid Console.

nsolid.otel.register(api)​

Registers the OpenTelemetry API with N|Solid so that you can use the OpenTelemetry trace API to create spans. It returns true on success and false if N|Solid couldn't install its global context manager or tracer provider. Calling it a second time throws ERR_NSOLID_OTEL_API_ALREADY_REGISTERED.

N|Solid enables and disables the API automatically as tracing is turned on and off.

const nsolid = require('nsolid')
const api = require('@opentelemetry/api')

if (!nsolid.otel.register(api)) {
throw new Error('Error registering api')
}

const tracer = api.trace.getTracer('Test tracer')
const span = tracer.startSpan('initial', { attributes: { a: 1, b: 2 } })
span.updateName('my name')
span.setAttributes({ c: 3, d: 4 })
span.setAttribute('e', 5)
span.addEvent('my_event 1', Date.now())
span.addEvent('my_event 2', { attr1: 'val1', attr2: 'val2' }, Date.now())
span.end()

nsolid.otel.registerInstrumentations(instrumentations)​

Registers instrumentation modules from the OpenTelemetry ecosystem that use the OpenTelemetry trace API. It accepts a single instrumentation or an array, and throws ERR_INVALID_ARG_TYPE for anything else. Registered instrumentations are enabled and disabled automatically as tracing is turned on and off.

To instrument everything that's available, use the @opentelemetry/auto-instrumentations-node package. Register the API first, so the instrumentations have a tracer provider:

const nsolid = require('nsolid')
const api = require('@opentelemetry/api')
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node')

nsolid.otel.register(api)
nsolid.otel.registerInstrumentations(getNodeAutoInstrumentations())

nsolid.packages()​

Returns the list of packages that your application can load. N|Solid finds them by starting from your package.json dependencies and walking every directory that could contain a module.

> nsolid.packages()
[
{
path: '/home/user/my-app/node_modules/infinite-monkey-db',
name: 'infinite-monkey-db',
version: '1.0.2',
main: 'index.js',
dependencies: [ '../readable-stream', '../stream-meter', '../timegap' ],
required: false
},
{
path: '/home/user/my-app/node_modules/stats-lite',
name: 'stats-lite',
version: '2.2.0',
main: 'stats.js',
dependencies: [ '../isnumber' ],
required: false
},
...
]

Each entry also includes an nsolid property if the package's package.json has an nsolid section. With disablePackageScan enabled, only packages that your application has actually loaded are returned.

You can also call nsolid.packages() asynchronously:

nsolid.packages((err, packages) => {
// ...
})

nsolid.pauseMetrics()​

Pauses process metrics collection. Does nothing if metrics are already paused.

note

Call this method from the main thread. In worker threads it does nothing.

nsolid.pauseMetrics()

nsolid.processStart​

The time the process started, in milliseconds since the epoch.

> nsolid.processStart
1716575443913

nsolid.profile([duration][, callback])​

Starts a CPU profile of the current thread from within your application. When it finishes, the profile is saved in the N|Solid Console. The default duration is 600000 milliseconds (10 minutes). To stop the profile early, call nsolid.profileEnd(). On a gRPC connection, the request is rejected while continuous CPU profiling (contCpuProfile) is on.

// Start a one-minute CPU profile
nsolid.profile(60000 /* milliseconds */, (err) => {
if (err) {
// The profile could not be started
}
// If there's no error, the profiler is running
})

You can also start the profiler synchronously. If it can't be started, the error is thrown:

try {
nsolid.profile(600000 /* milliseconds */)
} catch (err) {
// The profile could not be started
}

nsolid.profileEnd([callback])​

Stops the running CPU profile before its duration ends. If there's an error and you don't supply a callback, the error is thrown.

nsolid.profileEnd((err) => {
if (err) {
// Error stopping the profiler
}
// The profiler is now stopped
})

nsolid.resumeMetrics()​

Resumes metrics collection if it was paused. Otherwise does nothing.

note

Call this method from the main thread. In worker threads it does nothing.

nsolid.resumeMetrics()

nsolid.saveFatalError(error)​

When your N|Solid process terminates with an error, it tries to send the error to the N|Solid Console before it exits. If you handle uncaughtException yourself and exit asynchronously, call nsolid.saveFatalError() to report the error to the Console before your own shutdown.

The argument must be a native Error object; any other value is ignored. To clear a stored error, call nsolid.clearFatalError().

process.on('uncaughtException', (err) => {
nsolid.saveFatalError(err)
someImportantCleanup()
process.exit(1)
})

nsolid.setThreadName(name)​

Sets a label for the current thread, to make worker threads easier to manage in the N|Solid Console.

const { Worker, isMainThread } = require('node:worker_threads')
const { getThreadName, setThreadName } = require('nsolid')

if (!isMainThread) {
console.log(getThreadName()) // ''
setThreadName('worker-renamed')
console.log(getThreadName()) // worker-renamed
setTimeout(() => {}, 1000)
} else {
const worker = new Worker(__filename)
}

You can also name the main thread:

const { isMainThread } = require('node:worker_threads')
const { setThreadName } = require('nsolid')

if (isMainThread) setThreadName('main-thread')

The value passed to nsolid.setThreadName() must be a string; otherwise, an error is thrown.

const { Worker, isMainThread } = require('node:worker_threads')
const { setThreadName } = require('nsolid')

if (!isMainThread) {
try {
setThreadName(null)
} catch (err) {
// TypeError [ERR_INVALID_ARG_TYPE]: The "name" argument must be of type string. Received null
}
} else {
const worker = new Worker(__filename)
}

nsolid.snapshot([callback])​

Takes a heap snapshot from within your application and saves it in the N|Solid Console.

nsolid.snapshot((err) => {
if (err) {
// The snapshot could not be created
}
})

You can also call it synchronously. If the snapshot can't be created, the error is thrown:

try {
nsolid.snapshot()
} catch (err) {
// The snapshot could not be created
}

nsolid.startupTimes()​

Returns the startup times N|Solid tracked for the process, as high-resolution [seconds, nanoseconds] arrays. The default phases are:

Startup phase nameDescription
timeOriginThe reference point. Always [0, 0]; all other values are relative to it.
initialized_nodeTime to initialize Node.js and start the core process.
initialized_v8Time to initialize the V8 engine.
loaded_environmentTime to finish loading the environment and run the initial top-level JavaScript code, in core and in your main file.
bootstrap_completeTime at which bootstrap completed and the application was ready to begin asynchronous operations.
loop_startTime at which the first event loop iteration began.
> nsolid.startupTimes()
{
bootstrap_complete: [ 0, 87587200 ],
initialized_node: [ 0, 1162200 ],
initialized_v8: [ 0, 24932000 ],
loaded_environment: [ 0, 63593200 ],
loop_start: [ 0, 107348400 ],
timeOrigin: [ 0, 0 ]
}

You can also call nsolid.startupTimes() asynchronously:

nsolid.startupTimes((err, startupTimes) => {
// ...
})
tip

You can add your own startup phases to the startupTimes object with process.recordStartupTime(name).

// after creating a database client
process.recordStartupTime('db_initialized')
> nsolid.startupTimes()
{
bootstrap_complete: [ 0, 15298719 ],
db_initialized: [ 6, 144053957 ], // DB initialization in the context of the rest of the application bootstrap
initialized_node: [ 0, 297988 ],
initialized_v8: [ 0, 2603603 ],
loaded_environment: [ 0, 7437782 ],
loop_start: [ 0, 34829260 ],
timeOrigin: [ 0, 0 ]
}

nsolid.statsd​

An object for working with a StatsD endpoint:

PropertyDescription
counter(name, value)Sends a "counter" value to StatsD. Uses NSOLID_STATSD_BUCKET and NSOLID_STATSD_TAGS if configured.
formatThe StatsD format object (see below).
gauge(name, value)Sends a "gauge" value to StatsD. Uses NSOLID_STATSD_BUCKET and NSOLID_STATSD_TAGS if configured.
sendRaw(str)Sends a raw string, or an array of strings, to StatsD. You must follow the StatsD format (a terminating newline isn't required). Strings in an array are sent newline-separated. Over UDP, the data is split into packets of at most 1400 bytes to fit within a standard MTU; this applies to newline-separated strings and to arrays. Returns -1 if the StatsD agent isn't ready.
set(name, value)Sends a "set" value to StatsD. Uses NSOLID_STATSD_BUCKET and NSOLID_STATSD_TAGS if configured.
status()Returns the StatsD agent status.
tcpIp()If configured, returns the IP address that TCP StatsD data is sent to.
timing(name, value)Sends a "timing" value to StatsD. Uses NSOLID_STATSD_BUCKET and NSOLID_STATSD_TAGS if configured.
udpIp()If configured, returns the IP address that UDP StatsD data is sent to.

StatsD isn't configured by default, so the status is unconfigured. The possible statuses are:

  • unconfigured
  • initializing
  • connecting
  • ready
> nsolid.statsd.status()
'unconfigured'

The nsolid.statsd.format object:

PropertyDescription
bucket()Returns the bucket string prepended to all automatically generated StatsD metrics.
counter(name, value)Formats a "counter" string for the name and value.
gauge(name, value)Formats a "gauge" string for the name and value.
set(name, value)Formats a "set" string for the name and value.
tags()Returns the tags suffix (for example, |#tag1,tag2) appended to automatically generated metrics, or an empty string if no tags are configured.
timing(name, value)Formats a "timing" string for the name and value.
> nsolid.statsd.format.bucket()
'nsolid.prod.webserver.my-host.ced675f'

With NSOLID_STATSD_TAGS='testmode':

> nsolid.statsd.format.tags()
'|#testmode'

nsolid.tags​

Gets the N|Solid app tags, set with NSOLID_TAGS, the tags key in the nsolid section of package.json, or nsolid.start({ tags }). Tags are returned sorted.

> nsolid.tags
[ 'beta-service', 'experiment-4a' ]

nsolid.traceStats​

An object with getters for the process's trace counters. Each property is a getter that returns the current value.

> nsolid.traceStats
{
httpClientCount: [Getter],
httpServerCount: [Getter],
dnsCount: [Getter],
httpClientAbortCount: [Getter],
httpServerAbortCount: [Getter]
}
> nsolid.traceStats.httpClientCount
1
PropertyDescription
dnsCountThe total number of DNS lookups performed during the life of the process.
httpClientCountThe total number of outgoing HTTP(S) client requests performed.
httpClientAbortCountThe total number of outgoing HTTP(S) client requests that were aborted or timed out.
httpServerCountThe total number of incoming HTTP(S) requests served.
httpServerAbortCountThe total number of incoming HTTP(S) requests that were canceled.

nsolid.tracingEnabled​

Whether tracing is currently enabled for this process. Defaults to false. Use nsolid.enableTraces() and nsolid.disableTraces() to change it.

> nsolid.tracingEnabled
false

nsolid.zmq​

An object with the status getter for the N|Solid Agent's ZeroMQ connection.

PropertyDescription
status()Returns the ZeroMQ agent status.

The possible statuses are:

  • buffering
  • connecting
  • initializing
  • ready
  • unconfigured
> nsolid.zmq.status()
'ready'

There is no equivalent status getter for gRPC or N|Solid SaaS connections.

NodeSource Support