How to use the aws-xray-sdk.plugins function in aws-xray-sdk

To help you get started, we’ve selected a few aws-xray-sdk 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-samples / aws-xray-kubernetes / demo-app / service-a / server.js View on Github external
var AWS = XRay.captureAWS(require('aws-sdk'));
var http = XRay.captureHTTPs(require('http'));

const express = require('express');
var bodyParser = require('body-parser');
var queryString = require('querystring');


// Constants
const PORT = 8080;
const apiCNAME = process.env.API_CNAME || 'localhost';

// App
const app = express();

XRay.config([XRay.plugins.EC2Plugin, XRay.plugins.ECSPlugin]);
XRay.middleware.enableDynamicNaming();

app.use(bodyParser.urlencoded({extended: false}));
app.use(XRay.express.openSegment('service-a'));

app.get('/health', function(req, res) {
  res.status(200).send("Healthy");
});

app.get('/', function(req, res) {
  var seg = XRay.getSegment();
  seg.addAnnotation('service', 'service-b-request');

  var reqData = queryString.stringify(req.body);

  var options = {