@fluidframework/telemetry-utils 2.93.0 → 2.101.0

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 (133) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/DEV.md +33 -0
  3. package/api-extractor/api-extractor-lint-api-bundle.json +5 -0
  4. package/api-extractor/api-extractor-lint-bundle.json +1 -1
  5. package/api-extractor.json +2 -1
  6. package/api-report/telemetry-utils.legacy.beta.api.md +10 -7
  7. package/dist/api.d.ts +26 -0
  8. package/dist/api.d.ts.map +1 -0
  9. package/dist/api.js +40 -0
  10. package/dist/api.js.map +1 -0
  11. package/dist/config.d.ts +6 -6
  12. package/dist/config.d.ts.map +1 -1
  13. package/dist/config.js +4 -1
  14. package/dist/config.js.map +1 -1
  15. package/dist/errorLogging.d.ts +2 -2
  16. package/dist/errorLogging.d.ts.map +1 -1
  17. package/dist/errorLogging.js.map +1 -1
  18. package/dist/events.d.ts +3 -3
  19. package/dist/events.d.ts.map +1 -1
  20. package/dist/events.js.map +1 -1
  21. package/dist/{index.d.ts → internal.d.ts} +16 -4
  22. package/dist/internal.d.ts.map +1 -0
  23. package/dist/{index.js → internal.js} +22 -5
  24. package/dist/internal.js.map +1 -0
  25. package/dist/legacy.d.ts +2 -2
  26. package/dist/logger.d.ts +61 -21
  27. package/dist/logger.d.ts.map +1 -1
  28. package/dist/logger.js +74 -29
  29. package/dist/logger.js.map +1 -1
  30. package/dist/main.d.ts +8 -0
  31. package/dist/main.d.ts.map +1 -0
  32. package/dist/main.js +13 -0
  33. package/dist/main.js.map +1 -0
  34. package/dist/mockLogger.d.ts +5 -4
  35. package/dist/mockLogger.d.ts.map +1 -1
  36. package/dist/mockLogger.js +2 -2
  37. package/dist/mockLogger.js.map +1 -1
  38. package/dist/public.d.ts +1 -1
  39. package/dist/sampledTelemetryHelper.d.ts +5 -2
  40. package/dist/sampledTelemetryHelper.d.ts.map +1 -1
  41. package/dist/sampledTelemetryHelper.js +6 -1
  42. package/dist/sampledTelemetryHelper.js.map +1 -1
  43. package/dist/telemetryEventBatcher.d.ts +2 -2
  44. package/dist/telemetryEventBatcher.d.ts.map +1 -1
  45. package/dist/telemetryEventBatcher.js.map +1 -1
  46. package/dist/telemetryTypes.d.ts +65 -6
  47. package/dist/telemetryTypes.d.ts.map +1 -1
  48. package/dist/telemetryTypes.js.map +1 -1
  49. package/dist/telemetryTypesUndeprecated.d.ts +36 -0
  50. package/dist/telemetryTypesUndeprecated.d.ts.map +1 -0
  51. package/dist/telemetryTypesUndeprecated.js +7 -0
  52. package/dist/telemetryTypesUndeprecated.js.map +1 -0
  53. package/dist/thresholdCounter.d.ts +2 -2
  54. package/dist/thresholdCounter.d.ts.map +1 -1
  55. package/dist/thresholdCounter.js.map +1 -1
  56. package/dist/utils.d.ts +4 -4
  57. package/dist/utils.d.ts.map +1 -1
  58. package/dist/utils.js +9 -9
  59. package/dist/utils.js.map +1 -1
  60. package/internal.d.ts +2 -2
  61. package/legacy.d.ts +1 -1
  62. package/lib/api.d.ts +26 -0
  63. package/lib/api.d.ts.map +1 -0
  64. package/lib/api.js +22 -0
  65. package/lib/api.js.map +1 -0
  66. package/lib/config.d.ts +6 -6
  67. package/lib/config.d.ts.map +1 -1
  68. package/lib/config.js +4 -1
  69. package/lib/config.js.map +1 -1
  70. package/lib/errorLogging.d.ts +2 -2
  71. package/lib/errorLogging.d.ts.map +1 -1
  72. package/lib/errorLogging.js.map +1 -1
  73. package/lib/events.d.ts +3 -3
  74. package/lib/events.d.ts.map +1 -1
  75. package/lib/events.js.map +1 -1
  76. package/lib/{index.d.ts → internal.d.ts} +16 -4
  77. package/lib/internal.d.ts.map +1 -0
  78. package/lib/{index.js → internal.js} +5 -3
  79. package/lib/internal.js.map +1 -0
  80. package/lib/legacy.d.ts +2 -2
  81. package/lib/logger.d.ts +61 -21
  82. package/lib/logger.d.ts.map +1 -1
  83. package/lib/logger.js +71 -28
  84. package/lib/logger.js.map +1 -1
  85. package/lib/main.d.ts +8 -0
  86. package/lib/main.d.ts.map +1 -0
  87. package/lib/main.js +9 -0
  88. package/lib/main.js.map +1 -0
  89. package/lib/mockLogger.d.ts +5 -4
  90. package/lib/mockLogger.d.ts.map +1 -1
  91. package/lib/mockLogger.js +2 -2
  92. package/lib/mockLogger.js.map +1 -1
  93. package/lib/public.d.ts +1 -1
  94. package/lib/sampledTelemetryHelper.d.ts +5 -2
  95. package/lib/sampledTelemetryHelper.d.ts.map +1 -1
  96. package/lib/sampledTelemetryHelper.js +6 -1
  97. package/lib/sampledTelemetryHelper.js.map +1 -1
  98. package/lib/telemetryEventBatcher.d.ts +2 -2
  99. package/lib/telemetryEventBatcher.d.ts.map +1 -1
  100. package/lib/telemetryEventBatcher.js.map +1 -1
  101. package/lib/telemetryTypes.d.ts +65 -6
  102. package/lib/telemetryTypes.d.ts.map +1 -1
  103. package/lib/telemetryTypes.js.map +1 -1
  104. package/lib/telemetryTypesUndeprecated.d.ts +36 -0
  105. package/lib/telemetryTypesUndeprecated.d.ts.map +1 -0
  106. package/lib/telemetryTypesUndeprecated.js +6 -0
  107. package/lib/telemetryTypesUndeprecated.js.map +1 -0
  108. package/lib/thresholdCounter.d.ts +2 -2
  109. package/lib/thresholdCounter.d.ts.map +1 -1
  110. package/lib/thresholdCounter.js.map +1 -1
  111. package/lib/utils.d.ts +4 -4
  112. package/lib/utils.d.ts.map +1 -1
  113. package/lib/utils.js +9 -9
  114. package/lib/utils.js.map +1 -1
  115. package/package.json +21 -19
  116. package/src/api.ts +44 -0
  117. package/src/config.ts +29 -19
  118. package/src/errorLogging.ts +2 -2
  119. package/src/events.ts +3 -3
  120. package/src/{index.ts → internal.ts} +23 -8
  121. package/src/logger.ts +114 -37
  122. package/src/main.ts +19 -0
  123. package/src/mockLogger.ts +6 -6
  124. package/src/sampledTelemetryHelper.ts +12 -4
  125. package/src/telemetryEventBatcher.ts +3 -3
  126. package/src/telemetryTypes.ts +76 -6
  127. package/src/telemetryTypesUndeprecated.ts +51 -0
  128. package/src/thresholdCounter.ts +2 -2
  129. package/src/utils.ts +24 -13
  130. package/dist/index.d.ts.map +0 -1
  131. package/dist/index.js.map +0 -1
  132. package/lib/index.d.ts.map +0 -1
  133. package/lib/index.js.map +0 -1
@@ -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 type { ITelemetryGenericEventExt, ITelemetryLoggerExt } from "./telemetryTypes.js";
5
+ import type { ITelemetryGenericEventExt, TelemetryLoggerExt } from "./telemetryTypesUndeprecated.js";
6
6
  /**
7
7
  * Telemetry class that accumulates measurements which are eventually logged in a telemetry event through the provided
8
8
  * {@link TelemetryEventBatcher.logger | logger} when the number of calls to the function reaches the specified {@link TelemetryEventBatcher.threshold | threshold}.
@@ -47,7 +47,7 @@ export declare class TelemetryEventBatcher<TMetrics extends string> {
47
47
  /**
48
48
  * The logger to use to write the telemetry performance event.
49
49
  */
50
- logger: ITelemetryLoggerExt,
50
+ logger: TelemetryLoggerExt,
51
51
  /**
52
52
  * The number of logs to accumulate before sending the data to the logger.
53
53
  */
@@ -1 +1 @@
1
- {"version":3,"file":"telemetryEventBatcher.d.ts","sourceRoot":"","sources":["../src/telemetryEventBatcher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,yBAAyB,EACzB,mBAAmB,EAEnB,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;;;GAUG;AACH,qBAAa,qBAAqB,CAAC,QAAQ,SAAS,MAAM;IAiBxD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS;IAE1B;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS;IA7B3B;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAyC;IAEzD;;OAEG;IACH,OAAO,CAAC,SAAS,CAAyC;IAE1D;;OAEG;IACH,OAAO,CAAC,OAAO,CAAK;;IAGnB;;OAEG;IACc,SAAS,EAAE,yBAAyB;IAErD;;OAEG;IACc,MAAM,EAAE,mBAAmB;IAE5C;;OAEG;IACc,SAAS,EAAE,MAAM;IAGnC;;;;OAIG;IACI,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI;IAgBnE,OAAO,CAAC,QAAQ;CAsBhB"}
1
+ {"version":3,"file":"telemetryEventBatcher.d.ts","sourceRoot":"","sources":["../src/telemetryEventBatcher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,yBAAyB,EACzB,kBAAkB,EAElB,MAAM,iCAAiC,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,qBAAa,qBAAqB,CAAC,QAAQ,SAAS,MAAM;IAiBxD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS;IAE1B;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS;IA7B3B;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAyC;IAEzD;;OAEG;IACH,OAAO,CAAC,SAAS,CAAyC;IAE1D;;OAEG;IACH,OAAO,CAAC,OAAO,CAAK;;IAGnB;;OAEG;IACc,SAAS,EAAE,yBAAyB;IAErD;;OAEG;IACc,MAAM,EAAE,kBAAkB;IAE3C;;OAEG;IACc,SAAS,EAAE,MAAM;IAGnC;;;;OAIG;IACI,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI;IAgBnE,OAAO,CAAC,QAAQ;CAsBhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"telemetryEventBatcher.js","sourceRoot":"","sources":["../src/telemetryEventBatcher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAOtD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,qBAAqB;IAgBjC;IACC;;OAEG;IACc,SAAoC;IAErD;;OAEG;IACc,MAA2B;IAE5C;;OAEG;IACc,SAAiB;QAVjB,cAAS,GAAT,SAAS,CAA2B;QAKpC,WAAM,GAAN,MAAM,CAAqB;QAK3B,cAAS,GAAT,SAAS,CAAQ;QA7BnC;;WAEG;QACK,aAAQ,GAAsC,EAAE,CAAC;QAEzD;;WAEG;QACK,cAAS,GAAsC,EAAE,CAAC;QAE1D;;WAEG;QACK,YAAO,GAAG,CAAC,CAAC;IAiBjB,CAAC;IAEJ;;;;OAIG;IACI,gBAAgB,CAAC,UAAoC;QAC3D,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAe,EAAE,CAAC;YACzD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;YACjE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAC7B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,iBAAiB,EAC/C,UAAU,CAAC,GAAG,CAAC,CACf,CAAC;QACH,CAAC;QAED,IAAI,CAAC,OAAO,EAAE,CAAC;QAEf,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACpC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACjB,CAAC;IACF,CAAC;IAEO,QAAQ;QACf,MAAM,cAAc,GAAkC;YACrD,GAAG,IAAI,CAAC,SAAS;SACjB,CAAC;QAEF,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAe,EAAE,CAAC;YAC5D,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YACnC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC3B,cAAc,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,oBAAoB,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YAChF,CAAC;YACD,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;gBACvC,cAAc,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACpD,CAAC;QACF,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;QAEjD,kCAAkC;QAClC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACrB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { roundToDecimalPlaces } from \"./mathTools.js\";\nimport type {\n\tITelemetryGenericEventExt,\n\tITelemetryLoggerExt,\n\tITelemetryPerformanceEventExt,\n} from \"./telemetryTypes.js\";\n\n/**\n * Telemetry class that accumulates measurements which are eventually logged in a telemetry event through the provided\n * {@link TelemetryEventBatcher.logger | logger} when the number of calls to the function reaches the specified {@link TelemetryEventBatcher.threshold | threshold}.\n *\n * @remarks It is expected to be used for a single event type. If different properties should be logged at different times, a separate `TelemetryEventBatcher` should be created with separate `TMetrics` type.\n * @typeparam TMetrics - The set of keys that should be logged.\n * E.g., `keyof Foo` for logging properties `bar` and `baz` from `type Foo = { bar: number, baz: number }`.\n *\n * @sealed\n * @internal\n */\nexport class TelemetryEventBatcher<TMetrics extends string> {\n\t/**\n\t * Stores the sum of the custom data passed into the logger.\n\t */\n\tprivate dataSums: Partial<Record<TMetrics, number>> = {};\n\n\t/**\n\t * Stores the maximum value of the custom data passed into the logger.\n\t */\n\tprivate dataMaxes: Partial<Record<TMetrics, number>> = {};\n\n\t/**\n\t * Counter to keep track of the number of times the log function is called.\n\t */\n\tprivate counter = 0;\n\n\tpublic constructor(\n\t\t/**\n\t\t * Custom properties to include in the telemetry performance event when it is written.\n\t\t */\n\t\tprivate readonly eventBase: ITelemetryGenericEventExt,\n\n\t\t/**\n\t\t * The logger to use to write the telemetry performance event.\n\t\t */\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\n\t\t/**\n\t\t * The number of logs to accumulate before sending the data to the logger.\n\t\t */\n\t\tprivate readonly threshold: number,\n\t) {}\n\n\t/**\n\t * Accumulates the custom data and sends it to the logger every {@link TelemetryEventBatcher.threshold} calls.\n\t *\n\t * @param customData - A record storing the custom data to be accumulated and eventually logged.\n\t */\n\tpublic accumulateAndLog(customData: Record<TMetrics, number>): void {\n\t\tfor (const key of Object.keys(customData) as TMetrics[]) {\n\t\t\tthis.dataSums[key] = (this.dataSums[key] ?? 0) + customData[key];\n\t\t\tthis.dataMaxes[key] = Math.max(\n\t\t\t\tthis.dataMaxes[key] ?? Number.NEGATIVE_INFINITY,\n\t\t\t\tcustomData[key],\n\t\t\t);\n\t\t}\n\n\t\tthis.counter++;\n\n\t\tif (this.counter >= this.threshold) {\n\t\t\tthis.sendData();\n\t\t}\n\t}\n\n\tprivate sendData(): void {\n\t\tconst telemetryEvent: ITelemetryPerformanceEventExt = {\n\t\t\t...this.eventBase,\n\t\t};\n\n\t\tfor (const key of Object.keys(this.dataSums) as TMetrics[]) {\n\t\t\tconst dataSum = this.dataSums[key];\n\t\t\tif (dataSum !== undefined) {\n\t\t\t\ttelemetryEvent[`avg_${key}`] = roundToDecimalPlaces(dataSum / this.counter, 6);\n\t\t\t}\n\t\t\tif (this.dataMaxes[key] !== undefined) {\n\t\t\t\ttelemetryEvent[`max_${key}`] = this.dataMaxes[key];\n\t\t\t}\n\t\t}\n\n\t\tthis.logger.sendPerformanceEvent(telemetryEvent);\n\n\t\t// Reset the counter and the data.\n\t\tthis.counter = 0;\n\t\tthis.dataSums = {};\n\t\tthis.dataMaxes = {};\n\t}\n}\n"]}
1
+ {"version":3,"file":"telemetryEventBatcher.js","sourceRoot":"","sources":["../src/telemetryEventBatcher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAOtD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,qBAAqB;IAgBjC;IACC;;OAEG;IACc,SAAoC;IAErD;;OAEG;IACc,MAA0B;IAE3C;;OAEG;IACc,SAAiB;QAVjB,cAAS,GAAT,SAAS,CAA2B;QAKpC,WAAM,GAAN,MAAM,CAAoB;QAK1B,cAAS,GAAT,SAAS,CAAQ;QA7BnC;;WAEG;QACK,aAAQ,GAAsC,EAAE,CAAC;QAEzD;;WAEG;QACK,cAAS,GAAsC,EAAE,CAAC;QAE1D;;WAEG;QACK,YAAO,GAAG,CAAC,CAAC;IAiBjB,CAAC;IAEJ;;;;OAIG;IACI,gBAAgB,CAAC,UAAoC;QAC3D,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAe,EAAE,CAAC;YACzD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;YACjE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAC7B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,iBAAiB,EAC/C,UAAU,CAAC,GAAG,CAAC,CACf,CAAC;QACH,CAAC;QAED,IAAI,CAAC,OAAO,EAAE,CAAC;QAEf,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACpC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACjB,CAAC;IACF,CAAC;IAEO,QAAQ;QACf,MAAM,cAAc,GAAkC;YACrD,GAAG,IAAI,CAAC,SAAS;SACjB,CAAC;QAEF,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAe,EAAE,CAAC;YAC5D,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YACnC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC3B,cAAc,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,oBAAoB,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YAChF,CAAC;YACD,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;gBACvC,cAAc,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACpD,CAAC;QACF,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;QAEjD,kCAAkC;QAClC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACrB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { roundToDecimalPlaces } from \"./mathTools.js\";\nimport type {\n\tITelemetryGenericEventExt,\n\tTelemetryLoggerExt,\n\tITelemetryPerformanceEventExt,\n} from \"./telemetryTypesUndeprecated.js\";\n\n/**\n * Telemetry class that accumulates measurements which are eventually logged in a telemetry event through the provided\n * {@link TelemetryEventBatcher.logger | logger} when the number of calls to the function reaches the specified {@link TelemetryEventBatcher.threshold | threshold}.\n *\n * @remarks It is expected to be used for a single event type. If different properties should be logged at different times, a separate `TelemetryEventBatcher` should be created with separate `TMetrics` type.\n * @typeparam TMetrics - The set of keys that should be logged.\n * E.g., `keyof Foo` for logging properties `bar` and `baz` from `type Foo = { bar: number, baz: number }`.\n *\n * @sealed\n * @internal\n */\nexport class TelemetryEventBatcher<TMetrics extends string> {\n\t/**\n\t * Stores the sum of the custom data passed into the logger.\n\t */\n\tprivate dataSums: Partial<Record<TMetrics, number>> = {};\n\n\t/**\n\t * Stores the maximum value of the custom data passed into the logger.\n\t */\n\tprivate dataMaxes: Partial<Record<TMetrics, number>> = {};\n\n\t/**\n\t * Counter to keep track of the number of times the log function is called.\n\t */\n\tprivate counter = 0;\n\n\tpublic constructor(\n\t\t/**\n\t\t * Custom properties to include in the telemetry performance event when it is written.\n\t\t */\n\t\tprivate readonly eventBase: ITelemetryGenericEventExt,\n\n\t\t/**\n\t\t * The logger to use to write the telemetry performance event.\n\t\t */\n\t\tprivate readonly logger: TelemetryLoggerExt,\n\n\t\t/**\n\t\t * The number of logs to accumulate before sending the data to the logger.\n\t\t */\n\t\tprivate readonly threshold: number,\n\t) {}\n\n\t/**\n\t * Accumulates the custom data and sends it to the logger every {@link TelemetryEventBatcher.threshold} calls.\n\t *\n\t * @param customData - A record storing the custom data to be accumulated and eventually logged.\n\t */\n\tpublic accumulateAndLog(customData: Record<TMetrics, number>): void {\n\t\tfor (const key of Object.keys(customData) as TMetrics[]) {\n\t\t\tthis.dataSums[key] = (this.dataSums[key] ?? 0) + customData[key];\n\t\t\tthis.dataMaxes[key] = Math.max(\n\t\t\t\tthis.dataMaxes[key] ?? Number.NEGATIVE_INFINITY,\n\t\t\t\tcustomData[key],\n\t\t\t);\n\t\t}\n\n\t\tthis.counter++;\n\n\t\tif (this.counter >= this.threshold) {\n\t\t\tthis.sendData();\n\t\t}\n\t}\n\n\tprivate sendData(): void {\n\t\tconst telemetryEvent: ITelemetryPerformanceEventExt = {\n\t\t\t...this.eventBase,\n\t\t};\n\n\t\tfor (const key of Object.keys(this.dataSums) as TMetrics[]) {\n\t\t\tconst dataSum = this.dataSums[key];\n\t\t\tif (dataSum !== undefined) {\n\t\t\t\ttelemetryEvent[`avg_${key}`] = roundToDecimalPlaces(dataSum / this.counter, 6);\n\t\t\t}\n\t\t\tif (this.dataMaxes[key] !== undefined) {\n\t\t\t\ttelemetryEvent[`max_${key}`] = this.dataMaxes[key];\n\t\t\t}\n\t\t}\n\n\t\tthis.logger.sendPerformanceEvent(telemetryEvent);\n\n\t\t// Reset the counter and the data.\n\t\tthis.counter = 0;\n\t\tthis.dataSums = {};\n\t\tthis.dataMaxes = {};\n\t}\n}\n"]}
@@ -11,6 +11,8 @@ import type { ITelemetryBaseLogger, LogLevel, Tagged } from "@fluidframework/cor
11
11
  * error - Error log event, ideally 0 of these are logged during a session
12
12
  *
13
13
  * performance - Includes duration, and often has _start, _end, or _cancel suffixes for activity tracking
14
+ * @deprecated This type is being removed without a replacement.
15
+ * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.
14
16
  * @legacy @beta
15
17
  */
16
18
  export type TelemetryEventCategory = "generic" | "error" | "performance";
@@ -49,6 +51,8 @@ export interface ITelemetryEventExt extends ITelemetryPropertiesExt {
49
51
  /**
50
52
  * Informational (non-error) telemetry event
51
53
  * @remarks Maps to category = "generic"
54
+ * @deprecated This type is being removed without a replacement.
55
+ * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.
52
56
  * @legacy @beta
53
57
  */
54
58
  export interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {
@@ -65,6 +69,8 @@ export interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {
65
69
  /**
66
70
  * Error telemetry event.
67
71
  * @remarks Maps to category = "error"
72
+ * @deprecated This type is being removed without a replacement.
73
+ * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.
68
74
  * @legacy @beta
69
75
  */
70
76
  export interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {
@@ -76,6 +82,8 @@ export interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {
76
82
  /**
77
83
  * Performance telemetry event.
78
84
  * @remarks Maps to category = "performance"
85
+ * @deprecated This type is being removed without a replacement.
86
+ * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.
79
87
  * @legacy @beta
80
88
  */
81
89
  export interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {
@@ -84,22 +92,72 @@ export interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt
84
92
  */
85
93
  duration?: number;
86
94
  }
95
+ /**
96
+ * This is the externally facing type for a FluidFramework internal telemetry logger wrapper.
97
+ *
98
+ * @remarks
99
+ * The methods if this interface are not to be used directly by consumers and are all
100
+ * deprecated to removed without replacement. This type is not deprecated and will
101
+ * transition to an erased type to handle cases where "internal" `ITelemetryLoggerExt`
102
+ * previously leaked out.
103
+ *
104
+ * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for deprecation and breaking change details.
105
+ *
106
+ * @privateRemarks
107
+ * External APIs taking in an `ITelemetryLoggerExt` ideally should be updated to
108
+ * accept `ITelemetryBaseLogger` instead.
109
+ *
110
+ * @sealed
111
+ * @legacy
112
+ * @beta
113
+ */
114
+ export interface ITelemetryLoggerExt extends ITelemetryBaseLogger {
115
+ /**
116
+ * Send an information telemetry event.
117
+ * @param event - Event to send.
118
+ * @param error - Optional error object to log.
119
+ * @param logLevel - Optional level of the log. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevel.essential}.
120
+ * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevel.essential}.
121
+ * @deprecated This method is being removed without a replacement.
122
+ * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.
123
+ */
124
+ sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
125
+ /**
126
+ * Send an error telemetry event.
127
+ * @param event - Event to send.
128
+ * @param error - Optional error object to log.
129
+ * @deprecated This method is being removed without a replacement.
130
+ * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.
131
+ */
132
+ sendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;
133
+ /**
134
+ * Send a performance telemetry event.
135
+ * @param event - Event to send
136
+ * @param error - Optional error object to log.
137
+ * @param logLevel - Optional level of the log. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevel.essential}.
138
+ * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevel.essential}.
139
+ * @deprecated This method is being removed without a replacement.
140
+ * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.
141
+ */
142
+ sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
143
+ }
87
144
  /**
88
145
  * An extended {@link @fluidframework/core-interfaces#ITelemetryBaseLogger} which allows for more lenient event types.
89
146
  *
90
147
  * @remarks
91
148
  * This interface is meant to be used internally within the Fluid Framework,
92
149
  * and `ITelemetryBaseLogger` should be used when loggers are passed between layers.
93
- * @legacy @beta
150
+ * @internal
94
151
  */
95
- export interface ITelemetryLoggerExt extends ITelemetryBaseLogger {
152
+ export interface TelemetryLoggerExt extends ITelemetryBaseLogger {
96
153
  /**
97
154
  * Send an information telemetry event.
98
155
  * @param event - Event to send.
99
156
  * @param error - Optional error object to log.
100
- * @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.default}.
157
+ * @param logLevel - Optional level of the log. If undefined, the logLevel will be treated as {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
158
+ * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
101
159
  */
102
- sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
160
+ sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
103
161
  /**
104
162
  * Send an error telemetry event.
105
163
  * @param event - Event to send.
@@ -110,8 +168,9 @@ export interface ITelemetryLoggerExt extends ITelemetryBaseLogger {
110
168
  * Send a performance telemetry event.
111
169
  * @param event - Event to send
112
170
  * @param error - Optional error object to log.
113
- * @param logLevel - Optional level of the log. Default: {@link @fluidframework/core-interfaces#LogLevel.default}.
171
+ * @param logLevel - Optional level of the log. If undefined, the logLevel will be treated as {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
172
+ * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
114
173
  */
115
- sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
174
+ sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
116
175
  }
117
176
  //# sourceMappingURL=telemetryTypes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"telemetryTypes.d.ts","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAE9F;;;;;;;;;GASG;AACH,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,OAAO,GAAG,aAAa,CAAC;AAEzE;;;;;;;GAOG;AACH,MAAM,MAAM,6BAA6B,GACtC,MAAM,GACN,MAAM,GACN,OAAO,GACP,SAAS,GACT,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,GAC7B,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC;AAEzF;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC3C,MAAM,EACN,6BAA6B,GAAG,MAAM,CAAC,6BAA6B,CAAC,CACrE,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAmB,SAAQ,uBAAuB;IAClE;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAA0B,SAAQ,uBAAuB;IACzE;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,QAAQ,CAAC,EAAE,sBAAsB,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,uBAAuB;IACvE;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,6BAA8B,SAAQ,yBAAyB;IAC/E;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAChE;;;;;OAKG;IACH,kBAAkB,CACjB,KAAK,EAAE,yBAAyB,EAChC,KAAK,CAAC,EAAE,OAAO,EACf,QAAQ,CAAC,EAAE,OAAO,QAAQ,CAAC,OAAO,GAAG,OAAO,QAAQ,CAAC,OAAO,GAC1D,IAAI,CAAC;IAER;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,uBAAuB,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEtE;;;;;OAKG;IACH,oBAAoB,CACnB,KAAK,EAAE,6BAA6B,EACpC,KAAK,CAAC,EAAE,OAAO,EACf,QAAQ,CAAC,EAAE,OAAO,QAAQ,CAAC,OAAO,GAAG,OAAO,QAAQ,CAAC,OAAO,GAC1D,IAAI,CAAC;CACR"}
1
+ {"version":3,"file":"telemetryTypes.d.ts","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAE9F;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,OAAO,GAAG,aAAa,CAAC;AAEzE;;;;;;;GAOG;AACH,MAAM,MAAM,6BAA6B,GACtC,MAAM,GACN,MAAM,GACN,OAAO,GACP,SAAS,GACT,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,GAC7B,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC;AAEzF;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC3C,MAAM,EACN,6BAA6B,GAAG,MAAM,CAAC,6BAA6B,CAAC,CACrE,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAmB,SAAQ,uBAAuB;IAClE;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,yBAA0B,SAAQ,uBAAuB;IACzE;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,QAAQ,CAAC,EAAE,sBAAsB,CAAC;CAClC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,uBAAwB,SAAQ,uBAAuB;IACvE;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,6BAA8B,SAAQ,yBAAyB;IAC/E;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAChE;;;;;;;;OAQG;IACH,kBAAkB,CACjB,KAAK,EAAE,yBAAyB,EAChC,KAAK,CAAC,EAAE,OAAO,EACf,QAAQ,CAAC,EAAE,OAAO,QAAQ,CAAC,OAAO,GAAG,OAAO,QAAQ,CAAC,IAAI,GACvD,IAAI,CAAC;IAER;;;;;;OAMG;IACH,cAAc,CAAC,KAAK,EAAE,uBAAuB,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEtE;;;;;;;;OAQG;IACH,oBAAoB,CACnB,KAAK,EAAE,6BAA6B,EACpC,KAAK,CAAC,EAAE,OAAO,EACf,QAAQ,CAAC,EAAE,OAAO,QAAQ,CAAC,OAAO,GAAG,OAAO,QAAQ,CAAC,IAAI,GACvD,IAAI,CAAC;CACR;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAmB,SAAQ,oBAAoB;IAC/D;;;;;;OAMG;IACH,kBAAkB,CACjB,KAAK,EAAE,yBAAyB,EAChC,KAAK,CAAC,EAAE,OAAO,EACf,QAAQ,CAAC,EAAE,OAAO,QAAQ,CAAC,OAAO,GAAG,OAAO,QAAQ,CAAC,IAAI,GACvD,IAAI,CAAC;IAER;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,uBAAuB,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEtE;;;;;;OAMG;IACH,oBAAoB,CACnB,KAAK,EAAE,6BAA6B,EACpC,KAAK,CAAC,EAAE,OAAO,EACf,QAAQ,CAAC,EAAE,OAAO,QAAQ,CAAC,OAAO,GAAG,OAAO,QAAQ,CAAC,IAAI,GACvD,IAAI,CAAC;CACR"}
@@ -1 +1 @@
1
- {"version":3,"file":"telemetryTypes.js","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseLogger, LogLevel, Tagged } from \"@fluidframework/core-interfaces\";\n\n/**\n * The categories FF uses when instrumenting the code.\n *\n * generic - Informational log event\n *\n * error - Error log event, ideally 0 of these are logged during a session\n *\n * performance - Includes duration, and often has _start, _end, or _cancel suffixes for activity tracking\n * @legacy @beta\n */\nexport type TelemetryEventCategory = \"generic\" | \"error\" | \"performance\";\n\n/**\n * Property types that can be logged.\n *\n * @remarks\n * Includes extra types beyond {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType}, which must be\n * converted before sending to a base logger.\n * @legacy @beta\n */\nexport type TelemetryEventPropertyTypeExt =\n\t| string\n\t| number\n\t| boolean\n\t| undefined\n\t| (string | number | boolean)[]\n\t| Record<string, string | number | boolean | undefined | (string | number | boolean)[]>;\n\n/**\n * JSON-serializable properties, which will be logged with telemetry.\n * @legacy @beta\n */\nexport type ITelemetryPropertiesExt = Record<\n\tstring,\n\tTelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>\n>;\n\n/**\n * Interface for logging telemetry statements.\n * @remarks May contain any number of properties that get serialized as json payload.\n * @param category - category of the event, like \"error\", \"performance\", \"generic\", etc.\n * @param eventName - name of the event.\n *\n * @internal\n */\nexport interface ITelemetryEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.category}\n\t */\n\tcategory: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n}\n\n/**\n * Informational (non-error) telemetry event\n * @remarks Maps to category = \"generic\"\n * @legacy @beta\n */\nexport interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n\n\t/**\n\t * Optional event {@link @fluidframework/core-interfaces#ITelemetryBaseEvent.category}.\n\t * @defaultValue \"generic\"\n\t */\n\tcategory?: TelemetryEventCategory;\n}\n\n/**\n * Error telemetry event.\n * @remarks Maps to category = \"error\"\n * @legacy @beta\n */\nexport interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n}\n\n/**\n * Performance telemetry event.\n * @remarks Maps to category = \"performance\"\n * @legacy @beta\n */\nexport interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {\n\t/**\n\t * Duration of event (optional)\n\t */\n\tduration?: number;\n}\n\n/**\n * An extended {@link @fluidframework/core-interfaces#ITelemetryBaseLogger} which allows for more lenient event types.\n *\n * @remarks\n * This interface is meant to be used internally within the Fluid Framework,\n * and `ITelemetryBaseLogger` should be used when loggers are passed between layers.\n * @legacy @beta\n */\nexport interface ITelemetryLoggerExt extends ITelemetryBaseLogger {\n\t/**\n\t * Send an information telemetry event.\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. Default: {@link @fluidframework/core-interfaces#LogLevel.default}.\n\t */\n\tsendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.default,\n\t): void;\n\n\t/**\n\t * Send an error telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t */\n\tsendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;\n\n\t/**\n\t * Send a performance telemetry event.\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. Default: {@link @fluidframework/core-interfaces#LogLevel.default}.\n\t */\n\tsendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.default,\n\t): void;\n}\n"]}
1
+ {"version":3,"file":"telemetryTypes.js","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseLogger, LogLevel, Tagged } from \"@fluidframework/core-interfaces\";\n\n/**\n * The categories FF uses when instrumenting the code.\n *\n * generic - Informational log event\n *\n * error - Error log event, ideally 0 of these are logged during a session\n *\n * performance - Includes duration, and often has _start, _end, or _cancel suffixes for activity tracking\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport type TelemetryEventCategory = \"generic\" | \"error\" | \"performance\";\n\n/**\n * Property types that can be logged.\n *\n * @remarks\n * Includes extra types beyond {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType}, which must be\n * converted before sending to a base logger.\n * @legacy @beta\n */\nexport type TelemetryEventPropertyTypeExt =\n\t| string\n\t| number\n\t| boolean\n\t| undefined\n\t| (string | number | boolean)[]\n\t| Record<string, string | number | boolean | undefined | (string | number | boolean)[]>;\n\n/**\n * JSON-serializable properties, which will be logged with telemetry.\n * @legacy @beta\n */\nexport type ITelemetryPropertiesExt = Record<\n\tstring,\n\tTelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>\n>;\n\n/**\n * Interface for logging telemetry statements.\n * @remarks May contain any number of properties that get serialized as json payload.\n * @param category - category of the event, like \"error\", \"performance\", \"generic\", etc.\n * @param eventName - name of the event.\n *\n * @internal\n */\nexport interface ITelemetryEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.category}\n\t */\n\tcategory: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n}\n\n/**\n * Informational (non-error) telemetry event\n * @remarks Maps to category = \"generic\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n\n\t/**\n\t * Optional event {@link @fluidframework/core-interfaces#ITelemetryBaseEvent.category}.\n\t * @defaultValue \"generic\"\n\t */\n\tcategory?: TelemetryEventCategory;\n}\n\n/**\n * Error telemetry event.\n * @remarks Maps to category = \"error\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n}\n\n/**\n * Performance telemetry event.\n * @remarks Maps to category = \"performance\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {\n\t/**\n\t * Duration of event (optional)\n\t */\n\tduration?: number;\n}\n\n/**\n * This is the externally facing type for a FluidFramework internal telemetry logger wrapper.\n *\n * @remarks\n * The methods if this interface are not to be used directly by consumers and are all\n * deprecated to removed without replacement. This type is not deprecated and will\n * transition to an erased type to handle cases where \"internal\" `ITelemetryLoggerExt`\n * previously leaked out.\n *\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for deprecation and breaking change details.\n *\n * @privateRemarks\n * External APIs taking in an `ITelemetryLoggerExt` ideally should be updated to\n * accept `ITelemetryBaseLogger` instead.\n *\n * @sealed\n * @legacy\n * @beta\n */\nexport interface ITelemetryLoggerExt extends ITelemetryBaseLogger {\n\t/**\n\t * Send an information telemetry event.\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. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * @deprecated This method is being removed without a replacement.\n\t * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n\t */\n\tsendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void;\n\n\t/**\n\t * Send an error telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t * @deprecated This method is being removed without a replacement.\n\t * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n\t */\n\tsendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;\n\n\t/**\n\t * Send a performance telemetry event.\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. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * @deprecated This method is being removed without a replacement.\n\t * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n\t */\n\tsendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void;\n}\n\n/**\n * An extended {@link @fluidframework/core-interfaces#ITelemetryBaseLogger} which allows for more lenient event types.\n *\n * @remarks\n * This interface is meant to be used internally within the Fluid Framework,\n * and `ITelemetryBaseLogger` should be used when loggers are passed between layers.\n * @internal\n */\nexport interface TelemetryLoggerExt extends ITelemetryBaseLogger {\n\t/**\n\t * Send an information telemetry event.\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. If undefined, the logLevel will be treated as {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t */\n\tsendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void;\n\n\t/**\n\t * Send an error telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t */\n\tsendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;\n\n\t/**\n\t * Send a performance telemetry event.\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. If undefined, the logLevel will be treated as {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t */\n\tsendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void;\n}\n"]}
@@ -0,0 +1,36 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export type { TelemetryLoggerExt } from "./telemetryTypes.js";
6
+ import type { ITelemetryGenericEventExt as ExposedITelemetryGenericEventExt, ITelemetryErrorEventExt as ExposedITelemetryErrorEventExt, ITelemetryPerformanceEventExt as ExposedITelemetryPerformanceEventExt, TelemetryEventCategory as ExposedTelemetryEventCategory } from "./telemetryTypes.js";
7
+ /**
8
+ * Informational (non-error) telemetry event
9
+ * @remarks Maps to category = "generic"
10
+ * @internal
11
+ */
12
+ export type ITelemetryGenericEventExt = ExposedITelemetryGenericEventExt;
13
+ /**
14
+ * Error telemetry event.
15
+ * @remarks Maps to category = "error"
16
+ * @internal
17
+ */
18
+ export type ITelemetryErrorEventExt = ExposedITelemetryErrorEventExt;
19
+ /**
20
+ * Performance telemetry event.
21
+ * @remarks Maps to category = "performance"
22
+ * @internal
23
+ */
24
+ export type ITelemetryPerformanceEventExt = ExposedITelemetryPerformanceEventExt;
25
+ /**
26
+ * The categories FF uses when instrumenting the code.
27
+ *
28
+ * generic - Informational log event
29
+ *
30
+ * error - Error log event, ideally 0 of these are logged during a session
31
+ *
32
+ * performance - Includes duration, and often has _start, _end, or _cancel suffixes for activity tracking
33
+ * @internal
34
+ */
35
+ export type TelemetryEventCategory = ExposedTelemetryEventCategory;
36
+ //# sourceMappingURL=telemetryTypesUndeprecated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetryTypesUndeprecated.d.ts","sourceRoot":"","sources":["../src/telemetryTypesUndeprecated.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,KAAK,EACX,yBAAyB,IAAI,gCAAgC,EAC7D,uBAAuB,IAAI,8BAA8B,EACzD,6BAA6B,IAAI,oCAAoC,EACrE,sBAAsB,IAAI,6BAA6B,EACvD,MAAM,qBAAqB,CAAC;AAE7B;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG,gCAAgC,CAAC;AACzE;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AACrE;;;;GAIG;AACH,MAAM,MAAM,6BAA6B,GAAG,oCAAoC,CAAC;AACjF;;;;;;;;;GASG;AACH,MAAM,MAAM,sBAAsB,GAAG,6BAA6B,CAAC"}
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=telemetryTypesUndeprecated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetryTypesUndeprecated.js","sourceRoot":"","sources":["../src/telemetryTypesUndeprecated.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import-x/no-deprecated -- This file specifically works with deprecated types to undeprecate them for internal use */\n\n// This file contains exports that \"un-deprecate\" certain types that we want to\n// continue using internally while exposing deprecated version that will be\n// removed in a future release.\n\n// For internal maintenance convenience, we re-export some non-deprecated types\n// from telemetryTypes.ts too.\nexport type { TelemetryLoggerExt } from \"./telemetryTypes.js\";\n\nimport type {\n\tITelemetryGenericEventExt as ExposedITelemetryGenericEventExt,\n\tITelemetryErrorEventExt as ExposedITelemetryErrorEventExt,\n\tITelemetryPerformanceEventExt as ExposedITelemetryPerformanceEventExt,\n\tTelemetryEventCategory as ExposedTelemetryEventCategory,\n} from \"./telemetryTypes.js\";\n\n/**\n * Informational (non-error) telemetry event\n * @remarks Maps to category = \"generic\"\n * @internal\n */\nexport type ITelemetryGenericEventExt = ExposedITelemetryGenericEventExt;\n/**\n * Error telemetry event.\n * @remarks Maps to category = \"error\"\n * @internal\n */\nexport type ITelemetryErrorEventExt = ExposedITelemetryErrorEventExt;\n/**\n * Performance telemetry event.\n * @remarks Maps to category = \"performance\"\n * @internal\n */\nexport type ITelemetryPerformanceEventExt = ExposedITelemetryPerformanceEventExt;\n/**\n * The categories FF uses when instrumenting the code.\n *\n * generic - Informational log event\n *\n * error - Error log event, ideally 0 of these are logged during a session\n *\n * performance - Includes duration, and often has _start, _end, or _cancel suffixes for activity tracking\n * @internal\n */\nexport type TelemetryEventCategory = ExposedTelemetryEventCategory;\n"]}
@@ -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 type { ITelemetryLoggerExt } from "./telemetryTypes.js";
5
+ import type { TelemetryLoggerExt } 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
  *
@@ -12,7 +12,7 @@ export declare class ThresholdCounter {
12
12
  private readonly threshold;
13
13
  private readonly logger;
14
14
  private thresholdMultiple;
15
- constructor(threshold: number, logger: ITelemetryLoggerExt, thresholdMultiple?: number);
15
+ constructor(threshold: number, logger: TelemetryLoggerExt, thresholdMultiple?: number);
16
16
  /**
17
17
  * Sends the value if it's above the treshold.
18
18
  */
@@ -1 +1 @@
1
- {"version":3,"file":"thresholdCounter.d.ts","sourceRoot":"","sources":["../src/thresholdCounter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D;;;;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,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D;;;;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,kBAAkB,EACnC,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,MAAM,OAAO,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,CAAC;YAC5B,OAAO;QACR,CAAC;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,CAAC;YACtC,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;QACrD,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { 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"]}
1
+ {"version":3,"file":"thresholdCounter.js","sourceRoot":"","sources":["../src/thresholdCounter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAC5B,YACkB,SAAiB,EACjB,MAA0B,EACnC,oBAAoB,SAAS;QAFpB,cAAS,GAAT,SAAS,CAAQ;QACjB,WAAM,GAAN,MAAM,CAAoB;QACnC,sBAAiB,GAAjB,iBAAiB,CAAY;IACnC,CAAC;IAEJ;;OAEG;IACI,IAAI,CAAC,SAAiB,EAAE,KAAa;QAC3C,IAAI,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;YAC5B,OAAO;QACR,CAAC;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,CAAC;YACtC,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;QACrD,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TelemetryLoggerExt } 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: TelemetryLoggerExt,\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"]}
package/lib/utils.d.ts CHANGED
@@ -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 type { ITelemetryLoggerExt } from "./telemetryTypes.js";
5
+ import type { TelemetryLoggerExt } from "./telemetryTypesUndeprecated.js";
6
6
  /**
7
7
  * An object that contains a callback used in conjunction with the {@link createSampledLogger} utility function to provide custom logic for sampling events.
8
8
  *
@@ -19,7 +19,7 @@ export interface IEventSampler {
19
19
  *
20
20
  * @internal
21
21
  */
22
- export interface ISampledTelemetryLogger extends ITelemetryLoggerExt {
22
+ export interface ISampledTelemetryLogger extends TelemetryLoggerExt {
23
23
  /**
24
24
  * Indicates if the feature flag to disable sampling is set.
25
25
  *
@@ -31,7 +31,7 @@ export interface ISampledTelemetryLogger extends ITelemetryLoggerExt {
31
31
  isSamplingDisabled: boolean;
32
32
  }
33
33
  /**
34
- * 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}.
34
+ * Wraps around an existing logger matching the {@link TelemetryLoggerExt} interface and provides the ability to only log a subset of events using a sampling strategy provided by an {@link IEventSampler}.
35
35
  * 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.
36
36
  *
37
37
  * @remarks
@@ -46,7 +46,7 @@ export interface ISampledTelemetryLogger extends ITelemetryLoggerExt {
46
46
  *
47
47
  * @internal
48
48
  */
49
- export declare function createSampledLogger(logger: ITelemetryLoggerExt, eventSampler?: IEventSampler, skipLoggingWhenSamplingIsDisabled?: boolean): ISampledTelemetryLogger;
49
+ export declare function createSampledLogger(logger: TelemetryLoggerExt, eventSampler?: IEventSampler, skipLoggingWhenSamplingIsDisabled?: boolean): ISampledTelemetryLogger;
50
50
  /**
51
51
  * Runs the specified function and returns an object with the time it took to run as well as any output from it.
52
52
  * @remarks Useful in conjunction with {@link TelemetryEventBatcher}.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAA6B,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1F;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,OAAO,CAAC;CACtB;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,EAC5B,iCAAiC,CAAC,EAAE,OAAO,GACzC,uBAAuB,CA8CzB;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,CAAA;CAAE,CAKlF"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAEX,kBAAkB,EAClB,MAAM,iCAAiC,CAAC;AAEzC;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,OAAO,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IAClE;;;;;;;OAOG;IACH,kBAAkB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,kBAAkB,EAC1B,YAAY,CAAC,EAAE,aAAa,EAC5B,iCAAiC,CAAC,EAAE,OAAO,GACzC,uBAAuB,CAsDzB;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,CAAA;CAAE,CAKlF"}
package/lib/utils.js CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { loggerToMonitoringContext } from "./config.js";
6
6
  /**
7
- * 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}.
7
+ * Wraps around an existing logger matching the {@link TelemetryLoggerExt} interface and provides the ability to only log a subset of events using a sampling strategy provided by an {@link IEventSampler}.
8
8
  * 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.
9
9
  *
10
10
  * @remarks
@@ -23,7 +23,7 @@ export function createSampledLogger(logger, eventSampler, skipLoggingWhenSamplin
23
23
  const monitoringContext = loggerToMonitoringContext(logger);
24
24
  const isSamplingDisabled = monitoringContext.config.getBoolean("Fluid.Telemetry.DisableSampling") ?? false;
25
25
  const sampledLogger = {
26
- send: (event) => {
26
+ send: (event, logLevel) => {
27
27
  // The sampler uses the following logic for sending events:
28
28
  // 1. If isSamplingDisabled is true, then this means events should be unsampled. Therefore we send the event without any checks.
29
29
  // 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.
@@ -32,31 +32,31 @@ export function createSampledLogger(logger, eventSampler, skipLoggingWhenSamplin
32
32
  if (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {
33
33
  return;
34
34
  }
35
- logger.send(event);
35
+ logger.send(event, logLevel);
36
36
  }
37
37
  },
38
- sendTelemetryEvent: (event) => {
38
+ sendTelemetryEvent: (event, error, logLevel) => {
39
39
  if (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {
40
40
  if (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {
41
41
  return;
42
42
  }
43
- logger.sendTelemetryEvent(event);
43
+ logger.sendTelemetryEvent(event, error, logLevel);
44
44
  }
45
45
  },
46
- sendErrorEvent: (event) => {
46
+ sendErrorEvent: (event, error) => {
47
47
  if (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {
48
48
  if (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {
49
49
  return;
50
50
  }
51
- logger.sendErrorEvent(event);
51
+ logger.sendErrorEvent(event, error);
52
52
  }
53
53
  },
54
- sendPerformanceEvent: (event) => {
54
+ sendPerformanceEvent: (event, error, logLevel) => {
55
55
  if (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {
56
56
  if (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {
57
57
  return;
58
58
  }
59
- logger.sendPerformanceEvent(event);
59
+ logger.sendPerformanceEvent(event, error, logLevel);
60
60
  }
61
61
  },
62
62
  isSamplingDisabled,
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAgCxD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CAClC,MAA2B,EAC3B,YAA4B,EAC5B,iCAA2C;IAE3C,MAAM,iBAAiB,GAAG,yBAAyB,CAAC,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,0EAA0E;YAC1E,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC;QACF,CAAC;QACD,kBAAkB,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAC9D,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAClC,CAAC;QACF,CAAC;QACD,cAAc,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAC1D,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC;QACF,CAAC;QACD,oBAAoB,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAChE,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;YACpC,CAAC;QACF,CAAC;QACD,kBAAkB;KAClB,CAAC;IAEF,OAAO,aAAa,CAAC;AACtB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO,CAAI,aAAsB;IAChD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAC/B,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\n\nimport { loggerToMonitoringContext } from \"./config.js\";\nimport type { 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;\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\tskipLoggingWhenSamplingIsDisabled?: boolean,\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\t// 3. If skipLoggingWhenSamplingIsDisabled is true, then no event is sent.\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\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\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\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\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\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\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\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\n/**\n * Runs the specified function and returns an object with the time it took to run as well as any output from it.\n * @remarks Useful in conjunction with {@link TelemetryEventBatcher}.\n *\n * @param codeToMeasure - The code to be executed and measured.\n * @returns The total duration of the code execution and whatever the passed-in code block returns.\n * @internal\n */\nexport function measure<T>(codeToMeasure: () => T): { duration: number; output: T } {\n\tconst start = performance.now();\n\tconst output = codeToMeasure();\n\tconst duration = performance.now() - start;\n\treturn { duration, output };\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAmCxD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CAClC,MAA0B,EAC1B,YAA4B,EAC5B,iCAA2C;IAE3C,MAAM,iBAAiB,GAAG,yBAAyB,CAAC,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,EAAE,QAAmB,EAAQ,EAAE;YAC/D,2DAA2D;YAC3D,gIAAgI;YAChI,2LAA2L;YAC3L,0EAA0E;YAC1E,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAC9B,CAAC;QACF,CAAC;QACD,kBAAkB,EAAE,CACnB,KAAgC,EAChC,KAAe,EACf,QAAyD,EAClD,EAAE;YACT,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;YACnD,CAAC;QACF,CAAC;QACD,cAAc,EAAE,CAAC,KAAgC,EAAE,KAAe,EAAQ,EAAE;YAC3E,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACrC,CAAC;QACF,CAAC;QACD,oBAAoB,EAAE,CACrB,KAAgC,EAChC,KAAe,EACf,QAAyD,EAClD,EAAE;YACT,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,oBAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;YACrD,CAAC;QACF,CAAC;QACD,kBAAkB;KAClB,CAAC;IAEF,OAAO,aAAa,CAAC;AACtB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO,CAAI,aAAsB;IAChD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAC/B,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseEvent, LogLevel } from \"@fluidframework/core-interfaces\";\n\nimport { loggerToMonitoringContext } from \"./config.js\";\nimport type {\n\tITelemetryGenericEventExt,\n\tTelemetryLoggerExt,\n} from \"./telemetryTypesUndeprecated.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;\n}\n\n/**\n * A telemetry logger that has sampling capabilities\n *\n * @internal\n */\nexport interface ISampledTelemetryLogger extends TelemetryLoggerExt {\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 TelemetryLoggerExt} 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: TelemetryLoggerExt,\n\teventSampler?: IEventSampler,\n\tskipLoggingWhenSamplingIsDisabled?: boolean,\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, logLevel?: LogLevel): 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\t// 3. If skipLoggingWhenSamplingIsDisabled is true, then no event is sent.\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.send(event, logLevel);\n\t\t\t}\n\t\t},\n\t\tsendTelemetryEvent: (\n\t\t\tevent: ITelemetryGenericEventExt,\n\t\t\terror?: unknown,\n\t\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t\t): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendTelemetryEvent(event, error, logLevel);\n\t\t\t}\n\t\t},\n\t\tsendErrorEvent: (event: ITelemetryGenericEventExt, error?: unknown): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendErrorEvent(event, error);\n\t\t\t}\n\t\t},\n\t\tsendPerformanceEvent: (\n\t\t\tevent: ITelemetryGenericEventExt,\n\t\t\terror?: unknown,\n\t\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t\t): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendPerformanceEvent(event, error, logLevel);\n\t\t\t}\n\t\t},\n\t\tisSamplingDisabled,\n\t};\n\n\treturn sampledLogger;\n}\n\n/**\n * Runs the specified function and returns an object with the time it took to run as well as any output from it.\n * @remarks Useful in conjunction with {@link TelemetryEventBatcher}.\n *\n * @param codeToMeasure - The code to be executed and measured.\n * @returns The total duration of the code execution and whatever the passed-in code block returns.\n * @internal\n */\nexport function measure<T>(codeToMeasure: () => T): { duration: number; output: T } {\n\tconst start = performance.now();\n\tconst output = codeToMeasure();\n\tconst duration = performance.now() - start;\n\treturn { duration, output };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/telemetry-utils",
3
- "version": "2.93.0",
3
+ "version": "2.101.0",
4
4
  "description": "Collection of telemetry relates utilities for Fluid",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -16,35 +16,35 @@
16
16
  ".": {
17
17
  "import": {
18
18
  "types": "./lib/public.d.ts",
19
- "default": "./lib/index.js"
19
+ "default": "./lib/api.js"
20
20
  },
21
21
  "require": {
22
22
  "types": "./dist/public.d.ts",
23
- "default": "./dist/index.js"
23
+ "default": "./dist/api.js"
24
24
  }
25
25
  },
26
26
  "./legacy": {
27
27
  "import": {
28
28
  "types": "./lib/legacy.d.ts",
29
- "default": "./lib/index.js"
29
+ "default": "./lib/api.js"
30
30
  },
31
31
  "require": {
32
32
  "types": "./dist/legacy.d.ts",
33
- "default": "./dist/index.js"
33
+ "default": "./dist/api.js"
34
34
  }
35
35
  },
36
36
  "./internal": {
37
37
  "import": {
38
- "types": "./lib/index.d.ts",
39
- "default": "./lib/index.js"
38
+ "types": "./lib/internal.d.ts",
39
+ "default": "./lib/internal.js"
40
40
  },
41
41
  "require": {
42
- "types": "./dist/index.d.ts",
43
- "default": "./dist/index.js"
42
+ "types": "./dist/internal.d.ts",
43
+ "default": "./dist/internal.js"
44
44
  }
45
45
  }
46
46
  },
47
- "main": "lib/index.js",
47
+ "main": "lib/api.js",
48
48
  "types": "lib/public.d.ts",
49
49
  "c8": {
50
50
  "all": true,
@@ -69,20 +69,20 @@
69
69
  "temp-directory": "nyc/.nyc_output"
70
70
  },
71
71
  "dependencies": {
72
- "@fluid-internal/client-utils": "~2.93.0",
73
- "@fluidframework/core-interfaces": "~2.93.0",
74
- "@fluidframework/core-utils": "~2.93.0",
75
- "@fluidframework/driver-definitions": "~2.93.0",
72
+ "@fluid-internal/client-utils": "~2.101.0",
73
+ "@fluidframework/core-interfaces": "~2.101.0",
74
+ "@fluidframework/core-utils": "~2.101.0",
75
+ "@fluidframework/driver-definitions": "~2.101.0",
76
76
  "debug": "^4.3.4",
77
77
  "uuid": "^11.1.0"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@arethetypeswrong/cli": "^0.18.2",
81
81
  "@biomejs/biome": "~2.4.5",
82
- "@fluid-internal/mocha-test-setup": "~2.93.0",
83
- "@fluid-tools/build-cli": "^0.64.0",
82
+ "@fluid-internal/mocha-test-setup": "~2.101.0",
83
+ "@fluid-tools/build-cli": "^0.65.0",
84
84
  "@fluidframework/build-common": "^2.0.3",
85
- "@fluidframework/build-tools": "^0.64.0",
85
+ "@fluidframework/build-tools": "^0.65.0",
86
86
  "@fluidframework/eslint-config-fluid": "^9.0.0",
87
87
  "@fluidframework/telemetry-utils-previous": "npm:@fluidframework/telemetry-utils@2.92.0",
88
88
  "@microsoft/api-extractor": "7.58.1",
@@ -108,8 +108,8 @@
108
108
  },
109
109
  "scripts": {
110
110
  "api": "fluid-build . --task api",
111
- "api-extractor:commonjs": "flub generate entrypoints --resolutionConditions require --outFileLegacyBeta legacy --outDir ./dist",
112
- "api-extractor:esnext": "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat",
111
+ "api-extractor:commonjs": "flub generate entrypoints --resolutionConditions require --mainEntrypoint ./src/api.ts --outFileLegacyBeta legacy --outDir ./dist",
112
+ "api-extractor:esnext": "flub generate entrypoints --mainEntrypoint ./src/api.ts --outFileLegacyBeta legacy --outDir ./lib",
113
113
  "build": "fluid-build . --task build",
114
114
  "build:api-reports": "concurrently \"npm:build:api-reports:*\"",
115
115
  "build:api-reports:current": "api-extractor run --local --config api-extractor/api-extractor.current.json",
@@ -117,6 +117,7 @@
117
117
  "build:commonjs": "fluid-build . --task commonjs",
118
118
  "build:compile": "fluid-build . --task compile",
119
119
  "build:docs": "api-extractor run --local",
120
+ "build:entrypoints:node10": "flub generate node10Entrypoints",
120
121
  "build:esnext": "tsc --project ./tsconfig.json",
121
122
  "build:test": "npm run build:test:esm && npm run build:test:cjs",
122
123
  "build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
@@ -125,6 +126,7 @@
125
126
  "check:are-the-types-wrong": "attw --pack .",
126
127
  "check:biome": "biome check .",
127
128
  "check:exports": "concurrently \"npm:check:exports:*\"",
129
+ "check:exports:api-bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-api-bundle.json",
128
130
  "check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
129
131
  "check:exports:cjs:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.cjs.json",
130
132
  "check:exports:cjs:public": "api-extractor run --config api-extractor/api-extractor-lint-public.cjs.json",
package/src/api.ts ADDED
@@ -0,0 +1,44 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ // eslint-disable-next-line no-restricted-syntax
7
+ export * from "./main.js";
8
+
9
+ // Additional APIs that are deprecated and thus left out of the common export set.
10
+ export type {
11
+ ITelemetryErrorEventExt,
12
+ ITelemetryGenericEventExt,
13
+ ITelemetryLoggerExt,
14
+ ITelemetryPerformanceEventExt,
15
+ TelemetryEventCategory,
16
+ } from "./telemetryTypes.js";
17
+
18
+ // ----------------------------------------------------------------------------
19
+ // Export `createChildLogger` helper without internal `TelemetryLoggerExt`
20
+
21
+ import type { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
22
+
23
+ import type { ITelemetryLoggerPropertyBags } from "./logger.js";
24
+ import { createChildLogger as createChildLoggerInternal } from "./logger.js";
25
+ import type { ITelemetryLoggerExt } from "./telemetryTypes.js";
26
+
27
+ /**
28
+ * Create a child logger based on the provided props object.
29
+ *
30
+ * @remarks
31
+ * Passing in no props object (i.e. undefined) will return a logger that is effectively a no-op.
32
+ *
33
+ * @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.
34
+ *
35
+ * @legacy
36
+ * @beta
37
+ */
38
+ export function createChildLogger(props?: {
39
+ logger?: ITelemetryBaseLogger;
40
+ namespace?: string;
41
+ properties?: ITelemetryLoggerPropertyBags;
42
+ }): ITelemetryLoggerExt {
43
+ return createChildLoggerInternal(props);
44
+ }