@fluidframework/telemetry-utils 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.224419

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 (155) hide show
  1. package/.eslintrc.js +12 -13
  2. package/.mocharc.js +12 -0
  3. package/CHANGELOG.md +249 -0
  4. package/README.md +68 -1
  5. package/api-extractor-lint.json +4 -0
  6. package/api-extractor.json +2 -2
  7. package/api-report/telemetry-utils.api.md +444 -0
  8. package/dist/config.d.ts +47 -16
  9. package/dist/config.d.ts.map +1 -1
  10. package/dist/config.js +88 -38
  11. package/dist/config.js.map +1 -1
  12. package/dist/error.d.ts +112 -0
  13. package/dist/error.d.ts.map +1 -0
  14. package/dist/error.js +159 -0
  15. package/dist/error.js.map +1 -0
  16. package/dist/errorLogging.d.ts +86 -20
  17. package/dist/errorLogging.d.ts.map +1 -1
  18. package/dist/errorLogging.js +190 -60
  19. package/dist/errorLogging.js.map +1 -1
  20. package/dist/eventEmitterWithErrorHandling.d.ts +9 -3
  21. package/dist/eventEmitterWithErrorHandling.d.ts.map +1 -1
  22. package/dist/eventEmitterWithErrorHandling.js +16 -3
  23. package/dist/eventEmitterWithErrorHandling.js.map +1 -1
  24. package/dist/events.d.ts +27 -3
  25. package/dist/events.d.ts.map +1 -1
  26. package/dist/events.js +26 -2
  27. package/dist/events.js.map +1 -1
  28. package/dist/fluidErrorBase.d.ts +57 -16
  29. package/dist/fluidErrorBase.d.ts.map +1 -1
  30. package/dist/fluidErrorBase.js +27 -14
  31. package/dist/fluidErrorBase.js.map +1 -1
  32. package/dist/index.d.ts +12 -11
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +55 -21
  35. package/dist/index.js.map +1 -1
  36. package/dist/logger.d.ts +267 -51
  37. package/dist/logger.d.ts.map +1 -1
  38. package/dist/logger.js +423 -132
  39. package/dist/logger.js.map +1 -1
  40. package/dist/mockLogger.d.ts +39 -12
  41. package/dist/mockLogger.d.ts.map +1 -1
  42. package/dist/mockLogger.js +105 -22
  43. package/dist/mockLogger.js.map +1 -1
  44. package/dist/sampledTelemetryHelper.d.ts +18 -12
  45. package/dist/sampledTelemetryHelper.d.ts.map +1 -1
  46. package/dist/sampledTelemetryHelper.js +28 -19
  47. package/dist/sampledTelemetryHelper.js.map +1 -1
  48. package/dist/telemetry-utils-alpha.d.ts +290 -0
  49. package/dist/telemetry-utils-beta.d.ts +264 -0
  50. package/dist/telemetry-utils-public.d.ts +264 -0
  51. package/dist/telemetry-utils-untrimmed.d.ts +1102 -0
  52. package/dist/telemetryTypes.d.ts +115 -0
  53. package/dist/telemetryTypes.d.ts.map +1 -0
  54. package/dist/telemetryTypes.js +7 -0
  55. package/dist/telemetryTypes.js.map +1 -0
  56. package/dist/thresholdCounter.d.ts +6 -5
  57. package/dist/thresholdCounter.d.ts.map +1 -1
  58. package/dist/thresholdCounter.js +4 -3
  59. package/dist/thresholdCounter.js.map +1 -1
  60. package/dist/tsdoc-metadata.json +11 -0
  61. package/dist/utils.d.ts +54 -3
  62. package/dist/utils.d.ts.map +1 -1
  63. package/dist/utils.js +58 -3
  64. package/dist/utils.js.map +1 -1
  65. package/lib/config.d.ts +47 -16
  66. package/lib/config.d.ts.map +1 -1
  67. package/lib/config.js +85 -36
  68. package/lib/config.js.map +1 -1
  69. package/lib/error.d.ts +112 -0
  70. package/lib/error.d.ts.map +1 -0
  71. package/lib/error.js +150 -0
  72. package/lib/error.js.map +1 -0
  73. package/lib/errorLogging.d.ts +86 -20
  74. package/lib/errorLogging.d.ts.map +1 -1
  75. package/lib/errorLogging.js +189 -60
  76. package/lib/errorLogging.js.map +1 -1
  77. package/lib/eventEmitterWithErrorHandling.d.ts +9 -3
  78. package/lib/eventEmitterWithErrorHandling.d.ts.map +1 -1
  79. package/lib/eventEmitterWithErrorHandling.js +15 -2
  80. package/lib/eventEmitterWithErrorHandling.js.map +1 -1
  81. package/lib/events.d.ts +27 -3
  82. package/lib/events.d.ts.map +1 -1
  83. package/lib/events.js +26 -2
  84. package/lib/events.js.map +1 -1
  85. package/lib/fluidErrorBase.d.ts +57 -16
  86. package/lib/fluidErrorBase.d.ts.map +1 -1
  87. package/lib/fluidErrorBase.js +27 -14
  88. package/lib/fluidErrorBase.js.map +1 -1
  89. package/lib/index.d.ts +12 -11
  90. package/lib/index.d.ts.map +1 -1
  91. package/lib/index.js +11 -11
  92. package/lib/index.js.map +1 -1
  93. package/lib/logger.d.ts +267 -51
  94. package/lib/logger.d.ts.map +1 -1
  95. package/lib/logger.js +415 -131
  96. package/lib/logger.js.map +1 -1
  97. package/lib/mockLogger.d.ts +39 -12
  98. package/lib/mockLogger.d.ts.map +1 -1
  99. package/lib/mockLogger.js +106 -23
  100. package/lib/mockLogger.js.map +1 -1
  101. package/lib/sampledTelemetryHelper.d.ts +18 -12
  102. package/lib/sampledTelemetryHelper.d.ts.map +1 -1
  103. package/lib/sampledTelemetryHelper.js +26 -17
  104. package/lib/sampledTelemetryHelper.js.map +1 -1
  105. package/lib/telemetry-utils-alpha.d.ts +290 -0
  106. package/lib/telemetry-utils-beta.d.ts +264 -0
  107. package/lib/telemetry-utils-public.d.ts +264 -0
  108. package/lib/telemetry-utils-untrimmed.d.ts +1102 -0
  109. package/lib/telemetryTypes.d.ts +115 -0
  110. package/lib/telemetryTypes.d.ts.map +1 -0
  111. package/lib/telemetryTypes.js +6 -0
  112. package/lib/telemetryTypes.js.map +1 -0
  113. package/lib/thresholdCounter.d.ts +6 -5
  114. package/lib/thresholdCounter.d.ts.map +1 -1
  115. package/lib/thresholdCounter.js +4 -3
  116. package/lib/thresholdCounter.js.map +1 -1
  117. package/lib/utils.d.ts +54 -3
  118. package/lib/utils.d.ts.map +1 -1
  119. package/lib/utils.js +56 -2
  120. package/lib/utils.js.map +1 -1
  121. package/package.json +86 -57
  122. package/prettier.config.cjs +8 -0
  123. package/src/config.ts +254 -189
  124. package/src/error.ts +235 -0
  125. package/src/errorLogging.ts +440 -290
  126. package/src/eventEmitterWithErrorHandling.ts +26 -14
  127. package/src/events.ts +54 -25
  128. package/src/fluidErrorBase.ts +94 -46
  129. package/src/index.ts +76 -17
  130. package/src/logger.ts +966 -505
  131. package/src/mockLogger.ts +225 -83
  132. package/src/sampledTelemetryHelper.ts +136 -128
  133. package/src/telemetryTypes.ts +140 -0
  134. package/src/thresholdCounter.ts +38 -37
  135. package/src/utils.ts +108 -17
  136. package/tsconfig.esnext.json +6 -6
  137. package/tsconfig.json +9 -13
  138. package/dist/debugLogger.d.ts +0 -39
  139. package/dist/debugLogger.d.ts.map +0 -1
  140. package/dist/debugLogger.js +0 -101
  141. package/dist/debugLogger.js.map +0 -1
  142. package/dist/packageVersion.d.ts +0 -9
  143. package/dist/packageVersion.d.ts.map +0 -1
  144. package/dist/packageVersion.js +0 -12
  145. package/dist/packageVersion.js.map +0 -1
  146. package/lib/debugLogger.d.ts +0 -39
  147. package/lib/debugLogger.d.ts.map +0 -1
  148. package/lib/debugLogger.js +0 -97
  149. package/lib/debugLogger.js.map +0 -1
  150. package/lib/packageVersion.d.ts +0 -9
  151. package/lib/packageVersion.d.ts.map +0 -1
  152. package/lib/packageVersion.js +0 -9
  153. package/lib/packageVersion.js.map +0 -1
  154. package/src/debugLogger.ts +0 -126
  155. package/src/packageVersion.ts +0 -9
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAcH,+DAAoF;AACpF,qCAIkB;AAClB,iDAIwB;AAExB;;;GAGG;AACH,IAAY,gBAUX;AAVD,WAAY,gBAAgB;IACxB;;;OAGG;IACH,+CAA2B,CAAA;IAC3B,4FAA4F;IAC5F,iDAA6B,CAAA;IAC7B,8EAA8E;IAC9E,yCAAqB,CAAA;AACzB,CAAC,EAVW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAU3B;AAYD;;;;GAIG;AACH,MAAsB,eAAe;IAyDjC,YACuB,SAAkB,EAClB,UAAyC;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C,SAAiB,EAAE,KAAU;QAChD,IAAI,CAAC,WAAW,CAAC,4BAA4B,EAAE,EAAE,SAAS,EAAE,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC;IACM,YAAY,CAAC,KAA2B,EAAE,SAAc;QAC3D,IAAI,CAAC,WAAW,CAAC,yBAAyB,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IAClE,CAAC;IACM,WAAW,CAAC,SAAkB,EAAE,KAA4B;QAC/D,IAAI,CAAC,WAAW,CAAC,2BAA2B,CAAC,CAAC;IAClD,CAAC;IACM,UAAU,CAAC,SAAkB,EAAE,KAA4B;QAC9D,IAAI,CAAC,WAAW,CAAC,0BAA0B,CAAC,CAAC;IACjD,CAAC;IAEO,WAAW,CAAC,OAAe,EAAE,KAA4B,EAAE,GAAS;QACxE,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QAChC,KAAa,CAAC,KAAK,GAAG,KAAK,CAAC;QAC5B,KAAa,CAAC,KAAK,GAAG,KAAK,CAAC;QAC7B,8CAA8C;QAC9C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,MAAM,KAAK,CAAC;IAChB,CAAC;CACJ;AAhCA,8CAgCA","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 { BaseTelemetryNullLogger, performance } from \"@fluidframework/common-utils\";\nimport {\n CachedConfigProvider,\n loggerIsMonitoringContext,\n mixinMonitoringContext,\n} from \"./config\";\nimport {\n isILoggingError,\n extractLogSafeErrorProperties,\n generateStack,\n} from \"./errorLogging\";\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 /**\n * Data containing terms from code packages that may have been dynamically loaded\n * @deprecated 1.0, will be removed in next release (see issue #6603). Use `TelemetryDataTag.CodeArtifact` instead.\n */\n PackageData = \"PackageData\",\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 ITelemetryLogger {\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: ITelemetryGenericEvent, 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: ITelemetryGenericEvent & { category: TelemetryEventCategory; },\n error?: any) {\n const newEvent = { ...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: ITelemetryPerformanceEvent, 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 TelemetryDataTag.PackageData:\n // For Microsoft applications, PackageData 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 sends 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) {\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 */\n export 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"]}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEA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,MAAM,OAAO,GAAG,CAOtB,GAAM,EACN,MAAS,EAaR,EAAE;AACH,+DAA+D;AAC/D,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;KACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;IAClC,uFAAuF;KACtF,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;IAClB,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;IACxB,iDAAiD;IACjD,kDAAkD;IAClD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;QAChC,4EAA4E;QAC5E,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE;YACd,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC;QAChC,CAAC,CAAC;KACF;SAAM;QACN,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;KACzB;IACD,OAAO,EAAE,CAAC;AACX,CAAC,EAAE,EAAE,CAA+B,CAAC;AAvC1B,QAAA,OAAO,WAuCmB;AAEvC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACI,MAAM,gBAAgB,GAAG,CAM/B,MAAS,EAaR,EAAE,CAAC,IAAA,eAAO,EAAmC,gBAAgB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AAnBzE,QAAA,gBAAgB,oBAmByD","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\tITelemetryPerformanceEvent,\n\tITelemetryProperties,\n\tTelemetryBaseEventPropertyType as TelemetryEventPropertyType,\n\tLogLevel,\n\tTagged,\n\tITelemetryBaseProperties,\n\tTelemetryBaseEventPropertyType,\n} from \"@fluidframework/core-interfaces\";\nimport { IsomorphicPerformance, performance } from \"@fluid-internal/client-utils\";\nimport { CachedConfigProvider, loggerIsMonitoringContext, mixinMonitoringContext } from \"./config\";\nimport {\n\tisILoggingError,\n\textractLogSafeErrorProperties,\n\tgenerateStack,\n\tisTaggedTelemetryPropertyValue,\n} from \"./errorLogging\";\nimport {\n\tITelemetryEventExt,\n\tITelemetryGenericEventExt,\n\tITelemetryLoggerExt,\n\tITelemetryPerformanceEventExt,\n\tTelemetryEventPropertyTypeExt,\n\tTelemetryEventCategory,\n} from \"./telemetryTypes\";\n\nexport interface Memory {\n\tusedJSHeapSize: number;\n}\n\nexport interface PerformanceWithMemory extends IsomorphicPerformance {\n\treadonly memory: Memory;\n}\n\n/**\n * Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.\n *\n * @privateRemarks Please do not modify existing entries, to maintain backwards compatibility.\n *\n * @internal\n */\nexport enum TelemetryDataTag {\n\t/**\n\t * Data containing terms or IDs from code packages that may have been dynamically loaded\n\t */\n\tCodeArtifact = \"CodeArtifact\",\n\t/**\n\t * Personal data of a variety of classifications that pertains to the user\n\t */\n\tUserData = \"UserData\",\n}\n\n/**\n * @alpha\n */\nexport type TelemetryEventPropertyTypes = ITelemetryBaseProperties[string];\n\n/**\n * @alpha\n */\nexport interface ITelemetryLoggerPropertyBag {\n\t[index: string]: TelemetryEventPropertyTypes | (() => TelemetryEventPropertyTypes);\n}\n\n/**\n * @alpha\n */\nexport interface ITelemetryLoggerPropertyBags {\n\tall?: ITelemetryLoggerPropertyBag;\n\terror?: ITelemetryLoggerPropertyBag;\n}\n\n/**\n * Attempts to parse number from string.\n * If it fails, it will return the original string.\n *\n * @remarks\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 * @internal\n */\n// eslint-disable-next-line @rushstack/no-new-null\nexport function numberFromString(str: string | null | undefined): string | number | undefined {\n\tif (str === undefined || str === null) {\n\t\treturn undefined;\n\t}\n\tconst num = Number(str);\n\treturn Number.isNaN(num) ? str : num;\n}\n\n// TODO: add docs\n// eslint-disable-next-line jsdoc/require-description\n/**\n * @internal\n */\nexport function formatTick(tick: number): number {\n\treturn Math.floor(tick);\n}\n\n/**\n * String used to concatenate the namespace of parent loggers and their child loggers.\n * @internal\n */\nexport const eventNamespaceSeparator = \":\" as const;\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\t/**\n\t * {@inheritDoc eventNamespaceSeparator}\n\t */\n\tpublic static readonly eventNamespaceSeparator = eventNamespaceSeparator;\n\n\tpublic static sanitizePkgName(name: string): 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(\n\t\tevent: ITelemetryBaseEvent,\n\t\terror: unknown,\n\t\tfetchStack: boolean,\n\t): void {\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, logLevel?: LogLevel): 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 * @param logLevel - optional level of the log. It category of event is set as error,\n\t * then the logLevel will be upgraded to be an error.\n\t */\n\tpublic sendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel: typeof LogLevel.verbose | typeof LogLevel.default = LogLevel.default,\n\t): void {\n\t\tthis.sendTelemetryEventCore(\n\t\t\t{ ...event, category: event.category ?? \"generic\" },\n\t\t\terror,\n\t\t\tevent.category === \"error\" ? LogLevel.error : logLevel,\n\t\t);\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 * @param logLevel - optional level of the log.\n\t */\n\tprotected sendTelemetryEventCore(\n\t\tevent: ITelemetryGenericEventExt & { category: TelemetryEventCategory },\n\t\terror?: unknown,\n\t\tlogLevel?: LogLevel,\n\t): void {\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 = formatTick(newEvent.duration);\n\t\t}\n\n\t\tthis.send(newEvent, logLevel);\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?: unknown): void {\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\tLogLevel.error,\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 * @param logLevel - optional level of the log. It category of event is set as error,\n\t * then the logLevel will be upgraded to be an error.\n\t */\n\tpublic sendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel: typeof LogLevel.verbose | typeof LogLevel.default = LogLevel.default,\n\t): 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(\n\t\t\tperfEvent,\n\t\t\terror,\n\t\t\tperfEvent.category === \"error\" ? LogLevel.error : logLevel,\n\t\t);\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\treturn this.extendProperties(newEvent, includeErrorProps);\n\t}\n\n\tprivate extendProperties<T extends ITelemetryLoggerPropertyBag = ITelemetryLoggerPropertyBag>(\n\t\ttoExtend: T,\n\t\tincludeErrorProps: boolean,\n\t): T {\n\t\tconst eventLike: ITelemetryLoggerPropertyBag = toExtend;\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 (eventLike[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\teventLike[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 toExtend;\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 *\n * @internal\n */\nexport class TaggedLoggerAdapter implements ITelemetryBaseLogger {\n\tpublic constructor(private readonly logger: ITelemetryBaseLogger) {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseLogger.send}\n\t */\n\tpublic send(eventWithTagsMaybe: ITelemetryBaseEvent): void {\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\t}\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\t}\n\t\t\t\tcase TelemetryDataTag.UserData: {\n\t\t\t\t\t// Strip out anything tagged explicitly as UserData.\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\t}\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\t}\n\t\t\t}\n\t\t}\n\t\tthis.logger.send(newEvent);\n\t}\n}\n\n/**\n * Create a child logger based on the provided props object.\n *\n * @remarks\n * Passing in no props object (i.e. undefined) will return a logger that is effectively a no-op.\n *\n * @param props - logger is the base logger the child will log to after it's processing, namespace will be prefixed to all event names, properties are default properties that will be applied events.\n *\n * @alpha\n */\nexport function createChildLogger(props?: {\n\tlogger?: ITelemetryBaseLogger;\n\tnamespace?: string;\n\tproperties?: ITelemetryLoggerPropertyBags;\n}): ITelemetryLoggerExt {\n\treturn ChildLogger.create(props?.logger, props?.namespace, props?.properties);\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 */\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\tconst child = new ChildLogger(\n\t\t\t\tbaseLogger.baseLogger,\n\t\t\t\tcombinedNamespace,\n\t\t\t\tcombinedProperties,\n\t\t\t);\n\n\t\t\tif (!loggerIsMonitoringContext(child) && loggerIsMonitoringContext(baseLogger)) {\n\t\t\t\tmixinMonitoringContext(child, baseLogger.config);\n\t\t\t}\n\t\t\treturn child;\n\t\t}\n\n\t\treturn new ChildLogger(baseLogger ?? { send(): void {} }, namespace, properties);\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(this, baseLogger.config));\n\t\t}\n\t}\n\n\tpublic get minLogLevel(): LogLevel | undefined {\n\t\treturn this.baseLogger.minLogLevel;\n\t}\n\n\tprivate shouldFilterOutEvent(event: ITelemetryBaseEvent, logLevel?: LogLevel): boolean {\n\t\tconst eventLogLevel = logLevel ?? LogLevel.default;\n\t\tconst configLogLevel = this.baseLogger.minLogLevel ?? LogLevel.default;\n\t\t// Filter out in case event log level is below what is wanted in config.\n\t\treturn eventLogLevel < configLogLevel;\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, logLevel?: LogLevel): void {\n\t\tif (this.shouldFilterOutEvent(event, logLevel)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.baseLogger.send(this.prepareEvent(event), logLevel);\n\t}\n}\n\n/**\n * Input properties for {@link createMultiSinkLogger}.\n *\n * @internal\n */\nexport interface MultiSinkLoggerProperties {\n\t/**\n\t * Will be prefixed to all event names.\n\t */\n\tnamespace?: string;\n\n\t/**\n\t * Default properties that will be applied to all events flowing through this logger.\n\t */\n\tproperties?: ITelemetryLoggerPropertyBags;\n\n\t/**\n\t * The base loggers that this logger will forward the logs to, after it processes them.\n\t */\n\tloggers?: (ITelemetryBaseLogger | undefined)[];\n\n\t/**\n\t * If true, the logger will attempt to copy the custom properties (if they are of a known type, i.e. one from this package) of all the base loggers passed to it, to apply them itself to logs that flow through.\n\t */\n\ttryInheritProperties?: true;\n}\n\n/**\n * Create a logger which logs to multiple other loggers based on the provided props object.\n *\n * @internal\n */\nexport function createMultiSinkLogger(props: MultiSinkLoggerProperties): ITelemetryLoggerExt {\n\treturn new MultiSinkLogger(\n\t\tprops.namespace,\n\t\tprops.properties,\n\t\tprops.loggers?.filter((l): l is ITelemetryBaseLogger => l !== undefined),\n\t\tprops.tryInheritProperties,\n\t);\n}\n\n/**\n * Multi-sink logger\n * Takes multiple ITelemetryBaseLogger objects (sinks) and logs all events into each sink\n */\nexport class MultiSinkLogger extends TelemetryLogger {\n\tprotected loggers: ITelemetryBaseLogger[];\n\t// This is minimum of minLlogLevel of all loggers.\n\tprivate _minLogLevelOfAllLoggers: LogLevel;\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 loggers - The list of loggers to use as sinks\n\t * @param tryInheritProperties - Will attempted to copy those loggers properties to this loggers if they are of a known type e.g. one from this package\n\t */\n\tconstructor(\n\t\tnamespace?: string,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t\tloggers: ITelemetryBaseLogger[] = [],\n\t\ttryInheritProperties?: true,\n\t) {\n\t\tlet realProperties = properties === undefined ? undefined : { ...properties };\n\t\tif (tryInheritProperties === true) {\n\t\t\tconst merge = (realProperties ??= {});\n\t\t\tloggers\n\t\t\t\t.filter((l): l is this => l instanceof TelemetryLogger)\n\t\t\t\t.map((l) => l.properties ?? {})\n\t\t\t\t// eslint-disable-next-line unicorn/no-array-for-each\n\t\t\t\t.forEach((cv) => {\n\t\t\t\t\t// eslint-disable-next-line unicorn/no-array-for-each\n\t\t\t\t\tObject.keys(cv).forEach((k) => {\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\t\tmerge[k] = { ...cv[k], ...merge?.[k] };\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t}\n\n\t\tsuper(namespace, realProperties);\n\t\tthis.loggers = loggers;\n\t\tthis._minLogLevelOfAllLoggers = LogLevel.default;\n\t\tthis.calculateMinLogLevel();\n\t}\n\n\tpublic get minLogLevel(): LogLevel {\n\t\treturn this._minLogLevelOfAllLoggers;\n\t}\n\n\tprivate calculateMinLogLevel(): void {\n\t\tif (this.loggers.length > 0) {\n\t\t\tconst logLevels: LogLevel[] = [];\n\t\t\tfor (const logger of this.loggers) {\n\t\t\t\tlogLevels.push(logger.minLogLevel ?? LogLevel.default);\n\t\t\t}\n\t\t\tthis._minLogLevelOfAllLoggers = Math.min(...logLevels) as LogLevel;\n\t\t}\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): void {\n\t\tif (logger !== undefined && logger !== null) {\n\t\t\tthis.loggers.push(logger);\n\t\t\t// Update in case the logLevel of added logger is less than the current.\n\t\t\tthis.calculateMinLogLevel();\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\tfor (const logger of this.loggers) {\n\t\t\tlogger.send(newEvent);\n\t\t}\n\t}\n}\n\n/**\n * Describes what events {@link PerformanceEvent} should log.\n *\n * @remarks\n * By default, all events are logged, but the client can override this behavior.\n *\n * For example, there is rarely a need to record a start event, as we're really after\n * success / failure tracking, including duration (on success).\n *\n * @internal\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 *\n * @internal\n */\nexport class PerformanceEvent {\n\t/**\n\t * Creates an instance of {@link PerformanceEvent} and starts measurements\n\t * @param logger - the logger to be used for publishing events\n\t * @param event - the logging event details which will be published with the performance measurements\n\t * @param markers - See {@link IPerformanceEventMarkers}\n\t * @param recordHeapSize - whether or not to also record memory performance\n\t * @param emitLogs - should this instance emit logs. If set to false, logs will not be emitted to the logger,\n\t * but measurements will still be performed and any specified markers will be generated.\n\t * @returns An instance of {@link PerformanceEvent}\n\t */\n\tpublic static start(\n\t\tlogger: ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEvent,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t\trecordHeapSize: boolean = false,\n\t\temitLogs: boolean = true,\n\t): PerformanceEvent {\n\t\treturn new PerformanceEvent(logger, event, markers, recordHeapSize, emitLogs);\n\t}\n\n\t/**\n\t * Measure a synchronous task\n\t * @param logger - the logger to be used for publishing events\n\t * @param event - the logging event details which will be published with the performance measurements\n\t * @param callback - the task to be executed and measured\n\t * @param markers - See {@link IPerformanceEventMarkers}\n\t * @param sampleThreshold - events with the same name and category will be sent to the logger\n\t * only when we hit this many executions of the task. If unspecified, all events will be sent.\n\t * @returns The results of the executed task\n\t *\n\t * @remarks Note that if the \"same\" event (category + eventName) would be emitted by different\n\t * tasks (`callback`), `sampleThreshold` is still applied only based on the event's category + eventName,\n\t * so executing either of the tasks will increase the internal counter and they\n\t * effectively \"share\" the sampling rate for the event.\n\t */\n\tpublic static timedExec<T>(\n\t\tlogger: ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEvent,\n\t\tcallback: (event: PerformanceEvent) => T,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t\tsampleThreshold: number = 1,\n\t): T {\n\t\tconst perfEvent = PerformanceEvent.start(\n\t\t\tlogger,\n\t\t\tevent,\n\t\t\tmarkers,\n\t\t\tundefined, // recordHeapSize\n\t\t\tPerformanceEvent.shouldReport(event, sampleThreshold),\n\t\t);\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\t/**\n\t * Measure an asynchronous task\n\t * @param logger - the logger to be used for publishing events\n\t * @param event - the logging event details which will be published with the performance measurements\n\t * @param callback - the task to be executed and measured\n\t * @param markers - See {@link IPerformanceEventMarkers}\n\t * @param recordHeapSize - whether or not to also record memory performance\n\t * @param sampleThreshold - events with the same name and category will be sent to the logger\n\t * only when we hit this many executions of the task. If unspecified, all events will be sent.\n\t * @returns The results of the executed task\n\t *\n\t * @remarks Note that if the \"same\" event (category + eventName) would be emitted by different\n\t * tasks (`callback`), `sampleThreshold` is still applied only based on the event's category + eventName,\n\t * so executing either of the tasks will increase the internal counter and they\n\t * effectively \"share\" the sampling rate for the event.\n\t */\n\tpublic static async timedExecAsync<T>(\n\t\tlogger: ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEvent,\n\t\tcallback: (event: PerformanceEvent) => Promise<T>,\n\t\tmarkers?: IPerformanceEventMarkers,\n\t\trecordHeapSize?: boolean,\n\t\tsampleThreshold: number = 1,\n\t): Promise<T> {\n\t\tconst perfEvent = PerformanceEvent.start(\n\t\t\tlogger,\n\t\t\tevent,\n\t\t\tmarkers,\n\t\t\trecordHeapSize,\n\t\t\tPerformanceEvent.shouldReport(event, sampleThreshold),\n\t\t);\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(): number {\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\tprivate startMemoryCollection: number | undefined = 0;\n\n\tprotected constructor(\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tevent: ITelemetryGenericEvent,\n\t\tprivate readonly markers: IPerformanceEventMarkers = { end: true, cancel: \"generic\" },\n\t\tprivate readonly recordHeapSize: boolean = false,\n\t\tprivate readonly emitLogs: boolean = true,\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?.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(): void {\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(): void {\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?: unknown): 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(\n\t\teventNameSuffix: string,\n\t\tprops?: ITelemetryProperties,\n\t\terror?: unknown,\n\t): void {\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\tif (!this.emitLogs) {\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\tif (this.startMemoryCollection) {\n\t\t\t\tconst currentMemory = (performance as PerformanceWithMemory)?.memory\n\t\t\t\t\t?.usedJSHeapSize;\n\t\t\t\tconst differenceInKBytes = Math.floor(\n\t\t\t\t\t(currentMemory - this.startMemoryCollection) / 1024,\n\t\t\t\t);\n\t\t\t\tif (differenceInKBytes > 0) {\n\t\t\t\t\tevent.usedJSHeapSize = differenceInKBytes;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.recordHeapSize) {\n\t\t\tthis.startMemoryCollection = (performance as PerformanceWithMemory)?.memory\n\t\t\t\t?.usedJSHeapSize;\n\t\t}\n\n\t\tthis.logger.sendPerformanceEvent(event, error);\n\t}\n\n\tprivate static readonly eventHits = new Map<string, number>();\n\tprivate static shouldReport(event: ITelemetryGenericEvent, sampleThreshold: number): boolean {\n\t\tconst eventKey = `.${event.category}.${event.eventName}`;\n\t\tconst hitCount = PerformanceEvent.eventHits.get(eventKey) ?? 0;\n\t\tPerformanceEvent.eventHits.set(eventKey, hitCount >= sampleThreshold ? 1 : hitCount + 1);\n\t\treturn hitCount % sampleThreshold === 0;\n\t}\n}\n\n/**\n * Null logger that no-ops for all telemetry events passed to it.\n *\n * @deprecated This will be removed in a future release.\n * For internal use within the FluidFramework codebase, use {@link createChildLogger} with no arguments instead.\n * For external consumers we recommend writing a trivial implementation of {@link @fluidframework/core-interfaces#ITelemetryBaseLogger}\n * where the send() method does nothing and using that.\n *\n * @internal\n */\nexport class TelemetryNullLogger implements ITelemetryLoggerExt {\n\tpublic send(event: ITelemetryBaseEvent): void {}\n\tpublic sendTelemetryEvent(event: ITelemetryGenericEvent, error?: unknown): void {}\n\tpublic sendErrorEvent(event: ITelemetryErrorEvent, error?: unknown): void {}\n\tpublic sendPerformanceEvent(event: ITelemetryPerformanceEvent, error?: unknown): 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 a flat array or object - returns a stringified version of the array/object.\n * If the value is an object of type Tagged<TelemetryEventPropertyType> - 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 | Tagged<TelemetryEventPropertyTypeExt>,\n): TelemetryEventPropertyType | Tagged<TelemetryEventPropertyType> {\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\t}\n\t\tcase \"object\": {\n\t\t\t// We assume this is an array or flat object based on the input types\n\t\t\treturn JSON.stringify(x);\n\t\t}\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\t}\n\t}\n}\n\n/**\n * Tags all given `values` with the same `tag`.\n *\n * @param tag - The tag with which all `values` will be annotated.\n * @param values - The values to be tagged.\n *\n * @remarks\n * It supports properties of type {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType},\n * as well as callbacks that return that type.\n *\n * @example Sample usage\n * ```typescript\n * {\n * \t// ...Other properties being added to a telemetry event\n * \t...tagData(\"someTag\", {foo: 1, bar: 2}),\n * \t// ...\n * }\n * ```\n * This will result in `foo` and `bar` added to the event with their values tagged.\n *\n * @internal\n */\nexport const tagData = <\n\tT extends TelemetryDataTag,\n\tV extends Record<\n\t\tstring,\n\t\tTelemetryBaseEventPropertyType | (() => TelemetryBaseEventPropertyType)\n\t>,\n>(\n\ttag: T,\n\tvalues: V,\n): {\n\t[P in keyof V]:\n\t\t| (V[P] extends () => TelemetryBaseEventPropertyType\n\t\t\t\t? () => {\n\t\t\t\t\t\tvalue: ReturnType<V[P]>;\n\t\t\t\t\t\ttag: T;\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tvalue: Exclude<V[P], undefined>;\n\t\t\t\t\t\ttag: T;\n\t\t\t\t })\n\t\t| (V[P] extends undefined ? undefined : never);\n} =>\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\tObject.entries(values)\n\t\t.filter((e) => e[1] !== undefined)\n\t\t// eslint-disable-next-line unicorn/no-array-reduce, unicorn/prefer-object-from-entries\n\t\t.reduce((pv, cv) => {\n\t\t\tconst [key, value] = cv;\n\t\t\t// The ternary form is less legible in this case.\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (typeof value === \"function\") {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n\t\t\t\tpv[key] = () => {\n\t\t\t\t\treturn { tag, value: value() };\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tpv[key] = { tag, value };\n\t\t\t}\n\t\t\treturn pv;\n\t\t}, {}) as ReturnType<typeof tagData>;\n\n/**\n * Tags all provided `values` as {@link TelemetryDataTag.CodeArtifact}.\n *\n * @param values - The values to be tagged.\n *\n * @remarks\n * It supports properties of type {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType},\n * as well as callbacks that return that type.\n *\n * @example Sample usage\n * ```typescript\n * {\n * \t// ...Other properties being added to a telemetry event\n * \t...tagCodeArtifacts(\"someTag\", {foo: 1, bar: 2}),\n * \t// ...\n * }\n * ```\n * This will result in `foo` and `bar` added to the event with their values tagged as {@link TelemetryDataTag.CodeArtifact}.\n *\n * @see {@link tagData}\n *\n * @internal\n */\nexport const tagCodeArtifacts = <\n\tT extends Record<\n\t\tstring,\n\t\tTelemetryBaseEventPropertyType | (() => TelemetryBaseEventPropertyType)\n\t>,\n>(\n\tvalues: T,\n): {\n\t[P in keyof T]:\n\t\t| (T[P] extends () => TelemetryBaseEventPropertyType\n\t\t\t\t? () => {\n\t\t\t\t\t\tvalue: ReturnType<T[P]>;\n\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact;\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tvalue: Exclude<T[P], undefined>;\n\t\t\t\t\t\ttag: TelemetryDataTag.CodeArtifact;\n\t\t\t\t })\n\t\t| (T[P] extends undefined ? undefined : never);\n} => tagData<TelemetryDataTag.CodeArtifact, T>(TelemetryDataTag.CodeArtifact, values);\n"]}
@@ -2,38 +2,65 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { ITelemetryLogger, ITelemetryBaseEvent } from "@fluidframework/common-definitions";
6
- import { TelemetryLogger } from "./logger";
5
+ import { ITelemetryBaseEvent, ITelemetryBaseLogger, LogLevel } from "@fluidframework/core-interfaces";
6
+ import { ITelemetryLoggerExt } from "./telemetryTypes";
7
7
  /**
8
8
  * The MockLogger records events sent to it, and then can walk back over those events
9
9
  * searching for a set of expected events to match against the logged events.
10
+ *
11
+ * @internal
10
12
  */
11
- export declare class MockLogger extends TelemetryLogger implements ITelemetryLogger {
13
+ export declare class MockLogger implements ITelemetryBaseLogger {
14
+ readonly minLogLevel?: LogLevel | undefined;
12
15
  events: ITelemetryBaseEvent[];
13
- constructor();
16
+ constructor(minLogLevel?: LogLevel | undefined);
14
17
  clear(): void;
18
+ toTelemetryLogger(): ITelemetryLoggerExt;
15
19
  send(event: ITelemetryBaseEvent): void;
16
20
  /**
17
21
  * Search events logged since the last time matchEvents was called, looking for the given expected
18
22
  * events in order.
19
23
  * @param expectedEvents - events in order that are expected to appear in the recorded log.
24
+ * @param inlineDetailsProp - true if the "details" property in the actual event should be extracted and inlined.
20
25
  * These event objects may be subsets of the logged events.
21
- * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
26
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
22
27
  */
23
- matchEvents(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean;
24
- /** Asserts that matchEvents is true, and prints the actual/expected output if not */
25
- assertMatch(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string): void;
28
+ matchEvents(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], inlineDetailsProp?: boolean): boolean;
29
+ /**
30
+ * Asserts that matchEvents is true, and prints the actual/expected output if not.
31
+ */
32
+ assertMatch(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string, inlineDetailsProp?: boolean): void;
26
33
  /**
27
34
  * Search events logged since the last time matchEvents was called, looking for any of the given
28
35
  * expected events.
29
36
  * @param expectedEvents - events that are expected to appear in the recorded log.
37
+ * @param inlineDetailsProp - true if the "details" property in the actual event should be extracted and inlined.
30
38
  * These event objects may be subsets of the logged events.
31
- * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
39
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
32
40
  * @returns if any of the expected events is found.
33
41
  */
34
- matchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, "category">[]): boolean;
35
- /** Asserts that matchAnyEvent is true, and prints the actual/expected output if not */
36
- assertMatchAny(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string): void;
42
+ matchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], inlineDetailsProp?: boolean): boolean;
43
+ /**
44
+ * Asserts that matchAnyEvent is true, and prints the actual/expected output if not.
45
+ */
46
+ assertMatchAny(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string, inlineDetailsProp?: boolean): void;
47
+ /**
48
+ * Search events logged since the last time matchEvents was called, looking only for the given expected
49
+ * events in order.
50
+ * @param expectedEvents - events in order that are expected to be the only events in the recorded log.
51
+ * @param inlineDetailsProp - true if the "details" property in the actual event should be extracted and inlined.
52
+ * These event objects may be subsets of the logged events.
53
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
54
+ */
55
+ matchEventStrict(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], inlineDetailsProp?: boolean): boolean;
56
+ /**
57
+ * Asserts that matchEvents is true, and prints the actual/expected output if not
58
+ */
59
+ assertMatchStrict(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string, inlineDetailsProp?: boolean): void;
60
+ /**
61
+ * Asserts that matchAnyEvent is false for the given events, and prints the actual/expected output if not
62
+ */
63
+ assertMatchNone(disallowedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string, inlineDetailsProp?: boolean): void;
37
64
  private getMatchedEventsCount;
38
65
  /**
39
66
  * Ensure the expected event is a strict subset of the actual event
@@ -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,eAAgB,YAAW,gBAAgB;IACvE,MAAM,EAAE,mBAAmB,EAAE,CAAM;;IAInC,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;;;;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AC,mBAAmB,EAAE,UAAU,CAAC,EAAE,EACvD,OAAO,CAAC,EAAE,MAAM,EAChB,iBAAiB,GAAE,OAAe,GAChC,IAAI;IAYP;;;;;;;OAOG;IACH,gBAAgB,CACf,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,EACvD,iBAAiB,GAAE,OAAe,GAChC,OAAO;IAOV;;OAEG;IACH,iBAAiB,CAChB,cAAc,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,EACvD,OAAO,CAAC,EAAE,MAAM,EAChB,iBAAiB,GAAE,OAAe,GAChC,IAAI;IAYP;;OAEG;IACH,eAAe,CACd,gBAAgB,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,EAAE,EACzD,OAAO,CAAC,EAAE,MAAM,EAChB,iBAAiB,GAAE,OAAe,GAChC,IAAI;IAYP,OAAO,CAAC,qBAAqB;IAsB7B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;CAsB1B"}
@@ -5,19 +5,25 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.MockLogger = void 0;
8
+ const core_utils_1 = require("@fluidframework/core-utils");
8
9
  const logger_1 = require("./logger");
9
10
  /**
10
11
  * The MockLogger records events sent to it, and then can walk back over those events
11
12
  * searching for a set of expected events to match against the logged events.
13
+ *
14
+ * @internal
12
15
  */
13
- class MockLogger extends logger_1.TelemetryLogger {
14
- constructor() {
15
- super();
16
+ class MockLogger {
17
+ constructor(minLogLevel) {
18
+ this.minLogLevel = minLogLevel;
16
19
  this.events = [];
17
20
  }
18
21
  clear() {
19
22
  this.events = [];
20
23
  }
24
+ toTelemetryLogger() {
25
+ return (0, logger_1.createChildLogger)({ logger: this });
26
+ }
21
27
  send(event) {
22
28
  this.events.push(event);
23
29
  }
@@ -25,19 +31,22 @@ class MockLogger extends logger_1.TelemetryLogger {
25
31
  * Search events logged since the last time matchEvents was called, looking for the given expected
26
32
  * events in order.
27
33
  * @param expectedEvents - events in order that are expected to appear in the recorded log.
34
+ * @param inlineDetailsProp - true if the "details" property in the actual event should be extracted and inlined.
28
35
  * These event objects may be subsets of the logged events.
29
- * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
36
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
30
37
  */
31
- matchEvents(expectedEvents) {
32
- const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);
38
+ matchEvents(expectedEvents, inlineDetailsProp = false) {
39
+ const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents, inlineDetailsProp);
33
40
  // How many expected events were left over? Hopefully none.
34
41
  const unmatchedExpectedEventCount = expectedEvents.length - matchedExpectedEventCount;
35
42
  return unmatchedExpectedEventCount === 0;
36
43
  }
37
- /** Asserts that matchEvents is true, and prints the actual/expected output if not */
38
- assertMatch(expectedEvents, message) {
44
+ /**
45
+ * Asserts that matchEvents is true, and prints the actual/expected output if not.
46
+ */
47
+ assertMatch(expectedEvents, message, inlineDetailsProp = false) {
39
48
  const actualEvents = this.events;
40
- if (!this.matchEvents(expectedEvents)) {
49
+ if (!this.matchEvents(expectedEvents, inlineDetailsProp)) {
41
50
  throw new Error(`${message}
42
51
  expected:
43
52
  ${JSON.stringify(expectedEvents)}
@@ -50,18 +59,21 @@ ${JSON.stringify(actualEvents)}`);
50
59
  * Search events logged since the last time matchEvents was called, looking for any of the given
51
60
  * expected events.
52
61
  * @param expectedEvents - events that are expected to appear in the recorded log.
62
+ * @param inlineDetailsProp - true if the "details" property in the actual event should be extracted and inlined.
53
63
  * These event objects may be subsets of the logged events.
54
- * Note: category is ommitted from the type because it's usually uninteresting and tedious to type.
64
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
55
65
  * @returns if any of the expected events is found.
56
66
  */
57
- matchAnyEvent(expectedEvents) {
58
- const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents);
67
+ matchAnyEvent(expectedEvents, inlineDetailsProp = false) {
68
+ const matchedExpectedEventCount = this.getMatchedEventsCount(expectedEvents, inlineDetailsProp);
59
69
  return matchedExpectedEventCount > 0;
60
70
  }
61
- /** Asserts that matchAnyEvent is true, and prints the actual/expected output if not */
62
- assertMatchAny(expectedEvents, message) {
71
+ /**
72
+ * Asserts that matchAnyEvent is true, and prints the actual/expected output if not.
73
+ */
74
+ assertMatchAny(expectedEvents, message, inlineDetailsProp = false) {
63
75
  const actualEvents = this.events;
64
- if (!this.matchAnyEvent(expectedEvents)) {
76
+ if (!this.matchAnyEvent(expectedEvents, inlineDetailsProp)) {
65
77
  throw new Error(`${message}
66
78
  expected:
67
79
  ${JSON.stringify(expectedEvents)}
@@ -70,15 +82,55 @@ actual:
70
82
  ${JSON.stringify(actualEvents)}`);
71
83
  }
72
84
  }
73
- getMatchedEventsCount(expectedEvents) {
85
+ /**
86
+ * Search events logged since the last time matchEvents was called, looking only for the given expected
87
+ * events in order.
88
+ * @param expectedEvents - events in order that are expected to be the only events in the recorded log.
89
+ * @param inlineDetailsProp - true if the "details" property in the actual event should be extracted and inlined.
90
+ * These event objects may be subsets of the logged events.
91
+ * Note: category is omitted from the type because it's usually uninteresting and tedious to type.
92
+ */
93
+ matchEventStrict(expectedEvents, inlineDetailsProp = false) {
94
+ return (expectedEvents.length === this.events.length &&
95
+ this.matchEvents(expectedEvents, inlineDetailsProp));
96
+ }
97
+ /**
98
+ * Asserts that matchEvents is true, and prints the actual/expected output if not
99
+ */
100
+ assertMatchStrict(expectedEvents, message, inlineDetailsProp = false) {
101
+ const actualEvents = this.events;
102
+ if (!this.matchEventStrict(expectedEvents, inlineDetailsProp)) {
103
+ throw new Error(`${message}
104
+ expected:
105
+ ${JSON.stringify(expectedEvents)}
106
+
107
+ actual:
108
+ ${JSON.stringify(actualEvents)}`);
109
+ }
110
+ }
111
+ /**
112
+ * Asserts that matchAnyEvent is false for the given events, and prints the actual/expected output if not
113
+ */
114
+ assertMatchNone(disallowedEvents, message, inlineDetailsProp = false) {
115
+ const actualEvents = this.events;
116
+ if (this.matchAnyEvent(disallowedEvents, inlineDetailsProp)) {
117
+ throw new Error(`${message}
118
+ disallowed events:
119
+ ${JSON.stringify(disallowedEvents)}
120
+
121
+ actual:
122
+ ${JSON.stringify(actualEvents)}`);
123
+ }
124
+ }
125
+ getMatchedEventsCount(expectedEvents, inlineDetailsProp) {
74
126
  let iExpectedEvent = 0;
75
- this.events.forEach((event) => {
127
+ for (const event of this.events) {
76
128
  if (iExpectedEvent < expectedEvents.length &&
77
- MockLogger.eventsMatch(event, expectedEvents[iExpectedEvent])) {
129
+ MockLogger.eventsMatch(event, expectedEvents[iExpectedEvent], inlineDetailsProp)) {
78
130
  // We found the next expected event; increment
79
131
  ++iExpectedEvent;
80
132
  }
81
- });
133
+ }
82
134
  // Remove the events so far; next call will just compare subsequent events from here
83
135
  this.events = [];
84
136
  // Return the count of matched events.
@@ -87,10 +139,41 @@ ${JSON.stringify(actualEvents)}`);
87
139
  /**
88
140
  * Ensure the expected event is a strict subset of the actual event
89
141
  */
90
- static eventsMatch(actual, expected) {
91
- const masked = Object.assign(Object.assign({}, actual), expected);
92
- return JSON.stringify(masked) === JSON.stringify(actual);
142
+ static eventsMatch(actual, expected, inlineDetailsProp) {
143
+ const { details, ...actualForMatching } = actual;
144
+ // "details" is used in a lot of telemetry logs to group a bunch of properties together and stringify them.
145
+ // Some of the properties in the expected event may be inside "details". So, if inlineDetailsProp is true,
146
+ // extract the properties from "details" in the actual event and inline them in the actual event.
147
+ if (inlineDetailsProp && details !== undefined) {
148
+ (0, core_utils_1.assert)(typeof details === "string",
149
+ // eslint-disable-next-line unicorn/numeric-separators-style
150
+ 0x6c9 /* Details should a JSON stringified string if inlineDetailsProp is true */);
151
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
152
+ const detailsExpanded = JSON.parse(details);
153
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
154
+ return matchObjects({ ...actualForMatching, ...detailsExpanded }, expected);
155
+ }
156
+ return matchObjects(actual, expected);
93
157
  }
94
158
  }
95
159
  exports.MockLogger = MockLogger;
160
+ function matchObjects(actual, expected) {
161
+ for (const [expectedKey, expectedValue] of Object.entries(expected)) {
162
+ const actualValue = actual[expectedKey];
163
+ if (!Array.isArray(expectedValue) &&
164
+ expectedValue !== null &&
165
+ typeof expectedValue === "object") {
166
+ if (Array.isArray(actualValue) ||
167
+ actualValue === null ||
168
+ typeof actualValue !== "object" ||
169
+ !matchObjects(actualValue, expectedValue)) {
170
+ return false;
171
+ }
172
+ }
173
+ else if (JSON.stringify(actualValue) !== JSON.stringify(expectedValue)) {
174
+ return false;
175
+ }
176
+ }
177
+ return true;
178
+ }
96
179
  //# sourceMappingURL=mockLogger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mockLogger.js","sourceRoot":"","sources":["../src/mockLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,qCAA2C;AAE3C;;;GAGG;AACH,MAAa,UAAW,SAAQ,wBAAe;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,C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C;QAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;CACJ;AA3FD,gCA2FC","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 ommitted 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 ommitted 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 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;;;AAOH,2DAAoD;AAEpD,qCAA6C;AAE7C;;;;;GAKG;AACH,MAAa,UAAU;IAGtB,YAA4B,WAAsB;QAAtB,gBAAW,GAAX,WAAW,CAAW;QAFlD,WAAM,GAA0B,EAAE,CAAC;IAEkB,CAAC;IAEtD,KAAK;QACJ,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IAClB,CAAC;IAED,iBAAiB;QAChB,OAAO,IAAA,0BAAiB,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,CAAC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Q;gBAC/B,CAAC,YAAY,CACZ,WAAsC,EACtC,aAAwC,CACxC,EACA;gBACD,OAAO,KAAK,CAAC;aACb;SACD;aAAM,IAAI,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE;YACzE,OAAO,KAAK,CAAC;SACb;KACD;IACD,OAAO,IAAI,CAAC;AACb,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\tLogLevel,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { ITelemetryLoggerExt, ITelemetryPropertiesExt } from \"./telemetryTypes\";\nimport { createChildLogger } 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 *\n * @internal\n */\nexport class MockLogger implements ITelemetryBaseLogger {\n\tevents: ITelemetryBaseEvent[] = [];\n\n\tconstructor(public readonly minLogLevel?: LogLevel) {}\n\n\tclear(): void {\n\t\tthis.events = [];\n\t}\n\n\ttoTelemetryLogger(): ITelemetryLoggerExt {\n\t\treturn createChildLogger({ logger: this });\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 * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\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(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean = false,\n\t): boolean {\n\t\tconst matchedExpectedEventCount = this.getMatchedEventsCount(\n\t\t\texpectedEvents,\n\t\t\tinlineDetailsProp,\n\t\t);\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/**\n\t * Asserts that matchEvents is true, and prints the actual/expected output if not.\n\t */\n\tassertMatch(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t): void {\n\t\tconst actualEvents = this.events;\n\t\tif (!this.matchEvents(expectedEvents, inlineDetailsProp)) {\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 * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\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(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean = false,\n\t): boolean {\n\t\tconst matchedExpectedEventCount = this.getMatchedEventsCount(\n\t\t\texpectedEvents,\n\t\t\tinlineDetailsProp,\n\t\t);\n\t\treturn matchedExpectedEventCount > 0;\n\t}\n\n\t/**\n\t * Asserts that matchAnyEvent is true, and prints the actual/expected output if not.\n\t */\n\tassertMatchAny(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t): void {\n\t\tconst actualEvents = this.events;\n\t\tif (!this.matchAnyEvent(expectedEvents, inlineDetailsProp)) {\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 * @param inlineDetailsProp - true if the \"details\" property in the actual event should be extracted and inlined.\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(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean = false,\n\t): boolean {\n\t\treturn (\n\t\t\texpectedEvents.length === this.events.length &&\n\t\t\tthis.matchEvents(expectedEvents, inlineDetailsProp)\n\t\t);\n\t}\n\n\t/**\n\t * Asserts that matchEvents is true, and prints the actual/expected output if not\n\t */\n\tassertMatchStrict(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t): void {\n\t\tconst actualEvents = this.events;\n\t\tif (!this.matchEventStrict(expectedEvents, inlineDetailsProp)) {\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 * Asserts that matchAnyEvent is false for the given events, and prints the actual/expected output if not\n\t */\n\tassertMatchNone(\n\t\tdisallowedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tmessage?: string,\n\t\tinlineDetailsProp: boolean = false,\n\t): void {\n\t\tconst actualEvents = this.events;\n\t\tif (this.matchAnyEvent(disallowedEvents, inlineDetailsProp)) {\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(\n\t\texpectedEvents: Omit<ITelemetryBaseEvent, \"category\">[],\n\t\tinlineDetailsProp: boolean,\n\t): number {\n\t\tlet iExpectedEvent = 0;\n\t\tfor (const event of this.events) {\n\t\t\tif (\n\t\t\t\tiExpectedEvent < expectedEvents.length &&\n\t\t\t\tMockLogger.eventsMatch(event, expectedEvents[iExpectedEvent], inlineDetailsProp)\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\tinlineDetailsProp: boolean,\n\t): boolean {\n\t\tconst { details, ...actualForMatching } = actual;\n\t\t// \"details\" is used in a lot of telemetry logs to group a bunch of properties together and stringify them.\n\t\t// Some of the properties in the expected event may be inside \"details\". So, if inlineDetailsProp is true,\n\t\t// extract the properties from \"details\" in the actual event and inline them in the actual event.\n\t\tif (inlineDetailsProp && details !== undefined) {\n\t\t\tassert(\n\t\t\t\ttypeof details === \"string\",\n\t\t\t\t// eslint-disable-next-line unicorn/numeric-separators-style\n\t\t\t\t0x6c9 /* Details should a JSON stringified string if inlineDetailsProp is true */,\n\t\t\t);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tconst detailsExpanded = JSON.parse(details);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn matchObjects({ ...actualForMatching, ...detailsExpanded }, expected);\n\t\t}\n\t\treturn matchObjects(actual, expected);\n\t}\n}\n\nfunction matchObjects(actual: ITelemetryPropertiesExt, expected: ITelemetryPropertiesExt): boolean {\n\tfor (const [expectedKey, expectedValue] of Object.entries(expected)) {\n\t\tconst actualValue = actual[expectedKey];\n\t\tif (\n\t\t\t!Array.isArray(expectedValue) &&\n\t\t\texpectedValue !== null &&\n\t\t\ttypeof expectedValue === \"object\"\n\t\t) {\n\t\t\tif (\n\t\t\t\tArray.isArray(actualValue) ||\n\t\t\t\tactualValue === null ||\n\t\t\t\ttypeof actualValue !== \"object\" ||\n\t\t\t\t!matchObjects(\n\t\t\t\t\tactualValue as ITelemetryPropertiesExt,\n\t\t\t\t\texpectedValue as ITelemetryPropertiesExt,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else if (JSON.stringify(actualValue) !== JSON.stringify(expectedValue)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n"]}
@@ -2,13 +2,18 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { IDisposable, ITelemetryGenericEvent, ITelemetryLogger, ITelemetryProperties } from "@fluidframework/common-definitions";
5
+ import { ITelemetryGenericEvent, ITelemetryProperties, IDisposable } from "@fluidframework/core-interfaces";
6
+ import { ITelemetryLoggerExt } from "./telemetryTypes";
6
7
  /**
7
8
  * Helper class that executes a specified code block and writes an
8
- * {@link @fluidframework/common-definitions#ITelemetryPerformanceEvent} to a specified logger every time a specified
9
- * number of executions is reached (or when the class is disposed). The `duration` field in the telemetry event is
10
- * the duration of the latest execution (sample) of the specified function. See the documentation of the
11
- * `includeAggregateMetrics` parameter for additional details that can be included.
9
+ * {@link @fluidframework/core-interfaces#ITelemetryPerformanceEvent} to a specified logger every time a specified
10
+ * number of executions is reached (or when the class is disposed).
11
+ *
12
+ * The `duration` field in the telemetry event is the duration of the latest execution (sample) of the specified
13
+ * function. See the documentation of the `includeAggregateMetrics` parameter for additional details that can be
14
+ * included.
15
+ *
16
+ * @internal
12
17
  */
13
18
  export declare class SampledTelemetryHelper implements IDisposable {
14
19
  private readonly eventBase;
@@ -36,14 +41,15 @@ export declare class SampledTelemetryHelper implements IDisposable {
36
41
  * them is specified as a key in one of the ITelemetryProperties objects in this map, that key-value pair will be
37
42
  * ignored.
38
43
  */
39
- constructor(eventBase: ITelemetryGenericEvent, logger: ITelemetryLogger, sampleThreshold: number, includeAggregateMetrics?: boolean, perBucketProperties?: Map<string, ITelemetryProperties>);
44
+ constructor(eventBase: ITelemetryGenericEvent, logger: ITelemetryLoggerExt, sampleThreshold: number, includeAggregateMetrics?: boolean, perBucketProperties?: Map<string, ITelemetryProperties>);
40
45
  /**
41
- * @param codeToMeasure -
42
- * The code to be executed and measured.
43
- * @param bucket -
44
- * A key to track executions of the code block separately. Each different value of this parameter has a separate
45
- * set of executions and metrics tracked by the class. If no such distinction needs to be made, do not provide a
46
- * value.
46
+ * Executes the specified code and keeps track of execution time statistics.
47
+ * If it's been called enough times (the sampleThreshold for the class) then it generates a log message with the necessary information.
48
+ *
49
+ * @param codeToMeasure - The code to be executed and measured.
50
+ * @param bucket - A key to track executions of the code block separately.
51
+ * Each different value of this parameter has a separate set of executions and metrics tracked by the class.
52
+ * If no such distinction needs to be made, do not provide a value.
47
53
  * @returns Whatever the passed-in code block returns.
48
54
  */
49
55
  measure<T>(codeToMeasure: () => T, bucket?: string): T;
@@ -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,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,uBAAuB;IACxC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IA3BxC,QAAQ,EAAE,OAAO,CAAS;IAE1B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAmC;IAEnE;;;;;;;;;;;;;;;;;OAiBG;gBAEkB,SAAS,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