Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //inside aws console
- const { datadog } = __webpack_require__(416);
- const tracer = __webpack_require__(1172);
- const openTracing = __webpack_require__(13);
- let awsXRay = __webpack_require__(94);
- let activityTracer = tracer.init({service: 'activity_writer_lambda', env: 'beta', analytics: true});
- const bulkIndex = activityTracer.wrap("bulkIndex", (client, data) => {
- let activeSpan = activityTracer.scope().active();
- activeSpan.setOperationName("lambda-test-danny");
- const bulkBody = [];
- const insert_time = new Date().getTime();
- if (isDebugMode) {
- console.log('Batch to send to E.S : ' + JSON.stringify(data));
- }
- //some logic
- data.forEach(item => {
- bulkBody.push({
- index: {
- _index: indexFieldsResolver.getIndexName(item),
- _type: 'all',
- _id: indexFieldsResolver.getId(item)
- }
- });
- const activity = indexFieldsResolver.convertActivity(item);
- activity.insert_time = insert_time;
- bulkBody.push(activity);
- });
- data.forEach(item => {
- console.info('**********************************************************')
- activeSpan.setTag('activity.id', item.activityId);
- console.info('-----------------------------' + activeSpan);
- awsXRay.captureFunc("AI-beta-elasticsearch-activities-writer", (subsegment) => {
- subsegment.addMetadata('id', item.activityId, 'activity');
- });
- });
- }
- })
- […] //rest of function
- }
- function EsBulkIndexer() {
- return {
- index: index
- };
- async function index(client, records) {
- return bulkIndex(client, records); //function we trace
- }
- }
- module.exports = datadog((event, context, callback) => {
- EsBulkIndexer();
- }, {mergeDatadogXrayTraces: true, apiKey: <api_key>});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement