newrelic 8.11.0 → 8.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/NEWS.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### v8.11.1 (2022-05-13)
2
+
3
+ * Fixed an issue with winston instrumentation that caused agent to crash when creating a winston logger from an existing instantiated logger.
4
+
1
5
  ### v8.11.0 (2022-05-11)
2
6
 
3
7
  * Added application logging for Winston in the Node.js agent
@@ -7,6 +7,21 @@
7
7
 
8
8
  const createFormatter = require('@newrelic/winston-enricher/lib/createFormatter')
9
9
  const API = require('../../api')
10
+ const Stream = require('stream')
11
+
12
+ /**
13
+ * winston allows you to compose a logger
14
+ * from an instantiated logger. Through a series
15
+ * of inherited classes, this logger instance is a Stream.
16
+ * Check what gets passed into `winston.createLogger` to avoid
17
+ * instrumenting an already instrumented instance of a logger.
18
+ *
19
+ * @param {*} obj obj to check if a stream
20
+ * @returns {boolean}
21
+ */
22
+ function isStream(obj) {
23
+ return obj instanceof Stream
24
+ }
10
25
 
11
26
  module.exports = function instrument(agent, winston, _, shim) {
12
27
  const config = agent.config
@@ -32,9 +47,10 @@ module.exports = function instrument(agent, winston, _, shim) {
32
47
  return function createWrappedLogger() {
33
48
  const args = shim.argsToArray.apply(shim, arguments)
34
49
  const opts = args[0]
35
- if (!shim.isObject(opts)) {
50
+ if (!shim.isObject(opts) || isStream(opts)) {
36
51
  return createLogger.apply(this, args)
37
52
  }
53
+
38
54
  if ('transports' in opts) {
39
55
  // combine transport-level formatters with our own
40
56
  opts.transports = opts.transports.map((transport) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newrelic",
3
- "version": "8.11.0",
3
+ "version": "8.11.1",
4
4
  "author": "New Relic Node.js agent team <nodejs@newrelic.com>",
5
5
  "license": "Apache-2.0",
6
6
  "contributors": [