-
Notifications
You must be signed in to change notification settings - Fork 261
Expand file tree
/
Copy pathProcessTelemetryContext.ts
More file actions
645 lines (544 loc) · 26.2 KB
/
Copy pathProcessTelemetryContext.ts
File metadata and controls
645 lines (544 loc) · 26.2 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
"use strict";
import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums";
import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
import {
GetExtCfgMergeType, IBaseProcessingContext, IProcessTelemetryContext, IProcessTelemetryUnloadContext, IProcessTelemetryUpdateContext
} from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
import { IPlugin, ITelemetryPlugin } from "../JavaScriptSDK.Interfaces/ITelemetryPlugin";
import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPluginChain";
import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
import { _throwInternal, safeGetLogger } from "./DiagnosticLogger";
import { dumpObj } from "./EnvUtils";
import {
arrForEach, isArray, isFunction, isNullOrUndefined, isObject, isUndefined, objExtend, objForEachKey, objFreeze, objKeys, proxyFunctions
} from "./HelperFuncs";
import { STR_CORE, STR_DISABLED, STR_EMPTY } from "./InternalConstants";
import { doPerf } from "./PerfManager";
import { _getPluginState } from "./TelemetryHelpers";
const strTelemetryPluginChain = "TelemetryPluginChain";
const strHasRunFlags = "_hasRun";
const strGetTelCtx = "_getTelCtx";
let _chainId = 0;
interface OnCompleteCallback {
func: () => void;
self: any; // This for the function
args: any[]; // Additional arguments for the function
}
interface IInternalTelemetryPluginChain extends ITelemetryPluginChain {
_id: string;
_setNext: (nextPlugin: IInternalTelemetryPluginChain) => void;
}
interface IInternalContext<T extends IBaseProcessingContext> {
_next: () => ITelemetryPluginChain,
// The public context that will be exposed
ctx: T
}
function _getNextProxyStart<T, C = IConfiguration>(proxy: ITelemetryPluginChain, core: IAppInsightsCore, startAt: IPlugin): ITelemetryPluginChain {
while (proxy) {
if (proxy.getPlugin() === startAt) {
return proxy;
}
proxy = proxy.getNext();
}
// This wasn't found in the existing chain so create an isolated one with just this plugin
return createTelemetryProxyChain([startAt], core.config || {}, core);
}
/**
* @ignore
* @param telemetryChain
* @param config
* @param core
* @param startAt - Identifies the next plugin to execute, if null there is no "next" plugin and if undefined it should assume the start of the chain
* @returns
*/
function _createInternalContext<T extends IBaseProcessingContext>(telemetryChain: ITelemetryPluginChain, config: IConfiguration, core: IAppInsightsCore, startAt?: IPlugin): IInternalContext<T> {
// We have a special case where we want to start execution from this specific plugin
// or we simply reuse the existing telemetry plugin chain (normal execution case)
let _nextProxy: ITelemetryPluginChain | null = null; // By Default set as no next plugin
let _onComplete: OnCompleteCallback[] = [];
if (startAt !== null) {
// There is no next element (null) vs not defined (undefined) so use the full chain
_nextProxy = startAt ? _getNextProxyStart(telemetryChain, core, startAt) : telemetryChain;
}
let context: IInternalContext<T> = {
_next: _moveNext,
ctx: {
core: () => {
return core
},
diagLog: () => {
return safeGetLogger(core, config);
},
getCfg: () => {
return config;
},
getExtCfg: _getExtCfg,
getConfig: _getConfig,
hasNext: () => {
return !!_nextProxy;
},
getNext: () => {
return _nextProxy;
},
setNext: (nextPlugin:ITelemetryPluginChain) => {
_nextProxy = nextPlugin;
},
iterate: _iterateChain,
onComplete: _addOnComplete
} as T
};
function _addOnComplete(onComplete: () => void, that?: any, ...args: any[]) {
if (onComplete) {
_onComplete.push({
func: onComplete,
self: !isUndefined(that) ? that : context.ctx,
args: args
});
}
}
function _moveNext() {
let nextProxy = _nextProxy;
// Automatically move to the next plugin
_nextProxy = nextProxy ? nextProxy.getNext() : null;
if (!nextProxy) {
let onComplete = _onComplete;
if (onComplete && onComplete.length > 0) {
arrForEach(onComplete, (completeDetails) => {
try {
completeDetails.func.call(completeDetails.self, completeDetails.args);
} catch (e) {
_throwInternal(
core.logger,
eLoggingSeverity.WARNING,
_eInternalMessageId.PluginException,
"Unexpected Exception during onComplete - " + dumpObj(e));
}
});
_onComplete = [];
}
}
return nextProxy;
}
function _getExtCfg<T>(identifier: string, defaultValue: T|any = {}, mergeDefault: GetExtCfgMergeType = GetExtCfgMergeType.None) {
let theConfig: T;
if (config) {
let extConfig = config.extensionConfig;
if (extConfig && identifier) {
theConfig = extConfig[identifier];
}
}
if (!theConfig) {
// Just use the defaults
theConfig = defaultValue as T;
} else if (isObject(defaultValue)) {
if (mergeDefault !== GetExtCfgMergeType.None) {
// Merge the defaults and configured values
let newConfig = objExtend(true, defaultValue, theConfig);
if (config && mergeDefault === GetExtCfgMergeType.MergeDefaultFromRootOrDefault) {
// Enumerate over the defaultValues and if not already populated attempt to
// find a value from the root config
objForEachKey(defaultValue, (field) => {
// for each unspecified field, set the default value
if (isNullOrUndefined(newConfig[field])) {
let cfgValue = config[field];
if (!isNullOrUndefined(cfgValue)) {
newConfig[field] = cfgValue;
}
}
});
}
theConfig = newConfig;
}
}
return theConfig;
}
function _getConfig(identifier:string, field: string, defaultValue: number | string | boolean | string[] | RegExp[] | Function = false) {
let theValue;
let extConfig = _getExtCfg(identifier, null);
if (extConfig && !isNullOrUndefined(extConfig[field])) {
theValue = extConfig[field];
} else if (config && !isNullOrUndefined(config[field])) {
theValue = config[field];
}
return !isNullOrUndefined(theValue) ? theValue : defaultValue;
}
function _iterateChain<T extends ITelemetryPlugin = ITelemetryPlugin>(cb: (plugin: T) => void) {
// Keep processing until we reach the end of the chain
let nextPlugin: ITelemetryPluginChain;
while(!!(nextPlugin = context._next())) {
let plugin = nextPlugin.getPlugin();
if (plugin) {
// callback with the current on
cb(plugin as T);
}
}
}
return context;
}
/**
* Creates a new Telemetry Item context with the current config, core and plugin execution chain
* @param plugins - The plugin instances that will be executed
* @param config - The current config
* @param core - The current core instance
* @param startAt - Identifies the next plugin to execute, if null there is no "next" plugin and if undefined it should assume the start of the chain
*/
export function createProcessTelemetryContext(telemetryChain: ITelemetryPluginChain | null, config: IConfiguration, core:IAppInsightsCore, startAt?: IPlugin): IProcessTelemetryContext {
let internalContext: IInternalContext<IProcessTelemetryContext> = _createInternalContext<IProcessTelemetryContext>(telemetryChain, config, core, startAt);
let context = internalContext.ctx;
function _processNext(env: ITelemetryItem) {
let nextPlugin: ITelemetryPluginChain = internalContext._next();
// Run the next plugin which will call "processNext()"
nextPlugin && nextPlugin.processTelemetry(env, context);
return !nextPlugin;
}
function _createNew(plugins: IPlugin[] | ITelemetryPluginChain | null = null, startAt?: IPlugin) {
if (isArray(plugins)) {
plugins = createTelemetryProxyChain(plugins, config, core, startAt);
}
return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
}
context.processNext = _processNext;
context.createNew = _createNew;
return context;
}
/**
* Creates a new Telemetry Item context with the current config, core and plugin execution chain for handling the unloading of the chain
* @param plugins - The plugin instances that will be executed
* @param config - The current config
* @param core - The current core instance
* @param startAt - Identifies the next plugin to execute, if null there is no "next" plugin and if undefined it should assume the start of the chain
*/
export function createProcessTelemetryUnloadContext(telemetryChain: ITelemetryPluginChain, core: IAppInsightsCore, startAt?: IPlugin): IProcessTelemetryUnloadContext {
let config = core.config || {};
let internalContext: IInternalContext<IProcessTelemetryUnloadContext> = _createInternalContext<IProcessTelemetryUnloadContext>(telemetryChain, config, core, startAt);
let context = internalContext.ctx;
function _processNext(unloadState: ITelemetryUnloadState) {
let nextPlugin: ITelemetryPluginChain = internalContext._next();
nextPlugin && nextPlugin.unload(context, unloadState);
return !nextPlugin;
}
function _createNew(plugins: IPlugin[] | ITelemetryPluginChain = null, startAt?: IPlugin): IProcessTelemetryUnloadContext {
if (isArray(plugins)) {
plugins = createTelemetryProxyChain(plugins, config, core, startAt);
}
return createProcessTelemetryUnloadContext(plugins || context.getNext(), core, startAt);
}
context.processNext = _processNext;
context.createNew = _createNew
return context;
}
/**
* Creates a new Telemetry Item context with the current config, core and plugin execution chain for updating the configuration
* @param plugins - The plugin instances that will be executed
* @param config - The current config
* @param core - The current core instance
* @param startAt - Identifies the next plugin to execute, if null there is no "next" plugin and if undefined it should assume the start of the chain
*/
export function createProcessTelemetryUpdateContext(telemetryChain: ITelemetryPluginChain, core: IAppInsightsCore, startAt?: IPlugin): IProcessTelemetryUpdateContext {
let config = core.config || {};
let internalContext: IInternalContext<IProcessTelemetryUpdateContext> = _createInternalContext<IProcessTelemetryUpdateContext>(telemetryChain, config, core, startAt);
let context = internalContext.ctx;
function _processNext(updateState: ITelemetryUpdateState) {
return context.iterate((plugin) => {
if (isFunction(plugin.update)) {
plugin.update(context, updateState);
}
});
}
function _createNew(plugins: IPlugin[] | ITelemetryPluginChain = null, startAt?: IPlugin) {
if (isArray(plugins)) {
plugins = createTelemetryProxyChain(plugins, config, core, startAt);
}
return createProcessTelemetryUpdateContext(plugins || context.getNext(), core, startAt);
}
context.processNext = _processNext;
context.createNew = _createNew;
return context;
}
/**
* Creates an execution chain from the array of plugins
* @param plugins - The array of plugins that will be executed in this order
* @param defItemCtx - The default execution context to use when no telemetry context is passed to processTelemetry(), this
* should be for legacy plugins only. Currently, only used for passing the current core instance and to provide better error
* reporting (hasRun) when errors occur.
*/
export function createTelemetryProxyChain(plugins: IPlugin[], config: IConfiguration, core: IAppInsightsCore, startAt?: IPlugin): ITelemetryPluginChain {
let firstProxy: ITelemetryPluginChain = null;
let add = startAt ? false : true;
if (isArray(plugins) && plugins.length > 0) {
// Create the proxies and wire up the next plugin chain
let lastProxy: IInternalTelemetryPluginChain = null;
arrForEach(plugins, (thePlugin: ITelemetryPlugin) => {
if (!add && startAt === thePlugin) {
add = true;
}
if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
// Only add plugins that are processors
let newProxy = createTelemetryPluginProxy(thePlugin, config, core);
if (!firstProxy) {
firstProxy = newProxy;
}
if (lastProxy) {
// Set this new proxy as the next for the previous one
lastProxy._setNext(newProxy as IInternalTelemetryPluginChain);
}
lastProxy = newProxy as IInternalTelemetryPluginChain;
}
});
}
if (startAt && !firstProxy) {
// Special case where the "startAt" was not in the original list of plugins
return createTelemetryProxyChain([startAt], config, core);
}
return firstProxy;
}
/**
* Create the processing telemetry proxy instance, the proxy is used to abstract the current plugin to allow monitoring and
* execution plugins while passing around the dynamic execution state (IProcessTelemetryContext), the proxy instance no longer
* contains any execution state and can be reused between requests (this was not the case for 2.7.2 and earlier with the
* TelemetryPluginChain class).
* @param plugin - The plugin instance to proxy
* @param config - The default execution context to use when no telemetry context is passed to processTelemetry(), this
* should be for legacy plugins only. Currently, only used for passing the current core instance and to provide better error
* reporting (hasRun) when errors occur.
* @returns
*/
export function createTelemetryPluginProxy(plugin: ITelemetryPlugin, config: IConfiguration, core: IAppInsightsCore): ITelemetryPluginChain {
let nextProxy: IInternalTelemetryPluginChain = null;
let hasProcessTelemetry = isFunction(plugin.processTelemetry);
let hasSetNext = isFunction(plugin.setNextPlugin);
let chainId: string;
if (plugin) {
chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
} else {
chainId = "Unknown-0-" + _chainId++;
}
let proxyChain: IInternalTelemetryPluginChain = {
getPlugin: () => {
return plugin;
},
getNext: () => {
return nextProxy;
},
processTelemetry: _processTelemetry,
unload: _unloadPlugin,
update: _updatePlugin,
_id: chainId,
_setNext: (nextPlugin: IInternalTelemetryPluginChain) => {
nextProxy = nextPlugin;
}
};
function _getTelCtx() {
let itemCtx: IProcessTelemetryContext;
// Looks like a plugin didn't pass the (optional) context, so create a new one
if (plugin && isFunction(plugin[strGetTelCtx])) {
// This plugin extends from the BaseTelemetryPlugin so lets use it
itemCtx = plugin[strGetTelCtx]();
}
if (!itemCtx) {
// Create a temporary one
itemCtx = createProcessTelemetryContext(proxyChain, config, core);
}
return itemCtx;
}
function _processChain<T extends IBaseProcessingContext>(
itemCtx: T,
processPluginFn: (itemCtx: T) => boolean,
name: string,
details: () => any,
isAsync: boolean) {
let hasRun = false;
let identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
let hasRunContext = itemCtx[strHasRunFlags];
if (!hasRunContext) {
// Assign and populate
hasRunContext = itemCtx[strHasRunFlags] = {};
}
// Ensure that we keep the context in sync
itemCtx.setNext(nextProxy);
if (plugin) {
doPerf(itemCtx.core(), () => identifier + ":" + name, () => {
// Mark this component as having run
hasRunContext[chainId] = true;
try {
// Set a flag on the next plugin so we know if it was attempted to be executed
let nextId = nextProxy ? nextProxy._id : STR_EMPTY;
if (nextId) {
hasRunContext[nextId] = false;
}
hasRun = processPluginFn(itemCtx);
} catch (error) {
let hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
if (hasNextRun) {
// The next plugin after us has already run so set this one as complete
hasRun = true;
}
if (!nextProxy || !hasNextRun) {
// Either we have no next plugin or the current one did not attempt to call the next plugin
// Which means the current one is the root of the failure so log/report this failure
_throwInternal(
itemCtx.diagLog(),
eLoggingSeverity.CRITICAL,
_eInternalMessageId.PluginException,
"Plugin [" + identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
}
}
}, details, isAsync);
}
return hasRun;
}
function _processTelemetry(env: ITelemetryItem, itemCtx: IProcessTelemetryContext) {
itemCtx = itemCtx || _getTelCtx();
function _callProcessTelemetry(itemCtx: IProcessTelemetryContext) {
if (!plugin || !hasProcessTelemetry) {
return false;
}
let pluginState = _getPluginState(plugin);
if (pluginState.teardown || pluginState[STR_DISABLED]) {
return false;
}
// Ensure that we keep the context in sync (for processNext()), just in case a plugin
// doesn't calls processTelemetry() instead of itemContext.processNext() or some
// other form of error occurred
if (hasSetNext) {
// Backward compatibility setting the next plugin on the instance
plugin.setNextPlugin(nextProxy);
}
plugin.processTelemetry(env, itemCtx);
// Process Telemetry is expected to call itemCtx.processNext() or nextPlugin.processTelemetry()
return true;
}
if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", () => ({ item: env }), !((env as any).sync))) {
// The underlying plugin is either not defined, not enabled or does not have a processTelemetry implementation
// so we still want the next plugin to be executed.
itemCtx.processNext(env);
}
}
function _unloadPlugin(unloadCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) {
function _callTeardown() {
// Setting default of hasRun as false so the proxyProcessFn() is called as teardown() doesn't have to exist or call unloadNext().
let hasRun = false;
if (plugin) {
let pluginState = _getPluginState(plugin);
let pluginCore = plugin[STR_CORE] || pluginState.core;
// Only teardown the plugin if it was initialized by the current core (i.e. It's not a shared plugin)
if (plugin && (!pluginCore || pluginCore === unloadCtx.core()) && !pluginState.teardown) {
// Handle plugins that don't extend from the BaseTelemetryPlugin
pluginState.core = null;
pluginState.teardown = true;
pluginState.isInitialized = false;
if (plugin.teardown && plugin.teardown(unloadCtx, unloadState) === true) {
// plugin told us that it was going to (or has) call unloadCtx.processNext()
hasRun = true;
}
}
}
return hasRun;
}
if (!_processChain(unloadCtx, _callTeardown, "unload", () => {}, unloadState.isAsync)) {
// Only called if we hasRun was not true
unloadCtx.processNext(unloadState);
}
}
function _updatePlugin(updateCtx: IProcessTelemetryUpdateContext, updateState: ITelemetryUpdateState) {
function _callUpdate() {
// Setting default of hasRun as false so the proxyProcessFn() is called as teardown() doesn't have to exist or call unloadNext().
let hasRun = false;
if (plugin) {
let pluginState = _getPluginState(plugin);
let pluginCore = plugin[STR_CORE] || pluginState.core;
// Only update the plugin if it was initialized by the current core (i.e. It's not a shared plugin)
if (plugin && (!pluginCore || pluginCore === updateCtx.core()) && !pluginState.teardown) {
if (plugin.update && plugin.update(updateCtx, updateState) === true) {
// plugin told us that it was going to (or has) call unloadCtx.processNext()
hasRun = true;
}
}
}
return hasRun;
}
if (!_processChain(updateCtx, _callUpdate, "update", () => {}, false)) {
// Only called if we hasRun was not true
updateCtx.processNext(updateState);
}
}
return objFreeze(proxyChain);
}
/**
* This class will be removed!
* @deprecated use createProcessTelemetryContext() instead
*/
export class ProcessTelemetryContext implements IProcessTelemetryContext {
/**
* Gets the current core config instance
*/
public getCfg: () => IConfiguration;
public getExtCfg: <T>(identifier:string, defaultValue?:T|any) => T;
public getConfig: (identifier:string, field: string, defaultValue?: number | string | boolean | string[] | RegExp[] | Function) => number | string | boolean | string[] | RegExp[] | Function;
/**
* Returns the IAppInsightsCore instance for the current request
*/
public core: () => IAppInsightsCore;
/**
* Returns the current IDiagnosticsLogger for the current request
*/
public diagLog: () => IDiagnosticLogger;
/**
* Helper to allow inherited classes to check and possibly shortcut executing code only
* required if there is a nextPlugin
*/
public hasNext: () => boolean;
/**
* Returns the next configured plugin proxy
*/
public getNext: () => ITelemetryPluginChain;
/**
* Helper to set the next plugin proxy
*/
public setNext: (nextCtx:ITelemetryPluginChain) => void;
/**
* Call back for telemetry processing before it it is sent
* @param env - This is the current event being reported
* @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
* can optionally use this to access the current core instance or define / pass additional information
* to later plugins (vs appending items to the telemetry item)
* @returns boolean (true) if there is no more plugins to process otherwise false or undefined (void)
*/
public processNext: (env: ITelemetryItem) => boolean | void;
/**
* Synchronously iterate over the context chain running the callback for each plugin, once
* every plugin has been executed via the callback, any associated onComplete will be called.
* @param callback - The function call for each plugin in the context chain
*/
public iterate: <T extends ITelemetryPlugin = ITelemetryPlugin>(callback: (plugin: T) => void) => void;
/**
* Create a new context using the core and config from the current instance
* @param plugins - The execution order to process the plugins, if null or not supplied
* then the current execution order will be copied.
* @param startAt - The plugin to start processing from, if missing from the execution
* order then the next plugin will be NOT set.
*/
public createNew: (plugins?:IPlugin[]|ITelemetryPluginChain, startAt?:IPlugin) => IProcessTelemetryContext;
/**
* Set the function to call when the current chain has executed all processNext or unloadNext items.
*/
public onComplete: (onComplete: () => void) => void;
/**
* Creates a new Telemetry Item context with the current config, core and plugin execution chain
* @param plugins - The plugin instances that will be executed
* @param config - The current config
* @param core - The current core instance
*/
constructor(pluginChain: ITelemetryPluginChain, config: IConfiguration, core: IAppInsightsCore, startAt?:IPlugin) {
let _self = this;
let context = createProcessTelemetryContext(pluginChain, config, core, startAt);
// Proxy all functions of the context to this object
proxyFunctions(_self, context, objKeys(context) as any);
}
}