Registry /
observability / elastic-apm-http-client
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ const Client = require('elastic-apm-http-client')
✗ import Client from 'elastic-apm-http-client'
This package is CJS-only; there is no default ESM export. Use require().
default
✓ import Client from 'elastic-apm-http-client'
ESM import works via Node.js interop; requires Node >=12 and "type": "module" or .mjs extension.
default
✓ const Client = require('elastic-apm-http-client')
✗ import { Client } from 'elastic-apm-http-client'
The module exports a single constructor function as default. Named destructuring won't work.
Shows how to instantiate the client with required config and send a transaction object. Includes authentication via environment variables, common pitfalls like timestamp in microseconds, and proper flush.
const Client = require('elastic-apm-http-client')
const client = new Client({
serverUrl: process.env.APM_SERVER_URL || 'http://127.0.0.1:8200',
secretToken: process.env.APM_SECRET_TOKEN || '',
apiKey: process.env.APM_API_KEY || '',
serviceName: 'My Service',
agentName: 'my-nodejs-agent',
agentVersion: '1.0.0',
userAgent: 'My Custom Agent/1.0.0'
})
// Example: Send a transaction
client.sendTransaction({
id: 'abc123',
trace_id: 'abc123',
transaction_id: 'abc123',
name: 'GET /api/users',
type: 'request',
duration: 42,
result: 'success',
timestamp: Date.now() * 1000, // microseconds
context: {
request: { method: 'GET', url: 'http://example.com/api/users' }
},
sampled: true
})
client.flush(() => {
console.log('Data sent')
})
Errors
Common errors & fixes
Error: options.agentName, options.agentVersion, options.serviceName, and options.userAgent are required
Missing one or more required constructor options.
fixEnsure all four are provided: `agentName`, `agentVersion`, `serviceName`, `userAgent`.
TypeError: client.sendTransaction is not a function
The client instance was not properly created or the method name is misspelled (e.g., case sensitivity).
fixDouble-check that the client was created with `new Client(options)` and use `sendTransaction` (capital S, capital T).
Error: connect ECONNREFUSED 127.0.0.1:8200
APM Server is not running or not reachable at the configured URL.
fixStart the APM Server or update `serverUrl` to point to a valid server address.
Error: Unexpected token o in JSON at position 1
Trying to send an object that is not serializable or has circular references (though fast-safe-stringify helps, it may still fail on certain values).
fixEnsure the payload is a plain object without functions, Symbols, or circular references. Use JSON.parse(JSON.stringify(payload)) as a workaround.
Audit
Dependencies
core-util-isrequiredUsed for type checking (e.g., isString, isFunction).
end-of-streamrequiredDetects stream end/error for graceful shutdown.
fast-safe-stringifyrequiredSafely serializes objects to JSON, avoiding circular reference errors.
pumprequiredPipes streams together, auto-cleanup on error.
readable-streamrequiredProvides a modern streaming base class (used instead of core stream for compatibility).