Skip to content

Latest commit

 

History

History
203 lines (151 loc) · 7.28 KB

File metadata and controls

203 lines (151 loc) · 7.28 KB

@elastic/ecs-pino-format Changelog

v1.5.0

  • Bump dep to @elastic/ecs-helpers@2 which removes the dep on the old fast-safe-stringify lib that resulted in a maintenance warning about the string-similarity transitive dep.

  • Set http.request.id field (see ecs-helpers CHANGELOG).

  • Changed to a named export. The preferred way to import is now:

    const { ecsFormat } = require('@elastic/ecs-pino-format'); // CommonJS
    import { ecsFormat } from '@elastic/ecs-pino-format'; // ESM

    The old way will be deprecated and removed in the future:

    const ecsFormat = require('@elastic/ecs-pino-format'); // OLD
  • Add support for default import in TypeScript, with or without the esModuleInterop setting:

    import ecsFormat from '@elastic/ecs-pino-format';

    However, note that using named imports is now preferred.

v1.4.0

  • Add service.version, service.environment, and service.node.name log correlation fields, automatically inferred from an active APM agent. As well, the following ecsFormat configuration options have been added for overriding these and existing correlation fields: serviceName, serviceVersion, serviceEnvironment, serviceNodeName. (elastic/apm-agent-nodejs#3195, #121, #87)

  • Change to adding dotted field names ("ecs.version": "1.6.0"), rather than namespaced fields ("ecs": {"version": "1.6.0"}) for most fields. This is supported by the ecs-logging spec, and arguably preferred in the ECS logging docs. It is also what the ecs-logging-java libraries do. The resulting output is slightly shorter, and accidental collisions with user fields is less likely.

  • Stop adding ".log" suffix to event.dataset field. (#95)

v1.3.0

  • TypeScript types. (#82)

v1.2.0

  • Add an internal testing-only option (opts._elasticApm) to pass in the current loaded "elastic-apm-node" module for use in APM tracing integration. This option will be used by tests in the APM agent where the current agent import name is a local path rather than "elastic-apm-node" that this code normally uses.

v1.1.2

  • Fix a circular-require for code that uses both this package and 'elastic-apm-node'. (#79)

v1.1.1

v1.1.0

  • Fix a "TypeError: Cannot read property 'host' of undefined" crash when using convertReqRes: true and logging a req field that is not an HTTP request object. (#71)

  • Set the "message" to the empty string for logger calls that provide no message, e.g. log.info({foo: 'bar'}). In this case pino will not add a message field, which breaks ecs-logging spec. (#64)

  • Fix handling when the base option is used to the pino constructor. (#63)

    Before this change, using, for example: const log = pino({base: {foo: "bar"}, ...ecsFormat()}) would result in two issues:

    1. The log records would not include the "foo" field.
    2. The log records would include "process": {}, "host": {} for the expected process.pid and os.hostname.

    Further, if the following is used: const log = pino({base: null, ...ecsFormat()}) pino does not call formatters.bindings() at all, resulting in log records that were missing "ecs.version" (making them invalid ecs-logging records) and part of the APM integration.

  • Add apmIntegration: false option to all ecs-logging formatters to enable explicitly disabling Elastic APM integration. (#62)

  • Fix "elasticApm.isStarted is not a function" crash on startup. (#60)

v1.0.0

  • Update to @elastic/[email protected]: ecs.version is now "1.6.0", http.request.method is no longer lower-cased, improvements to HTTP serialization.

  • Add error logging feature. By default if an Error instance is passed as the err field, then it will be converted to ECS Error fields, e.g.:

    log.info({ err: new Error('boom') }, 'oops')

    yields:

    {
      "log.level": "info",
      "@timestamp": "2021-01-26T17:02:23.697Z",
      ...
      "error": {
        "type": "Error",
        "message": "boom",
        "stack_trace": "Error: boom\n    at Object.<anonymous> (..."
      },
      "message": "oops"
    }

    This special handling of the err field can be disabled via the convertErr: false formatter option.

  • Set "service.name" and "event.dataset" log fields if Elastic APM is started. This helps to filter for different log streams in the same pod and the latter is required for log anomaly detection. (#41)

  • Add support for ECS tracing fields. If it is detected that Elastic APM is in use and there is an active trace, then tracing fields will be added to log records. This enables linking between traces and log records in Kibana. (#35)

  • BREAKING CHANGE: Conversion of HTTP request and response objects is no longer done by default. One must use the new convertReqRes: true formatter option. As well, only the meta keys req and res will be handled. Before this change the meta keys req, res, request, and response would all be handled. (#32)

    Before (no longer works):

    const log = pino({ ...ecsFormat() })
    
    http.createServer(function handler (request, response) {
      // ...
      log.info({ request, response }, 'handled request')
    })
    

    After:

    const log = pino({ ...ecsFormat({ convertReqRes: true }) }) // <-- specify convertReqRes option
    
    http.createServer(function handler (req, res) {
      // ...
      log.info({ req, res }, 'handled request') // <-- only `req` and `res` are special
    })
    

v0.2.0

v0.1.0

Initial release.