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.

CAUTION: No-code instrumentation is one of the available approaches to integrate with OpenTelemetry.

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.json

Configuration 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

PropertyTypeRequiredDescription
moduleNamestringNo*Name of the npm module to instrument (e.g., "express", "lodash")
absolutePathstringNo*Absolute path to a specific file to instrument
supportedVersionsstring[]NoSupported version ranges (defaults to ["*"]) — applies only to moduleName
mainModuleMethodsarrayNoMethods exported directly by the module's main file
filesarrayNoList of files and methods to instrument
*Either moduleName or absolutePath must be specified.

Usage Guidelines

To configure no-code instrumentation correctly, follow these simple rules:

  • Use moduleName when instrumenting code from npm packages (like express or lodash)

  • Use absolutePath when instrumenting your own project files

  • Use mainModuleMethods to target functions exported directly by a module

  • Use files to target functions inside specific files

  • Use supportedVersions only with moduleName; it has no effect with absolutePath

  • When using absolutePath, omit file extensions in the name field (e.g. "utils/helper")

  • When using moduleName, include file extensions in the name field (e.g. "lib/util.js")

Function instrumentation (used in files and mainModuleMethods)

PropertyTypeRequiredDescription
namestringYes Relative path to the file (only used in files)
methodNamestringYes Name of the function or method to instrument
spanNamestringNoCustom span name (defaults to the method name)
attributes Attribute definition[]NoList of attributes to extract from function arguments
Note:
  • name is required only when the object is used inside the files array.
  • When used in mainModuleMethods, name is 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