@fluidframework/telemetry-utils 2.0.0-internal.3.0.5 → 2.0.0-internal.3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/.eslintrc.js +11 -13
  2. package/.mocharc.js +2 -2
  3. package/api-extractor.json +2 -2
  4. package/dist/config.d.ts.map +1 -1
  5. package/dist/config.js +3 -3
  6. package/dist/config.js.map +1 -1
  7. package/dist/debugLogger.d.ts.map +1 -1
  8. package/dist/debugLogger.js.map +1 -1
  9. package/dist/errorLogging.d.ts +5 -5
  10. package/dist/errorLogging.d.ts.map +1 -1
  11. package/dist/errorLogging.js +20 -18
  12. package/dist/errorLogging.js.map +1 -1
  13. package/dist/eventEmitterWithErrorHandling.d.ts.map +1 -1
  14. package/dist/eventEmitterWithErrorHandling.js.map +1 -1
  15. package/dist/events.d.ts.map +1 -1
  16. package/dist/events.js.map +1 -1
  17. package/dist/fluidErrorBase.d.ts.map +1 -1
  18. package/dist/fluidErrorBase.js +4 -4
  19. package/dist/fluidErrorBase.js.map +1 -1
  20. package/dist/index.d.ts +2 -2
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/logger.d.ts.map +1 -1
  24. package/dist/logger.js +13 -12
  25. package/dist/logger.js.map +1 -1
  26. package/dist/mockLogger.d.ts +5 -5
  27. package/dist/mockLogger.d.ts.map +1 -1
  28. package/dist/mockLogger.js +5 -5
  29. package/dist/mockLogger.js.map +1 -1
  30. package/dist/packageVersion.d.ts +1 -1
  31. package/dist/packageVersion.js +1 -1
  32. package/dist/packageVersion.js.map +1 -1
  33. package/dist/sampledTelemetryHelper.d.ts.map +1 -1
  34. package/dist/sampledTelemetryHelper.js.map +1 -1
  35. package/dist/telemetryTypes.d.ts.map +1 -1
  36. package/dist/telemetryTypes.js.map +1 -1
  37. package/dist/thresholdCounter.d.ts.map +1 -1
  38. package/dist/thresholdCounter.js.map +1 -1
  39. package/dist/utils.d.ts.map +1 -1
  40. package/dist/utils.js.map +1 -1
  41. package/lib/config.d.ts.map +1 -1
  42. package/lib/config.js +3 -3
  43. package/lib/config.js.map +1 -1
  44. package/lib/debugLogger.d.ts.map +1 -1
  45. package/lib/debugLogger.js +1 -1
  46. package/lib/debugLogger.js.map +1 -1
  47. package/lib/errorLogging.d.ts +5 -5
  48. package/lib/errorLogging.d.ts.map +1 -1
  49. package/lib/errorLogging.js +20 -18
  50. package/lib/errorLogging.js.map +1 -1
  51. package/lib/eventEmitterWithErrorHandling.d.ts.map +1 -1
  52. package/lib/eventEmitterWithErrorHandling.js.map +1 -1
  53. package/lib/events.d.ts.map +1 -1
  54. package/lib/events.js.map +1 -1
  55. package/lib/fluidErrorBase.d.ts.map +1 -1
  56. package/lib/fluidErrorBase.js +4 -4
  57. package/lib/fluidErrorBase.js.map +1 -1
  58. package/lib/index.d.ts +2 -2
  59. package/lib/index.d.ts.map +1 -1
  60. package/lib/index.js +2 -2
  61. package/lib/index.js.map +1 -1
  62. package/lib/logger.d.ts.map +1 -1
  63. package/lib/logger.js +14 -13
  64. package/lib/logger.js.map +1 -1
  65. package/lib/mockLogger.d.ts +5 -5
  66. package/lib/mockLogger.d.ts.map +1 -1
  67. package/lib/mockLogger.js +5 -5
  68. package/lib/mockLogger.js.map +1 -1
  69. package/lib/packageVersion.d.ts +1 -1
  70. package/lib/packageVersion.js +1 -1
  71. package/lib/packageVersion.js.map +1 -1
  72. package/lib/sampledTelemetryHelper.d.ts.map +1 -1
  73. package/lib/sampledTelemetryHelper.js.map +1 -1
  74. package/lib/telemetryTypes.d.ts.map +1 -1
  75. package/lib/telemetryTypes.js.map +1 -1
  76. package/lib/thresholdCounter.d.ts.map +1 -1
  77. package/lib/thresholdCounter.js.map +1 -1
  78. package/lib/utils.d.ts.map +1 -1
  79. package/lib/utils.js.map +1 -1
  80. package/package.json +107 -106
  81. package/prettier.config.cjs +1 -1
  82. package/src/config.ts +173 -172
  83. package/src/debugLogger.ts +118 -111
  84. package/src/errorLogging.ts +302 -299
  85. package/src/eventEmitterWithErrorHandling.ts +16 -12
  86. package/src/events.ts +26 -26
  87. package/src/fluidErrorBase.ts +42 -38
  88. package/src/index.ts +26 -16
  89. package/src/logger.ts +541 -533
  90. package/src/mockLogger.ts +113 -107
  91. package/src/packageVersion.ts +1 -1
  92. package/src/sampledTelemetryHelper.ts +122 -122
  93. package/src/telemetryTypes.ts +37 -37
  94. package/src/thresholdCounter.ts +34 -34
  95. package/src/utils.ts +15 -15
  96. package/tsconfig.esnext.json +6 -6
  97. package/tsconfig.json +9 -13
package/lib/logger.js CHANGED
@@ -14,7 +14,7 @@ var __rest = (this && this.__rest) || function (s, e) {
14
14
  return t;
15
15
  };
16
16
  import { performance } from "@fluidframework/common-utils";
17
- import { CachedConfigProvider, loggerIsMonitoringContext, mixinMonitoringContext, } from "./config";
17
+ import { CachedConfigProvider, loggerIsMonitoringContext, mixinMonitoringContext } from "./config";
18
18
  import { isILoggingError, extractLogSafeErrorProperties, generateStack, isTaggedTelemetryPropertyValue, } from "./errorLogging";
19
19
  /**
20
20
  * Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.
@@ -183,7 +183,7 @@ export class TaggedLoggerAdapter {
183
183
  };
184
184
  for (const key of Object.keys(eventWithTagsMaybe)) {
185
185
  const taggableProp = eventWithTagsMaybe[key];
186
- const { value, tag } = (typeof taggableProp === "object")
186
+ const { value, tag } = typeof taggableProp === "object"
187
187
  ? taggableProp
188
188
  : { value: taggableProp, tag: undefined };
189
189
  switch (tag) {
@@ -349,7 +349,9 @@ export class PerformanceEvent {
349
349
  throw error;
350
350
  }
351
351
  }
352
- get duration() { return performance.now() - this.startTime; }
352
+ get duration() {
353
+ return performance.now() - this.startTime;
354
+ }
353
355
  reportProgress(props, eventNameSuffix = "update") {
354
356
  this.reportEvent(eventNameSuffix, props);
355
357
  }
@@ -403,15 +405,12 @@ export class PerformanceEvent {
403
405
  * It can be used in places where logger instance is required, but events should be not send over.
404
406
  */
405
407
  export class TelemetryUTLogger {
406
- send(event) {
407
- }
408
- sendTelemetryEvent(event, error) {
409
- }
408
+ send(event) { }
409
+ sendTelemetryEvent(event, error) { }
410
410
  sendErrorEvent(event, error) {
411
411
  this.reportError("errorEvent in UT logger!", event, error);
412
412
  }
413
- sendPerformanceEvent(event, error) {
414
- }
413
+ sendPerformanceEvent(event, error) { }
415
414
  logGenericError(eventName, error) {
416
415
  this.reportError(`genericError in UT logger!`, { eventName }, error);
417
416
  }
@@ -481,10 +480,12 @@ function convertToBaseEvent(_a) {
481
480
  * @param x - value passed in to convert to a base property type
482
481
  */
483
482
  export function convertToBasePropertyType(x) {
484
- return isTaggedTelemetryPropertyValue(x) ? {
485
- value: convertToBasePropertyTypeUntagged(x.value),
486
- tag: x.tag,
487
- } : convertToBasePropertyTypeUntagged(x);
483
+ return isTaggedTelemetryPropertyValue(x)
484
+ ? {
485
+ value: convertToBasePropertyTypeUntagged(x.value),
486
+ tag: x.tag,
487
+ }
488
+ : convertToBasePropertyTypeUntagged(x);
488
489
  }
489
490
  function convertToBasePropertyTypeUntagged(x) {
490
491
  switch (typeof x) {
package/lib/logger.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;AAcH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EACH,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,GACzB,MAAM,UAAU,CAAC;AAClB,OAAO,EACH,eAAe,EACf,6BAA6B,EAC7B,aAAa,EACb,8BAA8B,GACjC,MAAM,gBAAgB,CAAC;AAUxB;;;GAGG;AACH,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IACxB,4FAA4F;IAC5F,iDAA6B,CAAA;IAC7B,8EAA8E;IAC9E,yCAAqB,CAAA;AACzB,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK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,SAAS,kBAAkB,CAAC,EAAqD;QAArD,EAAE,QAAQ,EAAE,SAAS,OAAgC,EAA3B,KAAK,cAA/B,yBAAiC,CAAF;IACvD,MAAM,QAAQ,GAAwB,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAC9D,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QAClC,QAAQ,CAAC,GAAG,CAAC,GAAG,yBAAyB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;KACzD;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB,CACrC,CAAkE;IAGlE,OAAO,8BAA8B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,KAAK,EAAE,iCAAiC,CAAC,CAAC,CAAC,KAAK,CAAC;QACjD,GAAG,EAAE,CAAC,CAAC,GAAG;KACb,CAAC,CAAC,CAAC,iCAAiC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,SAAS,iCAAiC,CACtC,CAAgC;IAEhC,QAAQ,OAAO,CAAC,EAAE;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,WAAW;YACZ,OAAO,CAAC,CAAC;QACb,KAAK,QAAQ;YACT,sDAAsD;YACtD,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC7B;YACI,wDAAwD;YACxD,OAAO,CAAC,KAAK,CAAC,iEAAiE,OAAO,CAAC,GAAG,CAAC,CAAC;YAC5F,OAAO,8BAA8B,OAAO,CAAC,GAAG,CAAC;KACxD;AACL,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n ITelemetryBaseEvent,\n ITelemetryBaseLogger,\n ITelemetryErrorEvent,\n ITelemetryGenericEvent,\n ITelemetryLogger,\n ITelemetryPerformanceEvent,\n ITelemetryProperties,\n TelemetryEventPropertyType,\n ITaggedTelemetryPropertyType,\n TelemetryEventCategory,\n} from \"@fluidframework/common-definitions\";\nimport { performance } from \"@fluidframework/common-utils\";\nimport {\n CachedConfigProvider,\n loggerIsMonitoringContext,\n mixinMonitoringContext,\n} from \"./config\";\nimport {\n isILoggingError,\n extractLogSafeErrorProperties,\n generateStack,\n isTaggedTelemetryPropertyValue,\n} from \"./errorLogging\";\nimport {\n ITaggedTelemetryPropertyTypeExt,\n ITelemetryEventExt,\n ITelemetryGenericEventExt,\n ITelemetryLoggerExt,\n ITelemetryPerformanceEventExt,\n TelemetryEventPropertyTypeExt,\n} from \"./telemetryTypes\";\n\n/**\n * Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.\n * Please do not modify existing entries for backwards compatibility.\n */\nexport enum TelemetryDataTag {\n /** Data containing terms or IDs from code packages that may have been dynamically loaded */\n CodeArtifact = \"CodeArtifact\",\n /** Personal data of a variety of classifications that pertains to the user */\n UserData = \"UserData\",\n}\n\nexport type TelemetryEventPropertyTypes = TelemetryEventPropertyType | ITaggedTelemetryPropertyType;\n\nexport interface ITelemetryLoggerPropertyBag {\n [index: string]: TelemetryEventPropertyTypes | (() => TelemetryEventPropertyTypes);\n}\nexport interface ITelemetryLoggerPropertyBags{\n all?: ITelemetryLoggerPropertyBag;\n error?: ITelemetryLoggerPropertyBag;\n}\n\n/**\n * TelemetryLogger class contains various helper telemetry methods,\n * encoding in one place schemas for various types of Fluid telemetry events.\n * Creates sub-logger that appends properties to all events\n */\nexport abstract class TelemetryLogger implements ITelemetryLoggerExt {\n public static readonly eventNamespaceSeparator = \":\";\n\n public static formatTick(tick: number): number {\n return Math.floor(tick);\n }\n\n /**\n * Attempts to parse number from string.\n * If fails,returns original string.\n * Used to make telemetry data typed (and support math operations, like comparison),\n * in places where we do expect numbers (like contentsize/duration property in http header)\n */\n public static numberFromString(str: string | null | undefined): string | number | undefined {\n if (str === undefined || str === null) {\n return undefined;\n }\n const num = Number(str);\n return Number.isNaN(num) ? str : num;\n }\n\n public static sanitizePkgName(name: string) {\n return name.replace(\"@\", \"\").replace(\"/\", \"-\");\n }\n\n /**\n * Take an unknown error object and add the appropriate info from it to the event. Message and stack will be copied\n * over from the error object, along with other telemetry properties if it's an ILoggingError.\n * @param event - Event being logged\n * @param error - Error to extract info from\n * @param fetchStack - Whether to fetch the current callstack if error.stack is undefined\n */\n public static prepareErrorObject(event: ITelemetryBaseEvent, error: any, fetchStack: boolean) {\n const { message, errorType, stack } = extractLogSafeErrorProperties(error, true /* sanitizeStack */);\n // First, copy over error message, stack, and errorType directly (overwrite if present on event)\n event.stack = stack;\n event.error = message; // Note that the error message goes on the 'error' field\n event.errorType = errorType;\n\n if (isILoggingError(error)) {\n // Add any other telemetry properties from the LoggingError\n const telemetryProp = error.getTelemetryProperties();\n for (const key of Object.keys(telemetryProp)) {\n if (event[key] !== undefined) {\n // Don't overwrite existing properties on the event\n continue;\n }\n event[key] = telemetryProp[key];\n }\n }\n\n // Collect stack if we were not able to extract it from error\n if (event.stack === undefined && fetchStack) {\n event.stack = generateStack();\n }\n }\n\n public constructor(\n protected readonly namespace?: string,\n protected readonly properties?: ITelemetryLoggerPropertyBags) {\n }\n\n /**\n * Send an event with the logger\n *\n * @param event - the event to send\n */\n public abstract send(event: ITelemetryBaseEvent): void;\n\n /**\n * Send a telemetry event with the logger\n *\n * @param event - the event to send\n * @param error - optional error object to log\n */\n public sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: any) {\n this.sendTelemetryEventCore({ ...event, category: event.category ?? \"generic\" }, error);\n }\n\n /**\n * Send a telemetry event with the logger\n *\n * @param event - the event to send\n * @param error - optional error object to log\n */\n protected sendTelemetryEventCore(\n event: ITelemetryGenericEventExt & { category: TelemetryEventCategory; },\n error?: any) {\n const newEvent = convertToBaseEvent(event);\n if (error !== undefined) {\n TelemetryLogger.prepareErrorObject(newEvent, error, false);\n }\n\n // Will include Nan & Infinity, but probably we do not care\n if (typeof newEvent.duration === \"number\") {\n newEvent.duration = TelemetryLogger.formatTick(newEvent.duration);\n }\n\n this.send(newEvent);\n }\n\n /**\n * Send an error telemetry event with the logger\n *\n * @param event - the event to send\n * @param error - optional error object to log\n */\n public sendErrorEvent(event: ITelemetryErrorEvent, error?: any) {\n this.sendTelemetryEventCore({\n // ensure the error field has some value,\n // this can and will be overridden by event, or error\n error: event.eventName,\n ...event,\n category: \"error\",\n }, error);\n }\n\n /**\n * Send a performance telemetry event with the logger\n *\n * @param event - Event to send\n * @param error - optional error object to log\n */\n public sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: any): void {\n const perfEvent = {\n ...event,\n category: event.category ?? \"performance\",\n };\n\n this.sendTelemetryEventCore(perfEvent, error);\n }\n\n protected prepareEvent(event: ITelemetryBaseEvent): ITelemetryBaseEvent {\n const includeErrorProps = event.category === \"error\" || event.error !== undefined;\n const newEvent: ITelemetryBaseEvent = {\n ...event,\n };\n if (this.namespace !== undefined) {\n newEvent.eventName = `${this.namespace}${TelemetryLogger.eventNamespaceSeparator}${newEvent.eventName}`;\n }\n if (this.properties) {\n const properties: (undefined | ITelemetryLoggerPropertyBag)[] = [];\n properties.push(this.properties.all);\n if (includeErrorProps) {\n properties.push(this.properties.error);\n }\n for (const props of properties) {\n if (props !== undefined) {\n for (const key of Object.keys(props)) {\n if (event[key] !== undefined) {\n continue;\n }\n const getterOrValue = props[key];\n // If this throws, hopefully it is handled elsewhere\n const value = typeof getterOrValue === \"function\" ? getterOrValue() : getterOrValue;\n if (value !== undefined) {\n newEvent[key] = value;\n }\n }\n }\n }\n }\n return newEvent;\n }\n}\n\n/**\n * @deprecated 0.56, remove TaggedLoggerAdapter once its usage is removed from\n * container-runtime. Issue: #8191\n * TaggedLoggerAdapter class can add tag handling to your logger.\n */\n export class TaggedLoggerAdapter implements ITelemetryBaseLogger {\n public constructor(\n private readonly logger: ITelemetryBaseLogger) {\n }\n\n public send(eventWithTagsMaybe: ITelemetryBaseEvent) {\n const newEvent: ITelemetryBaseEvent = {\n category: eventWithTagsMaybe.category,\n eventName: eventWithTagsMaybe.eventName,\n };\n for (const key of Object.keys(eventWithTagsMaybe)) {\n const taggableProp = eventWithTagsMaybe[key];\n const { value, tag } = (typeof taggableProp === \"object\")\n ? taggableProp\n : { value: taggableProp, tag: undefined };\n switch (tag) {\n case undefined:\n // No tag means we can log plainly\n newEvent[key] = value;\n break;\n case \"PackageData\": // For back-compat\n case TelemetryDataTag.CodeArtifact:\n // For Microsoft applications, CodeArtifact is safe for now\n // (we don't load 3P code in 1P apps)\n newEvent[key] = value;\n break;\n case TelemetryDataTag.UserData:\n // Strip out anything tagged explicitly as PII.\n // Alternate strategy would be to hash these props\n newEvent[key] = \"REDACTED (UserData)\";\n break;\n default:\n // If we encounter a tag we don't recognize\n // then we must assume we should scrub.\n newEvent[key] = \"REDACTED (unknown tag)\";\n break;\n }\n }\n this.logger.send(newEvent);\n }\n}\n\n/**\n * ChildLogger class contains various helper telemetry methods,\n * encoding in one place schemas for various types of Fluid telemetry events.\n * Creates sub-logger that appends properties to all events\n */\nexport class ChildLogger extends TelemetryLogger {\n /**\n * Create child logger\n * @param baseLogger - Base logger to use to output events. If undefined, proper child logger\n * is created, but it does not send telemetry events anywhere.\n * @param namespace - Telemetry event name prefix to add to all events\n * @param properties - Base properties to add to all events\n * @param propertyGetters - Getters to add additional properties to all events\n */\n public static create(\n baseLogger?: ITelemetryBaseLogger,\n namespace?: string,\n properties?: ITelemetryLoggerPropertyBags): TelemetryLogger {\n // if we are creating a child of a child, rather than nest, which will increase\n // the callstack overhead, just generate a new logger that includes everything from the previous\n if (baseLogger instanceof ChildLogger) {\n const combinedProperties: ITelemetryLoggerPropertyBags = {};\n for (const extendedProps of [baseLogger.properties, properties]) {\n if (extendedProps !== undefined) {\n if (extendedProps.all !== undefined) {\n combinedProperties.all = {\n ... combinedProperties.all,\n ... extendedProps.all,\n };\n }\n if (extendedProps.error !== undefined) {\n combinedProperties.error = {\n ... combinedProperties.error,\n ... extendedProps.error,\n };\n }\n }\n }\n\n const combinedNamespace = baseLogger.namespace === undefined\n ? namespace\n : namespace === undefined\n ? baseLogger.namespace\n : `${baseLogger.namespace}${TelemetryLogger.eventNamespaceSeparator}${namespace}`;\n\n return new ChildLogger(\n baseLogger.baseLogger,\n combinedNamespace,\n combinedProperties,\n );\n }\n\n return new ChildLogger(\n baseLogger ? baseLogger : new BaseTelemetryNullLogger(),\n namespace,\n properties);\n }\n\n private constructor(\n protected readonly baseLogger: ITelemetryBaseLogger,\n namespace: string | undefined,\n properties: ITelemetryLoggerPropertyBags | undefined,\n ) {\n super(namespace, properties);\n\n // propagate the monitoring context\n if (loggerIsMonitoringContext(baseLogger)) {\n mixinMonitoringContext(\n this,\n new CachedConfigProvider(baseLogger.config));\n }\n }\n\n /**\n * Send an event with the logger\n *\n * @param event - the event to send\n */\n public send(event: ITelemetryBaseEvent): void {\n this.baseLogger.send(this.prepareEvent(event));\n }\n}\n\n/**\n * Multi-sink logger\n * Takes multiple ITelemetryBaseLogger objects (sinks) and logs all events into each sink\n * Implements ITelemetryBaseLogger (through static create() method)\n */\nexport class MultiSinkLogger extends TelemetryLogger {\n protected loggers: ITelemetryBaseLogger[] = [];\n\n /**\n * Create multiple sink logger (i.e. logger that sends events to multiple sinks)\n * @param namespace - Telemetry event name prefix to add to all events\n * @param properties - Base properties to add to all events\n * @param propertyGetters - Getters to add additional properties to all events\n */\n constructor(\n namespace?: string,\n properties?: ITelemetryLoggerPropertyBags) {\n super(namespace, properties);\n }\n\n /**\n * Add logger to send all events to\n * @param logger - Logger to add\n */\n public addLogger(logger?: ITelemetryBaseLogger) {\n if (logger !== undefined && logger !== null) {\n this.loggers.push(logger);\n }\n }\n\n /**\n * Send an event to the loggers\n *\n * @param event - the event to send to all the registered logger\n */\n public send(event: ITelemetryBaseEvent): void {\n const newEvent = this.prepareEvent(event);\n this.loggers.forEach((logger: ITelemetryBaseLogger) => {\n logger.send(newEvent);\n });\n }\n}\n\n/**\n * Describes what events PerformanceEvent should log\n * By default, all events are logged, but client can override this behavior\n * For example, there is rarely a need to record start event, as we really after\n * success / failure tracking, including duration (on success).\n */\nexport interface IPerformanceEventMarkers {\n start?: true;\n end?: true;\n cancel?: \"generic\" | \"error\"; // tells wether to issue \"generic\" or \"error\" category cancel event\n}\n\n/**\n * Helper class to log performance events\n */\nexport class PerformanceEvent {\n public static start(logger: ITelemetryLogger, event: ITelemetryGenericEvent, markers?: IPerformanceEventMarkers) {\n return new PerformanceEvent(logger, event, markers);\n }\n\n public static timedExec<T>(\n logger: ITelemetryLogger,\n event: ITelemetryGenericEvent,\n callback: (event: PerformanceEvent) => T,\n markers?: IPerformanceEventMarkers,\n ) {\n const perfEvent = PerformanceEvent.start(logger, event, markers);\n try {\n const ret = callback(perfEvent);\n perfEvent.autoEnd();\n return ret;\n } catch (error) {\n perfEvent.cancel(undefined, error);\n throw error;\n }\n }\n\n public static async timedExecAsync<T>(\n logger: ITelemetryLogger,\n event: ITelemetryGenericEvent,\n callback: (event: PerformanceEvent) => Promise<T>,\n markers?: IPerformanceEventMarkers,\n ) {\n const perfEvent = PerformanceEvent.start(logger, event, markers);\n try {\n const ret = await callback(perfEvent);\n perfEvent.autoEnd();\n return ret;\n } catch (error) {\n perfEvent.cancel(undefined, error);\n throw error;\n }\n }\n\n public get duration() { return performance.now() - this.startTime; }\n\n private event?: ITelemetryGenericEvent;\n private readonly startTime = performance.now();\n private startMark?: string;\n\n protected constructor(\n private readonly logger: ITelemetryLogger,\n event: ITelemetryGenericEvent,\n private readonly markers: IPerformanceEventMarkers = { end: true, cancel: \"generic\" },\n ) {\n this.event = { ...event };\n if (this.markers.start) {\n this.reportEvent(\"start\");\n }\n\n if (typeof window === \"object\" && window != null && window.performance?.mark) {\n this.startMark = `${event.eventName}-start`;\n window.performance.mark(this.startMark);\n }\n }\n\n public reportProgress(props?: ITelemetryProperties, eventNameSuffix: string = \"update\"): void {\n this.reportEvent(eventNameSuffix, props);\n }\n\n private autoEnd() {\n // Event might have been cancelled or ended in the callback\n if (this.event && this.markers.end) {\n this.reportEvent(\"end\");\n }\n this.performanceEndMark();\n this.event = undefined;\n }\n\n public end(props?: ITelemetryProperties): void {\n this.reportEvent(\"end\", props);\n this.performanceEndMark();\n this.event = undefined;\n }\n\n private performanceEndMark() {\n if (this.startMark && this.event) {\n const endMark = `${this.event.eventName}-end`;\n window.performance.mark(endMark);\n window.performance.measure(`${this.event.eventName}`, this.startMark, endMark);\n this.startMark = undefined;\n }\n }\n\n public cancel(props?: ITelemetryProperties, error?: any): void {\n if (this.markers.cancel !== undefined) {\n this.reportEvent(\"cancel\", { category: this.markers.cancel, ...props }, error);\n }\n this.event = undefined;\n }\n\n /**\n * Report the event, if it hasn't already been reported.\n */\n public reportEvent(eventNameSuffix: string, props?: ITelemetryProperties, error?: any) {\n // There are strange sequences involving multiple Promise chains\n // where the event can be cancelled and then later a callback is invoked\n // and the caller attempts to end directly, e.g. issue #3936. Just return.\n if (!this.event) {\n return;\n }\n\n const event: ITelemetryPerformanceEvent = { ...this.event, ...props };\n event.eventName = `${event.eventName}_${eventNameSuffix}`;\n if (eventNameSuffix !== \"start\") {\n event.duration = this.duration;\n }\n\n this.logger.sendPerformanceEvent(event, error);\n }\n}\n\n/**\n * Logger that is useful for UT\n * It can be used in places where logger instance is required, but events should be not send over.\n */\nexport class TelemetryUTLogger implements ITelemetryLogger {\n public send(event: ITelemetryBaseEvent): void {\n }\n public sendTelemetryEvent(event: ITelemetryGenericEvent, error?: any) {\n }\n public sendErrorEvent(event: ITelemetryErrorEvent, error?: any) {\n this.reportError(\"errorEvent in UT logger!\", event, error);\n }\n public sendPerformanceEvent(event: ITelemetryPerformanceEvent, error?: any): void {\n }\n public logGenericError(eventName: string, error: any) {\n this.reportError(`genericError in UT logger!`, { eventName }, error);\n }\n public logException(event: ITelemetryErrorEvent, exception: any): void {\n this.reportError(\"exception in UT logger!\", event, exception);\n }\n public debugAssert(condition: boolean, event?: ITelemetryErrorEvent): void {\n this.reportError(\"debugAssert in UT logger!\");\n }\n public shipAssert(condition: boolean, event?: ITelemetryErrorEvent): void {\n this.reportError(\"shipAssert in UT logger!\");\n }\n\n private reportError(message: string, event?: ITelemetryErrorEvent, err?: any) {\n const error = new Error(message);\n (error as any).error = error;\n (error as any).event = event;\n // report to console as exception can be eaten\n console.error(message);\n console.error(error);\n throw error;\n }\n}\n\n/**\n * Null logger\n * It can be used in places where logger instance is required, but events should be not send over.\n */\nexport class BaseTelemetryNullLogger implements ITelemetryBaseLogger {\n /**\n * Send an event with the logger\n *\n * @param event - the event to send\n */\n public send(event: ITelemetryBaseEvent): void {\n return;\n }\n}\n\n/**\n * Null logger\n * It can be used in places where logger instance is required, but events should be not send over.\n */\nexport class TelemetryNullLogger implements ITelemetryLogger {\n public send(event: ITelemetryBaseEvent): void {}\n public sendTelemetryEvent(event: ITelemetryGenericEvent, error?: any): void {}\n public sendErrorEvent(event: ITelemetryErrorEvent, error?: any): void {}\n public sendPerformanceEvent(event: ITelemetryPerformanceEvent, error?: any): void {}\n}\n\n/**\n * Takes in an event object, and converts all of its values to a basePropertyType.\n * In the case of an invalid property type, the value will be converted to an error string.\n * @param event - Event with fields you want to stringify.\n */\nfunction convertToBaseEvent({ category, eventName, ...props }: ITelemetryEventExt): ITelemetryBaseEvent {\n const newEvent: ITelemetryBaseEvent = { category, eventName };\n for (const key of Object.keys(props)) {\n newEvent[key] = convertToBasePropertyType(props[key]);\n }\n return newEvent;\n}\n\n/**\n * Takes in value, and does one of 4 things.\n * if value is of primitive type - returns the original value.\n * If the value is an array of primitives - returns a stringified version of the array.\n * If the value is an object of type ITaggedTelemetryPropertyType - returns the object\n * with its values recursively converted to base property Type.\n * If none of these cases are reached - returns an error string\n * @param x - value passed in to convert to a base property type\n */\nexport function convertToBasePropertyType(\n x: TelemetryEventPropertyTypeExt | ITaggedTelemetryPropertyTypeExt,\n): TelemetryEventPropertyType | ITaggedTelemetryPropertyType {\n\n return isTaggedTelemetryPropertyValue(x) ? {\n value: convertToBasePropertyTypeUntagged(x.value),\n tag: x.tag,\n } : convertToBasePropertyTypeUntagged(x);\n}\n\nfunction convertToBasePropertyTypeUntagged(\n x: TelemetryEventPropertyTypeExt,\n): TelemetryEventPropertyType {\n switch (typeof x) {\n case \"string\":\n case \"number\":\n case \"boolean\":\n case \"undefined\":\n return x;\n case \"object\":\n // We assume this is an array based on the input types\n return JSON.stringify(x);\n default:\n // should never reach this case based on the input types\n console.error(`convertToBasePropertyTypeUntagged: INVALID PROPERTY (typed as ${typeof x})`);\n return `INVALID PROPERTY (typed as ${typeof x})`;\n }\n}\n"]}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;AAcH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACnG,OAAO,EACN,eAAe,EACf,6BAA6B,EAC7B,aAAa,EACb,8BAA8B,GAC9B,MAAM,gBAAgB,CAAC;AAUxB;;;GAGG;AACH,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC3B,4FAA4F;IAC5F,iDAA6B,CAAA;IAC7B,8EAA8E;IAC9E,yCAAqB,CAAA;AACtB,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B;AAYD;;;;GAIG;AACH,MAAM,OAAgB,eAAe;IA4DpC,YACoB,SAAkB,EAClB,UAAyC;QADzC,cAAS,GAAT,SAAS,CAAS;QAClB,eAAU,GAAV,UAAU,CAA+B;IAC1D,CAAC;IA5DG,MAAM,CAAC,UAAU,CAAC,IAAY;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,gBAAgB,CAAC,GAA8B;QAC5D,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KA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MAAM,UAAU,yBAAyB,CACxC,CAAkE;IAElE,OAAO,8BAA8B,CAAC,CAAC,CAAC;QACvC,CAAC,CAAC;YACA,KAAK,EAAE,iCAAiC,CAAC,CAAC,CAAC,KAAK,CAAC;YACjD,GAAG,EAAE,CAAC,CAAC,GAAG;SACT;QACH,CAAC,CAAC,iCAAiC,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,iCAAiC,CACzC,CAAgC;IAEhC,QAAQ,OAAO,CAAC,EAAE;QACjB,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,WAAW;YACf,OAAO,CAAC,CAAC;QACV,KAAK,QAAQ;YACZ,sDAAsD;YACtD,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC1B;YACC,wDAAwD;YACxD,OAAO,CAAC,KAAK,CACZ,iEAAiE,OAAO,CAAC,GAAG,CAC5E,CAAC;YACF,OAAO,8BAA8B,OAAO,CAAC,GAAG,CAAC;KAClD;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tITelemetryBaseEvent,\n\tITelemetryBaseLogger,\n\tITelemetryErrorEvent,\n\tITelemetryGenericEvent,\n\tITelemetryLogger,\n\tITelemetryPerformanceEvent,\n\tITelemetryProperties,\n\tTelemetryEventPropertyType,\n\tITaggedTelemetryPropertyType,\n\tTelemetryEventCategory,\n} from \"@fluidframework/common-definitions\";\nimport { performance } from \"@fluidframework/common-utils\";\nimport { CachedConfigProvider, loggerIsMonitoringContext, mixinMonitoringContext } from \"./config\";\nimport {\n\tisILoggingError,\n\textractLogSafeErrorProperties,\n\tgenerateStack,\n\tisTaggedTelemetryPropertyValue,\n} from \"./errorLogging\";\nimport {\n\tITaggedTelemetryPropertyTypeExt,\n\tITelemetryEventExt,\n\tITelemetryGenericEventExt,\n\tITelemetryLoggerExt,\n\tITelemetryPerformanceEventExt,\n\tTelemetryEventPropertyTypeExt,\n} from \"./telemetryTypes\";\n\n/**\n * Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.\n * Please do not modify existing entries for backwards compatibility.\n */\nexport enum TelemetryDataTag {\n\t/** Data containing terms or IDs from code packages that may have been dynamically loaded */\n\tCodeArtifact = \"CodeArtifact\",\n\t/** Personal data of a variety of classifications that pertains to the user */\n\tUserData = \"UserData\",\n}\n\nexport type TelemetryEventPropertyTypes = TelemetryEventPropertyType | ITaggedTelemetryPropertyType;\n\nexport interface ITelemetryLoggerPropertyBag {\n\t[index: string]: TelemetryEventPropertyTypes | (() => TelemetryEventPropertyTypes);\n}\nexport interface ITelemetryLoggerPropertyBags {\n\tall?: ITelemetryLoggerPropertyBag;\n\terror?: ITelemetryLoggerPropertyBag;\n}\n\n/**\n * TelemetryLogger class contains various helper telemetry methods,\n * encoding in one place schemas for various types of Fluid telemetry events.\n * Creates sub-logger that appends properties to all events\n */\nexport abstract class TelemetryLogger implements ITelemetryLoggerExt {\n\tpublic static readonly eventNamespaceSeparator = \":\";\n\n\tpublic static formatTick(tick: number): number {\n\t\treturn Math.floor(tick);\n\t}\n\n\t/**\n\t * Attempts to parse number from string.\n\t * If fails,returns original string.\n\t * Used to make telemetry data typed (and support math operations, like comparison),\n\t * in places where we do expect numbers (like contentsize/duration property in http header)\n\t */\n\tpublic static numberFromString(str: string | null | undefined): string | number | undefined {\n\t\tif (str === undefined || str === null) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst num = Number(str);\n\t\treturn Number.isNaN(num) ? str : num;\n\t}\n\n\tpublic static sanitizePkgName(name: string) {\n\t\treturn name.replace(\"@\", \"\").replace(\"/\", \"-\");\n\t}\n\n\t/**\n\t * Take an unknown error object and add the appropriate info from it to the event. Message and stack will be copied\n\t * over from the error object, along with other telemetry properties if it's an ILoggingError.\n\t * @param event - Event being logged\n\t * @param error - Error to extract info from\n\t * @param fetchStack - Whether to fetch the current callstack if error.stack is undefined\n\t */\n\tpublic static prepareErrorObject(event: ITelemetryBaseEvent, error: any, fetchStack: boolean) {\n\t\tconst { message, errorType, stack } = extractLogSafeErrorProperties(\n\t\t\terror,\n\t\t\ttrue /* sanitizeStack */,\n\t\t);\n\t\t// First, copy over error message, stack, and errorType directly (overwrite if present on event)\n\t\tevent.stack = stack;\n\t\tevent.error = message; // Note that the error message goes on the 'error' field\n\t\tevent.errorType = errorType;\n\n\t\tif (isILoggingError(error)) {\n\t\t\t// Add any other telemetry properties from the LoggingError\n\t\t\tconst telemetryProp = error.getTelemetryProperties();\n\t\t\tfor (const key of Object.keys(telemetryProp)) {\n\t\t\t\tif (event[key] !== undefined) {\n\t\t\t\t\t// Don't overwrite existing properties on the event\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tevent[key] = telemetryProp[key];\n\t\t\t}\n\t\t}\n\n\t\t// Collect stack if we were not able to extract it from error\n\t\tif (event.stack === undefined && fetchStack) {\n\t\t\tevent.stack = generateStack();\n\t\t}\n\t}\n\n\tpublic constructor(\n\t\tprotected readonly namespace?: string,\n\t\tprotected readonly properties?: ITelemetryLoggerPropertyBags,\n\t) {}\n\n\t/**\n\t * Send an event with the logger\n\t *\n\t * @param event - the event to send\n\t */\n\tpublic abstract send(event: ITelemetryBaseEvent): void;\n\n\t/**\n\t * Send a telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t */\n\tpublic sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: any) {\n\t\tthis.sendTelemetryEventCore({ ...event, category: event.category ?? \"generic\" }, error);\n\t}\n\n\t/**\n\t * Send a telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t */\n\tprotected sendTelemetryEventCore(\n\t\tevent: ITelemetryGenericEventExt & { category: TelemetryEventCategory },\n\t\terror?: any,\n\t) {\n\t\tconst newEvent = convertToBaseEvent(event);\n\t\tif (error !== undefined) {\n\t\t\tTelemetryLogger.prepareErrorObject(newEvent, error, false);\n\t\t}\n\n\t\t// Will include Nan & Infinity, but probably we do not care\n\t\tif (typeof newEvent.duration === \"number\") {\n\t\t\tnewEvent.duration = TelemetryLogger.formatTick(newEvent.duration);\n\t\t}\n\n\t\tthis.send(newEvent);\n\t}\n\n\t/**\n\t * Send an error telemetry event with the logger\n\t *\n\t * @param event - the event to send\n\t * @param error - optional error object to log\n\t */\n\tpublic sendErrorEvent(event: ITelemetryErrorEvent, error?: any) {\n\t\tthis.sendTelemetryEventCore(\n\t\t\t{\n\t\t\t\t// ensure the error field has some value,\n\t\t\t\t// this can and will be overridden by event, or error\n\t\t\t\terror: event.eventName,\n\t\t\t\t...event,\n\t\t\t\tcategory: \"error\",\n\t\t\t},\n\t\t\terror,\n\t\t);\n\t}\n\n\t/**\n\t * Send a performance telemetry event with the logger\n\t *\n\t * @param event - Event to send\n\t * @param error - optional error object to log\n\t */\n\tpublic sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: any): void {\n\t\tconst perfEvent = {\n\t\t\t...event,\n\t\t\tcategory: event.category ?? \"performance\",\n\t\t};\n\n\t\tthis.sendTelemetryEventCore(perfEvent, error);\n\t}\n\n\tprotected prepareEvent(event: ITelemetryBaseEvent): ITelemetryBaseEvent {\n\t\tconst includeErrorProps = event.category === \"error\" || event.error !== undefined;\n\t\tconst newEvent: ITelemetryBaseEvent = {\n\t\t\t...event,\n\t\t};\n\t\tif (this.namespace !== undefined) {\n\t\t\tnewEvent.eventName = `${this.namespace}${TelemetryLogger.eventNamespaceSeparator}${newEvent.eventName}`;\n\t\t}\n\t\tif (this.properties) {\n\t\t\tconst properties: (undefined | ITelemetryLoggerPropertyBag)[] = [];\n\t\t\tproperties.push(this.properties.all);\n\t\t\tif (includeErrorProps) {\n\t\t\t\tproperties.push(this.properties.error);\n\t\t\t}\n\t\t\tfor (const props of properties) {\n\t\t\t\tif (props !== undefined) {\n\t\t\t\t\tfor (const key of Object.keys(props)) {\n\t\t\t\t\t\tif (event[key] !== undefined) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst getterOrValue = props[key];\n\t\t\t\t\t\t// If this throws, hopefully it is handled elsewhere\n\t\t\t\t\t\tconst value =\n\t\t\t\t\t\t\ttypeof getterOrValue === \"function\" ? getterOrValue() : getterOrValue;\n\t\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\t\tnewEvent[key] = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn newEvent;\n\t}\n}\n\n/**\n * @deprecated 0.56, remove TaggedLoggerAdapter once its usage is removed from\n * container-runtime. Issue: #8191\n * TaggedLoggerAdapter class can add tag handling to your logger.\n */\nexport class TaggedLoggerAdapter implements ITelemetryBaseLogger {\n\tpublic constructor(private readonly logger: ITelemetryBaseLogger) {}\n\n\tpublic send(eventWithTagsMaybe: ITelemetryBaseEvent) {\n\t\tconst newEvent: ITelemetryBaseEvent = {\n\t\t\tcategory: eventWithTagsMaybe.category,\n\t\t\teventName: eventWithTagsMaybe.eventName,\n\t\t};\n\t\tfor (const key of Object.keys(eventWithTagsMaybe)) {\n\t\t\tconst taggableProp = eventWithTagsMaybe[key];\n\t\t\tconst { value, tag } =\n\t\t\t\ttypeof taggableProp === \"object\"\n\t\t\t\t\t? taggableProp\n\t\t\t\t\t: { value: taggableProp, tag: undefined };\n\t\t\tswitch (tag) {\n\t\t\t\tcase undefined:\n\t\t\t\t\t// No tag means we can log plainly\n\t\t\t\t\tnewEvent[key] = value;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"PackageData\": // For back-compat\n\t\t\t\tcase TelemetryDataTag.CodeArtifact:\n\t\t\t\t\t// For Microsoft applications, CodeArtifact is safe for now\n\t\t\t\t\t// (we don't load 3P code in 1P apps)\n\t\t\t\t\tnewEvent[key] = value;\n\t\t\t\t\tbreak;\n\t\t\t\tcase TelemetryDataTag.UserData:\n\t\t\t\t\t// Strip out anything tagged explicitly as PII.\n\t\t\t\t\t// Alternate strategy would be to hash these props\n\t\t\t\t\tnewEvent[key] = \"REDACTED (UserData)\";\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t// If we encounter a tag we don't recognize\n\t\t\t\t\t// then we must assume we should scrub.\n\t\t\t\t\tnewEvent[key] = \"REDACTED (unknown tag)\";\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tthis.logger.send(newEvent);\n\t}\n}\n\n/**\n * ChildLogger class contains various helper telemetry methods,\n * encoding in one place schemas for various types of Fluid telemetry events.\n * Creates sub-logger that appends properties to all events\n */\nexport class ChildLogger extends TelemetryLogger {\n\t/**\n\t * Create child logger\n\t * @param baseLogger - Base logger to use to output events. If undefined, proper child logger\n\t * is created, but it does not send telemetry events anywhere.\n\t * @param namespace - Telemetry event name prefix to add to all events\n\t * @param properties - Base properties to add to all events\n\t * @param propertyGetters - Getters to add additional properties to all events\n\t */\n\tpublic static create(\n\t\tbaseLogger?: ITelemetryBaseLogger,\n\t\tnamespace?: string,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t): TelemetryLogger {\n\t\t// if we are creating a child of a child, rather than nest, which will increase\n\t\t// the callstack overhead, just generate a new logger that includes everything from the previous\n\t\tif (baseLogger instanceof ChildLogger) {\n\t\t\tconst combinedProperties: ITelemetryLoggerPropertyBags = {};\n\t\t\tfor (const extendedProps of [baseLogger.properties, properties]) {\n\t\t\t\tif (extendedProps !== undefined) {\n\t\t\t\t\tif (extendedProps.all !== undefined) {\n\t\t\t\t\t\tcombinedProperties.all = {\n\t\t\t\t\t\t\t...combinedProperties.all,\n\t\t\t\t\t\t\t...extendedProps.all,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tif (extendedProps.error !== undefined) {\n\t\t\t\t\t\tcombinedProperties.error = {\n\t\t\t\t\t\t\t...combinedProperties.error,\n\t\t\t\t\t\t\t...extendedProps.error,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst combinedNamespace =\n\t\t\t\tbaseLogger.namespace === undefined\n\t\t\t\t\t? namespace\n\t\t\t\t\t: namespace === undefined\n\t\t\t\t\t? baseLogger.namespace\n\t\t\t\t\t: `${baseLogger.namespace}${TelemetryLogger.eventNamespaceSeparator}${namespace}`;\n\n\t\t\treturn new ChildLogger(baseLogger.baseLogger, combinedNamespace, combinedProperties);\n\t\t}\n\n\t\treturn new ChildLogger(\n\t\t\tbaseLogger ? baseLogger : new BaseTelemetryNullLogger(),\n\t\t\tnamespace,\n\t\t\tproperties,\n\t\t);\n\t}\n\n\tprivate constructor(\n\t\tprotected readonly baseLogger: ITelemetryBaseLogger,\n\t\tnamespace: string | undefined,\n\t\tproperties: ITelemetryLoggerPropertyBags | undefined,\n\t) {\n\t\tsuper(namespace, properties);\n\n\t\t// propagate the monitoring context\n\t\tif (loggerIsMonitoringContext(baseLogger)) {\n\t\t\tmixinMonitoringContext(this, new CachedConfigProvider(baseLogger.config));\n\t\t}\n\t}\n\n\t/**\n\t * Send an event with the logger\n\t *\n\t * @param event - the event to send\n\t */\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\tthis.baseLogger.send(this.prepareEvent(event));\n\t}\n}\n\n/**\n * Multi-sink logger\n * Takes multiple ITelemetryBaseLogger objects (sinks) and logs all events into each sink\n * Implements ITelemetryBaseLogger (through static create() method)\n */\nexport class MultiSinkLogger extends TelemetryLogger {\n\tprotected loggers: ITelemetryBaseLogger[] = [];\n\n\t/**\n\t * Create multiple sink logger (i.e. logger that sends events to multiple sinks)\n\t * @param namespace - Telemetry event name prefix to add to all events\n\t * @param properties - Base properties to add to all events\n\t * @param propertyGetters - Getters to add additional properties to all events\n\t */\n\tconstructor(namespace?: string, properties?: ITelemetryLoggerPropertyBags) {\n\t\tsuper(namespace, properties);\n\t}\n\n\t/**\n\t * Add logger to send all events to\n\t * @param logger - Logger to add\n\t */\n\tpublic addLogger(logger?: ITelemetryBaseLogger) {\n\t\tif (logger !== undefined && logger !== null) {\n\t\t\tthis.loggers.push(logger);\n\t\t}\n\t}\n\n\t/**\n\t * Send an event to the loggers\n\t *\n\t * @param event - the event to send to all the registered logger\n\t */\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\tconst newEvent = this.prepareEvent(event);\n\t\tthis.loggers.forEach((logger: ITelemetryBaseLogger) => {\n\t\t\tlogger.send(newEvent);\n\t\t});\n\t}\n}\n\n/**\n * Describes what events PerformanceEvent should log\n * By default, all events are logged, but client can override this behavior\n * For example, there is rarely a need to record start event, as we really after\n * success / failure tracking, including duration (on success).\n */\nexport interface IPerformanceEventMarkers {\n\tstart?: true;\n\tend?: true;\n\tcancel?: \"generic\" | \"error\"; // tells wether to issue \"generic\" or \"error\" category cancel event\n}\n\n/**\n * Helper class to log performance events\n */\nexport class PerformanceEvent {\n\tpublic static start(\n\t\tlogger: ITelemetryLogger,\n\t\tevent: ITelemetryGenericEvent,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t) {\n\t\treturn new PerformanceEvent(logger, event, markers);\n\t}\n\n\tpublic static timedExec<T>(\n\t\tlogger: ITelemetryLogger,\n\t\tevent: ITelemetryGenericEvent,\n\t\tcallback: (event: PerformanceEvent) => T,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t) {\n\t\tconst perfEvent = PerformanceEvent.start(logger, event, markers);\n\t\ttry {\n\t\t\tconst ret = callback(perfEvent);\n\t\t\tperfEvent.autoEnd();\n\t\t\treturn ret;\n\t\t} catch (error) {\n\t\t\tperfEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpublic static async timedExecAsync<T>(\n\t\tlogger: ITelemetryLogger,\n\t\tevent: ITelemetryGenericEvent,\n\t\tcallback: (event: PerformanceEvent) => Promise<T>,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t) {\n\t\tconst perfEvent = PerformanceEvent.start(logger, event, markers);\n\t\ttry {\n\t\t\tconst ret = await callback(perfEvent);\n\t\t\tperfEvent.autoEnd();\n\t\t\treturn ret;\n\t\t} catch (error) {\n\t\t\tperfEvent.cancel(undefined, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpublic get duration() {\n\t\treturn performance.now() - this.startTime;\n\t}\n\n\tprivate event?: ITelemetryGenericEvent;\n\tprivate readonly startTime = performance.now();\n\tprivate startMark?: string;\n\n\tprotected constructor(\n\t\tprivate readonly logger: ITelemetryLogger,\n\t\tevent: ITelemetryGenericEvent,\n\t\tprivate readonly markers: IPerformanceEventMarkers = { end: true, cancel: \"generic\" },\n\t) {\n\t\tthis.event = { ...event };\n\t\tif (this.markers.start) {\n\t\t\tthis.reportEvent(\"start\");\n\t\t}\n\n\t\tif (typeof window === \"object\" && window != null && window.performance?.mark) {\n\t\t\tthis.startMark = `${event.eventName}-start`;\n\t\t\twindow.performance.mark(this.startMark);\n\t\t}\n\t}\n\n\tpublic reportProgress(props?: ITelemetryProperties, eventNameSuffix: string = \"update\"): void {\n\t\tthis.reportEvent(eventNameSuffix, props);\n\t}\n\n\tprivate autoEnd() {\n\t\t// Event might have been cancelled or ended in the callback\n\t\tif (this.event && this.markers.end) {\n\t\t\tthis.reportEvent(\"end\");\n\t\t}\n\t\tthis.performanceEndMark();\n\t\tthis.event = undefined;\n\t}\n\n\tpublic end(props?: ITelemetryProperties): void {\n\t\tthis.reportEvent(\"end\", props);\n\t\tthis.performanceEndMark();\n\t\tthis.event = undefined;\n\t}\n\n\tprivate performanceEndMark() {\n\t\tif (this.startMark && this.event) {\n\t\t\tconst endMark = `${this.event.eventName}-end`;\n\t\t\twindow.performance.mark(endMark);\n\t\t\twindow.performance.measure(`${this.event.eventName}`, this.startMark, endMark);\n\t\t\tthis.startMark = undefined;\n\t\t}\n\t}\n\n\tpublic cancel(props?: ITelemetryProperties, error?: any): void {\n\t\tif (this.markers.cancel !== undefined) {\n\t\t\tthis.reportEvent(\"cancel\", { category: this.markers.cancel, ...props }, error);\n\t\t}\n\t\tthis.event = undefined;\n\t}\n\n\t/**\n\t * Report the event, if it hasn't already been reported.\n\t */\n\tpublic reportEvent(eventNameSuffix: string, props?: ITelemetryProperties, error?: any) {\n\t\t// There are strange sequences involving multiple Promise chains\n\t\t// where the event can be cancelled and then later a callback is invoked\n\t\t// and the caller attempts to end directly, e.g. issue #3936. Just return.\n\t\tif (!this.event) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst event: ITelemetryPerformanceEvent = { ...this.event, ...props };\n\t\tevent.eventName = `${event.eventName}_${eventNameSuffix}`;\n\t\tif (eventNameSuffix !== \"start\") {\n\t\t\tevent.duration = this.duration;\n\t\t}\n\n\t\tthis.logger.sendPerformanceEvent(event, error);\n\t}\n}\n\n/**\n * Logger that is useful for UT\n * It can be used in places where logger instance is required, but events should be not send over.\n */\nexport class TelemetryUTLogger implements ITelemetryLogger {\n\tpublic send(event: ITelemetryBaseEvent): void {}\n\tpublic sendTelemetryEvent(event: ITelemetryGenericEvent, error?: any) {}\n\tpublic sendErrorEvent(event: ITelemetryErrorEvent, error?: any) {\n\t\tthis.reportError(\"errorEvent in UT logger!\", event, error);\n\t}\n\tpublic sendPerformanceEvent(event: ITelemetryPerformanceEvent, error?: any): void {}\n\tpublic logGenericError(eventName: string, error: any) {\n\t\tthis.reportError(`genericError in UT logger!`, { eventName }, error);\n\t}\n\tpublic logException(event: ITelemetryErrorEvent, exception: any): void {\n\t\tthis.reportError(\"exception in UT logger!\", event, exception);\n\t}\n\tpublic debugAssert(condition: boolean, event?: ITelemetryErrorEvent): void {\n\t\tthis.reportError(\"debugAssert in UT logger!\");\n\t}\n\tpublic shipAssert(condition: boolean, event?: ITelemetryErrorEvent): void {\n\t\tthis.reportError(\"shipAssert in UT logger!\");\n\t}\n\n\tprivate reportError(message: string, event?: ITelemetryErrorEvent, err?: any) {\n\t\tconst error = new Error(message);\n\t\t(error as any).error = error;\n\t\t(error as any).event = event;\n\t\t// report to console as exception can be eaten\n\t\tconsole.error(message);\n\t\tconsole.error(error);\n\t\tthrow error;\n\t}\n}\n\n/**\n * Null logger\n * It can be used in places where logger instance is required, but events should be not send over.\n */\nexport class BaseTelemetryNullLogger implements ITelemetryBaseLogger {\n\t/**\n\t * Send an event with the logger\n\t *\n\t * @param event - the event to send\n\t */\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\treturn;\n\t}\n}\n\n/**\n * Null logger\n * It can be used in places where logger instance is required, but events should be not send over.\n */\nexport class TelemetryNullLogger implements ITelemetryLogger {\n\tpublic send(event: ITelemetryBaseEvent): void {}\n\tpublic sendTelemetryEvent(event: ITelemetryGenericEvent, error?: any): void {}\n\tpublic sendErrorEvent(event: ITelemetryErrorEvent, error?: any): void {}\n\tpublic sendPerformanceEvent(event: ITelemetryPerformanceEvent, error?: any): void {}\n}\n\n/**\n * Takes in an event object, and converts all of its values to a basePropertyType.\n * In the case of an invalid property type, the value will be converted to an error string.\n * @param event - Event with fields you want to stringify.\n */\nfunction convertToBaseEvent({\n\tcategory,\n\teventName,\n\t...props\n}: ITelemetryEventExt): ITelemetryBaseEvent {\n\tconst newEvent: ITelemetryBaseEvent = { category, eventName };\n\tfor (const key of Object.keys(props)) {\n\t\tnewEvent[key] = convertToBasePropertyType(props[key]);\n\t}\n\treturn newEvent;\n}\n\n/**\n * Takes in value, and does one of 4 things.\n * if value is of primitive type - returns the original value.\n * If the value is an array of primitives - returns a stringified version of the array.\n * If the value is an object of type ITaggedTelemetryPropertyType - returns the object\n * with its values recursively converted to base property Type.\n * If none of these cases are reached - returns an error string\n * @param x - value passed in to convert to a base property type\n */\nexport function convertToBasePropertyType(\n\tx: TelemetryEventPropertyTypeExt | ITaggedTelemetryPropertyTypeExt,\n): TelemetryEventPropertyType | ITaggedTelemetryPropertyType {\n\treturn isTaggedTelemetryPropertyValue(x)\n\t\t? {\n\t\t\t\tvalue: convertToBasePropertyTypeUntagged(x.value),\n\t\t\t\ttag: x.tag,\n\t\t }\n\t\t: convertToBasePropertyTypeUntagged(x);\n}\n\nfunction convertToBasePropertyTypeUntagged(\n\tx: TelemetryEventPropertyTypeExt,\n): TelemetryEventPropertyType {\n\tswitch (typeof x) {\n\t\tcase \"string\":\n\t\tcase \"number\":\n\t\tcase \"boolean\":\n\t\tcase \"undefined\":\n\t\t\treturn x;\n\t\tcase \"object\":\n\t\t\t// We assume this is an array based on the input types\n\t\t\treturn JSON.stringify(x);\n\t\tdefault:\n\t\t\t// should never reach this case based on the input types\n\t\t\tconsole.error(\n\t\t\t\t`convertToBasePropertyTypeUntagged: INVALID PROPERTY (typed as ${typeof x})`,\n\t\t\t);\n\t\t\treturn `INVALID PROPERTY (typed as ${typeof x})`;\n\t}\n}\n"]}
@@ -35,11 +35,11 @@ export declare class MockLogger extends TelemetryLogger implements ITelemetryLog
35
35
  /** Asserts that matchAnyEvent is true, and prints the actual/expected output if not */
36
36
  assertMatchAny(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string): void;
37
37
  /**
38
- * Search events logged since the last time matchEvents was called, looking only for the given expected
39
- * events in order.
40
- * @param expectedEvents - events in order that are expected to be the only events in the recorded log.
41
- * These event objects may be subsets of the logged events.
42
- * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
38
+ * Search events logged since the last time matchEvents was called, looking only for the given expected
39
+ * events in order.
40
+ * @param expectedEvents - events in order that are expected to be the only events in the recorded log.
41
+ * These event objects may be subsets of the logged events.
42
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
43
43
  */
44
44
  matchEventStrict(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean;
45
45
  /** Asserts that matchEvents is true, and prints the actual/expected output if not */
@@ -1 +1 @@
1
- {"version":3,"file":"mockLogger.d.ts","sourceRoot":"","sources":["../src/mockLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C;;;GAGG;AACH,qBAAa,UAAW,SAAQ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;GAGG;AACH,qBAAa,UAAW,SAAQ,eAAgB,YAAW,gBAAgB;IAC1E,MAAM,EAAE,mBAAmB,EAAE,CAAM;;IAMnC,KAAK;IAIL,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;IAItC;;;;;;OAMG;IACH,WAAW,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,GAAG,OAAO;IAO7E,qFAAqF;IACrF,WAAW,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM;IAYrF;;;;;;;OAOG;IACH,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,GAAG,OAAO;IAK/E,uFAAuF;IACvF,cAAc,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM;IAYxF;;;;;;OAMG;IACH,gBAAgB,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,GAAG,OAAO;IAIlF,qFAAqF;IACrF,iBAAiB,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM;IAY3F,6GAA6G;IAC7G,eAAe,CAAC,gBAAgB,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM;IAY3F,OAAO,CAAC,qBAAqB;IAmB7B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;CAO1B"}
package/lib/mockLogger.js CHANGED
@@ -68,11 +68,11 @@ ${JSON.stringify(actualEvents)}`);
68
68
  }
69
69
  }
70
70
  /**
71
- * Search events logged since the last time matchEvents was called, looking only for the given expected
72
- * events in order.
73
- * @param expectedEvents - events in order that are expected to be the only events in the recorded log.
74
- * These event objects may be subsets of the logged events.
75
- * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
71
+ * Search events logged since the last time matchEvents was called, looking only for the given expected
72
+ * events in order.
73
+ * @param expectedEvents - events in order that are expected to be the only events in the recorded log.
74
+ * These event objects may be subsets of the logged events.
75
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
76
76
  */
77
77
  matchEventStrict(expectedEvents) {
78
78
  return expectedEvents.length === this.events.length && this.matchEvents(expectedEvents);
@@ -1 +1 @@
1
- {"version":3,"file":"mockLogger.js","sourceRoot":"","sources":["../src/mockLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C;;;GAGG;AACH,MAAM,OAAO,UAAW,SAAQ,eAAe;IAG3C;QAAgB,KAAK,EAAE,CAAC;QAFxB,WAAM,GAA0B,EAAE,CAAC;IAEV,CAAC;IAE1B,KAAK;QACD,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACrB,CAAC;IAED,IAAI,CAAC,KAA0B;QAC3B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CAAC,cAAuD;QAC/D,MAAM,yBAAyB,GAAG,IAAI,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC;QAC7E,2DAA2D;QAC3D,MAAM,2BAA2B,GAAG,cAAc,CAAC,MAAM,GAAG,yBAAyB,CAAC;QACtF,OAAO,2BAA2B,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED,qFAAqF;IACrF,WAAW,CAAC,cAAuD,EAAE,OAAgB;QACjF,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;QACjC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE;YACnC,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO;;EAEpC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;;;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YACtC,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO;;EAEpC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC;;;EAGhC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;SACrB;IACT,CAAC;IAEO,qBAAqB,CAAC,cAAuD;QACjF,IAAI,cAAc,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAC1B,IAAI,cAAc,GAAG,cAAc,CAAC,MAAM;gBACtC,UAAU,CAAC,WAAW,CAAC,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC,EAC/D;gBACE,8CAA8C;gBAC9C,EAAE,cAAc,CAAC;aACpB;QACL,CAAC,CAAC,CAAC;QAEH,oFAAoF;QACpF,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QAEjB,sCAAsC;QACtC,OAAO,cAAc,CAAC;IAC1B,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,WAAW,CAAC,MAA2B,EAAE,QAA+C;QACnG,MAAM,MAAM,mCAAQ,MAAM,GAAK,QAAQ,CAAE,CAAC;QAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger, ITelemetryBaseEvent } from \"@fluidframework/common-definitions\";\nimport { TelemetryLogger } from \"./logger\";\n\n/**\n * The MockLogger records events sent to it, and then can walk back over those events\n * searching for a set of expected events to match against the logged events.\n */\nexport class MockLogger extends TelemetryLogger implements ITelemetryLogger {\n events: ITelemetryBaseEvent[] = [];\n\n constructor() { super(); }\n\n clear() {\n this.events = [];\n }\n\n send(event: ITelemetryBaseEvent): void {\n this.events.push(event);\n }\n\n /**\n * Search events logged since the last time matchEvents was called, looking for the given expected\n * events in order.\n * @param expectedEvents - events in order that are expected to appear in the recorded log.\n * These event objects may be subsets of the logged events.\n * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n */\n matchEvents(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): boolean {\n const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);\n // How many expected events were left over? Hopefully none.\n const unmatchedExpectedEventCount = expectedEvents.length - matchedExpectedEventCount;\n return unmatchedExpectedEventCount === 0;\n }\n\n /** Asserts that matchEvents is true, and prints the actual/expected output if not */\n assertMatch(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (!this.matchEvents(expectedEvents)) {\n throw new Error(`${message}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n /**\n * Search events logged since the last time matchEvents was called, looking for any of the given\n * expected events.\n * @param expectedEvents - events that are expected to appear in the recorded log.\n * These event objects may be subsets of the logged events.\n * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n * @returns if any of the expected events is found.\n */\n matchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): boolean {\n const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);\n return matchedExpectedEventCount > 0;\n }\n\n /** Asserts that matchAnyEvent is true, and prints the actual/expected output if not */\n assertMatchAny(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (!this.matchAnyEvent(expectedEvents)) {\n throw new Error(`${message}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n /**\n * Search events logged since the last time matchEvents was called, looking only for the given expected\n * events in order.\n * @param expectedEvents - events in order that are expected to be the only events in the recorded log.\n * These event objects may be subsets of the logged events.\n * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n */\n matchEventStrict(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): boolean {\n return expectedEvents.length === this.events.length && this.matchEvents(expectedEvents);\n }\n\n /** Asserts that matchEvents is true, and prints the actual/expected output if not */\n assertMatchStrict(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (!this.matchEventStrict(expectedEvents)) {\n throw new Error(`${message}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n /** Asserts that matchAnyEvent is false for the given events, and prints the actual/expected output if not */\n assertMatchNone(disallowedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n const actualEvents = this.events;\n if (this.matchAnyEvent(disallowedEvents)) {\n throw new Error(`${message}\ndisallowed events:\n${JSON.stringify(disallowedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n }\n }\n\n private getMatchedEventsCount(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): number {\n let iExpectedEvent = 0;\n this.events.forEach((event) => {\n if (iExpectedEvent < expectedEvents.length &&\n MockLogger.eventsMatch(event, expectedEvents[iExpectedEvent])\n ) {\n // We found the next expected event; increment\n ++iExpectedEvent;\n }\n });\n\n // Remove the events so far; next call will just compare subsequent events from here\n this.events = [];\n\n // Return the count of matched events.\n return iExpectedEvent;\n }\n\n /**\n * Ensure the expected event is a strict subset of the actual event\n */\n private static eventsMatch(actual: ITelemetryBaseEvent, expected: Omit<ITelemetryBaseEvent, \"category\">): boolean {\n const masked = { ...actual, ...expected };\n return JSON.stringify(masked) === JSON.stringify(actual);\n }\n}\n"]}
1
+ {"version":3,"file":"mockLogger.js","sourceRoot":"","sources":["../src/mockLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C;;;GAGG;AACH,MAAM,OAAO,UAAW,SAAQ,eAAe;IAG9C;QACC,KAAK,EAAE,CAAC;QAHT,WAAM,GAA0B,EAAE,CAAC;IAInC,CA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QACtC,OAAO,cAAc,CAAC;IACvB,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,WAAW,CACzB,MAA2B,EAC3B,QAA+C;QAE/C,MAAM,MAAM,mCAAQ,MAAM,GAAK,QAAQ,CAAE,CAAC;QAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC1D,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger, ITelemetryBaseEvent } from \"@fluidframework/common-definitions\";\nimport { TelemetryLogger } from \"./logger\";\n\n/**\n * The MockLogger records events sent to it, and then can walk back over those events\n * searching for a set of expected events to match against the logged events.\n */\nexport class MockLogger extends TelemetryLogger implements ITelemetryLogger {\n\tevents: ITelemetryBaseEvent[] = [];\n\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tclear() {\n\t\tthis.events = [];\n\t}\n\n\tsend(event: ITelemetryBaseEvent): void {\n\t\tthis.events.push(event);\n\t}\n\n\t/**\n\t * Search events logged since the last time matchEvents was called, looking for the given expected\n\t * events in order.\n\t * @param expectedEvents - events in order that are expected to appear in the recorded log.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t */\n\tmatchEvents(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): boolean {\n\t\tconst matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);\n\t\t// How many expected events were left over? Hopefully none.\n\t\tconst unmatchedExpectedEventCount = expectedEvents.length - matchedExpectedEventCount;\n\t\treturn unmatchedExpectedEventCount === 0;\n\t}\n\n\t/** Asserts that matchEvents is true, and prints the actual/expected output if not */\n\tassertMatch(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n\t\tconst actualEvents = this.events;\n\t\tif (!this.matchEvents(expectedEvents)) {\n\t\t\tthrow new Error(`${message}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\t/**\n\t * Search events logged since the last time matchEvents was called, looking for any of the given\n\t * expected events.\n\t * @param expectedEvents - events that are expected to appear in the recorded log.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t * @returns if any of the expected events is found.\n\t */\n\tmatchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): boolean {\n\t\tconst matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);\n\t\treturn matchedExpectedEventCount > 0;\n\t}\n\n\t/** Asserts that matchAnyEvent is true, and prints the actual/expected output if not */\n\tassertMatchAny(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n\t\tconst actualEvents = this.events;\n\t\tif (!this.matchAnyEvent(expectedEvents)) {\n\t\t\tthrow new Error(`${message}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\t/**\n\t * Search events logged since the last time matchEvents was called, looking only for the given expected\n\t * events in order.\n\t * @param expectedEvents - events in order that are expected to be the only events in the recorded log.\n\t * These event objects may be subsets of the logged events.\n\t * Note: category is omitted from the type because it's usually uninteresting and tedious to type.\n\t */\n\tmatchEventStrict(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): boolean {\n\t\treturn expectedEvents.length === this.events.length && this.matchEvents(expectedEvents);\n\t}\n\n\t/** Asserts that matchEvents is true, and prints the actual/expected output if not */\n\tassertMatchStrict(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n\t\tconst actualEvents = this.events;\n\t\tif (!this.matchEventStrict(expectedEvents)) {\n\t\t\tthrow new Error(`${message}\nexpected:\n${JSON.stringify(expectedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\t/** Asserts that matchAnyEvent is false for the given events, and prints the actual/expected output if not */\n\tassertMatchNone(disallowedEvents: Omit<ITelemetryBaseEvent, \"category\">[], message?: string) {\n\t\tconst actualEvents = this.events;\n\t\tif (this.matchAnyEvent(disallowedEvents)) {\n\t\t\tthrow new Error(`${message}\ndisallowed events:\n${JSON.stringify(disallowedEvents)}\n\nactual:\n${JSON.stringify(actualEvents)}`);\n\t\t}\n\t}\n\n\tprivate getMatchedEventsCount(expectedEvents: Omit<ITelemetryBaseEvent, \"category\">[]): number {\n\t\tlet iExpectedEvent = 0;\n\t\tthis.events.forEach((event) => {\n\t\t\tif (\n\t\t\t\tiExpectedEvent < expectedEvents.length &&\n\t\t\t\tMockLogger.eventsMatch(event, expectedEvents[iExpectedEvent])\n\t\t\t) {\n\t\t\t\t// We found the next expected event; increment\n\t\t\t\t++iExpectedEvent;\n\t\t\t}\n\t\t});\n\n\t\t// Remove the events so far; next call will just compare subsequent events from here\n\t\tthis.events = [];\n\n\t\t// Return the count of matched events.\n\t\treturn iExpectedEvent;\n\t}\n\n\t/**\n\t * Ensure the expected event is a strict subset of the actual event\n\t */\n\tprivate static eventsMatch(\n\t\tactual: ITelemetryBaseEvent,\n\t\texpected: Omit<ITelemetryBaseEvent, \"category\">,\n\t): boolean {\n\t\tconst masked = { ...actual, ...expected };\n\t\treturn JSON.stringify(masked) === JSON.stringify(actual);\n\t}\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/telemetry-utils";
8
- export declare const pkgVersion = "2.0.0-internal.3.0.5";
8
+ export declare const pkgVersion = "2.0.0-internal.3.1.1";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/telemetry-utils";
8
- export const pkgVersion = "2.0.0-internal.3.0.5";
8
+ export const pkgVersion = "2.0.0-internal.3.1.1";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,iCAAiC,CAAC;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/telemetry-utils\";\nexport const pkgVersion = \"2.0.0-internal.3.0.5\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,iCAAiC,CAAC;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/telemetry-utils\";\nexport const pkgVersion = \"2.0.0-internal.3.1.1\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sampledTelemetryHelper.d.ts","sourceRoot":"","sources":["../src/sampledTelemetryHelper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,WAAW,EACX,sBAAsB,EACtB,gBAAgB,EAEhB,oBAAoB,EACvB,MAAM,oCAAoC,CAAC;AAkC5C;;;;;;GAMG;AACF,qBAAa,sBAAuB,YAAW,WAAW;IAwBnD,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,C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,OAAO,CAAC,KAAyB;QACpC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IDisposable,\n ITelemetryGenericEvent,\n ITelemetryLogger,\n ITelemetryPerformanceEvent,\n ITelemetryProperties,\n} from \"@fluidframework/common-definitions\";\nimport { performance } from \"@fluidframework/common-utils\";\n\ninterface Measurements {\n // The names of the properties in this interface are the ones that will get stamped in the\n // telemetry event, changes should be considered carefully. The optional properties should\n // only be populated if 'includeAggregateMetrics' is true.\n\n /**\n * The duration of the latest execution.\n */\n duration: number;\n\n /**\n * The number of executions since the last time an event was generated.\n */\n count: number;\n\n /**\n * Total duration across all the executions since the last event was generated.\n */\n totalDuration?: number;\n\n /**\n * Min duration across all the executions since the last event was generated.\n */\n minDuration?: number;\n\n /**\n * Max duration across all the executions since the last event was generated.\n */\n maxDuration?: number;\n}\n\n/**\n * Helper class that executes a specified code block and writes an\n * {@link @fluidframework/common-definitions#ITelemetryPerformanceEvent} to a specified logger every time a specified\n * number of executions is reached (or when the class is disposed). The `duration` field in the telemetry event is\n * the duration of the latest execution (sample) of the specified function. See the documentation of the\n * `includeAggregateMetrics` parameter for additional details that can be included.\n */\n export class SampledTelemetryHelper implements IDisposable {\n disposed: boolean = false;\n\n private readonly measurementsMap = new Map<string, Measurements>();\n\n /**\n * @param eventBase -\n * Custom properties to include in the telemetry performance event when it is written.\n * @param logger -\n * The logger to use to write the telemetry performance event.\n * @param sampleThreshold -\n * Telemetry performance events will be generated every time we hit this many executions of the code block.\n * @param includeAggregateMetrics -\n * If set to `true`, the telemetry performance event will include aggregated metrics (total duration, min duration,\n * max duration) for all the executions in between generated events.\n * @param perBucketProperties -\n * Map of strings that represent different buckets (which can be specified when calling the 'measure' method), to\n * properties which should be added to the telemetry event for that bucket. If a bucket being measured does not\n * have an entry in this map, no additional properties will be added to its telemetry events. The following keys are\n * reserved for use by this class: \"duration\", \"count\", \"totalDuration\", \"minDuration\", \"maxDuration\". If any of\n * them is specified as a key in one of the ITelemetryProperties objects in this map, that key-value pair will be\n * ignored.\n */\n public constructor(\n private readonly eventBase: ITelemetryGenericEvent,\n private readonly logger: ITelemetryLogger,\n private readonly sampleThreshold: number,\n private readonly includeAggregateMetrics: boolean = false,\n private readonly perBucketProperties = new Map<string, ITelemetryProperties>()) {\n }\n\n /**\n * @param codeToMeasure -\n * The code to be executed and measured.\n * @param bucket -\n * A key to track executions of the code block separately. Each different value of this parameter has a separate\n * set of executions and metrics tracked by the class. If no such distinction needs to be made, do not provide a\n * value.\n * @returns Whatever the passed-in code block returns.\n */\n public measure<T>(codeToMeasure: () => T, bucket: string = \"\"): T {\n const start = performance.now();\n const returnValue = codeToMeasure();\n const duration = performance.now() - start;\n\n let m = this.measurementsMap.get(bucket);\n if (m === undefined) {\n m = { count: 0, duration: -1 };\n this.measurementsMap.set(bucket, m);\n }\n m.count++;\n m.duration = duration;\n\n if (this.includeAggregateMetrics) {\n m.totalDuration = (m.totalDuration ?? 0) + duration;\n m.minDuration = Math.min(m.minDuration ?? duration, duration);\n m.maxDuration = Math.max(m.maxDuration ?? 0, duration);\n }\n\n if (m.count >= this.sampleThreshold) {\n this.flushBucket(bucket);\n }\n\n return returnValue;\n }\n\n private flushBucket(bucket: string) {\n const measurements = this.measurementsMap.get(bucket);\n if (measurements === undefined) {\n return;\n }\n\n if (measurements.count !== 0) {\n const bucketProperties = this.perBucketProperties.get(bucket);\n\n const telemetryEvent: ITelemetryPerformanceEvent = {\n ...this.eventBase,\n ...bucketProperties, // If the bucket doesn't exist and this is undefined, things work as expected\n ...measurements,\n };\n\n this.logger.sendPerformanceEvent(telemetryEvent);\n this.measurementsMap.delete(bucket);\n }\n }\n\n public dispose(error?: Error | undefined): void {\n this.measurementsMap.forEach((_, k) => this.flushBucket(k));\n }\n}\n"]}
1
+ {"version":3,"file":"sampledTelemetryHelper.js","sourceRoot":"","sources":["../src/sampledTelemetryHelper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAiC3D;;;;;;GAMG;AACH,MAAM,OAAO,sBAAsB;IAKlC;;;;;;;;;;;;;;;;;OAiBG;IACH,YACkB,SAAiC,EACjC,MAAwB,EACxB,eAAuB,EACvB,0BAAmC,KAAK,EACxC,sBAAsB,IAAI,GAAG,EAAgC;QAJ7D,cAAS,GAAT,SAAS,CAAwB;QACjC,WAAM,GAAN,MAAM,CAAkB;QACxB,oBAAe,GAAf,eAAe,CAAQ;QACvB,4BAAuB,GAAvB,uBAAuB,CAAiB;QACxC,wBAAmB,GAAnB,mBAAmB,CAA0C;QA3B/E,aAAQ,GAAY,KAAK,CAAC;QAET,oBAAe,GAAG,IAAI,GAAG,EAAwB,CAAC;IA0BhE,CAAC;IAEJ;;;;;;;;OAQG;IACI,OAAO,CAAI,aAAsB,EAAE,SAAiB,EAAE;;QAC5D,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAChC,MAAM,WAAW,GAAG,aAAa,EAAE,CAAC;QACpC,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QAE3C,IAAI,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,SAAS,EAAE;YACpB,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;SACpC;QACD,CAAC,CAAC,KAAK,EAAE,CAAC;QACV,CAAC,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEt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Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDisposable,\n\tITelemetryGenericEvent,\n\tITelemetryLogger,\n\tITelemetryPerformanceEvent,\n\tITelemetryProperties,\n} from \"@fluidframework/common-definitions\";\nimport { performance } from \"@fluidframework/common-utils\";\n\ninterface Measurements {\n\t// The names of the properties in this interface are the ones that will get stamped in the\n\t// telemetry event, changes should be considered carefully. The optional properties should\n\t// only be populated if 'includeAggregateMetrics' is true.\n\n\t/**\n\t * The duration of the latest execution.\n\t */\n\tduration: number;\n\n\t/**\n\t * The number of executions since the last time an event was generated.\n\t */\n\tcount: number;\n\n\t/**\n\t * Total duration across all the executions since the last event was generated.\n\t */\n\ttotalDuration?: number;\n\n\t/**\n\t * Min duration across all the executions since the last event was generated.\n\t */\n\tminDuration?: number;\n\n\t/**\n\t * Max duration across all the executions since the last event was generated.\n\t */\n\tmaxDuration?: number;\n}\n\n/**\n * Helper class that executes a specified code block and writes an\n * {@link @fluidframework/common-definitions#ITelemetryPerformanceEvent} to a specified logger every time a specified\n * number of executions is reached (or when the class is disposed). The `duration` field in the telemetry event is\n * the duration of the latest execution (sample) of the specified function. See the documentation of the\n * `includeAggregateMetrics` parameter for additional details that can be included.\n */\nexport class SampledTelemetryHelper implements IDisposable {\n\tdisposed: boolean = false;\n\n\tprivate readonly measurementsMap = new Map<string, Measurements>();\n\n\t/**\n\t * @param eventBase -\n\t * Custom properties to include in the telemetry performance event when it is written.\n\t * @param logger -\n\t * The logger to use to write the telemetry performance event.\n\t * @param sampleThreshold -\n\t * Telemetry performance events will be generated every time we hit this many executions of the code block.\n\t * @param includeAggregateMetrics -\n\t * If set to `true`, the telemetry performance event will include aggregated metrics (total duration, min duration,\n\t * max duration) for all the executions in between generated events.\n\t * @param perBucketProperties -\n\t * Map of strings that represent different buckets (which can be specified when calling the 'measure' method), to\n\t * properties which should be added to the telemetry event for that bucket. If a bucket being measured does not\n\t * have an entry in this map, no additional properties will be added to its telemetry events. The following keys are\n\t * reserved for use by this class: \"duration\", \"count\", \"totalDuration\", \"minDuration\", \"maxDuration\". If any of\n\t * them is specified as a key in one of the ITelemetryProperties objects in this map, that key-value pair will be\n\t * ignored.\n\t */\n\tpublic constructor(\n\t\tprivate readonly eventBase: ITelemetryGenericEvent,\n\t\tprivate readonly logger: ITelemetryLogger,\n\t\tprivate readonly sampleThreshold: number,\n\t\tprivate readonly includeAggregateMetrics: boolean = false,\n\t\tprivate readonly perBucketProperties = new Map<string, ITelemetryProperties>(),\n\t) {}\n\n\t/**\n\t * @param codeToMeasure -\n\t * The code to be executed and measured.\n\t * @param bucket -\n\t * A key to track executions of the code block separately. Each different value of this parameter has a separate\n\t * set of executions and metrics tracked by the class. If no such distinction needs to be made, do not provide a\n\t * value.\n\t * @returns Whatever the passed-in code block returns.\n\t */\n\tpublic measure<T>(codeToMeasure: () => T, bucket: string = \"\"): T {\n\t\tconst start = performance.now();\n\t\tconst returnValue = codeToMeasure();\n\t\tconst duration = performance.now() - start;\n\n\t\tlet m = this.measurementsMap.get(bucket);\n\t\tif (m === undefined) {\n\t\t\tm = { count: 0, duration: -1 };\n\t\t\tthis.measurementsMap.set(bucket, m);\n\t\t}\n\t\tm.count++;\n\t\tm.duration = duration;\n\n\t\tif (this.includeAggregateMetrics) {\n\t\t\tm.totalDuration = (m.totalDuration ?? 0) + duration;\n\t\t\tm.minDuration = Math.min(m.minDuration ?? duration, duration);\n\t\t\tm.maxDuration = Math.max(m.maxDuration ?? 0, duration);\n\t\t}\n\n\t\tif (m.count >= this.sampleThreshold) {\n\t\t\tthis.flushBucket(bucket);\n\t\t}\n\n\t\treturn returnValue;\n\t}\n\n\tprivate flushBucket(bucket: string) {\n\t\tconst measurements = this.measurementsMap.get(bucket);\n\t\tif (measurements === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (measurements.count !== 0) {\n\t\t\tconst bucketProperties = this.perBucketProperties.get(bucket);\n\n\t\t\tconst telemetryEvent: ITelemetryPerformanceEvent = {\n\t\t\t\t...this.eventBase,\n\t\t\t\t...bucketProperties, // If the bucket doesn't exist and this is undefined, things work as expected\n\t\t\t\t...measurements,\n\t\t\t};\n\n\t\t\tthis.logger.sendPerformanceEvent(telemetryEvent);\n\t\t\tthis.measurementsMap.delete(bucket);\n\t\t}\n\t}\n\n\tpublic dispose(error?: Error | undefined): void {\n\t\tthis.measurementsMap.forEach((_, k) => this.flushBucket(k));\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"telemetryTypes.d.ts","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAElG;;;GAGG;AACH,oBAAY,6BAA6B,GACnC,MAAM,GACN,MAAM,GACN,OAAO,GACP,SAAS,GACT,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;AAEnC;;;;GAIG;AACJ,MAAM,WAAW,+BAA+B;IAC5C,KAAK,EAAE,6BAA6B,CAAC;IACrC,GAAG,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACpC,CAAC,KAAK,EAAE,MAAM,GAAG,6BAA6B,GAAG,+BAA+B,CAAC;CACpF;AAED;;;;;GAKG;AACF,MAAM,WAAW,kBAAmB,SAAQ,uBAAuB;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACF,MAAM,WAAW,yBAA0B,SAAQ,uBAAuB;IACvE,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,sBAAsB,CAAC;CACrC;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,uBAAuB;IACpE,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,6BAA8B,SAAQ,yBAAyB;IAC5E,QAAQ,CAAC,EA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EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,6BAA8B,SAAQ,yBAAyB;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAChE;;;;OAIG;IACH,kBAAkB,CAAC,KAAK,EAAE,yBAAyB,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IAExE;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,uBAAuB,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IAElE;;;OAGG;IACH,oBAAoB,CAAC,KAAK,EAAE,6BAA6B,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;CAC9E"}
@@ -1 +1 @@
1
- {"version":3,"file":"telemetryTypes.js","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger, TelemetryEventCategory } from \"@fluidframework/common-definitions\";\n\n/**\n * Property types that can be logged.\n * Includes extra types beyond TelemetryEventPropertyType (which will be deprecated in favor of this one)\n */\nexport type TelemetryEventPropertyTypeExt =\n | string\n | number\n | boolean\n | undefined\n | (string | number | boolean)[];\n\n /**\n * A property to be logged to telemetry containing both the value and a tag. Tags are generic strings that can be used\n * to mark pieces of information that should be organized or handled differently by loggers in various first or third\n * party scenarios. For example, tags are used to mark personal information that should not be stored in logs.\n */\nexport interface ITaggedTelemetryPropertyTypeExt {\n value: TelemetryEventPropertyTypeExt;\n tag: string;\n}\n\n/**\n * JSON-serializable properties, which will be logged with telemetry.\n */\nexport interface ITelemetryPropertiesExt {\n [index: string]: TelemetryEventPropertyTypeExt | ITaggedTelemetryPropertyTypeExt;\n}\n\n/**\n * Interface for logging telemetry statements.\n * Can contain any number of properties that get serialized as json payload.\n * @param category - category of the event, like \"error\", \"performance\", \"generic\", etc.\n * @param eventName - name of the event.\n */\n export interface ITelemetryEventExt extends ITelemetryPropertiesExt {\n category: string;\n eventName: string;\n}\n\n/**\n * Informational (non-error) telemetry event\n * Maps to category = \"generic\"\n */\n export interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {\n eventName: string;\n category?: TelemetryEventCategory;\n}\n\n/**\n * Error telemetry event.\n * Maps to category = \"error\"\n */\nexport interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {\n eventName: string;\n}\n\n/**\n * Performance telemetry event.\n * Maps to category = \"performance\"\n */\nexport interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {\n duration?: number; // Duration of event (optional)\n}\n\n/**\n * An extended TelemetryLogger interface which allows for more lenient event types.\n * This interface is meant to be used internally within the Fluid Framework,\n * and ITelemetryBaseLogger should be used when loggers are passed between layers.\n */\nexport interface ITelemetryLoggerExt extends ITelemetryBaseLogger {\n /**\n * Send information telemetry event\n * @param event - Event to send\n * @param error - optional error object to log\n */\n sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: any): void;\n\n /**\n * Send error telemetry event\n * @param event - Event to send\n */\n sendErrorEvent(event: ITelemetryErrorEventExt, error?: any): void;\n\n /**\n * Send performance telemetry event\n * @param event - Event to send\n */\n sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: any): void;\n}\n"]}
1
+ {"version":3,"file":"telemetryTypes.js","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger, TelemetryEventCategory } from \"@fluidframework/common-definitions\";\n\n/**\n * Property types that can be logged.\n * Includes extra types beyond TelemetryEventPropertyType (which will be deprecated in favor of this one)\n */\nexport type TelemetryEventPropertyTypeExt =\n\t| string\n\t| number\n\t| boolean\n\t| undefined\n\t| (string | number | boolean)[];\n\n/**\n * A property to be logged to telemetry containing both the value and a tag. Tags are generic strings that can be used\n * to mark pieces of information that should be organized or handled differently by loggers in various first or third\n * party scenarios. For example, tags are used to mark personal information that should not be stored in logs.\n */\nexport interface ITaggedTelemetryPropertyTypeExt {\n\tvalue: TelemetryEventPropertyTypeExt;\n\ttag: string;\n}\n\n/**\n * JSON-serializable properties, which will be logged with telemetry.\n */\nexport interface ITelemetryPropertiesExt {\n\t[index: string]: TelemetryEventPropertyTypeExt | ITaggedTelemetryPropertyTypeExt;\n}\n\n/**\n * Interface for logging telemetry statements.\n * Can contain any number of properties that get serialized as json payload.\n * @param category - category of the event, like \"error\", \"performance\", \"generic\", etc.\n * @param eventName - name of the event.\n */\nexport interface ITelemetryEventExt extends ITelemetryPropertiesExt {\n\tcategory: string;\n\teventName: string;\n}\n\n/**\n * Informational (non-error) telemetry event\n * Maps to category = \"generic\"\n */\nexport interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {\n\teventName: string;\n\tcategory?: TelemetryEventCategory;\n}\n\n/**\n * Error telemetry event.\n * Maps to category = \"error\"\n */\nexport interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {\n\teventName: string;\n}\n\n/**\n * Performance telemetry event.\n * Maps to category = \"performance\"\n */\nexport interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {\n\tduration?: number; // Duration of event (optional)\n}\n\n/**\n * An extended TelemetryLogger interface which allows for more lenient event types.\n * This interface is meant to be used internally within the Fluid Framework,\n * and ITelemetryBaseLogger should be used when loggers are passed between layers.\n */\nexport interface ITelemetryLoggerExt extends ITelemetryBaseLogger {\n\t/**\n\t * Send information telemetry event\n\t * @param event - Event to send\n\t * @param error - optional error object to log\n\t */\n\tsendTelemetryEvent(event: ITelemetryGenericEventExt, error?: any): void;\n\n\t/**\n\t * Send error telemetry event\n\t * @param event - Event to send\n\t */\n\tsendErrorEvent(event: ITelemetryErrorEventExt, error?: any): void;\n\n\t/**\n\t * Send performance telemetry event\n\t * @param event - Event to send\n\t */\n\tsendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: any): void;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"thresholdCounter.d.ts","sourceRoot":"","sources":["../src/thresholdCounter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE;;;GAGG;AACH,qBAAa,gBAAgB;IAErB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,iBAAiB;gBAFR,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,gBAAgB,EACjC,iBAAiB,SAAY;IAGzC;;OAEG;IACI,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAU5C;;;;;;OAMG;IACI,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAUzD"}
1
+ {"version":3,"file":"thresholdCounter.d.ts","sourceRoot":"","sources":["../src/thresholdCounter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE;;;GAGG;AACH,qBAAa,gBAAgB;IAE3B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,iBAAiB;gBAFR,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,gBAAgB,EACjC,iBAAiB,SAAY;IAGtC;;OAEG;IACI,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAU5C;;;;;;OAMG;IACI,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAUtD"}
@@ -1 +1 @@
1
- {"version":3,"file":"thresholdCounter.js","sourceRoot":"","sources":["../src/thresholdCounter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IACzB,YACqB,SAAiB,EACjB,MAAwB,EACjC,oBAAoB,SAAS;QAFpB,cAAS,GAAT,SAAS,CAAQ;QACjB,WAAM,GAAN,MAAM,CAAkB;QACjC,sBAAiB,GAAjB,iBAAiB,CAAY;IACtC,CAAC;IAEJ;;OAEG;IACI,IAAI,CAAC,SAAiB,EAAE,KAAa;QACxC,IAAI,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE;YACxB,OAAO;SACV;QACD,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;YAC7B,SAAS;YACT,KAAK;SACR,CAAC,CAAC;IACP,CAAC;IAED;;;;;;OAMG;IACI,cAAc,CAAC,SAAiB,EAAE,KAAa;QAClD,IAAI,KAAK,KAAK,IAAI,CAAC,iBAAiB,EAAE;YAClC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;gBAC7B,SAAS;gBACT,KAAK;aACR,CAAC,CAAC;YACH,sCAAsC;YACtC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC;SACvD;IACL,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\n\n/**\n * Utility counter which will send event only if the provided value\n * is above a configured threshold\n */\nexport class ThresholdCounter {\n public constructor(\n private readonly threshold: number,\n private readonly logger: ITelemetryLogger,\n private thresholdMultiple = threshold,\n ) {}\n\n /**\n * Sends the value if it's above the treshold.\n */\n public send(eventName: string, value: number) {\n if (value < this.threshold) {\n return;\n }\n this.logger.sendPerformanceEvent({\n eventName,\n value,\n });\n }\n\n /**\n * Sends the value if it's above the threshold\n * and a multiple of the threshold.\n *\n * To be used in scenarios where we'd like to record a\n * threshold violation while reducing telemetry noise.\n */\n public sendIfMultiple(eventName: string, value: number) {\n if (value === this.thresholdMultiple) {\n this.logger.sendPerformanceEvent({\n eventName,\n value,\n });\n // reduce number of \"multiple\" events.\n this.thresholdMultiple = this.thresholdMultiple * 2;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"thresholdCounter.js","sourceRoot":"","sources":["../src/thresholdCounter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAC5B,YACkB,SAAiB,EACjB,MAAwB,EACjC,oBAAoB,SAAS;QAFpB,cAAS,GAAT,SAAS,CAAQ;QACjB,WAAM,GAAN,MAAM,CAAkB;QACjC,sBAAiB,GAAjB,iBAAiB,CAAY;IACnC,CAAC;IAEJ;;OAEG;IACI,IAAI,CAAC,SAAiB,EAAE,KAAa;QAC3C,IAAI,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE;YAC3B,OAAO;SACP;QACD,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;YAChC,SAAS;YACT,KAAK;SACL,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACI,cAAc,CAAC,SAAiB,EAAE,KAAa;QACrD,IAAI,KAAK,KAAK,IAAI,CAAC,iBAAiB,EAAE;YACrC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;gBAChC,SAAS;gBACT,KAAK;aACL,CAAC,CAAC;YACH,sCAAsC;YACtC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC;SACpD;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\n\n/**\n * Utility counter which will send event only if the provided value\n * is above a configured threshold\n */\nexport class ThresholdCounter {\n\tpublic constructor(\n\t\tprivate readonly threshold: number,\n\t\tprivate readonly logger: ITelemetryLogger,\n\t\tprivate thresholdMultiple = threshold,\n\t) {}\n\n\t/**\n\t * Sends the value if it's above the treshold.\n\t */\n\tpublic send(eventName: string, value: number) {\n\t\tif (value < this.threshold) {\n\t\t\treturn;\n\t\t}\n\t\tthis.logger.sendPerformanceEvent({\n\t\t\teventName,\n\t\t\tvalue,\n\t\t});\n\t}\n\n\t/**\n\t * Sends the value if it's above the threshold\n\t * and a multiple of the threshold.\n\t *\n\t * To be used in scenarios where we'd like to record a\n\t * threshold violation while reducing telemetry noise.\n\t */\n\tpublic sendIfMultiple(eventName: string, value: number) {\n\t\tif (value === this.thresholdMultiple) {\n\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\teventName,\n\t\t\t\tvalue,\n\t\t\t});\n\t\t\t// reduce number of \"multiple\" events.\n\t\t\tthis.thresholdMultiple = this.thresholdMultiple * 2;\n\t\t}\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAEH,oBAAoB,EACpB,sBAAsB,EACzB,MAAM,oCAAoC,CAAC;AAE5C;;;;;;GAMG;AACH,wBAAgB,UAAU,CACtB,SAAS,EAAE,GAAG,EACd,MAAM,EAAE,oBAAoB,EAC5B,KAAK,EAAE,MAAM,GAAG,sBAAsB,GACvC,SAAS,IAAI,IAAI,CAUnB"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAEN,oBAAoB,EACpB,sBAAsB,EACtB,MAAM,oCAAoC,CAAC;AAE5C;;;;;;GAMG;AACH,wBAAgB,UAAU,CACzB,SAAS,EAAE,GAAG,EACd,MAAM,EAAE,oBAAoB,EAC5B,KAAK,EAAE,MAAM,GAAG,sBAAsB,GACpC,SAAS,IAAI,IAAI,CAUnB"}
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACtB,SAAc,EACd,MAA4B,EAC5B,KAAsC;IAEtC,IAAI,SAAS,EAAE;QACX,OAAO,IAAI,CAAC;KACf;IACD,MAAM,QAAQ,GACV,OAAO,KAAK,KAAK,QAAQ;QACzB,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE;QACzC,CAAC,iBAAG,QAAQ,EAAE,OAAO,IAAK,KAAK,CAAE,CAAC;IACtC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtB,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n ITelemetryBaseEvent,\n ITelemetryBaseLogger,\n ITelemetryGenericEvent,\n} from \"@fluidframework/common-definitions\";\n\n/**\n * Like assert, but logs only if the condition is false, rather than throwing\n * @param condition - The condition to attest too\n * @param logger - The logger to log with\n * @param event - The string or event to log\n * @returns - The outcome of the condition\n */\nexport function logIfFalse(\n condition: any,\n logger: ITelemetryBaseLogger,\n event: string | ITelemetryGenericEvent,\n): condition is true {\n if (condition) {\n return true;\n }\n const newEvent: ITelemetryBaseEvent =\n typeof event === \"string\"\n ? { eventName: event, category: \"error\" }\n : { category: \"error\", ...event };\n logger.send(newEvent);\n return false;\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACzB,SAAc,EACd,MAA4B,EAC5B,KAAsC;IAEtC,IAAI,SAAS,EAAE;QACd,OAAO,IAAI,CAAC;KACZ;IACD,MAAM,QAAQ,GACb,OAAO,KAAK,KAAK,QAAQ;QACxB,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE;QACzC,CAAC,iBAAG,QAAQ,EAAE,OAAO,IAAK,KAAK,CAAE,CAAC;IACpC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtB,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n\tITelemetryBaseEvent,\n\tITelemetryBaseLogger,\n\tITelemetryGenericEvent,\n} from \"@fluidframework/common-definitions\";\n\n/**\n * Like assert, but logs only if the condition is false, rather than throwing\n * @param condition - The condition to attest too\n * @param logger - The logger to log with\n * @param event - The string or event to log\n * @returns - The outcome of the condition\n */\nexport function logIfFalse(\n\tcondition: any,\n\tlogger: ITelemetryBaseLogger,\n\tevent: string | ITelemetryGenericEvent,\n): condition is true {\n\tif (condition) {\n\t\treturn true;\n\t}\n\tconst newEvent: ITelemetryBaseEvent =\n\t\ttypeof event === \"string\"\n\t\t\t? { eventName: event, category: \"error\" }\n\t\t\t: { category: \"error\", ...event };\n\tlogger.send(newEvent);\n\treturn false;\n}\n"]}