/
index.js
43 lines (40 loc) · 1.2 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"use strict"
/* eslint-disable no-console */
const AWS_XRAY = require('aws-xray-sdk');
const FAKE_XRAY = {
plugins: {},
config: () => {},
express: {
openSegment: () => function(req, res, next) {next();},
closeSegment: () => function(req, res, next) {next();}
},
captureAWS: (capture) => capture,
getSegment: () => {},
captureAsyncFunc: function(name, callback) {callback();},
setAWSWhitelist: () => {},
appendAWSWhitelist: () => {},
setStreamingThreshold: () => {},
setLogger: () => {},
getLogger: () => {},
setDaemonAddress: () => {},
captureFunc: function(name, callback) {callback();},
captureCallbackFunc: function(name, callback) {callback();},
captureAWSClient: (client) => client,
captureHTTPs: (capture) => capture,
captureHTTPsGlobal: (capture) => capture,
capturePromise: () => {},
utils: {},
database: {},
middleware: {},
getNamespace: () => {},
resolveSegment: () => {},
setSegment: () => {},
isAutomaticMode: () => false,
enableAutomaticMode: () => {},
enableManualMode: () => {},
setContextMissingStrategy: () => {},
Segment: {},
Subsegment: {},
SegmentUtils: {}
};
module.exports = parseInt(process.env.AWS_XRAY) ? AWS_XRAY : FAKE_XRAY;