Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "aws-xray-sdk-core in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'aws-xray-sdk-core' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

exports.handler = (event, context, callback) => {
  // It changes to a boolean value with `!!`
  context.callbackWaitsForEmptyEventLoop =
    !!event.callbackWaitsForEmptyEventLoop

  if (event.asyncTest) {
    setTimeout(() => console.log('sleep 3500 msec'), 3500)
  }

  // https://docs.aws.amazon.com/xray/latest/devguide/scorekeep-lambda.html
  // For testing AWSXRay support
  AWSXRay.captureFunc('annotations', (subsegment) => {
    subsegment.addAnnotation('Name', 'name')
    subsegment.addAnnotation('UserID', 'piyo')
  })

  /* eslint-disable no-eval */
  eval(event.callbackCode)
}
var AWSXRay = require("aws-xray-sdk-core");
var logger = require('winston');
AWSXRay.setLogger(logger);
var AWS = AWSXRay.captureAWS(require('aws-sdk'));

var docClient = new AWS.DynamoDB.DocumentClient({
  apiVersion: '2012-08-10'
});

// Table name is configured as env var.
var table = process.env.TABLE_NAME;

exports.handler = (event, context, callback) => {

  console.log('Received event:', JSON.stringify(event, null, 2));

  var responseBody = {
      message: ""
  };
'use strict';

const AWSXRay = require('aws-xray-sdk-core');
const AWS = AWSXRay.captureAWS(require('aws-sdk'));
//const AWS = require('aws-sdk');
const uuidv4 = require('uuid/v4');
const crypto = require('crypto');
const kinesis = new AWS.Kinesis();
const kms = new AWS.KMS();

// function to determine if the cookie exists and is valid
const verify = (cookie, secret) => {
	let segments = cookie.split('/');
	return segments.length === 2 && (crypto.createHmac('sha256', secret).update(segments[0]).digest('hex') === segments[1]);
}

let secret = undefined

const decrypt = () => {
	if (!secret) {
return new Promise((resolve) => {
          //  Publish the message body as an AWS X-Ray annotation.
          //  This allows us to trace the message processing through AWS X-Ray.
          AWSXRay.captureAsyncFunc(topicName, (subsegment0) => {
            subsegment = subsegment0;
            try {
              const msg = JSON.parse(buffer.toString());
              const body = msg.body || msg;
              if (!body) {
                console.log('awsGetTopic', 'no_body');
                return resolve('no_body');
              }
              for (const key of Object.keys(body)) {
                //  Log only scalar values.
                const val = body[key];
                if (val === null || val === undefined) continue;
                if (typeof val === 'object') continue;
                subsegment.addAnnotation(key, val);
              }
            } catch (error) {
import { env } from '../common/environment';
import * as InternalTypes from '../common/internal-message-types';
import { invokeMessengerReply } from '../common/lambda-utils';
import * as Subscription from '../models/subscription';
import * as ActionHelper from './action-helper';
import * as NextEpisodeController from './controllers/next-episode.controller';
import * as SearchController from './controllers/search.controller';
import * as TrendingController from './controllers/trending.controller';

const { ActionTypes, ReplyKind } = InternalTypes;

if (!process.env.IS_LOCAL) {
  // tslint:disable-next-line: no-console
  console.log('capturing outgoing http calls in X-Ray');
  // tslint:disable-next-line no-var-requires
  AWSXRay.captureHTTPsGlobal(require('http'));
}

export async function handler(
  action: InternalTypes.AnyAction,
  context: {},
  callback: LambdaCallback,
): Promise {
  if (env !== 'test') {
    console.log('entry'); // tslint:disable-line:no-console
    prettyPrint(action);
  }

  const socialId = ActionHelper.getSocialId(action);

  // compute the reply
  let reply;
import { LambdaCallback } from '../common/aws-lambda-types';
import { getError } from '../common/common-utils';
import { errorMessages } from '../common/constants';
import { env } from '../common/environment';
import * as InternalTypes from '../common/internal-message-types';
import * as MessengerTypes from '../common/messenger-types';
import * as MessengerAPI from '../common/messenger.api';
import { generateGenericTemplate } from './messenger.formatter';

const { ReplyKind } = InternalTypes;

if (!process.env.IS_LOCAL) {
  // tslint:disable-next-line: no-console
  console.log('capturing outgoing http calls in X-Ray');
  // tslint:disable-next-line no-var-requires
  AWSXRay.captureHTTPsGlobal(require('http'));
}

export async function handler(
  reply: InternalTypes.AnyReplyKind,
  context: {},
  callback: LambdaCallback,
): Promise {
  if (env !== 'test') {
    console.log('input', JSON.stringify(reply)); // tslint:disable-line:no-console
  }

  if (isEmpty(reply.metaData)) {
    return callback(new Error('no metaData'));
  }
  const metaData = reply.metaData.fbMessenger;
  if (isEmpty(metaData)) {
var myFunction = function(event, context, callback) {
  var sns = new AWS.SNS();
  var chance = new Chance();
  var userid = event.userid;
  var name = chance.first();

  AWSXRay.captureFunc('annotations', function(subsegment){
    subsegment.addAnnotation('Name', name);
    subsegment.addAnnotation('UserID', event.userid);
  });

  // Notify
  var params = {
    Message: 'Created randon name "' + name + '"" for user "' + userid + '".',
    Subject: 'New user: ' + name,
    TopicArn: process.env.TOPIC_ARN
  };
  sns.publish(params, function(err, data) {
    if (err) {
      console.log(err, err.stack);
      callback(err);
    }
    else {
var AWSXRay = require("aws-xray-sdk-core");
var logger = require('winston');
AWSXRay.setLogger(logger);
var AWS = AWSXRay.captureAWS(require('aws-sdk'));

var docClient = new AWS.DynamoDB.DocumentClient({
  apiVersion: '2012-08-10'
});

// Table name is configured as env var.
var table = process.env.TABLE_NAME;

exports.handler = (event, context, callback) => {

  console.log('Received event:', JSON.stringify(event, null, 2));

  var responseBody = {
      message: ""
  };
image.toBuffer(async (err, data, info) => {
				if (err) {
					reject(err);
				}

				// Pass PNG images through PNGQuant as Sharp is not good at compressing them.
				// See https://github.com/lovell/sharp/issues/478
				if ( info.format === 'png' ) {

					if ( enableTracing ) {
						var mainSegment = AWSXRay.getSegment();
						var segment = mainSegment.addNewSubsegment( 'imagemin-pngquant' );
					}

					data = await imageminPngquant()( data );

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

					// Make sure we update the size in the info, to reflect the new
					// size after lossless-compression.
					info.size = data.length;
				}

				callback && callback(null, data, info);
				resolve({ data, info });
var AWSXRay = require('aws-xray-sdk-core');
var AWS = AWSXRay.captureAWS(require('aws-sdk'));

AWS.config.update({region: process.env.AWS_REGION});
var Chance = require('chance');

var myFunction = function(event, context, callback) {
  var sns = new AWS.SNS();
  var chance = new Chance();
  var userid = event.userid;
  var name = chance.first();

  AWSXRay.captureFunc('annotations', function(subsegment){
    subsegment.addAnnotation('Name', name);
    subsegment.addAnnotation('UserID', event.userid);
  });

  // Notify

Is your System Free of Underlying Vulnerabilities?
Find Out Now