How to use correlation-id - 3 common examples

To help you get started, we’ve selected a few correlation-id examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alphagov / pay-selfservice / app / services / clients / base_client / wrapper.js View on Github external
return (uri, opts, cb) => new Promise((resolve, reject) => {
    const namespace = getNamespace(clsXrayConfig.nameSpaceName)
    const clsSegment = namespace ? namespace.get(clsXrayConfig.segmentKeyName) : null

    const args = [uri, opts, cb]
    uri = args.find(arg => typeof arg === 'string')
    opts = args.find(arg => typeof arg === 'object') || {}
    cb = args.find(arg => typeof arg === 'function')
    if (verb) opts.method = verb.toUpperCase()
    if (uri && !opts.uri && !opts.url) opts.url = uri
    const context = {
      correlationId: correlator.getId(),
      startTime: new Date(),
      url: joinURL(lodash.get(opts, 'baseUrl', ''), opts.url),
      method: opts.method,
      description: opts.description,
      service: opts.service
    }

    // Set headers and optional x-ray trace headers
    lodash.set(opts, `headers.${CORRELATION_HEADER}`, context.correlationId)
    if (clsSegment) {
      const subSegment = opts.subSegment || new AWSXRay.Segment('_request_nbc', null, clsSegment.trace_id)
      opts.headers['X-Amzn-Trace-Id'] = 'Root=' + clsSegment.trace_id + ';Parent=' + subSegment.id + ';Sampled=1'
    }
    opts.headers['Content-Type'] = opts.headers['Content-Type'] || 'application/json'

    // Set up post response and error handling method
github felixheck / laabr / src / correlator.js View on Github external
function getCorrelator () {
  return {
    get: correlator.getId,
    with: correlator.withId,
    bind: correlator.bindId
  }
}
github felixheck / laabr / src / correlator.js View on Github external
server.ext('onRequest', function (req, reply) {
    req.headers['x-laabr-cid'] = req.headers[field] || req.id

    return correlator.withId(req.headers['x-laabr-cid'], function () {
      reply.continue()
    })
  })
}

correlation-id

Correlation id for node.js

MIT
Latest version published 4 months ago

Package Health Score

66 / 100
Full package analysis