@fluidframework/telemetry-utils 2.0.0-rc.1.0.6 → 2.0.0-rc.2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/{.mocharc.js → .mocharc.cjs} +1 -1
  2. package/CHANGELOG.md +23 -0
  3. package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -2
  4. package/api-extractor-lint.json +1 -1
  5. package/api-extractor.json +1 -1
  6. package/api-report/telemetry-utils.api.md +10 -33
  7. package/dist/config.d.ts +2 -2
  8. package/dist/config.d.ts.map +1 -1
  9. package/dist/config.js +3 -3
  10. package/dist/config.js.map +1 -1
  11. package/dist/error.d.ts +2 -2
  12. package/dist/error.d.ts.map +1 -1
  13. package/dist/error.js +9 -9
  14. package/dist/error.js.map +1 -1
  15. package/dist/errorLogging.d.ts +4 -4
  16. package/dist/errorLogging.d.ts.map +1 -1
  17. package/dist/errorLogging.js +19 -60
  18. package/dist/errorLogging.js.map +1 -1
  19. package/dist/eventEmitterWithErrorHandling.d.ts +1 -1
  20. package/dist/eventEmitterWithErrorHandling.js +1 -1
  21. package/dist/eventEmitterWithErrorHandling.js.map +1 -1
  22. package/dist/events.d.ts +2 -3
  23. package/dist/events.d.ts.map +1 -1
  24. package/dist/events.js.map +1 -1
  25. package/dist/fluidErrorBase.d.ts +4 -3
  26. package/dist/fluidErrorBase.d.ts.map +1 -1
  27. package/dist/fluidErrorBase.js.map +1 -1
  28. package/dist/index.d.ts +12 -12
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +58 -60
  31. package/dist/index.js.map +1 -1
  32. package/dist/logger.d.ts +7 -23
  33. package/dist/logger.d.ts.map +1 -1
  34. package/dist/logger.js +12 -29
  35. package/dist/logger.js.map +1 -1
  36. package/dist/mockLogger.d.ts +1 -1
  37. package/dist/mockLogger.d.ts.map +1 -1
  38. package/dist/mockLogger.js +2 -2
  39. package/dist/mockLogger.js.map +1 -1
  40. package/dist/package.json +3 -0
  41. package/dist/sampledTelemetryHelper.d.ts +4 -4
  42. package/dist/sampledTelemetryHelper.d.ts.map +1 -1
  43. package/dist/sampledTelemetryHelper.js +1 -1
  44. package/dist/sampledTelemetryHelper.js.map +1 -1
  45. package/dist/telemetry-utils-alpha.d.ts +4 -15
  46. package/dist/telemetry-utils-beta.d.ts +4 -32
  47. package/dist/telemetry-utils-public.d.ts +4 -32
  48. package/dist/telemetry-utils-untrimmed.d.ts +11 -50
  49. package/dist/thresholdCounter.d.ts +1 -1
  50. package/dist/thresholdCounter.d.ts.map +1 -1
  51. package/dist/thresholdCounter.js.map +1 -1
  52. package/dist/tsdoc-metadata.json +1 -1
  53. package/dist/utils.d.ts +1 -20
  54. package/dist/utils.d.ts.map +1 -1
  55. package/dist/utils.js +3 -27
  56. package/dist/utils.js.map +1 -1
  57. package/lib/config.d.ts +2 -2
  58. package/lib/config.d.ts.map +1 -1
  59. package/lib/config.js +1 -1
  60. package/lib/config.js.map +1 -1
  61. package/lib/error.d.ts +2 -2
  62. package/lib/error.d.ts.map +1 -1
  63. package/lib/error.js +1 -1
  64. package/lib/error.js.map +1 -1
  65. package/lib/errorLogging.d.ts +4 -4
  66. package/lib/errorLogging.d.ts.map +1 -1
  67. package/lib/errorLogging.js +15 -56
  68. package/lib/errorLogging.js.map +1 -1
  69. package/lib/eventEmitterWithErrorHandling.d.ts +1 -1
  70. package/lib/eventEmitterWithErrorHandling.js +1 -1
  71. package/lib/eventEmitterWithErrorHandling.js.map +1 -1
  72. package/lib/events.d.ts +2 -3
  73. package/lib/events.d.ts.map +1 -1
  74. package/lib/events.js.map +1 -1
  75. package/lib/fluidErrorBase.d.ts +4 -3
  76. package/lib/fluidErrorBase.d.ts.map +1 -1
  77. package/lib/fluidErrorBase.js.map +1 -1
  78. package/lib/index.d.ts +12 -12
  79. package/lib/index.d.ts.map +1 -1
  80. package/lib/index.js +11 -11
  81. package/lib/index.js.map +1 -1
  82. package/lib/logger.d.ts +7 -23
  83. package/lib/logger.d.ts.map +1 -1
  84. package/lib/logger.js +3 -19
  85. package/lib/logger.js.map +1 -1
  86. package/lib/mockLogger.d.ts +1 -1
  87. package/lib/mockLogger.d.ts.map +1 -1
  88. package/lib/mockLogger.js +1 -1
  89. package/lib/mockLogger.js.map +1 -1
  90. package/lib/sampledTelemetryHelper.d.ts +4 -4
  91. package/lib/sampledTelemetryHelper.d.ts.map +1 -1
  92. package/lib/sampledTelemetryHelper.js +1 -1
  93. package/lib/sampledTelemetryHelper.js.map +1 -1
  94. package/lib/{telemetry-utils-alpha.d.mts → telemetry-utils-alpha.d.ts} +4 -15
  95. package/lib/{telemetry-utils-beta.d.mts → telemetry-utils-beta.d.ts} +4 -32
  96. package/lib/{telemetry-utils-public.d.mts → telemetry-utils-public.d.ts} +4 -32
  97. package/lib/{telemetry-utils-untrimmed.d.mts → telemetry-utils-untrimmed.d.ts} +11 -50
  98. package/lib/test/EventEmitterWithErrorHandling.spec.js +86 -0
  99. package/lib/test/EventEmitterWithErrorHandling.spec.js.map +1 -0
  100. package/lib/test/childLogger.spec.js +233 -0
  101. package/lib/test/childLogger.spec.js.map +1 -0
  102. package/lib/test/config.spec.js +229 -0
  103. package/lib/test/config.spec.js.map +1 -0
  104. package/lib/test/error.spec.js +161 -0
  105. package/lib/test/error.spec.js.map +1 -0
  106. package/lib/test/errorLogging.spec.js +801 -0
  107. package/lib/test/errorLogging.spec.js.map +1 -0
  108. package/lib/test/errorTypeLoggingTest.spec.js +107 -0
  109. package/lib/test/errorTypeLoggingTest.spec.js.map +1 -0
  110. package/lib/test/mockLogger.spec.js +164 -0
  111. package/lib/test/mockLogger.spec.js.map +1 -0
  112. package/lib/test/multiSinkLogger.spec.js +84 -0
  113. package/lib/test/multiSinkLogger.spec.js.map +1 -0
  114. package/lib/test/performanceEvent.spec.js +86 -0
  115. package/lib/test/performanceEvent.spec.js.map +1 -0
  116. package/lib/test/sampledTelemetryHelper.spec.js +169 -0
  117. package/lib/test/sampledTelemetryHelper.spec.js.map +1 -0
  118. package/lib/test/telemetryLogger.spec.js +357 -0
  119. package/lib/test/telemetryLogger.spec.js.map +1 -0
  120. package/lib/test/thresholdCounter.spec.js +51 -0
  121. package/lib/test/thresholdCounter.spec.js.map +1 -0
  122. package/lib/test/types/validateTelemetryUtilsPrevious.generated.js +132 -0
  123. package/lib/test/types/validateTelemetryUtilsPrevious.generated.js.map +1 -0
  124. package/lib/test/utils.spec.js +284 -0
  125. package/lib/test/utils.spec.js.map +1 -0
  126. package/lib/thresholdCounter.d.ts +1 -1
  127. package/lib/thresholdCounter.d.ts.map +1 -1
  128. package/lib/thresholdCounter.js.map +1 -1
  129. package/lib/utils.d.ts +1 -20
  130. package/lib/utils.d.ts.map +1 -1
  131. package/lib/utils.js +1 -24
  132. package/lib/utils.js.map +1 -1
  133. package/package.json +75 -26
  134. package/src/config.ts +2 -2
  135. package/src/error.ts +2 -2
  136. package/src/errorLogging.ts +27 -68
  137. package/src/eventEmitterWithErrorHandling.ts +1 -1
  138. package/src/events.ts +2 -4
  139. package/src/fluidErrorBase.ts +4 -3
  140. package/src/index.ts +12 -13
  141. package/src/logger.ts +12 -28
  142. package/src/mockLogger.ts +2 -2
  143. package/src/sampledTelemetryHelper.ts +10 -11
  144. package/src/thresholdCounter.ts +1 -1
  145. package/src/utils.ts +3 -36
  146. package/tsconfig.cjs.json +7 -0
  147. package/tsconfig.json +2 -3
  148. package/tsconfig.esnext.json +0 -7
  149. /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"sampledTelemetryHelper.js","sourceRoot":"","sources":["../src/sampledTelemetryHelper.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,+DAA2D;AAqC3D;;;;;;;;;;GAUG;AACH,MAAa,sBAAsB;IAKlC;;;;;;;;;;;;;;;;;OAiBG;IACH,YACkB,SAAiC,EACjC,MAA2B,EAC3B,eAAuB,EACvB,0BAAmC,KAAK,EACxC,sBAAsB,IAAI,GAAG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,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,eAAe,EAAE;YACpC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;SACzB;QAED,OAAO,WAAW,CAAC;IACpB,CAAC;IAEO,WAAW,CAAC,MAAc;QACjC,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,YAAY,KAAK,SAAS,EAAE;YAC/B,OAAO;SACP;QAED,IAAI,YAAY,CAAC,KAAK,KAAK,CAAC,EAAE;YAC7B,MAAM,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAE9D,MAAM,cAAc,GAA+B;gBAClD,GAAG,IAAI,CAAC,SAAS;gBACjB,GAAG,gBAAgB;gBACnB,GAAG,YAAY;aACf,CAAC;YAEF,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;YACjD,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SACpC;IACF,CAAC;IAEM,OAAO,CAAC,KAAyB;QACvC,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE;YAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IACvE,CAAC;CACD;AA1FD,wDA0FC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tITelemetryGenericEvent,\n\tITelemetryPerformanceEvent,\n\tITelemetryProperties,\n\tIDisposable,\n} from \"@fluidframework/core-interfaces\";\nimport { performance } from \"@fluid-internal/client-utils\";\nimport { ITelemetryLoggerExt } from \"./telemetryTypes\";\n\n/**\n * @privateRemarks\n *\n * The names of the properties in this interface are the ones that will get stamped in the\n * telemetry event, changes should be considered carefully. The optional properties should\n * only be populated if 'includeAggregateMetrics' is true.\n */\ninterface Measurements {\n\t/**\n\t * The duration of the latest execution.\n\t */\n\tduration: number;\n\n\t/**\n\t * The number of executions since the last time an event was generated.\n\t */\n\tcount: number;\n\n\t/**\n\t * Total duration across all the executions since the last event was generated.\n\t */\n\ttotalDuration?: number;\n\n\t/**\n\t * Min duration across all the executions since the last event was generated.\n\t */\n\tminDuration?: number;\n\n\t/**\n\t * Max duration across all the executions since the last event was generated.\n\t */\n\tmaxDuration?: number;\n}\n\n/**\n * Helper class that executes a specified code block and writes an\n * {@link @fluidframework/core-interfaces#ITelemetryPerformanceEvent} to a specified logger every time a specified\n * number of executions is reached (or when the class is disposed).\n *\n * The `duration` field in the telemetry event is the duration of the latest execution (sample) of the specified\n * function. See the documentation of the `includeAggregateMetrics` parameter for additional details that can be\n * included.\n *\n * @internal\n */\nexport class SampledTelemetryHelper implements IDisposable {\n\tdisposed: boolean = false;\n\n\tprivate readonly measurementsMap = new Map<string, Measurements>();\n\n\t/**\n\t * @param eventBase -\n\t * Custom properties to include in the telemetry performance event when it is written.\n\t * @param logger -\n\t * The logger to use to write the telemetry performance event.\n\t * @param sampleThreshold -\n\t * Telemetry performance events will be generated every time we hit this many executions of the code block.\n\t * @param includeAggregateMetrics -\n\t * If set to `true`, the telemetry performance event will include aggregated metrics (total duration, min duration,\n\t * max duration) for all the executions in between generated events.\n\t * @param perBucketProperties -\n\t * Map of strings that represent different buckets (which can be specified when calling the 'measure' method), to\n\t * properties which should be added to the telemetry event for that bucket. If a bucket being measured does not\n\t * have an entry in this map, no additional properties will be added to its telemetry events. The following keys are\n\t * reserved for use by this class: \"duration\", \"count\", \"totalDuration\", \"minDuration\", \"maxDuration\". If any of\n\t * them is specified as a key in one of the ITelemetryProperties objects in this map, that key-value pair will be\n\t * ignored.\n\t */\n\tpublic constructor(\n\t\tprivate readonly eventBase: ITelemetryGenericEvent,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly sampleThreshold: number,\n\t\tprivate readonly includeAggregateMetrics: boolean = false,\n\t\tprivate readonly perBucketProperties = new Map<string, ITelemetryProperties>(),\n\t) {}\n\n\t/**\n\t * Executes the specified code and keeps track of execution time statistics.\n\t * If it's been called enough times (the sampleThreshold for the class) then it generates a log message with the necessary information.\n\t *\n\t * @param codeToMeasure - The code to be executed and measured.\n\t * @param bucket - A key to track executions of the code block separately.\n\t * Each different value of this parameter has a separate set of executions and metrics tracked by the class.\n\t * If no such distinction needs to be made, do not provide a value.\n\t * @returns Whatever the passed-in code block returns.\n\t */\n\tpublic measure<T>(codeToMeasure: () => T, bucket: string = \"\"): T {\n\t\tconst start = performance.now();\n\t\tconst returnValue = codeToMeasure();\n\t\tconst duration = performance.now() - start;\n\n\t\tlet m = this.measurementsMap.get(bucket);\n\t\tif (m === undefined) {\n\t\t\tm = { count: 0, duration: -1 };\n\t\t\tthis.measurementsMap.set(bucket, m);\n\t\t}\n\t\tm.count++;\n\t\tm.duration = duration;\n\n\t\tif (this.includeAggregateMetrics) {\n\t\t\tm.totalDuration = (m.totalDuration ?? 0) + duration;\n\t\t\tm.minDuration = Math.min(m.minDuration ?? duration, duration);\n\t\t\tm.maxDuration = Math.max(m.maxDuration ?? 0, duration);\n\t\t}\n\n\t\tif (m.count >= this.sampleThreshold) {\n\t\t\tthis.flushBucket(bucket);\n\t\t}\n\n\t\treturn returnValue;\n\t}\n\n\tprivate flushBucket(bucket: string): void {\n\t\tconst measurements = this.measurementsMap.get(bucket);\n\t\tif (measurements === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (measurements.count !== 0) {\n\t\t\tconst bucketProperties = this.perBucketProperties.get(bucket);\n\n\t\t\tconst telemetryEvent: ITelemetryPerformanceEvent = {\n\t\t\t\t...this.eventBase,\n\t\t\t\t...bucketProperties, // If the bucket doesn't exist and this is undefined, things work as expected\n\t\t\t\t...measurements,\n\t\t\t};\n\n\t\t\tthis.logger.sendPerformanceEvent(telemetryEvent);\n\t\t\tthis.measurementsMap.delete(bucket);\n\t\t}\n\t}\n\n\tpublic dispose(error?: Error | undefined): void {\n\t\tfor (const [k] of this.measurementsMap.entries()) this.flushBucket(k);\n\t}\n}\n"]}
1
+ {"version":3,"file":"sampledTelemetryHelper.js","sourceRoot":"","sources":["../src/sampledTelemetryHelper.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAA2D;AAyC3D;;;;;;;;;;GAUG;AACH,MAAa,sBAAsB;IAKlC;;;;;;;;;;;;;;;;;OAiBG;IACH,YACkB,SAAoC,EACpC,MAA2B,EAC3B,eAAuB,EACvB,0BAAmC,KAAK,EACxC,sBAAsB,IAAI,GAAG,EAAoC;QAJjE,cAAS,GAAT,SAAS,CAA2B;QACpC,WAAM,GAAN,MAAM,CAAqB;QAC3B,oBAAe,GAAf,eAAe,CAAQ;QACvB,4BAAuB,GAAvB,uBAAuB,CAAiB;QACxC,wBAAmB,GAAnB,mBAAmB,CAA8C;QA3BnF,aAAQ,GAAY,KAAK,CAAC;QAET,oBAAe,GAAG,IAAI,GAAG,EAAwB,CAAC;IA0BhE,CAAC;IAEJ;;;;;;;;;OASG;IACI,OAAO,CAAI,aAAsB,EAAE,SAAiB,EAAE;QAC5D,MAAM,KAAK,GAAG,0BAAW,CAAC,GAAG,EAAE,CAAC;QAChC,MAAM,WAAW,GAAG,aAAa,EAAE,CAAC;QACpC,MAAM,QAAQ,GAAG,0BAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QAE3C,IAAI,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,SAAS,EAAE;YACpB,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;SACpC;QACD,CAAC,CAAC,KAAK,EAAE,CAAC;QACV,CAAC,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEtB,IAAI,IA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right (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseProperties, IDisposable } from \"@fluidframework/core-interfaces\";\nimport { performance } from \"@fluid-internal/client-utils\";\nimport {\n\tITelemetryLoggerExt,\n\ttype ITelemetryGenericEventExt,\n\ttype ITelemetryPerformanceEventExt,\n} from \"./telemetryTypes.js\";\n\n/**\n * @privateRemarks\n *\n * The names of the properties in this interface are the ones that will get stamped in the\n * telemetry event, changes should be considered carefully. The optional properties should\n * only be populated if 'includeAggregateMetrics' is true.\n */\ninterface Measurements {\n\t/**\n\t * The duration of the latest execution.\n\t */\n\tduration: number;\n\n\t/**\n\t * The number of executions since the last time an event was generated.\n\t */\n\tcount: number;\n\n\t/**\n\t * Total duration across all the executions since the last event was generated.\n\t */\n\ttotalDuration?: number;\n\n\t/**\n\t * Min duration across all the executions since the last event was generated.\n\t */\n\tminDuration?: number;\n\n\t/**\n\t * Max duration across all the executions since the last event was generated.\n\t */\n\tmaxDuration?: number;\n}\n\n/**\n * Helper class that executes a specified code block and writes an\n * {@link @fluidframework/core-interfaces#ITelemetryPerformanceEvent} to a specified logger every time a specified\n * number of executions is reached (or when the class is disposed).\n *\n * The `duration` field in the telemetry event is the duration of the latest execution (sample) of the specified\n * function. See the documentation of the `includeAggregateMetrics` parameter for additional details that can be\n * included.\n *\n * @internal\n */\nexport class SampledTelemetryHelper implements IDisposable {\n\tdisposed: boolean = false;\n\n\tprivate readonly measurementsMap = new Map<string, Measurements>();\n\n\t/**\n\t * @param eventBase -\n\t * Custom properties to include in the telemetry performance event when it is written.\n\t * @param logger -\n\t * The logger to use to write the telemetry performance event.\n\t * @param sampleThreshold -\n\t * Telemetry performance events will be generated every time we hit this many executions of the code block.\n\t * @param includeAggregateMetrics -\n\t * If set to `true`, the telemetry performance event will include aggregated metrics (total duration, min duration,\n\t * max duration) for all the executions in between generated events.\n\t * @param perBucketProperties -\n\t * Map of strings that represent different buckets (which can be specified when calling the 'measure' method), to\n\t * properties which should be added to the telemetry event for that bucket. If a bucket being measured does not\n\t * have an entry in this map, no additional properties will be added to its telemetry events. The following keys are\n\t * reserved for use by this class: \"duration\", \"count\", \"totalDuration\", \"minDuration\", \"maxDuration\". If any of\n\t * them is specified as a key in one of the ITelemetryBaseProperties objects in this map, that key-value pair will be\n\t * ignored.\n\t */\n\tpublic constructor(\n\t\tprivate readonly eventBase: ITelemetryGenericEventExt,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly sampleThreshold: number,\n\t\tprivate readonly includeAggregateMetrics: boolean = false,\n\t\tprivate readonly perBucketProperties = new Map<string, ITelemetryBaseProperties>(),\n\t) {}\n\n\t/**\n\t * Executes the specified code and keeps track of execution time statistics.\n\t * If it's been called enough times (the sampleThreshold for the class) then it generates a log message with the necessary information.\n\t *\n\t * @param codeToMeasure - The code to be executed and measured.\n\t * @param bucket - A key to track executions of the code block separately.\n\t * Each different value of this parameter has a separate set of executions and metrics tracked by the class.\n\t * If no such distinction needs to be made, do not provide a value.\n\t * @returns Whatever the passed-in code block returns.\n\t */\n\tpublic measure<T>(codeToMeasure: () => T, bucket: string = \"\"): T {\n\t\tconst start = performance.now();\n\t\tconst returnValue = codeToMeasure();\n\t\tconst duration = performance.now() - start;\n\n\t\tlet m = this.measurementsMap.get(bucket);\n\t\tif (m === undefined) {\n\t\t\tm = { count: 0, duration: -1 };\n\t\t\tthis.measurementsMap.set(bucket, m);\n\t\t}\n\t\tm.count++;\n\t\tm.duration = duration;\n\n\t\tif (this.includeAggregateMetrics) {\n\t\t\tm.totalDuration = (m.totalDuration ?? 0) + duration;\n\t\t\tm.minDuration = Math.min(m.minDuration ?? duration, duration);\n\t\t\tm.maxDuration = Math.max(m.maxDuration ?? 0, duration);\n\t\t}\n\n\t\tif (m.count >= this.sampleThreshold) {\n\t\t\tthis.flushBucket(bucket);\n\t\t}\n\n\t\treturn returnValue;\n\t}\n\n\tprivate flushBucket(bucket: string): void {\n\t\tconst measurements = this.measurementsMap.get(bucket);\n\t\tif (measurements === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (measurements.count !== 0) {\n\t\t\tconst bucketProperties = this.perBucketProperties.get(bucket);\n\n\t\t\tconst telemetryEvent: ITelemetryPerformanceEventExt = {\n\t\t\t\t...this.eventBase,\n\t\t\t\t...bucketProperties, // If the bucket doesn't exist and this is undefined, things work as expected\n\t\t\t\t...measurements,\n\t\t\t};\n\n\t\t\tthis.logger.sendPerformanceEvent(telemetryEvent);\n\t\t\tthis.measurementsMap.delete(bucket);\n\t\t}\n\t}\n\n\tpublic dispose(error?: Error | undefined): void {\n\t\tfor (const [k] of this.measurementsMap.entries()) this.flushBucket(k);\n\t}\n}\n"]}
@@ -1,28 +1,21 @@
1
- /// <reference types="node" />
2
-
3
1
  import { ConfigTypes } from '@fluidframework/core-interfaces';
4
- import { EventEmitter } from 'events';
2
+ import type { EventEmitter } from '@fluid-internal/client-utils';
5
3
  import { EventEmitterEventType } from '@fluid-internal/client-utils';
6
4
  import { IConfigProviderBase } from '@fluidframework/core-interfaces';
7
- import { IDisposable } from '@fluidframework/core-interfaces';
5
+ import type { IDisposable } from '@fluidframework/core-interfaces';
8
6
  import { IErrorBase } from '@fluidframework/core-interfaces';
9
7
  import { IEvent } from '@fluidframework/core-interfaces';
10
8
  import { IGenericError } from '@fluidframework/core-interfaces';
11
- import { ILoggingError } from '@fluidframework/core-interfaces';
9
+ import type { ILoggingError } from '@fluidframework/core-interfaces';
12
10
  import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
13
11
  import { ITelemetryBaseEvent } from '@fluidframework/core-interfaces';
14
12
  import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
15
13
  import { ITelemetryBaseProperties } from '@fluidframework/core-interfaces';
16
- import { ITelemetryErrorEvent } from '@fluidframework/core-interfaces';
17
- import { ITelemetryGenericEvent } from '@fluidframework/core-interfaces';
18
- import { ITelemetryPerformanceEvent } from '@fluidframework/core-interfaces';
19
- import { ITelemetryProperties } from '@fluidframework/core-interfaces';
20
14
  import { IUsageError } from '@fluidframework/core-interfaces';
21
15
  import { Lazy } from '@fluidframework/core-utils';
22
16
  import { LogLevel } from '@fluidframework/core-interfaces';
23
17
  import { Tagged } from '@fluidframework/core-interfaces';
24
18
  import { TelemetryBaseEventPropertyType } from '@fluidframework/core-interfaces';
25
- import { TelemetryEventPropertyType } from '@fluidframework/core-interfaces';
26
19
  import { TypedEventEmitter } from '@fluid-internal/client-utils';
27
20
 
28
21
  /* Excluded from this release type: connectedEventName */
@@ -64,7 +57,7 @@ export declare function createChildLogger(props?: {
64
57
  * @privateRemarks
65
58
  * This probably doesn't belong in this package, as it is not telemetry-specific, and is really only intended for internal fluid-framework use.
66
59
  * We should consider moving it to the `core-utils` package.
67
- * @public
60
+ * @alpha
68
61
  */
69
62
  export declare class EventEmitterWithErrorHandling<TEvent extends IEvent = IEvent> extends TypedEventEmitter<TEvent> {
70
63
  private readonly errorHandler;
@@ -210,8 +203,6 @@ export declare interface ITelemetryPropertiesExt {
210
203
 
211
204
  /* Excluded from this release type: LoggingError */
212
205
 
213
- /* Excluded from this release type: logIfFalse */
214
-
215
206
  /* Excluded from this release type: mixinMonitoringContext */
216
207
 
217
208
  /* Excluded from this release type: MockLogger */
@@ -276,8 +267,6 @@ export declare type TelemetryEventPropertyTypeExt = string | number | boolean |
276
267
  */
277
268
  export declare type TelemetryEventPropertyTypes = ITelemetryBaseProperties[string];
278
269
 
279
- /* Excluded from this release type: TelemetryNullLogger */
280
-
281
270
  /* Excluded from this release type: ThresholdCounter */
282
271
 
283
272
  /* Excluded from this release type: UsageError */
@@ -1,28 +1,21 @@
1
- /// <reference types="node" />
2
-
3
1
  import { ConfigTypes } from '@fluidframework/core-interfaces';
4
- import { EventEmitter } from 'events';
2
+ import type { EventEmitter } from '@fluid-internal/client-utils';
5
3
  import { EventEmitterEventType } from '@fluid-internal/client-utils';
6
4
  import { IConfigProviderBase } from '@fluidframework/core-interfaces';
7
- import { IDisposable } from '@fluidframework/core-interfaces';
5
+ import type { IDisposable } from '@fluidframework/core-interfaces';
8
6
  import { IErrorBase } from '@fluidframework/core-interfaces';
9
7
  import { IEvent } from '@fluidframework/core-interfaces';
10
8
  import { IGenericError } from '@fluidframework/core-interfaces';
11
- import { ILoggingError } from '@fluidframework/core-interfaces';
9
+ import type { ILoggingError } from '@fluidframework/core-interfaces';
12
10
  import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
13
11
  import { ITelemetryBaseEvent } from '@fluidframework/core-interfaces';
14
12
  import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
15
13
  import { ITelemetryBaseProperties } from '@fluidframework/core-interfaces';
16
- import { ITelemetryErrorEvent } from '@fluidframework/core-interfaces';
17
- import { ITelemetryGenericEvent } from '@fluidframework/core-interfaces';
18
- import { ITelemetryPerformanceEvent } from '@fluidframework/core-interfaces';
19
- import { ITelemetryProperties } from '@fluidframework/core-interfaces';
20
14
  import { IUsageError } from '@fluidframework/core-interfaces';
21
15
  import { Lazy } from '@fluidframework/core-utils';
22
16
  import { LogLevel } from '@fluidframework/core-interfaces';
23
17
  import { Tagged } from '@fluidframework/core-interfaces';
24
18
  import { TelemetryBaseEventPropertyType } from '@fluidframework/core-interfaces';
25
- import { TelemetryEventPropertyType } from '@fluidframework/core-interfaces';
26
19
  import { TypedEventEmitter } from '@fluid-internal/client-utils';
27
20
 
28
21
  /* Excluded from this release type: connectedEventName */
@@ -41,22 +34,7 @@ import { TypedEventEmitter } from '@fluid-internal/client-utils';
41
34
 
42
35
  /* Excluded from this release type: disconnectedEventName */
43
36
 
44
- /**
45
- * Event Emitter helper class
46
- *
47
- * @remarks
48
- * Any exceptions thrown by listeners will be caught and raised through "error" event.
49
- * Any exception thrown by "error" listeners will propagate to the caller.
50
- * @privateRemarks
51
- * This probably doesn't belong in this package, as it is not telemetry-specific, and is really only intended for internal fluid-framework use.
52
- * We should consider moving it to the `core-utils` package.
53
- * @public
54
- */
55
- export declare class EventEmitterWithErrorHandling<TEvent extends IEvent = IEvent> extends TypedEventEmitter<TEvent> {
56
- private readonly errorHandler;
57
- constructor(errorHandler: (eventName: EventEmitterEventType, error: any) => void);
58
- emit(event: EventEmitterEventType, ...args: unknown[]): boolean;
59
- }
37
+ /* Excluded from this release type: EventEmitterWithErrorHandling */
60
38
 
61
39
  /* Excluded from this release type: eventNamespaceSeparator */
62
40
 
@@ -185,8 +163,6 @@ export declare interface ITelemetryPropertiesExt {
185
163
 
186
164
  /* Excluded from this release type: LoggingError */
187
165
 
188
- /* Excluded from this release type: logIfFalse */
189
-
190
166
  /* Excluded from this release type: mixinMonitoringContext */
191
167
 
192
168
  /* Excluded from this release type: MockLogger */
@@ -219,8 +195,6 @@ export declare interface ITelemetryPropertiesExt {
219
195
 
220
196
  /* Excluded from this release type: TaggedLoggerAdapter */
221
197
 
222
- /* Excluded from this release type: TelemetryBaseEventPropertyType */
223
-
224
198
  /* Excluded from this release type: TelemetryDataTag */
225
199
 
226
200
  /**
@@ -250,8 +224,6 @@ export declare type TelemetryEventPropertyTypeExt = string | number | boolean |
250
224
 
251
225
  /* Excluded from this release type: TelemetryEventPropertyTypes */
252
226
 
253
- /* Excluded from this release type: TelemetryNullLogger */
254
-
255
227
  /* Excluded from this release type: ThresholdCounter */
256
228
 
257
229
  /* Excluded from this release type: UsageError */
@@ -1,28 +1,21 @@
1
- /// <reference types="node" />
2
-
3
1
  import { ConfigTypes } from '@fluidframework/core-interfaces';
4
- import { EventEmitter } from 'events';
2
+ import type { EventEmitter } from '@fluid-internal/client-utils';
5
3
  import { EventEmitterEventType } from '@fluid-internal/client-utils';
6
4
  import { IConfigProviderBase } from '@fluidframework/core-interfaces';
7
- import { IDisposable } from '@fluidframework/core-interfaces';
5
+ import type { IDisposable } from '@fluidframework/core-interfaces';
8
6
  import { IErrorBase } from '@fluidframework/core-interfaces';
9
7
  import { IEvent } from '@fluidframework/core-interfaces';
10
8
  import { IGenericError } from '@fluidframework/core-interfaces';
11
- import { ILoggingError } from '@fluidframework/core-interfaces';
9
+ import type { ILoggingError } from '@fluidframework/core-interfaces';
12
10
  import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
13
11
  import { ITelemetryBaseEvent } from '@fluidframework/core-interfaces';
14
12
  import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
15
13
  import { ITelemetryBaseProperties } from '@fluidframework/core-interfaces';
16
- import { ITelemetryErrorEvent } from '@fluidframework/core-interfaces';
17
- import { ITelemetryGenericEvent } from '@fluidframework/core-interfaces';
18
- import { ITelemetryPerformanceEvent } from '@fluidframework/core-interfaces';
19
- import { ITelemetryProperties } from '@fluidframework/core-interfaces';
20
14
  import { IUsageError } from '@fluidframework/core-interfaces';
21
15
  import { Lazy } from '@fluidframework/core-utils';
22
16
  import { LogLevel } from '@fluidframework/core-interfaces';
23
17
  import { Tagged } from '@fluidframework/core-interfaces';
24
18
  import { TelemetryBaseEventPropertyType } from '@fluidframework/core-interfaces';
25
- import { TelemetryEventPropertyType } from '@fluidframework/core-interfaces';
26
19
  import { TypedEventEmitter } from '@fluid-internal/client-utils';
27
20
 
28
21
  /* Excluded from this release type: connectedEventName */
@@ -41,22 +34,7 @@ import { TypedEventEmitter } from '@fluid-internal/client-utils';
41
34
 
42
35
  /* Excluded from this release type: disconnectedEventName */
43
36
 
44
- /**
45
- * Event Emitter helper class
46
- *
47
- * @remarks
48
- * Any exceptions thrown by listeners will be caught and raised through "error" event.
49
- * Any exception thrown by "error" listeners will propagate to the caller.
50
- * @privateRemarks
51
- * This probably doesn't belong in this package, as it is not telemetry-specific, and is really only intended for internal fluid-framework use.
52
- * We should consider moving it to the `core-utils` package.
53
- * @public
54
- */
55
- export declare class EventEmitterWithErrorHandling<TEvent extends IEvent = IEvent> extends TypedEventEmitter<TEvent> {
56
- private readonly errorHandler;
57
- constructor(errorHandler: (eventName: EventEmitterEventType, error: any) => void);
58
- emit(event: EventEmitterEventType, ...args: unknown[]): boolean;
59
- }
37
+ /* Excluded from this release type: EventEmitterWithErrorHandling */
60
38
 
61
39
  /* Excluded from this release type: eventNamespaceSeparator */
62
40
 
@@ -185,8 +163,6 @@ export declare interface ITelemetryPropertiesExt {
185
163
 
186
164
  /* Excluded from this release type: LoggingError */
187
165
 
188
- /* Excluded from this release type: logIfFalse */
189
-
190
166
  /* Excluded from this release type: mixinMonitoringContext */
191
167
 
192
168
  /* Excluded from this release type: MockLogger */
@@ -219,8 +195,6 @@ export declare interface ITelemetryPropertiesExt {
219
195
 
220
196
  /* Excluded from this release type: TaggedLoggerAdapter */
221
197
 
222
- /* Excluded from this release type: TelemetryBaseEventPropertyType */
223
-
224
198
  /* Excluded from this release type: TelemetryDataTag */
225
199
 
226
200
  /**
@@ -250,8 +224,6 @@ export declare type TelemetryEventPropertyTypeExt = string | number | boolean |
250
224
 
251
225
  /* Excluded from this release type: TelemetryEventPropertyTypes */
252
226
 
253
- /* Excluded from this release type: TelemetryNullLogger */
254
-
255
227
  /* Excluded from this release type: ThresholdCounter */
256
228
 
257
229
  /* Excluded from this release type: UsageError */
@@ -1,28 +1,21 @@
1
- /// <reference types="node" />
2
-
3
1
  import { ConfigTypes } from '@fluidframework/core-interfaces';
4
- import { EventEmitter } from 'events';
2
+ import type { EventEmitter } from '@fluid-internal/client-utils';
5
3
  import { EventEmitterEventType } from '@fluid-internal/client-utils';
6
4
  import { IConfigProviderBase } from '@fluidframework/core-interfaces';
7
- import { IDisposable } from '@fluidframework/core-interfaces';
5
+ import type { IDisposable } from '@fluidframework/core-interfaces';
8
6
  import { IErrorBase } from '@fluidframework/core-interfaces';
9
7
  import { IEvent } from '@fluidframework/core-interfaces';
10
8
  import { IGenericError } from '@fluidframework/core-interfaces';
11
- import { ILoggingError } from '@fluidframework/core-interfaces';
9
+ import type { ILoggingError } from '@fluidframework/core-interfaces';
12
10
  import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
13
11
  import { ITelemetryBaseEvent } from '@fluidframework/core-interfaces';
14
12
  import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
15
13
  import { ITelemetryBaseProperties } from '@fluidframework/core-interfaces';
16
- import { ITelemetryErrorEvent } from '@fluidframework/core-interfaces';
17
- import { ITelemetryGenericEvent } from '@fluidframework/core-interfaces';
18
- import { ITelemetryPerformanceEvent } from '@fluidframework/core-interfaces';
19
- import { ITelemetryProperties } from '@fluidframework/core-interfaces';
20
14
  import { IUsageError } from '@fluidframework/core-interfaces';
21
15
  import { Lazy } from '@fluidframework/core-utils';
22
16
  import { LogLevel } from '@fluidframework/core-interfaces';
23
17
  import { Tagged } from '@fluidframework/core-interfaces';
24
18
  import { TelemetryBaseEventPropertyType } from '@fluidframework/core-interfaces';
25
- import { TelemetryEventPropertyType } from '@fluidframework/core-interfaces';
26
19
  import { TypedEventEmitter } from '@fluid-internal/client-utils';
27
20
 
28
21
  /**
@@ -148,7 +141,7 @@ export declare const disconnectedEventName = "disconnected";
148
141
  * @privateRemarks
149
142
  * This probably doesn't belong in this package, as it is not telemetry-specific, and is really only intended for internal fluid-framework use.
150
143
  * We should consider moving it to the `core-utils` package.
151
- * @public
144
+ * @alpha
152
145
  */
153
146
  export declare class EventEmitterWithErrorHandling<TEvent extends IEvent = IEvent> extends TypedEventEmitter<TEvent> {
154
147
  private readonly errorHandler;
@@ -341,11 +334,11 @@ export declare interface IFluidErrorBase extends Error {
341
334
  /**
342
335
  * Get the telemetry properties stashed on this error for logging.
343
336
  */
344
- getTelemetryProperties(): ITelemetryProperties;
337
+ getTelemetryProperties(): ITelemetryBaseProperties;
345
338
  /**
346
339
  * Add telemetry properties to this error which will be logged with the error
347
340
  */
348
- addTelemetryProperties: (props: ITelemetryProperties) => void;
341
+ addTelemetryProperties: (props: ITelemetryPropertiesExt) => void;
349
342
  }
350
343
 
351
344
  /**
@@ -569,28 +562,13 @@ export declare class LoggingError extends Error implements ILoggingError, Omit<I
569
562
  /**
570
563
  * Add additional properties to be logged
571
564
  */
572
- addTelemetryProperties(props: ITelemetryBaseProperties): void;
565
+ addTelemetryProperties(props: ITelemetryPropertiesExt): void;
573
566
  /**
574
567
  * Get all properties fit to be logged to telemetry for this error
575
568
  */
576
569
  getTelemetryProperties(): ITelemetryBaseProperties;
577
570
  }
578
571
 
579
- /**
580
- * Like assert, but logs only if the condition is false, rather than throwing
581
- * @param condition - The condition to attest too
582
- * @param logger - The logger to log with
583
- * @param event - The string or event to log
584
- * @returns The outcome of the condition
585
- *
586
- * @internal
587
- *
588
- * @deprecated
589
- * This API will be removed in a future release.
590
- * No replacement API is intended, but reproducing its behavior should be trivial for anyone who needs it.
591
- */
592
- export declare function logIfFalse(condition: unknown, logger: ITelemetryBaseLogger, event: string | ITelemetryGenericEvent): condition is true;
593
-
594
572
  /**
595
573
  * Creates a {@link MonitoringContext} from the provided logger.
596
574
  *
@@ -865,10 +843,10 @@ export declare class SampledTelemetryHelper implements IDisposable {
865
843
  * properties which should be added to the telemetry event for that bucket. If a bucket being measured does not
866
844
  * have an entry in this map, no additional properties will be added to its telemetry events. The following keys are
867
845
  * reserved for use by this class: "duration", "count", "totalDuration", "minDuration", "maxDuration". If any of
868
- * them is specified as a key in one of the ITelemetryProperties objects in this map, that key-value pair will be
846
+ * them is specified as a key in one of the ITelemetryBaseProperties objects in this map, that key-value pair will be
869
847
  * ignored.
870
848
  */
871
- constructor(eventBase: ITelemetryGenericEvent, logger: ITelemetryLoggerExt, sampleThreshold: number, includeAggregateMetrics?: boolean, perBucketProperties?: Map<string, ITelemetryProperties>);
849
+ constructor(eventBase: ITelemetryGenericEventExt, logger: ITelemetryLoggerExt, sampleThreshold: number, includeAggregateMetrics?: boolean, perBucketProperties?: Map<string, ITelemetryBaseProperties>);
872
850
  /**
873
851
  * Executes the specified code and keeps track of execution time statistics.
874
852
  * If it's been called enough times (the sampleThreshold for the class) then it generates a log message with the necessary information.
@@ -916,7 +894,7 @@ export declare const sessionStorageConfigProvider: Lazy<IConfigProviderBase>;
916
894
  *
917
895
  * @internal
918
896
  */
919
- export declare const tagCodeArtifacts: <T extends Record<string, TelemetryEventPropertyType | (() => TelemetryBaseEventPropertyType)>>(values: T) => { [P in keyof T]: (T[P] extends () => TelemetryBaseEventPropertyType ? () => {
897
+ export declare const tagCodeArtifacts: <T extends Record<string, TelemetryBaseEventPropertyType | (() => TelemetryBaseEventPropertyType)>>(values: T) => { [P in keyof T]: (T[P] extends () => TelemetryBaseEventPropertyType ? () => {
920
898
  value: ReturnType<T[P]>;
921
899
  tag: TelemetryDataTag.CodeArtifact;
922
900
  } : {
@@ -946,7 +924,7 @@ export declare const tagCodeArtifacts: <T extends Record<string, TelemetryEventP
946
924
  *
947
925
  * @internal
948
926
  */
949
- export declare const tagData: <T extends TelemetryDataTag, V extends Record<string, TelemetryEventPropertyType | (() => TelemetryBaseEventPropertyType)>>(tag: T, values: V) => { [P in keyof V]: (V[P] extends () => TelemetryBaseEventPropertyType ? () => {
927
+ export declare const tagData: <T extends TelemetryDataTag, V extends Record<string, TelemetryBaseEventPropertyType | (() => TelemetryBaseEventPropertyType)>>(tag: T, values: V) => { [P in keyof V]: (V[P] extends () => TelemetryBaseEventPropertyType ? () => {
950
928
  value: ReturnType<V[P]>;
951
929
  tag: T;
952
930
  } : {
@@ -1018,23 +996,6 @@ export declare type TelemetryEventPropertyTypeExt = string | number | boolean |
1018
996
  */
1019
997
  export declare type TelemetryEventPropertyTypes = ITelemetryBaseProperties[string];
1020
998
 
1021
- /**
1022
- * Null logger that no-ops for all telemetry events passed to it.
1023
- *
1024
- * @deprecated This will be removed in a future release.
1025
- * For internal use within the FluidFramework codebase, use {@link createChildLogger} with no arguments instead.
1026
- * For external consumers we recommend writing a trivial implementation of {@link @fluidframework/core-interfaces#ITelemetryBaseLogger}
1027
- * where the send() method does nothing and using that.
1028
- *
1029
- * @internal
1030
- */
1031
- export declare class TelemetryNullLogger implements ITelemetryLoggerExt {
1032
- send(event: ITelemetryBaseEvent): void;
1033
- sendTelemetryEvent(event: ITelemetryGenericEvent, error?: unknown): void;
1034
- sendErrorEvent(event: ITelemetryErrorEvent, error?: unknown): void;
1035
- sendPerformanceEvent(event: ITelemetryPerformanceEvent, error?: unknown): void;
1036
- }
1037
-
1038
999
  /**
1039
1000
  * Utility counter which will send event only if the provided value is above a configured threshold.
1040
1001
  *
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { ITelemetryLoggerExt } from "./telemetryTypes";
5
+ import { ITelemetryLoggerExt } from "./telemetryTypes.js";
6
6
  /**
7
7
  * Utility counter which will send event only if the provided value is above a configured threshold.
8
8
  *
@@ -1 +1 @@
1
- {"version":3,"file":"thresholdCounter.d.ts","sourceRoot":"","sources":["../src/thresholdCounter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;GAIG;AACH,qBAAa,gBAAgB;IAE3B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,iBAAiB;gBAFR,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,mBAAmB,EACpC,iBAAiB,SAAY;IAGtC;;OAEG;IACI,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAUnD;;;;;;OAMG;IACI,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAU7D"}
1
+ {"version":3,"file":"thresholdCounter.d.ts","sourceRoot":"","sources":["../src/thresholdCounter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;;GAIG;AACH,qBAAa,gBAAgB;IAE3B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,iBAAiB;gBAFR,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,mBAAmB,EACpC,iBAAiB,SAAY;IAGtC;;OAEG;IACI,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAUnD;;;;;;OAMG;IACI,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAU7D"}
@@ -1 +1 @@
1
- {"version":3,"file":"thresholdCounter.js","sourceRoot":"","sources":["../src/thresholdCounter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;;;GAIG;AACH,MAAa,gBAAgB;IAC5B,YACkB,SAAiB,EACjB,MAA2B,EACpC,oBAAoB,SAAS;QAFpB,cAAS,GAAT,SAAS,CAAQ;QACjB,WAAM,GAAN,MAAM,CAAqB;QACpC,sBAAiB,GAAjB,iBAAiB,CAAY;IACnC,CAAC;IAEJ;;OAEG;IACI,IAAI,CAAC,SAAiB,EAAE,KAAa;QAC3C,IAAI,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE;YAC3B,OAAO;SACP;QACD,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;YAChC,SAAS;YACT,KAAK;SACL,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACI,cAAc,CAAC,SAAiB,EAAE,KAAa;QACrD,IAAI,KAAK,KAAK,IAAI,CAAC,iBAAiB,EAAE;YACrC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;gBAChC,SAAS;gBACT,KAAK;aACL,CAAC,CAAC;YACH,sCAAsC;YACtC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC;SACpD;IACF,CAAC;CACD;AArCD,4CAqCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt } from \"./telemetryTypes\";\n\n/**\n * Utility counter which will send event only if the provided value is above a configured threshold.\n *\n * @internal\n */\nexport class ThresholdCounter {\n\tpublic constructor(\n\t\tprivate readonly threshold: number,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate thresholdMultiple = threshold,\n\t) {}\n\n\t/**\n\t * Sends the value if it's above the treshold.\n\t */\n\tpublic send(eventName: string, value: number): void {\n\t\tif (value < this.threshold) {\n\t\t\treturn;\n\t\t}\n\t\tthis.logger.sendPerformanceEvent({\n\t\t\teventName,\n\t\t\tvalue,\n\t\t});\n\t}\n\n\t/**\n\t * Sends the value if it's above the threshold\n\t * and a multiple of the threshold.\n\t *\n\t * To be used in scenarios where we'd like to record a\n\t * threshold violation while reducing telemetry noise.\n\t */\n\tpublic sendIfMultiple(eventName: string, value: number): void {\n\t\tif (value === this.thresholdMultiple) {\n\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\teventName,\n\t\t\t\tvalue,\n\t\t\t});\n\t\t\t// reduce number of \"multiple\" events.\n\t\t\tthis.thresholdMultiple = this.thresholdMultiple * 2;\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"thresholdCounter.js","sourceRoot":"","sources":["../src/thresholdCounter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;;;GAIG;AACH,MAAa,gBAAgB;IAC5B,YACkB,SAAiB,EACjB,MAA2B,EACpC,oBAAoB,SAAS;QAFpB,cAAS,GAAT,SAAS,CAAQ;QACjB,WAAM,GAAN,MAAM,CAAqB;QACpC,sBAAiB,GAAjB,iBAAiB,CAAY;IACnC,CAAC;IAEJ;;OAEG;IACI,IAAI,CAAC,SAAiB,EAAE,KAAa;QAC3C,IAAI,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE;YAC3B,OAAO;SACP;QACD,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;YAChC,SAAS;YACT,KAAK;SACL,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACI,cAAc,CAAC,SAAiB,EAAE,KAAa;QACrD,IAAI,KAAK,KAAK,IAAI,CAAC,iBAAiB,EAAE;YACrC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;gBAChC,SAAS;gBACT,KAAK;aACL,CAAC,CAAC;YACH,sCAAsC;YACtC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC;SACpD;IACF,CAAC;CACD;AArCD,4CAqCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt } from \"./telemetryTypes.js\";\n\n/**\n * Utility counter which will send event only if the provided value is above a configured threshold.\n *\n * @internal\n */\nexport class ThresholdCounter {\n\tpublic constructor(\n\t\tprivate readonly threshold: number,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate thresholdMultiple = threshold,\n\t) {}\n\n\t/**\n\t * Sends the value if it's above the treshold.\n\t */\n\tpublic send(eventName: string, value: number): void {\n\t\tif (value < this.threshold) {\n\t\t\treturn;\n\t\t}\n\t\tthis.logger.sendPerformanceEvent({\n\t\t\teventName,\n\t\t\tvalue,\n\t\t});\n\t}\n\n\t/**\n\t * Sends the value if it's above the threshold\n\t * and a multiple of the threshold.\n\t *\n\t * To be used in scenarios where we'd like to record a\n\t * threshold violation while reducing telemetry noise.\n\t */\n\tpublic sendIfMultiple(eventName: string, value: number): void {\n\t\tif (value === this.thresholdMultiple) {\n\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\teventName,\n\t\t\t\tvalue,\n\t\t\t});\n\t\t\t// reduce number of \"multiple\" events.\n\t\t\tthis.thresholdMultiple = this.thresholdMultiple * 2;\n\t\t}\n\t}\n}\n"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.38.3"
8
+ "packageVersion": "7.42.3"
9
9
  }
10
10
  ]
11
11
  }
package/dist/utils.d.ts CHANGED
@@ -1,23 +1,4 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { ITelemetryBaseLogger, ITelemetryGenericEvent } from "@fluidframework/core-interfaces";
6
- import { ITelemetryLoggerExt } from "./telemetryTypes";
7
- /**
8
- * Like assert, but logs only if the condition is false, rather than throwing
9
- * @param condition - The condition to attest too
10
- * @param logger - The logger to log with
11
- * @param event - The string or event to log
12
- * @returns The outcome of the condition
13
- *
14
- * @internal
15
- *
16
- * @deprecated
17
- * This API will be removed in a future release.
18
- * No replacement API is intended, but reproducing its behavior should be trivial for anyone who needs it.
19
- */
20
- export declare function logIfFalse(condition: unknown, logger: ITelemetryBaseLogger, event: string | ITelemetryGenericEvent): condition is true;
1
+ import { ITelemetryLoggerExt } from "./telemetryTypes.js";
21
2
  /**
22
3
  * An object that contains a callback used in conjunction with the {@link createSampledLogger} utility function to provide custom logic for sampling events.
23
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAEN,oBAAoB,EACpB,sBAAsB,EACtB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAA6B,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAElF;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CACzB,SAAS,EAAE,OAAO,EAClB,MAAM,EAAE,oBAAoB,EAC5B,KAAK,EAAE,MAAM,GAAG,sBAAsB,GACpC,SAAS,IAAI,IAAI,CAUnB;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,OAAO,GAAG,SAAS,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;IACnE;;;;;;;OAOG;IACH,kBAAkB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,mBAAmB,EAC3B,YAAY,CAAC,EAAE,aAAa,GAC1B,uBAAuB,CAiCzB"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAMA,OAAO,EAA6B,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAErF;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,OAAO,GAAG,SAAS,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;IACnE;;;;;;;OAOG;IACH,kBAAkB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,mBAAmB,EAC3B,YAAY,CAAC,EAAE,aAAa,GAC1B,uBAAuB,CAiCzB"}
package/dist/utils.js CHANGED
@@ -1,31 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSampledLogger = exports.logIfFalse = void 0;
4
- const config_1 = require("./config");
5
- /**
6
- * Like assert, but logs only if the condition is false, rather than throwing
7
- * @param condition - The condition to attest too
8
- * @param logger - The logger to log with
9
- * @param event - The string or event to log
10
- * @returns The outcome of the condition
11
- *
12
- * @internal
13
- *
14
- * @deprecated
15
- * This API will be removed in a future release.
16
- * No replacement API is intended, but reproducing its behavior should be trivial for anyone who needs it.
17
- */
18
- function logIfFalse(condition, logger, event) {
19
- if (condition) {
20
- return true;
21
- }
22
- const newEvent = typeof event === "string"
23
- ? { eventName: event, category: "error" }
24
- : { category: "error", ...event };
25
- logger.send(newEvent);
26
- return false;
27
- }
28
- exports.logIfFalse = logIfFalse;
3
+ exports.createSampledLogger = void 0;
4
+ const config_js_1 = require("./config.js");
29
5
  /**
30
6
  * Wraps around an existing logger matching the {@link ITelemetryLoggerExt} interface and provides the ability to only log a subset of events using a sampling strategy provided by an ${@link IEventSampler}.
31
7
  * You can chose to not provide an event sampler which is effectively a no-op, meaning that it will be treated as if the sampler always returns true.
@@ -43,7 +19,7 @@ exports.logIfFalse = logIfFalse;
43
19
  * @internal
44
20
  */
45
21
  function createSampledLogger(logger, eventSampler) {
46
- const monitoringContext = (0, config_1.loggerToMonitoringContext)(logger);
22
+ const monitoringContext = (0, config_js_1.loggerToMonitoringContext)(logger);
47
23
  const isSamplingDisabled = monitoringContext.config.getBoolean("Fluid.Telemetry.DisableSampling") ?? false;
48
24
  const sampledLogger = {
49
25
  send: (event) => {
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AASA,qCAAqD;AAGrD;;;;;;;;;;;;GAYG;AACH,SAAgB,UAAU,CACzB,SAAkB,EAClB,MAA4B,EAC5B,KAAsC;IAEtC,IAAI,SAAS,EAAE;QACd,OAAO,IAAI,CAAC;KACZ;IACD,MAAM,QAAQ,GACb,OAAO,KAAK,KAAK,QAAQ;QACxB,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE;QACzC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC;IACpC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtB,OAAO,KAAK,CAAC;AACd,CAAC;AAdD,gCAcC;AA+BD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,mBAAmB,CAClC,MAA2B,EAC3B,YAA4B;IAE5B,MAAM,iBAAiB,GAAG,IAAA,kCAAyB,EAAC,MAAM,CAAC,CAAC;IAC5D,MAAM,kBAAkB,GACvB,iBAAiB,CAAC,MAAM,CAAC,UAAU,CAAC,iCAAiC,CAAC,IAAI,KAAK,CAAC;IAEjF,MAAM,aAAa,GAAG;QACrB,IAAI,EAAE,CAAC,KAA0B,EAAQ,EAAE;YAC1C,2DAA2D;YAC3D,gIAAgI;YAChI,2LAA2L;YAC3L,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE;gBAC9E,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACnB;QACF,CAAC;QACD,kBAAkB,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAC9D,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE;gBAC9E,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;aACjC;QACF,CAAC;QACD,cAAc,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAC1D,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE;gBAC9E,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;aAC7B;QACF,CAAC;QACD,oBAAoB,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAChE,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE;gBAC9E,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;aACnC;QACF,CAAC;QACD,kBAAkB;KAClB,CAAC;IAEF,OAAO,aAAa,CAAC;AACtB,CAAC;AApCD,kDAoCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n\tITelemetryBaseEvent,\n\tITelemetryBaseLogger,\n\tITelemetryGenericEvent,\n} from \"@fluidframework/core-interfaces\";\nimport { loggerToMonitoringContext } from \"./config\";\nimport { ITelemetryGenericEventExt, ITelemetryLoggerExt } from \"./telemetryTypes\";\n\n/**\n * Like assert, but logs only if the condition is false, rather than throwing\n * @param condition - The condition to attest too\n * @param logger - The logger to log with\n * @param event - The string or event to log\n * @returns The outcome of the condition\n *\n * @internal\n *\n * @deprecated\n * This API will be removed in a future release.\n * No replacement API is intended, but reproducing its behavior should be trivial for anyone who needs it.\n */\nexport function logIfFalse(\n\tcondition: unknown,\n\tlogger: ITelemetryBaseLogger,\n\tevent: string | ITelemetryGenericEvent,\n): condition is true {\n\tif (condition) {\n\t\treturn true;\n\t}\n\tconst newEvent: ITelemetryBaseEvent =\n\t\ttypeof event === \"string\"\n\t\t\t? { eventName: event, category: \"error\" }\n\t\t\t: { category: \"error\", ...event };\n\tlogger.send(newEvent);\n\treturn false;\n}\n\n/**\n * An object that contains a callback used in conjunction with the {@link createSampledLogger} utility function to provide custom logic for sampling events.\n *\n * @internal\n */\nexport interface IEventSampler {\n\t/**\n\t * @returns true if the event should be sampled or false if not\n\t */\n\tsample: () => boolean | undefined;\n}\n\n/**\n * A telemetry logger that has sampling capabilities\n *\n * @internal\n */\nexport interface ISampledTelemetryLogger extends ITelemetryLoggerExt {\n\t/**\n\t * Indicates if the feature flag to disable sampling is set.\n\t *\n\t * @remarks Exposed to enable some advanced scenarios where the code using the sampled logger\n\t * could take advantage of skipping the execution of some logic when it can determine\n\t * it won't be necessary because the telemetry event that needs it wouldn't be\n\t * emitted anyway.\n\t */\n\tisSamplingDisabled: boolean;\n}\n\n/**\n * Wraps around an existing logger matching the {@link ITelemetryLoggerExt} interface and provides the ability to only log a subset of events using a sampling strategy provided by an ${@link IEventSampler}.\n * You can chose to not provide an event sampler which is effectively a no-op, meaning that it will be treated as if the sampler always returns true.\n *\n * @remarks\n * The sampling functionality uses the Fluid telemetry logging configuration along with the optionally provided event sampling callback to determine whether an event should\n * be logged or not.\n *\n * Configuration object parameters:\n * 'Fluid.Telemetry.DisableSampling': if this config value is set to true, all events will be unsampled and therefore logged.\n * Otherwise only a sample will be logged according to the provided event sampler callback.\n *\n * Note that the same sampler is used for all APIs of the returned logger. If you want separate events flowing through the returned logger to be sampled separately, the {@link IEventSampler} you provide should track them separately.\n *\n * @internal\n */\nexport function createSampledLogger(\n\tlogger: ITelemetryLoggerExt,\n\teventSampler?: IEventSampler,\n): ISampledTelemetryLogger {\n\tconst monitoringContext = loggerToMonitoringContext(logger);\n\tconst isSamplingDisabled =\n\t\tmonitoringContext.config.getBoolean(\"Fluid.Telemetry.DisableSampling\") ?? false;\n\n\tconst sampledLogger = {\n\t\tsend: (event: ITelemetryBaseEvent): void => {\n\t\t\t// The sampler uses the following logic for sending events:\n\t\t\t// 1. If isSamplingDisabled is true, then this means events should be unsampled. Therefore we send the event without any checks.\n\t\t\t// 2. If isSamplingDisabled is false, then event should be sampled using the event sampler, if the sampler is not defined just send all events, other use the eventSampler.sample() method.\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tlogger.send(event);\n\t\t\t}\n\t\t},\n\t\tsendTelemetryEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tlogger.sendTelemetryEvent(event);\n\t\t\t}\n\t\t},\n\t\tsendErrorEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tlogger.sendErrorEvent(event);\n\t\t\t}\n\t\t},\n\t\tsendPerformanceEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tlogger.sendPerformanceEvent(event);\n\t\t\t}\n\t\t},\n\t\tisSamplingDisabled,\n\t};\n\n\treturn sampledLogger;\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAKA,2CAAwD;AAgCxD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,mBAAmB,CAClC,MAA2B,EAC3B,YAA4B;IAE5B,MAAM,iBAAiB,GAAG,IAAA,qCAAyB,EAAC,MAAM,CAAC,CAAC;IAC5D,MAAM,kBAAkB,GACvB,iBAAiB,CAAC,MAAM,CAAC,UAAU,CAAC,iCAAiC,CAAC,IAAI,KAAK,CAAC;IAEjF,MAAM,aAAa,GAAG;QACrB,IAAI,EAAE,CAAC,KAA0B,EAAQ,EAAE;YAC1C,2DAA2D;YAC3D,gIAAgI;YAChI,2LAA2L;YAC3L,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE;gBAC9E,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACnB;QACF,CAAC;QACD,kBAAkB,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAC9D,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE;gBAC9E,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;aACjC;QACF,CAAC;QACD,cAAc,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAC1D,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE;gBAC9E,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;aAC7B;QACF,CAAC;QACD,oBAAoB,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAChE,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE;gBAC9E,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;aACnC;QACF,CAAC;QACD,kBAAkB;KAClB,CAAC;IAEF,OAAO,aAAa,CAAC;AACtB,CAAC;AApCD,kDAoCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\nimport { loggerToMonitoringContext } from \"./config.js\";\nimport { ITelemetryGenericEventExt, ITelemetryLoggerExt } from \"./telemetryTypes.js\";\n\n/**\n * An object that contains a callback used in conjunction with the {@link createSampledLogger} utility function to provide custom logic for sampling events.\n *\n * @internal\n */\nexport interface IEventSampler {\n\t/**\n\t * @returns true if the event should be sampled or false if not\n\t */\n\tsample: () => boolean | undefined;\n}\n\n/**\n * A telemetry logger that has sampling capabilities\n *\n * @internal\n */\nexport interface ISampledTelemetryLogger extends ITelemetryLoggerExt {\n\t/**\n\t * Indicates if the feature flag to disable sampling is set.\n\t *\n\t * @remarks Exposed to enable some advanced scenarios where the code using the sampled logger\n\t * could take advantage of skipping the execution of some logic when it can determine\n\t * it won't be necessary because the telemetry event that needs it wouldn't be\n\t * emitted anyway.\n\t */\n\tisSamplingDisabled: boolean;\n}\n\n/**\n * Wraps around an existing logger matching the {@link ITelemetryLoggerExt} interface and provides the ability to only log a subset of events using a sampling strategy provided by an ${@link IEventSampler}.\n * You can chose to not provide an event sampler which is effectively a no-op, meaning that it will be treated as if the sampler always returns true.\n *\n * @remarks\n * The sampling functionality uses the Fluid telemetry logging configuration along with the optionally provided event sampling callback to determine whether an event should\n * be logged or not.\n *\n * Configuration object parameters:\n * 'Fluid.Telemetry.DisableSampling': if this config value is set to true, all events will be unsampled and therefore logged.\n * Otherwise only a sample will be logged according to the provided event sampler callback.\n *\n * Note that the same sampler is used for all APIs of the returned logger. If you want separate events flowing through the returned logger to be sampled separately, the {@link IEventSampler} you provide should track them separately.\n *\n * @internal\n */\nexport function createSampledLogger(\n\tlogger: ITelemetryLoggerExt,\n\teventSampler?: IEventSampler,\n): ISampledTelemetryLogger {\n\tconst monitoringContext = loggerToMonitoringContext(logger);\n\tconst isSamplingDisabled =\n\t\tmonitoringContext.config.getBoolean(\"Fluid.Telemetry.DisableSampling\") ?? false;\n\n\tconst sampledLogger = {\n\t\tsend: (event: ITelemetryBaseEvent): void => {\n\t\t\t// The sampler uses the following logic for sending events:\n\t\t\t// 1. If isSamplingDisabled is true, then this means events should be unsampled. Therefore we send the event without any checks.\n\t\t\t// 2. If isSamplingDisabled is false, then event should be sampled using the event sampler, if the sampler is not defined just send all events, other use the eventSampler.sample() method.\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tlogger.send(event);\n\t\t\t}\n\t\t},\n\t\tsendTelemetryEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tlogger.sendTelemetryEvent(event);\n\t\t\t}\n\t\t},\n\t\tsendErrorEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tlogger.sendErrorEvent(event);\n\t\t\t}\n\t\t},\n\t\tsendPerformanceEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tlogger.sendPerformanceEvent(event);\n\t\t\t}\n\t\t},\n\t\tisSamplingDisabled,\n\t};\n\n\treturn sampledLogger;\n}\n"]}
package/lib/config.d.ts CHANGED
@@ -4,8 +4,8 @@
4
4
  */
5
5
  import { ITelemetryBaseLogger, IConfigProviderBase, ConfigTypes } from "@fluidframework/core-interfaces";
6
6
  import { Lazy } from "@fluidframework/core-utils";
7
- import { createChildLogger } from "./logger";
8
- import { ITelemetryLoggerExt } from "./telemetryTypes";
7
+ import { createChildLogger } from "./logger.js";
8
+ import { ITelemetryLoggerExt } from "./telemetryTypes.js";
9
9
  /**
10
10
  * Explicitly typed interface for reading configurations.
11
11
  *
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAoB,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,WAAW,eAAgB,SAAQ,mBAAmB;IAC3D,UAAU,CAAC,IAAI,EAAE,MAAM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";
2
+ import { createChildLogger, tagCodeArtifacts } from "./logger.js";
3
3
  /**
4
4
  * Creates a base configuration provider based on `sessionStorage`
5
5
  *