message: Add telemetry for size of uploaded snapshot, number of blobs and number of de-dupped blobs
diff: @@ -784,7 +784,7 @@ export class OdspDocumentStorageService implements IDocumentStorageService {
  await Promise.all(this.blobsCachePendingHashes.values());
  // This cache is associated with mapping sha to path for currently generated summary.
  const blobsShaToPathCacheLatest: Map<string, string> = new Map();
  - const snapshotTree = await this.convertSummaryToSnapshotTree(parentHandle, tree, blobsShaToPathCacheLatest);
  + const { snapshotTree, reusedBlobs, blobs } = await this.convertSummaryToSnapshotTree(parentHandle, tree, blobsShaToPathCacheLatest);
  const snapshot: ISnapshotRequest = {
  entries: snapshotTree.entries!,
  @@ -807,6 +807,9 @@ export class OdspDocumentStorageService implements IDocumentStorageService {
  attempt: options.refresh ? 2 : 1,
  hasClaims: !!options.claims,
  headers: Object.keys(headers).length !== 0 ? true : undefined,
  + blobs,
  + reusedBlobs,
  + size: postBody.length,
  },
  async () => {
  const response = await fetchHelper<ISnapshotResponse>(
  @@ -830,11 +833,14 @@ export class OdspDocumentStorageService implements IDocumentStorageService {
  blobsShaToPathCacheLatest: Map<string, string>,
  depth: number = 0,
  path: string = "",
  - ): Promise<ISnapshotTree> {
  + ) {
  const snapshotTree: ISnapshotTree = {
  entries: [],
  }!;
  + let reusedBlobs = 0;
  + let blobs = 0;
  +
  const keys = Object.keys(tree.tree);
  for (const key of keys) {
  const summaryObject = tree.tree[key];
  @@ -844,12 +850,15 @@ export class OdspDocumentStorageService implements IDocumentStorageService {
  switch (summaryObject.type) {
  case api.SummaryType.Tree: {
  - value = await this.convertSummaryToSnapshotTree(
  + const result = await this.convertSummaryToSnapshotTree(
  parentHandle,
  summaryObject,
  blobsShaToPathCacheLatest,
  depth + 1,
  `${path}/${key}`);
  + value = result.snapshotTree;
  + reusedBlobs += result.reusedBlobs;
  + blobs += result.blobs;
  break;
  }
  case api.SummaryType.Blob: {
  @@ -864,6 +873,7 @@ export class OdspDocumentStorageService implements IDocumentStorageService {
  // If the cache has the hash of the blob and handle of last summary is also present, then use that
  // to generate complete path for the given blob.
  if (!completePath || !this.lastSummaryHandle) {
  + blobs++;
  value = {
  content,
  encoding,
  @@ -871,6 +881,7 @@ export class OdspDocumentStorageService implements IDocumentStorageService {
  completePath = `/.app${path}/${key}`;
  blobsShaToPathCacheLatest.set(hash, completePath);
  } else {
  + reusedBlobs++;
  id = `${this.lastSummaryHandle}${completePath}`;
  }
  break;
  @@ -924,7 +935,7 @@ export class OdspDocumentStorageService implements IDocumentStorageService {
  snapshotTree.entries!.push(entry);
  }
  - return snapshotTree;
  + return { snapshotTree, blobs, reusedBlobs };
  }
  }
  