No-code instrumentation for Node.js in Splunk Observability Cloud
No-Code Instrumentation enables distributed tracing in Node.js applications without modifying the source code. Instrumentation is configured declaratively via a JSON file. Spans are generated based on configuration and can include custom attributes extracted from function arguments.
Configuration file location
By default, the instrumentation loads its configuration from a file named nocode.config.json in the current working directory. You can override this location using the NOCODE_CONFIG_PATH environment variable:
export NOCODE_CONFIG_PATH=/path/to/your/config.jsonConfiguration file structure
The configuration file contains an array of instrumentation definitions. These map to OpenTelemetry's InstrumentationModuleDefinition and InstrumentationFileDefinition objects.
[
{
"moduleName": "mynodemodule",
"supportedVersions": [">=4.0.0"],
"files": [
{
"name": "lib/util.js",
"methodName": "processData",
"spanName": "mynodemodule.processData",
"attributes": [
{
"attrIndex": 0,
"attrPath": "user.id",
"key": "user.id"
}
]
}
]
},
{
"absolutePath": "/absolute/path/to/your/project/src/utils/helper.js",
"files": [
{
"name": "utils/helper",
"methodName": "calculateTotal",
"spanName": "helper.calculateTotal",
"attributes": [
{
"attrIndex": 0,
"attrPath": "items.length",
"key": "item.count"
},
{
"attrIndex": 1,
"attrPath": "options.currency",
"key": "currency"
}
]
}
]
}
]Configuration properties
To define how specific functions should be traced, the configuration file uses structured objects. Below are the key components and their properties:
Instrumentation definition
| Property | Type | Required | Description |
|---|---|---|---|
| moduleName | string | No* | Name of the npm module to instrument (e.g., "express", "lodash") |
| absolutePath | string | No* | Absolute path to a specific file to instrument |
| supportedVersions | string[] | No | Supported version ranges (defaults to ["*"]) — applies only to moduleName |
| mainModuleMethods | array | No | Methods exported directly by the module's main file |
| files | array | No | List of files and methods to instrument |
Usage guidelines
To configure no-code instrumentation correctly, follow these simple rules:
Use
moduleNamewhen instrumenting code from npm packages (likeexpressorlodash)Use
absolutePathwhen instrumenting your own project filesUse
mainModuleMethodsto target functions exported directly by a moduleUse
filesto target functions inside specific filesUse
supportedVersionsonly withmoduleName; it has no effect withabsolutePathWhen using
absolutePath, omit file extensions in thenamefield (e.g."utils/helper")When using
moduleName, include file extensions in thenamefield (e.g."lib/util.js")
Function instrumentation (used in files and mainModuleMethods)
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Relative path to the file (only used in files) |
| methodName | string | Yes | Name of the function or method to instrument |
| spanName | string | No | Custom span name (defaults to the method name) |
| attributes | Attribute definition[] | No | List of attributes to extract from function arguments |
nameis required only when the object is used inside thefilesarray.- When used in
mainModuleMethods,nameis omitted because the method is exported directly by the module.
Limitations
- File-level granularity: Can only instrument functions exported from modules, not internal functions
- Static configuration: Configuration is loaded once at startup and cannot be changed at runtime