1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var CorrelationContextManager = require("./AutoCollection/CorrelationContextManager");
|
4 | var AutoCollectConsole = require("./AutoCollection/Console");
|
5 | var AutoCollectExceptions = require("./AutoCollection/Exceptions");
|
6 | var AutoCollectPerformance = require("./AutoCollection/Performance");
|
7 | var AutoCollectHttpDependencies = require("./AutoCollection/HttpDependencies");
|
8 | var AutoCollectHttpRequests = require("./AutoCollection/HttpRequests");
|
9 | var Logging = require("./Library/Logging");
|
10 |
|
11 |
|
12 | exports.TelemetryClient = require("./Library/NodeClient");
|
13 | exports.Contracts = require("./Declarations/Contracts");
|
14 |
|
15 | var _isConsole = true;
|
16 | var _isConsoleLog = false;
|
17 | var _isExceptions = true;
|
18 | var _isPerformance = true;
|
19 | var _isRequests = true;
|
20 | var _isDependencies = true;
|
21 | var _isDiskRetry = true;
|
22 | var _isCorrelating = true;
|
23 | var _diskRetryInterval = undefined;
|
24 | var _diskRetryMaxBytes = undefined;
|
25 | var _console;
|
26 | var _exceptions;
|
27 | var _performance;
|
28 | var _serverRequests;
|
29 | var _clientRequests;
|
30 | var _isStarted = false;
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 | function setup(instrumentationKey) {
|
42 | if (!exports.defaultClient) {
|
43 | exports.defaultClient = new exports.TelemetryClient(instrumentationKey);
|
44 | _console = new AutoCollectConsole(exports.defaultClient);
|
45 | _exceptions = new AutoCollectExceptions(exports.defaultClient);
|
46 | _performance = new AutoCollectPerformance(exports.defaultClient);
|
47 | _serverRequests = new AutoCollectHttpRequests(exports.defaultClient);
|
48 | _clientRequests = new AutoCollectHttpDependencies(exports.defaultClient);
|
49 | }
|
50 | else {
|
51 | Logging.info("The default client is already setup");
|
52 | }
|
53 | if (exports.defaultClient && exports.defaultClient.channel) {
|
54 | exports.defaultClient.channel.setUseDiskRetryCaching(_isDiskRetry, _diskRetryInterval, _diskRetryMaxBytes);
|
55 | }
|
56 | return Configuration;
|
57 | }
|
58 | exports.setup = setup;
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 | function start() {
|
66 | if (!!exports.defaultClient) {
|
67 | _isStarted = true;
|
68 | _console.enable(_isConsole, _isConsoleLog);
|
69 | _exceptions.enable(_isExceptions);
|
70 | _performance.enable(_isPerformance);
|
71 | _serverRequests.useAutoCorrelation(_isCorrelating);
|
72 | _serverRequests.enable(_isRequests);
|
73 | _clientRequests.enable(_isDependencies);
|
74 | }
|
75 | else {
|
76 | Logging.warn("Start cannot be called before setup");
|
77 | }
|
78 | return Configuration;
|
79 | }
|
80 | exports.start = start;
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 | function getCorrelationContext() {
|
95 | if (_isCorrelating) {
|
96 | return CorrelationContextManager.CorrelationContextManager.getCurrentContext();
|
97 | }
|
98 | return null;
|
99 | }
|
100 | exports.getCorrelationContext = getCorrelationContext;
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 | function wrapWithCorrelationContext(fn) {
|
108 | return CorrelationContextManager.CorrelationContextManager.wrapCallback(fn);
|
109 | }
|
110 | exports.wrapWithCorrelationContext = wrapWithCorrelationContext;
|
111 |
|
112 |
|
113 |
|
114 | var Configuration = (function () {
|
115 | function Configuration() {
|
116 | }
|
117 | |
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 | Configuration.setAutoCollectConsole = function (value, collectConsoleLog) {
|
124 | if (collectConsoleLog === void 0) { collectConsoleLog = false; }
|
125 | _isConsole = value;
|
126 | _isConsoleLog = collectConsoleLog;
|
127 | if (_isStarted) {
|
128 | _console.enable(value, collectConsoleLog);
|
129 | }
|
130 | return Configuration;
|
131 | };
|
132 | |
133 |
|
134 |
|
135 |
|
136 |
|
137 | Configuration.setAutoCollectExceptions = function (value) {
|
138 | _isExceptions = value;
|
139 | if (_isStarted) {
|
140 | _exceptions.enable(value);
|
141 | }
|
142 | return Configuration;
|
143 | };
|
144 | |
145 |
|
146 |
|
147 |
|
148 |
|
149 | Configuration.setAutoCollectPerformance = function (value) {
|
150 | _isPerformance = value;
|
151 | if (_isStarted) {
|
152 | _performance.enable(value);
|
153 | }
|
154 | return Configuration;
|
155 | };
|
156 | |
157 |
|
158 |
|
159 |
|
160 |
|
161 | Configuration.setAutoCollectRequests = function (value) {
|
162 | _isRequests = value;
|
163 | if (_isStarted) {
|
164 | _serverRequests.enable(value);
|
165 | }
|
166 | return Configuration;
|
167 | };
|
168 | |
169 |
|
170 |
|
171 |
|
172 |
|
173 | Configuration.setAutoCollectDependencies = function (value) {
|
174 | _isDependencies = value;
|
175 | if (_isStarted) {
|
176 | _clientRequests.enable(value);
|
177 | }
|
178 | return Configuration;
|
179 | };
|
180 | |
181 |
|
182 |
|
183 |
|
184 |
|
185 | Configuration.setAutoDependencyCorrelation = function (value) {
|
186 | _isCorrelating = value;
|
187 | if (_isStarted) {
|
188 | _serverRequests.useAutoCorrelation(value);
|
189 | }
|
190 | return Configuration;
|
191 | };
|
192 | |
193 |
|
194 |
|
195 |
|
196 |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 | Configuration.setUseDiskRetryCaching = function (value, resendInterval, maxBytesOnDisk) {
|
203 | _isDiskRetry = value;
|
204 | _diskRetryInterval = resendInterval;
|
205 | _diskRetryMaxBytes = maxBytesOnDisk;
|
206 | if (exports.defaultClient && exports.defaultClient.channel) {
|
207 | exports.defaultClient.channel.setUseDiskRetryCaching(value, resendInterval, maxBytesOnDisk);
|
208 | }
|
209 | return Configuration;
|
210 | };
|
211 | |
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 | Configuration.setInternalLogging = function (enableDebugLogging, enableWarningLogging) {
|
218 | if (enableDebugLogging === void 0) { enableDebugLogging = false; }
|
219 | if (enableWarningLogging === void 0) { enableWarningLogging = true; }
|
220 | Logging.enableDebug = enableDebugLogging;
|
221 | Logging.disableWarnings = !enableWarningLogging;
|
222 | return Configuration;
|
223 | };
|
224 |
|
225 | Configuration.start = start;
|
226 | return Configuration;
|
227 | }());
|
228 | exports.Configuration = Configuration;
|
229 |
|
230 |
|
231 |
|
232 | function dispose() {
|
233 | exports.defaultClient = null;
|
234 | _isStarted = false;
|
235 | if (_console) {
|
236 | _console.dispose();
|
237 | }
|
238 | if (_exceptions) {
|
239 | _exceptions.dispose();
|
240 | }
|
241 | if (_performance) {
|
242 | _performance.dispose();
|
243 | }
|
244 | if (_serverRequests) {
|
245 | _serverRequests.dispose();
|
246 | }
|
247 | if (_clientRequests) {
|
248 | _clientRequests.dispose();
|
249 | }
|
250 | }
|
251 | exports.dispose = dispose;
|
252 |
|
\ | No newline at end of file |