How to use the aws-xray-sdk-core.getLogger function in aws-xray-sdk-core

To help you get started, we’ve selected a few aws-xray-sdk-core 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 aws / aws-xray-sdk-node / packages / express / lib / express_mw.js View on Github external
// ensure `endSegment` is only called once
        // in some versions of node.js 10.x and in all versions of node.js 11.x and higher,
        // the 'finish' and 'close' event are BOTH triggered.
        // Previously, only one or the other was triggered:
        // https://github.com/nodejs/node/pull/20611
        if (didEnd) return;
        didEnd = true;
        if (this.statusCode === 429)
          segment.addThrottleFlag();
        if (AWSXRay.utils.getCauseTypeFromHttpStatus(this.statusCode))
          segment[AWSXRay.utils.getCauseTypeFromHttpStatus(this.statusCode)] = true;

        segment.http.close(this);
        segment.close();

        AWSXRay.getLogger().debug('Closed express segment successfully: { url: ' + req.url + ', name: ' + segment.name + ', trace_id: ' +
          segment.trace_id + ', id: ' + segment.id + ', sampled: ' + !segment.notTraced + ' }');
      };
github aws / aws-xray-sdk-node / packages / express / lib / express_mw.js View on Github external
return function open(req, res, next) {
      var amznTraceHeader = mwUtils.processHeaders(req);
      var name = mwUtils.resolveName(req.headers.host);
      var segment = new Segment(name, amznTraceHeader.Root, amznTraceHeader.Parent);

      mwUtils.resolveSampling(amznTraceHeader, segment, res);
      segment.addIncomingRequestData(new IncomingRequestData(req));

      AWSXRay.getLogger().debug('Starting express segment: { url: ' + req.url + ', name: ' + segment.name + ', trace_id: ' +
        segment.trace_id + ', id: ' + segment.id + ', sampled: ' + !segment.notTraced + ' }');

      var didEnd = false;
      var endSegment = function () {
        // ensure `endSegment` is only called once
        // in some versions of node.js 10.x and in all versions of node.js 11.x and higher,
        // the 'finish' and 'close' event are BOTH triggered.
        // Previously, only one or the other was triggered:
        // https://github.com/nodejs/node/pull/20611
        if (didEnd) return;
        didEnd = true;
        if (this.statusCode === 429)
          segment.addThrottleFlag();
        if (AWSXRay.utils.getCauseTypeFromHttpStatus(this.statusCode))
          segment[AWSXRay.utils.getCauseTypeFromHttpStatus(this.statusCode)] = true;
github aws / aws-xray-sdk-node / packages / mysql / lib / mysql_p.js View on Github external
return function() {
    var args = resolveArguments(arguments);
    var parent = AWSXRay.resolveSegment(args.segment);
    var command;
    var originalOperation = this['__'+name];

    if (args.segment)
      delete arguments[arguments.length-1];

    if (!parent) {
      AWSXRay.getLogger().info('Failed to capture MySQL. Cannot resolve sub/segment.');
      return originalOperation.apply(this, arguments);
    }

    var config = this.config.connectionConfig || this.config;
    var subsegment = parent.addNewSubsegment(config.database + '@' + config.host);

    if (args.callback) {
      var cb = args.callback;

      if (AWSXRay.isAutomaticMode()) {
        args.callback = function autoContext(err, data) {
          var session = AWSXRay.getNamespace();

          session.run(function() {
            AWSXRay.setSegment(subsegment);
            cb(err, data);
github aws / aws-xray-sdk-node / packages / postgres / lib / postgres_p.js View on Github external
function captureQuery() {
  var args = resolveArguments(arguments);
  var parent = AWSXRay.resolveSegment(args.segment);

  if (!parent) {
    AWSXRay.getLogger().info('Failed to capture Postgres. Cannot resolve sub/segment.');
    return this.__query.apply(this, arguments);
  }

  var subsegment = parent.addNewSubsegment(this.database + '@' + this.host);

  if (args.callback) {
    var cb = args.callback;

    if (AWSXRay.isAutomaticMode()) {
      args.callback = function autoContext(err, data) {
        var session = AWSXRay.getNamespace();

        session.run(function() {
          AWSXRay.setSegment(subsegment);
          cb(err, data);
        });
github aws / aws-xray-sdk-node / packages / express / lib / express_mw.js View on Github external
return function close(err, req, res, next) {
      var segment = AWSXRay.resolveSegment(req.segment);

      if (segment && err) {
        segment.close(err);

        AWSXRay.getLogger().debug('Closed express segment with error: { url: ' + req.url + ', name: ' + segment.name + ', trace_id: ' +
          segment.trace_id + ', id: ' + segment.id + ', sampled: ' + !segment.notTraced + ' }');

      } else if (segment) {
        segment.close();

        AWSXRay.getLogger().debug('Closed express segment successfully: { url: ' + req.url + ', name: ' + segment.name + ', trace_id: ' +
          segment.trace_id + ', id: ' + segment.id + ', sampled: ' + !segment.notTraced + ' }');
      }

      if (next)
        next(err);
    };
  }