@fluidframework/container-runtime 2.0.0-internal.5.3.2 → 2.0.0-internal.6.0.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 (290) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/dist/batchTracker.d.ts +2 -1
  3. package/dist/batchTracker.d.ts.map +1 -1
  4. package/dist/batchTracker.js +1 -1
  5. package/dist/batchTracker.js.map +1 -1
  6. package/dist/blobManager.d.ts +13 -2
  7. package/dist/blobManager.d.ts.map +1 -1
  8. package/dist/blobManager.js +103 -25
  9. package/dist/blobManager.js.map +1 -1
  10. package/dist/connectionTelemetry.d.ts.map +1 -1
  11. package/dist/connectionTelemetry.js +12 -4
  12. package/dist/connectionTelemetry.js.map +1 -1
  13. package/dist/containerRuntime.d.ts +69 -22
  14. package/dist/containerRuntime.d.ts.map +1 -1
  15. package/dist/containerRuntime.js +344 -238
  16. package/dist/containerRuntime.js.map +1 -1
  17. package/dist/dataStore.js +11 -2
  18. package/dist/dataStore.js.map +1 -1
  19. package/dist/dataStoreContext.d.ts +1 -1
  20. package/dist/dataStoreContext.d.ts.map +1 -1
  21. package/dist/dataStoreContext.js +40 -44
  22. package/dist/dataStoreContext.js.map +1 -1
  23. package/dist/dataStoreContexts.js +1 -1
  24. package/dist/dataStoreContexts.js.map +1 -1
  25. package/dist/dataStores.d.ts +21 -5
  26. package/dist/dataStores.d.ts.map +1 -1
  27. package/dist/dataStores.js +102 -58
  28. package/dist/dataStores.js.map +1 -1
  29. package/dist/deltaManagerSummarizerProxy.d.ts.map +1 -1
  30. package/dist/deltaManagerSummarizerProxy.js +2 -0
  31. package/dist/deltaManagerSummarizerProxy.js.map +1 -1
  32. package/dist/deltaScheduler.d.ts.map +1 -1
  33. package/dist/deltaScheduler.js +5 -5
  34. package/dist/deltaScheduler.js.map +1 -1
  35. package/dist/gc/garbageCollection.d.ts.map +1 -1
  36. package/dist/gc/garbageCollection.js +29 -25
  37. package/dist/gc/garbageCollection.js.map +1 -1
  38. package/dist/gc/gcConfigs.js +13 -11
  39. package/dist/gc/gcConfigs.js.map +1 -1
  40. package/dist/gc/gcHelpers.d.ts +1 -0
  41. package/dist/gc/gcHelpers.d.ts.map +1 -1
  42. package/dist/gc/gcHelpers.js +5 -6
  43. package/dist/gc/gcHelpers.js.map +1 -1
  44. package/dist/gc/gcSummaryStateTracker.js +4 -6
  45. package/dist/gc/gcSummaryStateTracker.js.map +1 -1
  46. package/dist/gc/gcTelemetry.d.ts.map +1 -1
  47. package/dist/gc/gcTelemetry.js +44 -33
  48. package/dist/gc/gcTelemetry.js.map +1 -1
  49. package/dist/id-compressor/idCompressor.d.ts +3 -3
  50. package/dist/id-compressor/idCompressor.d.ts.map +1 -1
  51. package/dist/id-compressor/idCompressor.js +52 -52
  52. package/dist/id-compressor/idCompressor.js.map +1 -1
  53. package/dist/id-compressor/idRange.js +2 -2
  54. package/dist/id-compressor/idRange.js.map +1 -1
  55. package/dist/id-compressor/sessionIdNormalizer.js +11 -16
  56. package/dist/id-compressor/sessionIdNormalizer.js.map +1 -1
  57. package/dist/index.d.ts +1 -1
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js.map +1 -1
  60. package/dist/opLifecycle/batchManager.js +10 -6
  61. package/dist/opLifecycle/batchManager.js.map +1 -1
  62. package/dist/opLifecycle/opCompressor.d.ts +2 -2
  63. package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
  64. package/dist/opLifecycle/opCompressor.js +7 -2
  65. package/dist/opLifecycle/opCompressor.js.map +1 -1
  66. package/dist/opLifecycle/opDecompressor.d.ts +2 -2
  67. package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
  68. package/dist/opLifecycle/opDecompressor.js +12 -10
  69. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  70. package/dist/opLifecycle/opGroupingManager.js +13 -5
  71. package/dist/opLifecycle/opGroupingManager.js.map +1 -1
  72. package/dist/opLifecycle/opSplitter.d.ts +2 -2
  73. package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
  74. package/dist/opLifecycle/opSplitter.js +11 -7
  75. package/dist/opLifecycle/opSplitter.js.map +1 -1
  76. package/dist/opLifecycle/outbox.d.ts +6 -5
  77. package/dist/opLifecycle/outbox.d.ts.map +1 -1
  78. package/dist/opLifecycle/outbox.js +6 -14
  79. package/dist/opLifecycle/outbox.js.map +1 -1
  80. package/dist/opLifecycle/remoteMessageProcessor.d.ts +6 -1
  81. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  82. package/dist/opLifecycle/remoteMessageProcessor.js +8 -2
  83. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  84. package/dist/opProperties.js +1 -2
  85. package/dist/opProperties.js.map +1 -1
  86. package/dist/packageVersion.d.ts +1 -1
  87. package/dist/packageVersion.js +1 -1
  88. package/dist/packageVersion.js.map +1 -1
  89. package/dist/pendingStateManager.d.ts +6 -3
  90. package/dist/pendingStateManager.d.ts.map +1 -1
  91. package/dist/pendingStateManager.js +41 -32
  92. package/dist/pendingStateManager.js.map +1 -1
  93. package/dist/scheduleManager.d.ts.map +1 -1
  94. package/dist/scheduleManager.js +15 -11
  95. package/dist/scheduleManager.js.map +1 -1
  96. package/dist/summary/orderedClientElection.d.ts +2 -1
  97. package/dist/summary/orderedClientElection.d.ts.map +1 -1
  98. package/dist/summary/orderedClientElection.js +18 -19
  99. package/dist/summary/orderedClientElection.js.map +1 -1
  100. package/dist/summary/runningSummarizer.d.ts +3 -5
  101. package/dist/summary/runningSummarizer.d.ts.map +1 -1
  102. package/dist/summary/runningSummarizer.js +42 -66
  103. package/dist/summary/runningSummarizer.js.map +1 -1
  104. package/dist/summary/summarizer.js +5 -8
  105. package/dist/summary/summarizer.js.map +1 -1
  106. package/dist/summary/summarizerClientElection.js +5 -9
  107. package/dist/summary/summarizerClientElection.js.map +1 -1
  108. package/dist/summary/summarizerHeuristics.js +8 -12
  109. package/dist/summary/summarizerHeuristics.js.map +1 -1
  110. package/dist/summary/summarizerNode/summarizerNode.d.ts +5 -5
  111. package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  112. package/dist/summary/summarizerNode/summarizerNode.js +26 -22
  113. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
  114. package/dist/summary/summarizerNode/summarizerNodeUtils.js +2 -4
  115. package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  116. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +4 -3
  117. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  118. package/dist/summary/summarizerNode/summarizerNodeWithGc.js +13 -16
  119. package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  120. package/dist/summary/summaryCollection.js +3 -5
  121. package/dist/summary/summaryCollection.js.map +1 -1
  122. package/dist/summary/summaryFormat.js +1 -2
  123. package/dist/summary/summaryFormat.js.map +1 -1
  124. package/dist/summary/summaryGenerator.d.ts.map +1 -1
  125. package/dist/summary/summaryGenerator.js +67 -21
  126. package/dist/summary/summaryGenerator.js.map +1 -1
  127. package/dist/summary/summaryManager.d.ts +2 -3
  128. package/dist/summary/summaryManager.d.ts.map +1 -1
  129. package/dist/summary/summaryManager.js +9 -7
  130. package/dist/summary/summaryManager.js.map +1 -1
  131. package/lib/batchTracker.d.ts +2 -1
  132. package/lib/batchTracker.d.ts.map +1 -1
  133. package/lib/batchTracker.js +2 -2
  134. package/lib/batchTracker.js.map +1 -1
  135. package/lib/blobManager.d.ts +13 -2
  136. package/lib/blobManager.d.ts.map +1 -1
  137. package/lib/blobManager.js +103 -25
  138. package/lib/blobManager.js.map +1 -1
  139. package/lib/connectionTelemetry.d.ts.map +1 -1
  140. package/lib/connectionTelemetry.js +13 -5
  141. package/lib/connectionTelemetry.js.map +1 -1
  142. package/lib/containerRuntime.d.ts +69 -22
  143. package/lib/containerRuntime.d.ts.map +1 -1
  144. package/lib/containerRuntime.js +343 -238
  145. package/lib/containerRuntime.js.map +1 -1
  146. package/lib/dataStore.js +11 -2
  147. package/lib/dataStore.js.map +1 -1
  148. package/lib/dataStoreContext.d.ts +1 -1
  149. package/lib/dataStoreContext.d.ts.map +1 -1
  150. package/lib/dataStoreContext.js +42 -46
  151. package/lib/dataStoreContext.js.map +1 -1
  152. package/lib/dataStoreContexts.js +2 -2
  153. package/lib/dataStoreContexts.js.map +1 -1
  154. package/lib/dataStores.d.ts +21 -5
  155. package/lib/dataStores.d.ts.map +1 -1
  156. package/lib/dataStores.js +103 -59
  157. package/lib/dataStores.js.map +1 -1
  158. package/lib/deltaManagerSummarizerProxy.d.ts.map +1 -1
  159. package/lib/deltaManagerSummarizerProxy.js +2 -0
  160. package/lib/deltaManagerSummarizerProxy.js.map +1 -1
  161. package/lib/deltaScheduler.d.ts.map +1 -1
  162. package/lib/deltaScheduler.js +6 -6
  163. package/lib/deltaScheduler.js.map +1 -1
  164. package/lib/gc/garbageCollection.d.ts.map +1 -1
  165. package/lib/gc/garbageCollection.js +30 -26
  166. package/lib/gc/garbageCollection.js.map +1 -1
  167. package/lib/gc/gcConfigs.js +13 -11
  168. package/lib/gc/gcConfigs.js.map +1 -1
  169. package/lib/gc/gcHelpers.d.ts +1 -0
  170. package/lib/gc/gcHelpers.d.ts.map +1 -1
  171. package/lib/gc/gcHelpers.js +5 -6
  172. package/lib/gc/gcHelpers.js.map +1 -1
  173. package/lib/gc/gcSummaryStateTracker.js +4 -6
  174. package/lib/gc/gcSummaryStateTracker.js.map +1 -1
  175. package/lib/gc/gcTelemetry.d.ts.map +1 -1
  176. package/lib/gc/gcTelemetry.js +45 -34
  177. package/lib/gc/gcTelemetry.js.map +1 -1
  178. package/lib/id-compressor/idCompressor.d.ts +3 -3
  179. package/lib/id-compressor/idCompressor.d.ts.map +1 -1
  180. package/lib/id-compressor/idCompressor.js +52 -52
  181. package/lib/id-compressor/idCompressor.js.map +1 -1
  182. package/lib/id-compressor/idRange.js +2 -2
  183. package/lib/id-compressor/idRange.js.map +1 -1
  184. package/lib/id-compressor/sessionIdNormalizer.js +11 -16
  185. package/lib/id-compressor/sessionIdNormalizer.js.map +1 -1
  186. package/lib/index.d.ts +1 -1
  187. package/lib/index.d.ts.map +1 -1
  188. package/lib/index.js.map +1 -1
  189. package/lib/opLifecycle/batchManager.js +10 -6
  190. package/lib/opLifecycle/batchManager.js.map +1 -1
  191. package/lib/opLifecycle/opCompressor.d.ts +2 -2
  192. package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
  193. package/lib/opLifecycle/opCompressor.js +8 -3
  194. package/lib/opLifecycle/opCompressor.js.map +1 -1
  195. package/lib/opLifecycle/opDecompressor.d.ts +2 -2
  196. package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
  197. package/lib/opLifecycle/opDecompressor.js +13 -11
  198. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  199. package/lib/opLifecycle/opGroupingManager.js +13 -5
  200. package/lib/opLifecycle/opGroupingManager.js.map +1 -1
  201. package/lib/opLifecycle/opSplitter.d.ts +2 -2
  202. package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
  203. package/lib/opLifecycle/opSplitter.js +12 -8
  204. package/lib/opLifecycle/opSplitter.js.map +1 -1
  205. package/lib/opLifecycle/outbox.d.ts +6 -5
  206. package/lib/opLifecycle/outbox.d.ts.map +1 -1
  207. package/lib/opLifecycle/outbox.js +7 -15
  208. package/lib/opLifecycle/outbox.js.map +1 -1
  209. package/lib/opLifecycle/remoteMessageProcessor.d.ts +6 -1
  210. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  211. package/lib/opLifecycle/remoteMessageProcessor.js +8 -2
  212. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  213. package/lib/opProperties.js +1 -2
  214. package/lib/opProperties.js.map +1 -1
  215. package/lib/packageVersion.d.ts +1 -1
  216. package/lib/packageVersion.js +1 -1
  217. package/lib/packageVersion.js.map +1 -1
  218. package/lib/pendingStateManager.d.ts +6 -3
  219. package/lib/pendingStateManager.d.ts.map +1 -1
  220. package/lib/pendingStateManager.js +41 -32
  221. package/lib/pendingStateManager.js.map +1 -1
  222. package/lib/scheduleManager.d.ts.map +1 -1
  223. package/lib/scheduleManager.js +16 -12
  224. package/lib/scheduleManager.js.map +1 -1
  225. package/lib/summary/orderedClientElection.d.ts +2 -1
  226. package/lib/summary/orderedClientElection.d.ts.map +1 -1
  227. package/lib/summary/orderedClientElection.js +19 -20
  228. package/lib/summary/orderedClientElection.js.map +1 -1
  229. package/lib/summary/runningSummarizer.d.ts +3 -5
  230. package/lib/summary/runningSummarizer.d.ts.map +1 -1
  231. package/lib/summary/runningSummarizer.js +43 -67
  232. package/lib/summary/runningSummarizer.js.map +1 -1
  233. package/lib/summary/summarizer.js +6 -9
  234. package/lib/summary/summarizer.js.map +1 -1
  235. package/lib/summary/summarizerClientElection.js +5 -9
  236. package/lib/summary/summarizerClientElection.js.map +1 -1
  237. package/lib/summary/summarizerHeuristics.js +8 -12
  238. package/lib/summary/summarizerHeuristics.js.map +1 -1
  239. package/lib/summary/summarizerNode/summarizerNode.d.ts +5 -5
  240. package/lib/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  241. package/lib/summary/summarizerNode/summarizerNode.js +27 -23
  242. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
  243. package/lib/summary/summarizerNode/summarizerNodeUtils.js +2 -4
  244. package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  245. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts +4 -3
  246. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  247. package/lib/summary/summarizerNode/summarizerNodeWithGc.js +14 -17
  248. package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  249. package/lib/summary/summaryCollection.js +3 -5
  250. package/lib/summary/summaryCollection.js.map +1 -1
  251. package/lib/summary/summaryFormat.js +1 -2
  252. package/lib/summary/summaryFormat.js.map +1 -1
  253. package/lib/summary/summaryGenerator.d.ts.map +1 -1
  254. package/lib/summary/summaryGenerator.js +68 -22
  255. package/lib/summary/summaryGenerator.js.map +1 -1
  256. package/lib/summary/summaryManager.d.ts +2 -3
  257. package/lib/summary/summaryManager.d.ts.map +1 -1
  258. package/lib/summary/summaryManager.js +10 -8
  259. package/lib/summary/summaryManager.js.map +1 -1
  260. package/package.json +30 -18
  261. package/src/batchTracker.ts +4 -3
  262. package/src/blobManager.ts +113 -15
  263. package/src/connectionTelemetry.ts +7 -3
  264. package/src/containerRuntime.ts +354 -194
  265. package/src/dataStore.ts +10 -1
  266. package/src/dataStoreContext.ts +31 -33
  267. package/src/dataStoreContexts.ts +2 -2
  268. package/src/dataStores.ts +108 -71
  269. package/src/deltaManagerSummarizerProxy.ts +2 -0
  270. package/src/deltaScheduler.ts +6 -10
  271. package/src/gc/garbageCollection.ts +13 -8
  272. package/src/gc/gcHelpers.ts +1 -0
  273. package/src/gc/gcTelemetry.ts +13 -10
  274. package/src/id-compressor/idCompressor.ts +6 -5
  275. package/src/index.ts +0 -1
  276. package/src/opLifecycle/opCompressor.ts +4 -3
  277. package/src/opLifecycle/opDecompressor.ts +4 -3
  278. package/src/opLifecycle/opSplitter.ts +4 -3
  279. package/src/opLifecycle/outbox.ts +13 -25
  280. package/src/opLifecycle/remoteMessageProcessor.ts +8 -2
  281. package/src/packageVersion.ts +1 -1
  282. package/src/pendingStateManager.ts +34 -25
  283. package/src/scheduleManager.ts +2 -2
  284. package/src/summary/orderedClientElection.ts +4 -3
  285. package/src/summary/runningSummarizer.ts +18 -44
  286. package/src/summary/summarizer.ts +2 -2
  287. package/src/summary/summarizerNode/summarizerNode.ts +13 -15
  288. package/src/summary/summarizerNode/summarizerNodeWithGc.ts +8 -7
  289. package/src/summary/summaryGenerator.ts +6 -2
  290. package/src/summary/summaryManager.ts +9 -5
@@ -3,20 +3,8 @@
3
3
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
4
  * Licensed under the MIT License.
5
5
  */
6
- var __rest = (this && this.__rest) || function (s, e) {
7
- var t = {};
8
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
9
- t[p] = s[p];
10
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
11
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
12
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
13
- t[p[i]] = s[p[i]];
14
- }
15
- return t;
16
- };
17
6
  Object.defineProperty(exports, "__esModule", { value: true });
18
7
  exports.sendGCUnexpectedUsageEvent = exports.GCTelemetryTracker = void 0;
19
- const runtime_utils_1 = require("@fluidframework/runtime-utils");
20
8
  const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
21
9
  const gcDefinitions_1 = require("./gcDefinitions");
22
10
  const gcHelpers_1 = require("./gcHelpers");
@@ -88,11 +76,19 @@ class GCTelemetryTracker {
88
76
  // Add the unique event id so that we don't generate a log for this event again in this session..
89
77
  this.loggedUnreferencedEvents.add(uniqueEventId);
90
78
  const state = nodeStateTracker.state;
91
- const { usageType, currentReferenceTimestampMs, packagePath, id, fromId } = nodeUsageProps, propsToLog = __rest(nodeUsageProps, ["usageType", "currentReferenceTimestampMs", "packagePath", "id", "fromId"]);
92
- const eventProps = Object.assign(Object.assign({ id: (0, gcHelpers_1.tagAsCodeArtifact)(id), type: nodeType, unrefTime: nodeStateTracker.unreferencedTimestampMs, age: nodeUsageProps.currentReferenceTimestampMs -
93
- nodeStateTracker.unreferencedTimestampMs, timeout: state === gcDefinitions_1.UnreferencedState.Inactive
79
+ const { usageType, currentReferenceTimestampMs, packagePath, id, fromId, ...propsToLog } = nodeUsageProps;
80
+ const eventProps = {
81
+ type: nodeType,
82
+ unrefTime: nodeStateTracker.unreferencedTimestampMs,
83
+ age: nodeUsageProps.currentReferenceTimestampMs -
84
+ nodeStateTracker.unreferencedTimestampMs,
85
+ timeout: state === gcDefinitions_1.UnreferencedState.Inactive
94
86
  ? this.configs.inactiveTimeoutMs
95
- : this.configs.sweepTimeoutMs, fromId: fromId ? (0, gcHelpers_1.tagAsCodeArtifact)(fromId) : undefined }, propsToLog), this.createContainerMetadata);
87
+ : this.configs.sweepTimeoutMs,
88
+ ...(0, telemetry_utils_1.tagCodeArtifacts)({ id, fromId }),
89
+ ...propsToLog,
90
+ ...this.createContainerMetadata,
91
+ };
96
92
  // This will log the following events:
97
93
  // GC_Tombstone_DataStore_Revived, GC_Tombstone_SubDataStore_Revived, GC_Tombstone_Blob_Revived
98
94
  if (nodeUsageProps.usageType === "Revived" && nodeUsageProps.isTombstoned) {
@@ -109,7 +105,11 @@ class GCTelemetryTracker {
109
105
  // Inactive errors are usages of Objects that are unreferenced for at least a period of 7 days.
110
106
  // SweepReady errors are usages of Objects that will be deleted by GC Sweep!
111
107
  if (this.isSummarizerClient) {
112
- this.pendingEventsQueue.push(Object.assign(Object.assign({}, eventProps), { usageType: nodeUsageProps.usageType, state }));
108
+ this.pendingEventsQueue.push({
109
+ ...eventProps,
110
+ usageType: nodeUsageProps.usageType,
111
+ state,
112
+ });
113
113
  }
114
114
  else {
115
115
  // For non-summarizer clients, only log "Loaded" type events since these objects may not be loaded in the
@@ -117,14 +117,16 @@ class GCTelemetryTracker {
117
117
  // Events generated:
118
118
  // InactiveObject_Loaded, SweepReadyObject_Loaded
119
119
  if (nodeUsageProps.usageType === "Loaded") {
120
- const { id: taggedId, fromId: taggedFromId } = eventProps, otherProps = __rest(eventProps, ["id", "fromId"]);
120
+ const { id: taggedId, fromId: taggedFromId, ...otherProps } = eventProps;
121
121
  const event = {
122
122
  eventName: `${state}Object_${nodeUsageProps.usageType}`,
123
- pkg: (0, runtime_utils_1.packagePathToTelemetryProperty)(nodeUsageProps.packagePath),
123
+ pkg: (0, telemetry_utils_1.tagCodeArtifacts)({ pkg: nodeUsageProps.packagePath?.join("/") }).pkg,
124
124
  stack: (0, telemetry_utils_1.generateStack)(),
125
125
  id: taggedId,
126
126
  fromId: taggedFromId,
127
- details: JSON.stringify(Object.assign({}, otherProps)),
127
+ details: JSON.stringify({
128
+ ...otherProps,
129
+ }),
128
130
  };
129
131
  // Do not log the inactive object x events as error events as they are not the best signal for
130
132
  // detecting something wrong with GC either from the partner or from the runtime itself.
@@ -150,10 +152,9 @@ class GCTelemetryTracker {
150
152
  * @param explicitReferences - New references added explicity between the previous and the current run.
151
153
  */
152
154
  logIfMissingExplicitReferences(currentGCData, previousGCData, explicitReferences, logger) {
153
- var _a, _b;
154
155
  for (const [nodeId, currentOutboundRoutes] of Object.entries(currentGCData.gcNodes)) {
155
- const previousRoutes = (_a = previousGCData.gcNodes[nodeId]) !== null && _a !== void 0 ? _a : [];
156
- const explicitRoutes = (_b = explicitReferences.get(nodeId)) !== null && _b !== void 0 ? _b : [];
156
+ const previousRoutes = previousGCData.gcNodes[nodeId] ?? [];
157
+ const explicitRoutes = explicitReferences.get(nodeId) ?? [];
157
158
  /**
158
159
  * 1. For routes in the current GC data, routes that were not present in previous GC data and did not have
159
160
  * explicit references should be added to missing explicit routes list.
@@ -175,8 +176,10 @@ class GCTelemetryTracker {
175
176
  if (missingExplicitRoutes.length > 0) {
176
177
  logger.sendErrorEvent({
177
178
  eventName: "gcUnknownOutboundReferences",
178
- id: (0, gcHelpers_1.tagAsCodeArtifact)(nodeId),
179
- routes: (0, gcHelpers_1.tagAsCodeArtifact)(JSON.stringify(missingExplicitRoutes)),
179
+ ...(0, telemetry_utils_1.tagCodeArtifacts)({
180
+ id: nodeId,
181
+ routes: JSON.stringify(missingExplicitRoutes),
182
+ }),
180
183
  });
181
184
  }
182
185
  }
@@ -192,7 +195,7 @@ class GCTelemetryTracker {
192
195
  // InactiveObject_Loaded, InactiveObject_Changed, InactiveObject_Revived
193
196
  // SweepReadyObject_Loaded, SweepReadyObject_Changed, SweepReadyObject_Revived
194
197
  for (const eventProps of this.pendingEventsQueue) {
195
- const { usageType, state, id, fromId } = eventProps, propsToLog = __rest(eventProps, ["usageType", "state", "id", "fromId"]);
198
+ const { usageType, state, id, fromId, ...propsToLog } = eventProps;
196
199
  /**
197
200
  * Revived event is logged only if the node is active. If the node is not active, the reference to it was
198
201
  * from another unreferenced node and this scenario is not interesting to log.
@@ -209,11 +212,15 @@ class GCTelemetryTracker {
209
212
  : undefined;
210
213
  const event = {
211
214
  eventName: `${state}Object_${usageType}`,
212
- details: JSON.stringify(Object.assign({}, propsToLog)),
215
+ details: JSON.stringify({
216
+ ...propsToLog,
217
+ }),
213
218
  id,
214
219
  fromId,
215
- pkg: pkg ? (0, gcHelpers_1.tagAsCodeArtifact)(pkg.join("/")) : undefined,
216
- fromPkg: fromPkg ? (0, gcHelpers_1.tagAsCodeArtifact)(fromPkg.join("/")) : undefined,
220
+ ...(0, telemetry_utils_1.tagCodeArtifacts)({
221
+ pkg: pkg?.join("/"),
222
+ fromPkg: fromPkg?.join("/"),
223
+ }),
217
224
  };
218
225
  if (state === gcDefinitions_1.UnreferencedState.Inactive) {
219
226
  logger.sendTelemetryEvent(event);
@@ -254,9 +261,13 @@ class GCTelemetryTracker {
254
261
  if (deletedNodeIds.length > 0) {
255
262
  logger.sendTelemetryEvent({
256
263
  eventName: "GC_SweepReadyObjects_Delete",
257
- details: JSON.stringify(Object.assign({ timeout: this.configs.sweepTimeoutMs, completedGCRuns,
258
- lastSummaryTime }, this.createContainerMetadata)),
259
- id: (0, gcHelpers_1.tagAsCodeArtifact)(JSON.stringify(deletedNodeIds)),
264
+ details: JSON.stringify({
265
+ timeout: this.configs.sweepTimeoutMs,
266
+ completedGCRuns,
267
+ lastSummaryTime,
268
+ ...this.createContainerMetadata,
269
+ }),
270
+ ...(0, telemetry_utils_1.tagCodeArtifacts)({ id: JSON.stringify(deletedNodeIds) }),
260
271
  });
261
272
  }
262
273
  }
@@ -267,7 +278,7 @@ exports.GCTelemetryTracker = GCTelemetryTracker;
267
278
  * tombstoned or deleted object is loaded.
268
279
  */
269
280
  function sendGCUnexpectedUsageEvent(mc, event, packagePath, error) {
270
- event.pkg = (0, runtime_utils_1.packagePathToTelemetryProperty)(packagePath);
281
+ event.pkg = (0, telemetry_utils_1.tagCodeArtifacts)({ pkg: packagePath?.join("/") })?.pkg;
271
282
  event.tombstoneFlags = JSON.stringify({
272
283
  DisableTombstone: mc.config.getBoolean(gcDefinitions_1.disableTombstoneKey),
273
284
  ThrowOnTombstoneUsage: mc.config.getBoolean(gcDefinitions_1.throwOnTombstoneUsageKey),
@@ -1 +1 @@
1
- {"version":3,"file":"gcTelemetry.js","sourceRoot":"","sources":["../../src/gc/gcTelemetry.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;AAIH,iEAA+E;AAC/E,qEAIyC;AAEzC,mDASyB;AAEzB,2CAAgD;AAsChD;;;;;;;;GAQG;AACH,MAAa,kBAAkB;IAO9B,YACkB,EAAqB,EACrB,OAGhB,EACgB,kBAA2B,EAC3B,6BAAsC,EACtC,uBAAiD,EACjD,WAA2C,EAC3C,mBAEwB,EACxB,kBAE0B;QAd1B,OAAE,GAAF,EAAE,CAAmB;QACrB,YAAO,GAAP,OAAO,CAGvB;QACgB,uBAAkB,GAAlB,kBAAkB,CAAS;QAC3B,kCAA6B,GAA7B,6BAA6B,CAAS;QACtC,4BAAuB,GAAvB,uBAAuB,CAA0B;QACjD,gBAAW,GAAX,WAAW,CAAgC;QAC3C,wBAAmB,GAAnB,mBAAmB,CAEK;QACxB,uBAAkB,GAAlB,kBAAkB,CAEQ;QArB5C,iHAAiH;QACjH,sBAAsB;QACL,6BAAwB,GAAgB,IAAI,GAAG,EAAE,CAAC;QACnE,6EAA6E;QACrE,uBAAkB,GAA8B,EAAE,CAAC;IAkBxD,CAAC;IAEJ;;;;OAIG;IACK,uBAAuB,CAC9B,MAAc,EACd,QAAoB,EACpB,SAAwB,EACxB,gBAA0C,EAC1C,aAAqB;QAErB,IAAI,gBAAgB,CAAC,KAAK,KAAK,iCAAiB,CAAC,MAAM,EAAE;YACxD,OAAO,KAAK,CAAC;SACb;QAED,gHAAgH;QAChH,oDAAoD;QACpD,IAAI,QAAQ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rE,oBAAoB,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,uCAAuB,CAAC;KACnE,CAAC,CAAC;IACH,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC;QACjC,eAAe,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,2BAAW,CAAC;KAClD,CAAC,CAAC;IAEH,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC5C,CAAC;AApBD,gEAoBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryGenericEvent } from \"@fluidframework/core-interfaces\";\nimport { IGarbageCollectionData } from \"@fluidframework/runtime-definitions\";\nimport { packagePathToTelemetryProperty } from \"@fluidframework/runtime-utils\";\nimport {\n\tgenerateStack,\n\tITelemetryLoggerExt,\n\tMonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport { ICreateContainerMetadata } from \"../summary\";\nimport {\n\tdisableSweepLogKey,\n\tGCNodeType,\n\tUnreferencedState,\n\tIGarbageCollectorConfigs,\n\tdisableTombstoneKey,\n\tthrowOnTombstoneUsageKey,\n\tthrowOnTombstoneLoadKey,\n\trunSweepKey,\n} from \"./gcDefinitions\";\nimport { UnreferencedStateTracker } from \"./gcUnreferencedStateTracker\";\nimport { tagAsCodeArtifact } from \"./gcHelpers\";\n\ntype NodeUsageType = \"Changed\" | \"Loaded\" | \"Revived\";\n\n/** Properties that are common to IUnreferencedEventProps and INodeUsageProps */\ninterface ICommonProps {\n\tusageType: NodeUsageType;\n\tcompletedGCRuns: number;\n\tisTombstoned: boolean;\n\tlastSummaryTime?: number;\n\tviaHandle?: boolean;\n}\n\n/** The event that is logged when unreferenced node is used after a certain time. */\ninterface IUnreferencedEventProps extends ICreateContainerMetadata, ICommonProps {\n\tstate: UnreferencedState;\n\tid: {\n\t\tvalue: string;\n\t\ttag: string;\n\t};\n\ttype: GCNodeType;\n\tunrefTime: number;\n\tage: number;\n\ttimeout?: number;\n\tfromId?: {\n\t\tvalue: string;\n\t\ttag: string;\n\t};\n}\n\n/** Properties passed to nodeUsed function when a node is used. */\ninterface INodeUsageProps extends ICommonProps {\n\tid: string;\n\tcurrentReferenceTimestampMs: number | undefined;\n\tpackagePath: readonly string[] | undefined;\n\tfromId?: string;\n}\n\n/**\n * Encapsulates the logic that tracks the various telemetry logged by the Garbage Collector. There are 4 types of\n * telemetry logged:\n * 1. inactiveObject telemetry - When an inactive node is used - A node that has been unreferenced for inactiveTimeoutMs.\n * 2. sweepReadyObject telemetry - When a sweep ready node is used - A node that has been unreferenced for sweepTimeoutMs.\n * 3. Tombstone telemetry - When a tombstoned node is used - A node that that has been marked as tombstone.\n * 4. Sweep / deleted telemetry - When a node is detected as sweep ready in the sweep phase.\n * 5. Unknown outbound reference telemetry - When a node is referenced but GC is not explicitly notified of it.\n */\nexport class GCTelemetryTracker {\n\t// Keeps track of unreferenced events that are logged for a node. This is used to limit the log generation to one\n\t// per event per node.\n\tprivate readonly loggedUnreferencedEvents: Set<string> = new Set();\n\t// Queue for unreferenced events that should be logged the next time GC runs.\n\tprivate pendingEventsQueue: IUnreferencedEventProps[] = [];\n\n\tconstructor(\n\t\tprivate readonly mc: MonitoringContext,\n\t\tprivate readonly configs: Pick<\n\t\t\tIGarbageCollectorConfigs,\n\t\t\t\"inactiveTimeoutMs\" | \"sweepTimeoutMs\"\n\t\t>,\n\t\tprivate readonly isSummarizerClient: boolean,\n\t\tprivate readonly gcTombstoneEnforcementAllowed: boolean,\n\t\tprivate readonly createContainerMetadata: ICreateContainerMetadata,\n\t\tprivate readonly getNodeType: (nodeId: string) => GCNodeType,\n\t\tprivate readonly getNodeStateTracker: (\n\t\t\tnodeId: string,\n\t\t) => UnreferencedStateTracker | undefined,\n\t\tprivate readonly getNodePackagePath: (\n\t\t\tnodePath: string,\n\t\t) => Promise<readonly string[] | undefined>,\n\t) {}\n\n\t/**\n\t * Returns whether an event should be logged for a node that isn't active anymore. Some scenarios where we won't log:\n\t * 1. When a DDS is changed or loaded. The corresponding data store's event will be logged instead.\n\t * 2. An event is logged only once per container instance per event per node.\n\t */\n\tprivate shouldLogNonActiveEvent(\n\t\tnodeId: string,\n\t\tnodeType: GCNodeType,\n\t\tusageType: NodeUsageType,\n\t\tnodeStateTracker: UnreferencedStateTracker,\n\t\tuniqueEventId: string,\n\t) {\n\t\tif (nodeStateTracker.state === UnreferencedState.Active) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// For sub data store (DDS) nodes, if they are changed or loaded, its data store will also be changed or loaded,\n\t\t// so skip logging to make the telemetry less noisy.\n\t\tif (nodeType === GCNodeType.SubDataStore && usageType !== \"Revived\") {\n\t\t\treturn false;\n\t\t}\n\t\tif (nodeType === GCNodeType.Other) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Called when a node is used. If the node is not active, log an event indicating object is used when its not active.\n\t */\n\tpublic nodeUsed(nodeUsageProps: INodeUsageProps) {\n\t\t// If there is no reference timestamp to work with, no ops have been processed after creation. If so, skip\n\t\t// logging as nothing interesting would have happened worth logging.\n\t\t// If the node is not unreferenced, skip logging.\n\t\tconst nodeStateTracker = this.getNodeStateTracker(nodeUsageProps.id);\n\t\tif (!nodeStateTracker || nodeUsageProps.currentReferenceTimestampMs === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We log these events once per event per node. A unique id is generated by joining node state (inactive / sweep ready),\n\t\t// node's id and usage (loaded / changed / revived).\n\t\tconst uniqueEventId = `${nodeStateTracker.state}-${nodeUsageProps.id}-${nodeUsageProps.usageType}`;\n\t\tconst nodeType = this.getNodeType(nodeUsageProps.id);\n\t\tif (\n\t\t\t!this.shouldLogNonActiveEvent(\n\t\t\t\tnodeUsageProps.id,\n\t\t\t\tnodeType,\n\t\t\t\tnodeUsageProps.usageType,\n\t\t\t\tnodeStateTracker,\n\t\t\t\tuniqueEventId,\n\t\t\t)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Add the unique event id so that we don't generate a log for this event again in this session..\n\t\tthis.loggedUnreferencedEvents.add(uniqueEventId);\n\n\t\tconst state = nodeStateTracker.state;\n\t\tconst { usageType, currentReferenceTimestampMs, packagePath, id, fromId, ...propsToLog } =\n\t\t\tnodeUsageProps;\n\t\tconst eventProps: Omit<IUnreferencedEventProps, \"state\" | \"usageType\"> = {\n\t\t\tid: tagAsCodeArtifact(id),\n\t\t\ttype: nodeType,\n\t\t\tunrefTime: nodeStateTracker.unreferencedTimestampMs,\n\t\t\tage:\n\t\t\t\tnodeUsageProps.currentReferenceTimestampMs -\n\t\t\t\tnodeStateTracker.unreferencedTimestampMs,\n\t\t\ttimeout:\n\t\t\t\tstate === UnreferencedState.Inactive\n\t\t\t\t\t? this.configs.inactiveTimeoutMs\n\t\t\t\t\t: this.configs.sweepTimeoutMs,\n\t\t\tfromId: fromId ? tagAsCodeArtifact(fromId) : undefined,\n\t\t\t...propsToLog,\n\t\t\t...this.createContainerMetadata,\n\t\t};\n\n\t\t// This will log the following events:\n\t\t// GC_Tombstone_DataStore_Revived, GC_Tombstone_SubDataStore_Revived, GC_Tombstone_Blob_Revived\n\t\tif (nodeUsageProps.usageType === \"Revived\" && nodeUsageProps.isTombstoned) {\n\t\t\tsendGCUnexpectedUsageEvent(\n\t\t\t\tthis.mc,\n\t\t\t\t{\n\t\t\t\t\teventName: `GC_Tombstone_${nodeType}_Revived`,\n\t\t\t\t\tcategory: \"generic\",\n\t\t\t\t\turl: tagAsCodeArtifact(id),\n\t\t\t\t\tgcTombstoneEnforcementAllowed: this.gcTombstoneEnforcementAllowed,\n\t\t\t\t},\n\t\t\t\tundefined /* packagePath */,\n\t\t\t);\n\t\t}\n\n\t\t// For summarizer client, queue the event so it is logged the next time GC runs if the event is still valid.\n\t\t// For non-summarizer client, log the event now since GC won't run on it. This may result in false positives\n\t\t// but it's a good signal nonetheless and we can consume it with a grain of salt.\n\t\t// Inactive errors are usages of Objects that are unreferenced for at least a period of 7 days.\n\t\t// SweepReady errors are usages of Objects that will be deleted by GC Sweep!\n\t\tif (this.isSummarizerClient) {\n\t\t\tthis.pendingEventsQueue.push({\n\t\t\t\t...eventProps,\n\t\t\t\tusageType: nodeUsageProps.usageType,\n\t\t\t\tstate,\n\t\t\t});\n\t\t} else {\n\t\t\t// For non-summarizer clients, only log \"Loaded\" type events since these objects may not be loaded in the\n\t\t\t// summarizer clients if they are based off of user actions (such as scrolling to content for these objects)\n\t\t\t// Events generated:\n\t\t\t// InactiveObject_Loaded, SweepReadyObject_Loaded\n\t\t\tif (nodeUsageProps.usageType === \"Loaded\") {\n\t\t\t\tconst { id: taggedId, fromId: taggedFromId, ...otherProps } = eventProps;\n\t\t\t\tconst event = {\n\t\t\t\t\teventName: `${state}Object_${nodeUsageProps.usageType}`,\n\t\t\t\t\tpkg: packagePathToTelemetryProperty(nodeUsageProps.packagePath),\n\t\t\t\t\tstack: generateStack(),\n\t\t\t\t\tid: taggedId,\n\t\t\t\t\tfromId: taggedFromId,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t...otherProps,\n\t\t\t\t\t}),\n\t\t\t\t};\n\n\t\t\t\t// Do not log the inactive object x events as error events as they are not the best signal for\n\t\t\t\t// detecting something wrong with GC either from the partner or from the runtime itself.\n\t\t\t\tif (state === UnreferencedState.Inactive) {\n\t\t\t\t\tthis.mc.logger.sendTelemetryEvent(event);\n\t\t\t\t} else {\n\t\t\t\t\tthis.mc.logger.sendErrorEvent(event);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Log all new references or outbound routes in the current graph that haven't been explicitly notified to GC.\n\t * The principle is that every new reference or outbound route must be notified to GC via the\n\t * addedOutboundReference method. It it hasn't, its a bug and we want to identify these scenarios.\n\t *\n\t * In more simple terms:\n\t * Missing Explicit References = Current References - Previous References - Explicitly Added References;\n\t *\n\t * @param currentGCData - The GC data (reference graph) from the current GC run.\n\t * @param previousGCData - The GC data (reference graph) from the previous GC run.\n\t * @param explicitReferences - New references added explicity between the previous and the current run.\n\t */\n\tpublic logIfMissingExplicitReferences(\n\t\tcurrentGCData: IGarbageCollectionData,\n\t\tpreviousGCData: IGarbageCollectionData,\n\t\texplicitReferences: Map<string, string[]>,\n\t\tlogger: ITelemetryLoggerExt,\n\t) {\n\t\tfor (const [nodeId, currentOutboundRoutes] of Object.entries(currentGCData.gcNodes)) {\n\t\t\tconst previousRoutes = previousGCData.gcNodes[nodeId] ?? [];\n\t\t\tconst explicitRoutes = explicitReferences.get(nodeId) ?? [];\n\n\t\t\t/**\n\t\t\t * 1. For routes in the current GC data, routes that were not present in previous GC data and did not have\n\t\t\t * explicit references should be added to missing explicit routes list.\n\t\t\t * 2. Only include data store and blob routes since GC only works for these two.\n\t\t\t * Note: Due to a bug with de-duped blobs, only adding data store routes for now.\n\t\t\t * 3. Ignore DDS routes to their parent datastores since those were added implicitly. So, there won't be\n\t\t\t * explicit routes to them.\n\t\t\t */\n\t\t\tconst missingExplicitRoutes: string[] = [];\n\t\t\tfor (const route of currentOutboundRoutes) {\n\t\t\t\tconst nodeType = this.getNodeType(route);\n\t\t\t\tif (\n\t\t\t\t\t(nodeType === GCNodeType.DataStore || nodeType === GCNodeType.Blob) &&\n\t\t\t\t\t!nodeId.startsWith(route) &&\n\t\t\t\t\t!previousRoutes.includes(route) &&\n\t\t\t\t\t!explicitRoutes.includes(route)\n\t\t\t\t) {\n\t\t\t\t\tmissingExplicitRoutes.push(route);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (missingExplicitRoutes.length > 0) {\n\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\teventName: \"gcUnknownOutboundReferences\",\n\t\t\t\t\tid: tagAsCodeArtifact(nodeId),\n\t\t\t\t\troutes: tagAsCodeArtifact(JSON.stringify(missingExplicitRoutes)),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Log events that are pending in pendingEventsQueue. This is called after GC runs in the summarizer client\n\t * so that the state of an unreferenced node is updated.\n\t */\n\tpublic async logPendingEvents(logger: ITelemetryLoggerExt) {\n\t\t// Events sent come only from the summarizer client. In between summaries, events are pushed to a queue and at\n\t\t// summary time they are then logged.\n\t\t// Events generated:\n\t\t// InactiveObject_Loaded, InactiveObject_Changed, InactiveObject_Revived\n\t\t// SweepReadyObject_Loaded, SweepReadyObject_Changed, SweepReadyObject_Revived\n\t\tfor (const eventProps of this.pendingEventsQueue) {\n\t\t\tconst { usageType, state, id, fromId, ...propsToLog } = eventProps;\n\t\t\t/**\n\t\t\t * Revived event is logged only if the node is active. If the node is not active, the reference to it was\n\t\t\t * from another unreferenced node and this scenario is not interesting to log.\n\t\t\t * Loaded and Changed events are logged only if the node is not active. If the node is active, it was\n\t\t\t * revived and a Revived event will be logged for it.\n\t\t\t */\n\t\t\tconst nodeStateTracker = this.getNodeStateTracker(eventProps.id.value);\n\t\t\tconst active =\n\t\t\t\tnodeStateTracker === undefined ||\n\t\t\t\tnodeStateTracker.state === UnreferencedState.Active;\n\t\t\tif ((usageType === \"Revived\") === active) {\n\t\t\t\tconst pkg = await this.getNodePackagePath(eventProps.id.value);\n\t\t\t\tconst fromPkg = eventProps.fromId\n\t\t\t\t\t? await this.getNodePackagePath(eventProps.fromId.value)\n\t\t\t\t\t: undefined;\n\t\t\t\tconst event = {\n\t\t\t\t\teventName: `${state}Object_${usageType}`,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t...propsToLog,\n\t\t\t\t\t}),\n\t\t\t\t\tid,\n\t\t\t\t\tfromId,\n\t\t\t\t\tpkg: pkg ? tagAsCodeArtifact(pkg.join(\"/\")) : undefined,\n\t\t\t\t\tfromPkg: fromPkg ? tagAsCodeArtifact(fromPkg.join(\"/\")) : undefined,\n\t\t\t\t};\n\n\t\t\t\tif (state === UnreferencedState.Inactive) {\n\t\t\t\t\tlogger.sendTelemetryEvent(event);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.sendErrorEvent(event);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.pendingEventsQueue = [];\n\t}\n\n\t/**\n\t * For nodes that are ready to sweep, log an event for now. Until we start running sweep which deletes objects,\n\t * this will give us a view into how much deleted content a container has.\n\t */\n\tpublic logSweepEvents(\n\t\tlogger: ITelemetryLoggerExt,\n\t\tcurrentReferenceTimestampMs: number,\n\t\tunreferencedNodesState: Map<string, UnreferencedStateTracker>,\n\t\tcompletedGCRuns: number,\n\t\tlastSummaryTime?: number,\n\t) {\n\t\tif (\n\t\t\tthis.mc.config.getBoolean(disableSweepLogKey) === true ||\n\t\t\tthis.configs.sweepTimeoutMs === undefined\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst deletedNodeIds: string[] = [];\n\t\tfor (const [nodeId, nodeStateTracker] of unreferencedNodesState) {\n\t\t\tif (nodeStateTracker.state !== UnreferencedState.SweepReady) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nodeType = this.getNodeType(nodeId);\n\t\t\tif (nodeType !== GCNodeType.DataStore && nodeType !== GCNodeType.Blob) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Log deleted event for each node only once to reduce noise in telemetry.\n\t\t\tconst uniqueEventId = `Deleted-${nodeId}`;\n\t\t\tif (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.loggedUnreferencedEvents.add(uniqueEventId);\n\t\t\tdeletedNodeIds.push(nodeId);\n\t\t}\n\n\t\tif (deletedNodeIds.length > 0) {\n\t\t\tlogger.sendTelemetryEvent({\n\t\t\t\teventName: \"GC_SweepReadyObjects_Delete\",\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\ttimeout: this.configs.sweepTimeoutMs,\n\t\t\t\t\tcompletedGCRuns,\n\t\t\t\t\tlastSummaryTime,\n\t\t\t\t\t...this.createContainerMetadata,\n\t\t\t\t}),\n\t\t\t\tid: tagAsCodeArtifact(JSON.stringify(deletedNodeIds)),\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Consolidates info / logic for logging when we encounter unexpected usage of GC'd objects. For example, when a\n * tombstoned or deleted object is loaded.\n */\nexport function sendGCUnexpectedUsageEvent(\n\tmc: MonitoringContext,\n\tevent: ITelemetryGenericEvent & {\n\t\tcategory: \"error\" | \"generic\";\n\t\tgcTombstoneEnforcementAllowed: boolean | undefined;\n\t},\n\tpackagePath: readonly string[] | undefined,\n\terror?: unknown,\n) {\n\tevent.pkg = packagePathToTelemetryProperty(packagePath);\n\tevent.tombstoneFlags = JSON.stringify({\n\t\tDisableTombstone: mc.config.getBoolean(disableTombstoneKey),\n\t\tThrowOnTombstoneUsage: mc.config.getBoolean(throwOnTombstoneUsageKey),\n\t\tThrowOnTombstoneLoad: mc.config.getBoolean(throwOnTombstoneLoadKey),\n\t});\n\tevent.sweepFlags = JSON.stringify({\n\t\tEnableSweepFlag: mc.config.getBoolean(runSweepKey),\n\t});\n\n\tmc.logger.sendTelemetryEvent(event, error);\n}\n"]}
1
+ {"version":3,"file":"gcTelemetry.js","sourceRoot":"","sources":["../../src/gc/gcTelemetry.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,qEAKyC;AAEzC,mDASyB;AAEzB,2CAAgD;AAsChD;;;;;;;;GAQG;AACH,MAAa,kBAAkB;IAO9B,YACkB,EAAqB,EACrB,OAGhB,EACgB,kBAA2B,EAC3B,6BAAsC,EACtC,uBAAiD,EACjD,WAA2C,EAC3C,mBAEwB,EACxB,kBAE0B;QAd1B,OAAE,GAAF,EAAE,CAAmB;QACrB,YAAO,GAAP,OAAO,CAGvB;QACgB,uBAAkB,GAAlB,kBAAkB,CAAS;QAC3B,kCAA6B,GAA7B,6BAA6B,CAAS;QACtC,4BAAuB,GAAvB,uBAAuB,CAA0B;QACjD,gBAAW,GAAX,WAAW,CAAgC;QAC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;;;GAGG;AACH,SAAgB,0BAA0B,CACzC,EAAqB,EACrB,KAGC,EACD,WAA0C,EAC1C,KAAe;IAEf,KAAK,CAAC,GAAG,GAAG,IAAA,kCAAgB,EAAC,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC;IACnE,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC;QACrC,gBAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,mCAAmB,CAAC;QAC3D,qBAAqB,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,wCAAwB,CAAC;QACrE,oBAAoB,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,uCAAuB,CAAC;KACnE,CAAC,CAAC;IACH,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC;QACjC,eAAe,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,2BAAW,CAAC;KAClD,CAAC,CAAC;IAEH,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC5C,CAAC;AApBD,gEAoBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryGenericEvent } from \"@fluidframework/core-interfaces\";\nimport { IGarbageCollectionData } from \"@fluidframework/runtime-definitions\";\nimport {\n\tgenerateStack,\n\tITelemetryLoggerExt,\n\tMonitoringContext,\n\ttagCodeArtifacts,\n} from \"@fluidframework/telemetry-utils\";\nimport { ICreateContainerMetadata } from \"../summary\";\nimport {\n\tdisableSweepLogKey,\n\tGCNodeType,\n\tUnreferencedState,\n\tIGarbageCollectorConfigs,\n\tdisableTombstoneKey,\n\tthrowOnTombstoneUsageKey,\n\tthrowOnTombstoneLoadKey,\n\trunSweepKey,\n} from \"./gcDefinitions\";\nimport { UnreferencedStateTracker } from \"./gcUnreferencedStateTracker\";\nimport { tagAsCodeArtifact } from \"./gcHelpers\";\n\ntype NodeUsageType = \"Changed\" | \"Loaded\" | \"Revived\";\n\n/** Properties that are common to IUnreferencedEventProps and INodeUsageProps */\ninterface ICommonProps {\n\tusageType: NodeUsageType;\n\tcompletedGCRuns: number;\n\tisTombstoned: boolean;\n\tlastSummaryTime?: number;\n\tviaHandle?: boolean;\n}\n\n/** The event that is logged when unreferenced node is used after a certain time. */\ninterface IUnreferencedEventProps extends ICreateContainerMetadata, ICommonProps {\n\tstate: UnreferencedState;\n\tid: {\n\t\tvalue: string;\n\t\ttag: string;\n\t};\n\ttype: GCNodeType;\n\tunrefTime: number;\n\tage: number;\n\ttimeout?: number;\n\tfromId?: {\n\t\tvalue: string;\n\t\ttag: string;\n\t};\n}\n\n/** Properties passed to nodeUsed function when a node is used. */\ninterface INodeUsageProps extends ICommonProps {\n\tid: string;\n\tcurrentReferenceTimestampMs: number | undefined;\n\tpackagePath: readonly string[] | undefined;\n\tfromId?: string;\n}\n\n/**\n * Encapsulates the logic that tracks the various telemetry logged by the Garbage Collector. There are 4 types of\n * telemetry logged:\n * 1. inactiveObject telemetry - When an inactive node is used - A node that has been unreferenced for inactiveTimeoutMs.\n * 2. sweepReadyObject telemetry - When a sweep ready node is used - A node that has been unreferenced for sweepTimeoutMs.\n * 3. Tombstone telemetry - When a tombstoned node is used - A node that that has been marked as tombstone.\n * 4. Sweep / deleted telemetry - When a node is detected as sweep ready in the sweep phase.\n * 5. Unknown outbound reference telemetry - When a node is referenced but GC is not explicitly notified of it.\n */\nexport class GCTelemetryTracker {\n\t// Keeps track of unreferenced events that are logged for a node. This is used to limit the log generation to one\n\t// per event per node.\n\tprivate readonly loggedUnreferencedEvents: Set<string> = new Set();\n\t// Queue for unreferenced events that should be logged the next time GC runs.\n\tprivate pendingEventsQueue: IUnreferencedEventProps[] = [];\n\n\tconstructor(\n\t\tprivate readonly mc: MonitoringContext,\n\t\tprivate readonly configs: Pick<\n\t\t\tIGarbageCollectorConfigs,\n\t\t\t\"inactiveTimeoutMs\" | \"sweepTimeoutMs\"\n\t\t>,\n\t\tprivate readonly isSummarizerClient: boolean,\n\t\tprivate readonly gcTombstoneEnforcementAllowed: boolean,\n\t\tprivate readonly createContainerMetadata: ICreateContainerMetadata,\n\t\tprivate readonly getNodeType: (nodeId: string) => GCNodeType,\n\t\tprivate readonly getNodeStateTracker: (\n\t\t\tnodeId: string,\n\t\t) => UnreferencedStateTracker | undefined,\n\t\tprivate readonly getNodePackagePath: (\n\t\t\tnodePath: string,\n\t\t) => Promise<readonly string[] | undefined>,\n\t) {}\n\n\t/**\n\t * Returns whether an event should be logged for a node that isn't active anymore. Some scenarios where we won't log:\n\t * 1. When a DDS is changed or loaded. The corresponding data store's event will be logged instead.\n\t * 2. An event is logged only once per container instance per event per node.\n\t */\n\tprivate shouldLogNonActiveEvent(\n\t\tnodeId: string,\n\t\tnodeType: GCNodeType,\n\t\tusageType: NodeUsageType,\n\t\tnodeStateTracker: UnreferencedStateTracker,\n\t\tuniqueEventId: string,\n\t) {\n\t\tif (nodeStateTracker.state === UnreferencedState.Active) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// For sub data store (DDS) nodes, if they are changed or loaded, its data store will also be changed or loaded,\n\t\t// so skip logging to make the telemetry less noisy.\n\t\tif (nodeType === GCNodeType.SubDataStore && usageType !== \"Revived\") {\n\t\t\treturn false;\n\t\t}\n\t\tif (nodeType === GCNodeType.Other) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Called when a node is used. If the node is not active, log an event indicating object is used when its not active.\n\t */\n\tpublic nodeUsed(nodeUsageProps: INodeUsageProps) {\n\t\t// If there is no reference timestamp to work with, no ops have been processed after creation. If so, skip\n\t\t// logging as nothing interesting would have happened worth logging.\n\t\t// If the node is not unreferenced, skip logging.\n\t\tconst nodeStateTracker = this.getNodeStateTracker(nodeUsageProps.id);\n\t\tif (!nodeStateTracker || nodeUsageProps.currentReferenceTimestampMs === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We log these events once per event per node. A unique id is generated by joining node state (inactive / sweep ready),\n\t\t// node's id and usage (loaded / changed / revived).\n\t\tconst uniqueEventId = `${nodeStateTracker.state}-${nodeUsageProps.id}-${nodeUsageProps.usageType}`;\n\t\tconst nodeType = this.getNodeType(nodeUsageProps.id);\n\t\tif (\n\t\t\t!this.shouldLogNonActiveEvent(\n\t\t\t\tnodeUsageProps.id,\n\t\t\t\tnodeType,\n\t\t\t\tnodeUsageProps.usageType,\n\t\t\t\tnodeStateTracker,\n\t\t\t\tuniqueEventId,\n\t\t\t)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Add the unique event id so that we don't generate a log for this event again in this session..\n\t\tthis.loggedUnreferencedEvents.add(uniqueEventId);\n\n\t\tconst state = nodeStateTracker.state;\n\t\tconst { usageType, currentReferenceTimestampMs, packagePath, id, fromId, ...propsToLog } =\n\t\t\tnodeUsageProps;\n\t\tconst eventProps: Omit<IUnreferencedEventProps, \"state\" | \"usageType\"> = {\n\t\t\ttype: nodeType,\n\t\t\tunrefTime: nodeStateTracker.unreferencedTimestampMs,\n\t\t\tage:\n\t\t\t\tnodeUsageProps.currentReferenceTimestampMs -\n\t\t\t\tnodeStateTracker.unreferencedTimestampMs,\n\t\t\ttimeout:\n\t\t\t\tstate === UnreferencedState.Inactive\n\t\t\t\t\t? this.configs.inactiveTimeoutMs\n\t\t\t\t\t: this.configs.sweepTimeoutMs,\n\t\t\t...tagCodeArtifacts({ id, fromId }),\n\t\t\t...propsToLog,\n\t\t\t...this.createContainerMetadata,\n\t\t};\n\n\t\t// This will log the following events:\n\t\t// GC_Tombstone_DataStore_Revived, GC_Tombstone_SubDataStore_Revived, GC_Tombstone_Blob_Revived\n\t\tif (nodeUsageProps.usageType === \"Revived\" && nodeUsageProps.isTombstoned) {\n\t\t\tsendGCUnexpectedUsageEvent(\n\t\t\t\tthis.mc,\n\t\t\t\t{\n\t\t\t\t\teventName: `GC_Tombstone_${nodeType}_Revived`,\n\t\t\t\t\tcategory: \"generic\",\n\t\t\t\t\turl: tagAsCodeArtifact(id),\n\t\t\t\t\tgcTombstoneEnforcementAllowed: this.gcTombstoneEnforcementAllowed,\n\t\t\t\t},\n\t\t\t\tundefined /* packagePath */,\n\t\t\t);\n\t\t}\n\n\t\t// For summarizer client, queue the event so it is logged the next time GC runs if the event is still valid.\n\t\t// For non-summarizer client, log the event now since GC won't run on it. This may result in false positives\n\t\t// but it's a good signal nonetheless and we can consume it with a grain of salt.\n\t\t// Inactive errors are usages of Objects that are unreferenced for at least a period of 7 days.\n\t\t// SweepReady errors are usages of Objects that will be deleted by GC Sweep!\n\t\tif (this.isSummarizerClient) {\n\t\t\tthis.pendingEventsQueue.push({\n\t\t\t\t...eventProps,\n\t\t\t\tusageType: nodeUsageProps.usageType,\n\t\t\t\tstate,\n\t\t\t});\n\t\t} else {\n\t\t\t// For non-summarizer clients, only log \"Loaded\" type events since these objects may not be loaded in the\n\t\t\t// summarizer clients if they are based off of user actions (such as scrolling to content for these objects)\n\t\t\t// Events generated:\n\t\t\t// InactiveObject_Loaded, SweepReadyObject_Loaded\n\t\t\tif (nodeUsageProps.usageType === \"Loaded\") {\n\t\t\t\tconst { id: taggedId, fromId: taggedFromId, ...otherProps } = eventProps;\n\t\t\t\tconst event = {\n\t\t\t\t\teventName: `${state}Object_${nodeUsageProps.usageType}`,\n\t\t\t\t\tpkg: tagCodeArtifacts({ pkg: nodeUsageProps.packagePath?.join(\"/\") }).pkg,\n\t\t\t\t\tstack: generateStack(),\n\t\t\t\t\tid: taggedId,\n\t\t\t\t\tfromId: taggedFromId,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t...otherProps,\n\t\t\t\t\t}),\n\t\t\t\t};\n\n\t\t\t\t// Do not log the inactive object x events as error events as they are not the best signal for\n\t\t\t\t// detecting something wrong with GC either from the partner or from the runtime itself.\n\t\t\t\tif (state === UnreferencedState.Inactive) {\n\t\t\t\t\tthis.mc.logger.sendTelemetryEvent(event);\n\t\t\t\t} else {\n\t\t\t\t\tthis.mc.logger.sendErrorEvent(event);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Log all new references or outbound routes in the current graph that haven't been explicitly notified to GC.\n\t * The principle is that every new reference or outbound route must be notified to GC via the\n\t * addedOutboundReference method. It it hasn't, its a bug and we want to identify these scenarios.\n\t *\n\t * In more simple terms:\n\t * Missing Explicit References = Current References - Previous References - Explicitly Added References;\n\t *\n\t * @param currentGCData - The GC data (reference graph) from the current GC run.\n\t * @param previousGCData - The GC data (reference graph) from the previous GC run.\n\t * @param explicitReferences - New references added explicity between the previous and the current run.\n\t */\n\tpublic logIfMissingExplicitReferences(\n\t\tcurrentGCData: IGarbageCollectionData,\n\t\tpreviousGCData: IGarbageCollectionData,\n\t\texplicitReferences: Map<string, string[]>,\n\t\tlogger: ITelemetryLoggerExt,\n\t) {\n\t\tfor (const [nodeId, currentOutboundRoutes] of Object.entries(currentGCData.gcNodes)) {\n\t\t\tconst previousRoutes = previousGCData.gcNodes[nodeId] ?? [];\n\t\t\tconst explicitRoutes = explicitReferences.get(nodeId) ?? [];\n\n\t\t\t/**\n\t\t\t * 1. For routes in the current GC data, routes that were not present in previous GC data and did not have\n\t\t\t * explicit references should be added to missing explicit routes list.\n\t\t\t * 2. Only include data store and blob routes since GC only works for these two.\n\t\t\t * Note: Due to a bug with de-duped blobs, only adding data store routes for now.\n\t\t\t * 3. Ignore DDS routes to their parent datastores since those were added implicitly. So, there won't be\n\t\t\t * explicit routes to them.\n\t\t\t */\n\t\t\tconst missingExplicitRoutes: string[] = [];\n\t\t\tfor (const route of currentOutboundRoutes) {\n\t\t\t\tconst nodeType = this.getNodeType(route);\n\t\t\t\tif (\n\t\t\t\t\t(nodeType === GCNodeType.DataStore || nodeType === GCNodeType.Blob) &&\n\t\t\t\t\t!nodeId.startsWith(route) &&\n\t\t\t\t\t!previousRoutes.includes(route) &&\n\t\t\t\t\t!explicitRoutes.includes(route)\n\t\t\t\t) {\n\t\t\t\t\tmissingExplicitRoutes.push(route);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (missingExplicitRoutes.length > 0) {\n\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\teventName: \"gcUnknownOutboundReferences\",\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tid: nodeId,\n\t\t\t\t\t\troutes: JSON.stringify(missingExplicitRoutes),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Log events that are pending in pendingEventsQueue. This is called after GC runs in the summarizer client\n\t * so that the state of an unreferenced node is updated.\n\t */\n\tpublic async logPendingEvents(logger: ITelemetryLoggerExt) {\n\t\t// Events sent come only from the summarizer client. In between summaries, events are pushed to a queue and at\n\t\t// summary time they are then logged.\n\t\t// Events generated:\n\t\t// InactiveObject_Loaded, InactiveObject_Changed, InactiveObject_Revived\n\t\t// SweepReadyObject_Loaded, SweepReadyObject_Changed, SweepReadyObject_Revived\n\t\tfor (const eventProps of this.pendingEventsQueue) {\n\t\t\tconst { usageType, state, id, fromId, ...propsToLog } = eventProps;\n\t\t\t/**\n\t\t\t * Revived event is logged only if the node is active. If the node is not active, the reference to it was\n\t\t\t * from another unreferenced node and this scenario is not interesting to log.\n\t\t\t * Loaded and Changed events are logged only if the node is not active. If the node is active, it was\n\t\t\t * revived and a Revived event will be logged for it.\n\t\t\t */\n\t\t\tconst nodeStateTracker = this.getNodeStateTracker(eventProps.id.value);\n\t\t\tconst active =\n\t\t\t\tnodeStateTracker === undefined ||\n\t\t\t\tnodeStateTracker.state === UnreferencedState.Active;\n\t\t\tif ((usageType === \"Revived\") === active) {\n\t\t\t\tconst pkg = await this.getNodePackagePath(eventProps.id.value);\n\t\t\t\tconst fromPkg = eventProps.fromId\n\t\t\t\t\t? await this.getNodePackagePath(eventProps.fromId.value)\n\t\t\t\t\t: undefined;\n\t\t\t\tconst event = {\n\t\t\t\t\teventName: `${state}Object_${usageType}`,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t...propsToLog,\n\t\t\t\t\t}),\n\t\t\t\t\tid,\n\t\t\t\t\tfromId,\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tpkg: pkg?.join(\"/\"),\n\t\t\t\t\t\tfromPkg: fromPkg?.join(\"/\"),\n\t\t\t\t\t}),\n\t\t\t\t};\n\n\t\t\t\tif (state === UnreferencedState.Inactive) {\n\t\t\t\t\tlogger.sendTelemetryEvent(event);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.sendErrorEvent(event);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.pendingEventsQueue = [];\n\t}\n\n\t/**\n\t * For nodes that are ready to sweep, log an event for now. Until we start running sweep which deletes objects,\n\t * this will give us a view into how much deleted content a container has.\n\t */\n\tpublic logSweepEvents(\n\t\tlogger: ITelemetryLoggerExt,\n\t\tcurrentReferenceTimestampMs: number,\n\t\tunreferencedNodesState: Map<string, UnreferencedStateTracker>,\n\t\tcompletedGCRuns: number,\n\t\tlastSummaryTime?: number,\n\t) {\n\t\tif (\n\t\t\tthis.mc.config.getBoolean(disableSweepLogKey) === true ||\n\t\t\tthis.configs.sweepTimeoutMs === undefined\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst deletedNodeIds: string[] = [];\n\t\tfor (const [nodeId, nodeStateTracker] of unreferencedNodesState) {\n\t\t\tif (nodeStateTracker.state !== UnreferencedState.SweepReady) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nodeType = this.getNodeType(nodeId);\n\t\t\tif (nodeType !== GCNodeType.DataStore && nodeType !== GCNodeType.Blob) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Log deleted event for each node only once to reduce noise in telemetry.\n\t\t\tconst uniqueEventId = `Deleted-${nodeId}`;\n\t\t\tif (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.loggedUnreferencedEvents.add(uniqueEventId);\n\t\t\tdeletedNodeIds.push(nodeId);\n\t\t}\n\n\t\tif (deletedNodeIds.length > 0) {\n\t\t\tlogger.sendTelemetryEvent({\n\t\t\t\teventName: \"GC_SweepReadyObjects_Delete\",\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\ttimeout: this.configs.sweepTimeoutMs,\n\t\t\t\t\tcompletedGCRuns,\n\t\t\t\t\tlastSummaryTime,\n\t\t\t\t\t...this.createContainerMetadata,\n\t\t\t\t}),\n\t\t\t\t...tagCodeArtifacts({ id: JSON.stringify(deletedNodeIds) }),\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Consolidates info / logic for logging when we encounter unexpected usage of GC'd objects. For example, when a\n * tombstoned or deleted object is loaded.\n */\nexport function sendGCUnexpectedUsageEvent(\n\tmc: MonitoringContext,\n\tevent: ITelemetryGenericEvent & {\n\t\tcategory: \"error\" | \"generic\";\n\t\tgcTombstoneEnforcementAllowed: boolean | undefined;\n\t},\n\tpackagePath: readonly string[] | undefined,\n\terror?: unknown,\n) {\n\tevent.pkg = tagCodeArtifacts({ pkg: packagePath?.join(\"/\") })?.pkg;\n\tevent.tombstoneFlags = JSON.stringify({\n\t\tDisableTombstone: mc.config.getBoolean(disableTombstoneKey),\n\t\tThrowOnTombstoneUsage: mc.config.getBoolean(throwOnTombstoneUsageKey),\n\t\tThrowOnTombstoneLoad: mc.config.getBoolean(throwOnTombstoneLoadKey),\n\t});\n\tevent.sweepFlags = JSON.stringify({\n\t\tEnableSweepFlag: mc.config.getBoolean(runSweepKey),\n\t});\n\n\tmc.logger.sendTelemetryEvent(event, error);\n}\n"]}
@@ -2,9 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
6
5
  import { IIdCompressor, IIdCompressorCore, LocalCompressedId, FinalCompressedId, SessionSpaceCompressedId, StableId, OpSpaceCompressedId, SessionId, CompressedId } from "@fluidframework/runtime-definitions";
7
6
  import type { IdCreationRange, SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession, VersionedSerializedIdCompressor } from "@fluidframework/runtime-definitions";
7
+ import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
8
8
  /**
9
9
  * Roughly equates to a minimum of 1M sessions before we start allocating 64 bit IDs.
10
10
  * This value must *NOT* change without careful consideration to compatibility.
@@ -23,7 +23,6 @@ export declare function isLocalId(id: CompressedId): id is LocalCompressedId;
23
23
  */
24
24
  export declare class IdCompressor implements IIdCompressorCore, IIdCompressor {
25
25
  readonly localSessionId: SessionId;
26
- private readonly logger?;
27
26
  /**
28
27
  * Max allowed cluster size
29
28
  */
@@ -99,11 +98,12 @@ export declare class IdCompressor implements IIdCompressorCore, IIdCompressor {
99
98
  * Can be searched in O(log n) to determine clusters for any final ID.
100
99
  */
101
100
  private readonly finalIdToCluster;
101
+ private readonly logger;
102
102
  /**
103
103
  * @param localSessionId - the `IdCompressor`'s current local session ID.
104
104
  * {@link generateStableId}.
105
105
  */
106
- constructor(localSessionId: SessionId, logger?: ITelemetryLoggerExt | undefined);
106
+ constructor(localSessionId: SessionId, logger?: ITelemetryBaseLogger);
107
107
  /**
108
108
  * Creates a session object for the supplied ID.
109
109
  * Must only be called once per ID.
@@ -1 +1 @@
1
- {"version":3,"file":"idCompressor.d.ts","sourceRoot":"","sources":["../../src/id-compressor/idCompressor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,EACN,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,EACxB,QAAQ,EACR,mBAAmB,EACnB,SAAS,EACT,YAAY,EACZ,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