Node.js Agent version 4.xedit

See the Upgrade to v4.x guide.

4.0.0 - 2023/09/07edit

Breaking changesedit
  • Set the new minimum supported Node.js to version 14.17.0. Users of earlier Node.js versions can use elastic-apm-node v3.x, which supports back to Node.js v8.6.
  • Ignore a timer option passed to startTransaction() and startSpan() APIs. This option was never documented. It would be surprising if any user is impacted by this.
  • Remove long deprecated support for the ELASTIC_APM_-prefixed environment variables for the Kubernetes config options. For example, one must use KUBERNETES_POD_NAME and not ELASTIC_APM_KUBERNETES_POD_NAME. (#2661)
  • The config option filterHttpHeaders is now removed. (#3539)
  • Remove the deprecated span.toString() and transaction.toString() APIs. See the upgrading doc for details. (#2348)
  • Remove instrumentation support for the old hapi package — the current @hapi/hapi package is still instrumented. (#2691)
  • Change apm.startTransaction() api to return a noop transaction instead of null, if the agent is not yet started. (#2429)
  • Drop support for the obsolete "patch" context manager, i.e. the contextManager: "patch" config option. This was a limited async context management that predated the preferred AsyncLocalStorage core Node.js mechanism for context tracking. It was deprecated in v3.37.0. As well, the related and deprecated asyncHooks config option has been removed. (#3529)
  • Remove the logUncaughtExceptions config option. See Upgrading to v4 for details. (#2412)
  • Remove transaction.subtype and transaction.action properties from API. This also impacts apm.startTransaction([name][, type][, options]) and transaction.setType(...), both of which now no longer accept subtype and action parameters. These two properties were deprecated in v3.25.0. (#3557)
  • Remove support for the erroneous ELASTIC_SANITIZE_FIELD_NAMES and ELASTIC_IGNORE_MESSAGE_QUEUES config environment variables. The correct env vars are ELASTIC_APM_SANITIZE_FIELD_NAMES and ELASTIC_APM_IGNORE_MESSAGE_QUEUES, respectively, and were supported starting in v3.36.0.
Featuresedit
  • The apm.destroy() method is now async. Almost no users should need to use this method. However, if used, to be sure to wait for APM agent shutdown to be complete, one can now await apm.destroy(). (#3222)
  • Support instrumenting mongodb v6. (#3596)
Bug fixesedit
  • Fix instrumentation of mongodb to avoid multiple command handler registrations when client is created via MongoClient.connect static method. (#3586)
Choresedit
  • Add a warning message when a duration or size config option is provided without units. (#2121)
  • Change default value of useElasticTraceparentHeader config option to false. This means that for outgoing HTTP requests, the APM agent will no longer add the elastic-apm-traceparent header. This vendor-specific header was used in the past while the W3C trace-context spec was still in development. Now that it is in wide use, the elastic-apm-traceparent header is only useful for interaction with very old Elastic APM agents.
  • Add default ports into context.service.target.name for HTTP spans conforming to the spec update done in https://github.com/elastic/apm/pull/700 (#3590)