Skip to content

Commit

Permalink
[DebugPlugin] Add an option to disable DebugPlugin processTelemetry l…
Browse files Browse the repository at this point in the history
…ogging #1650
  • Loading branch information
MSNev committed Sep 4, 2021
1 parent 44ec248 commit 1dfa87a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
23 changes: 13 additions & 10 deletions extensions/applicationinsights-debugplugin-js/src/DebugPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ import { IDebugPluginConfig } from './interfaces/IDebugPluginConfig';

interface IDebugConfig {

trackers?: () => string[];
trackers: () => string[];

excludeKeys?: () => string[];
excludeKeys: () => string[];

cssPrefix?: () => string;
cssPrefix: () => string;

disableNotifications?: () => boolean;
disableNotifications: () => boolean;

dumpToConsole?: () => boolean;
dumpToConsole: () => boolean;

maxMessages?: () => number;
maxMessages: () => number;

showFunctions?: () => boolean;
showFunctions: () => boolean;

logProcessTelemetry: () => boolean;
}

const getDefaultConfig = (): IDebugConfig => {
Expand Down Expand Up @@ -64,7 +66,8 @@ const getDefaultConfig = (): IDebugConfig => {
disableNotifications: () => false,
dumpToConsole: () => false,
maxMessages: () => 5000,
showFunctions: () => false
showFunctions: () => false,
logProcessTelemetry: () => false
};

return config;
Expand Down Expand Up @@ -111,7 +114,7 @@ export default class DebugPlugin extends BaseTelemetryPlugin {
/**
* the config for this plugin
*/
let _theConfig: IDebugConfig = {};
let _theConfig: IDebugConfig = getDefaultConfig();

dynamicProto(DebugPlugin, this, (_self, base) => {
_self.initialize = (config: IConfiguration | IDebugPluginConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain) => {
Expand Down Expand Up @@ -355,7 +358,7 @@ export default class DebugPlugin extends BaseTelemetryPlugin {
console.log(`[${_self.identifier}:processTelemetry] complete`);
}

if (!debugBins['processTelemetry']) {
if (!debugBins['processTelemetry'] && _theConfig.logProcessTelemetry() === true) {
dashboard.newLogEntry(event, dateNow() - startTime, `[${_self.identifier}:processTelemetry[${event.baseType}]`, 0, 'processTelemetry');
}
_self.processNext(event, itemCtx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ export interface IDebugPluginConfig extends IConfiguration{
* [Optional] Flag for whether to include functions in the DebugPlugin dashboard. Defaults to false
*/
showFunctions?: boolean;

/**
* [Optional] If processTelemetry is not included in the trackers should the DebugPlugin log the arguments - defaults to false
*/
logProcessTelemetry?: boolean;
}

0 comments on commit 1dfa87a

Please sign in to comment.