@fluidframework/odsp-driver 0.53.0 → 0.54.0-47413

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.
@@ -5,7 +5,11 @@
5
5
 
6
6
  import { ITelemetryLogger } from "@fluidframework/common-definitions";
7
7
  import { performance } from "@fluidframework/common-utils";
8
- import { ChildLogger, TelemetryLogger } from "@fluidframework/telemetry-utils";
8
+ import {
9
+ ChildLogger,
10
+ loggerToMonitoringContext,
11
+ MonitoringContext,
12
+ } from "@fluidframework/telemetry-utils";
9
13
  import {
10
14
  IDocumentDeltaConnection,
11
15
  IDocumentDeltaStorageService,
@@ -40,18 +44,6 @@ import { EpochTracker } from "./epochTracker";
40
44
  import { OpsCache } from "./opsCaching";
41
45
  import { RetryErrorsStorageAdapter } from "./retryErrorsStorageAdapter";
42
46
 
43
- // Gate that when set to "1", instructs to fetch the binary format snapshot from the spo.
44
- function gatesBinaryFormatSnapshot() {
45
- try {
46
- if (typeof localStorage === "object" && localStorage !== null) {
47
- if (localStorage.binaryFormatSnapshot === "1") {
48
- return true;
49
- }
50
- }
51
- } catch (e) {}
52
- return false;
53
- }
54
-
55
47
  /**
56
48
  * The DocumentService manages the Socket.IO connection and manages routing requests to connected
57
49
  * clients
@@ -99,7 +91,7 @@ export class OdspDocumentService implements IDocumentService {
99
91
 
100
92
  private storageManager?: OdspDocumentStorageService;
101
93
 
102
- private readonly logger: TelemetryLogger;
94
+ private readonly mc: MonitoringContext;
103
95
 
104
96
  private readonly joinSessionKey: string;
105
97
 
@@ -140,16 +132,18 @@ export class OdspDocumentService implements IDocumentService {
140
132
  };
141
133
 
142
134
  this.joinSessionKey = `${this.odspResolvedUrl.hashedDocumentId}/joinsession`;
143
- this.logger = ChildLogger.create(logger,
135
+ this.mc = loggerToMonitoringContext(
136
+ ChildLogger.create(logger,
144
137
  undefined,
145
138
  {
146
139
  all: {
147
140
  odc: isOdcOrigin(new URL(this.odspResolvedUrl.endpoints.snapshotStorageUrl).origin),
148
141
  },
149
- });
142
+ }));
150
143
 
151
144
  this.hostPolicy = hostPolicy;
152
- this.hostPolicy.fetchBinarySnapshotFormat ??= gatesBinaryFormatSnapshot();
145
+ this.hostPolicy.fetchBinarySnapshotFormat ??=
146
+ this.mc.config.getBoolean("Fluid.Driver.Odsp.binaryFormatSnapshot");
153
147
  if (this.odspResolvedUrl.summarizer) {
154
148
  this.hostPolicy = { ...this.hostPolicy, summarizerClient: true };
155
149
  }
@@ -172,7 +166,7 @@ export class OdspDocumentService implements IDocumentService {
172
166
  this.storageManager = new OdspDocumentStorageService(
173
167
  this.odspResolvedUrl,
174
168
  this.getStorageToken,
175
- this.logger,
169
+ this.mc.logger,
176
170
  true,
177
171
  this.cache,
178
172
  this.hostPolicy,
@@ -187,7 +181,7 @@ export class OdspDocumentService implements IDocumentService {
187
181
  );
188
182
  }
189
183
 
190
- return new RetryErrorsStorageAdapter(this.storageManager, this.logger);
184
+ return new RetryErrorsStorageAdapter(this.storageManager, this.mc.logger);
191
185
  }
192
186
 
193
187
  /**
@@ -201,7 +195,7 @@ export class OdspDocumentService implements IDocumentService {
201
195
  this.odspResolvedUrl.endpoints.deltaStorageUrl,
202
196
  this.getStorageToken,
203
197
  this.epochTracker,
204
- this.logger,
198
+ this.mc.logger,
205
199
  );
206
200
 
207
201
  // batch size, please see issue #5211 for data around batch sizing
@@ -209,7 +203,7 @@ export class OdspDocumentService implements IDocumentService {
209
203
  const concurrency = this.hostPolicy.concurrentOpsBatches ?? 1;
210
204
  return new OdspDeltaStorageWithCache(
211
205
  snapshotOps,
212
- this.logger,
206
+ this.mc.logger,
213
207
  batchSize,
214
208
  concurrency,
215
209
  async (from, to, telemetryProps, fetchReason) => service.get(from, to, telemetryProps, fetchReason),
@@ -308,7 +302,7 @@ export class OdspDocumentService implements IDocumentService {
308
302
  this.odspResolvedUrl,
309
303
  "opStream/joinSession",
310
304
  "POST",
311
- this.logger,
305
+ this.mc.logger,
312
306
  this.getStorageToken,
313
307
  this.epochTracker,
314
308
  requestSocketToken,
@@ -348,7 +342,7 @@ export class OdspDocumentService implements IDocumentService {
348
342
  io,
349
343
  client,
350
344
  webSocketUrl,
351
- this.logger,
345
+ this.mc.logger,
352
346
  60000,
353
347
  this.epochTracker,
354
348
  this.socketReferenceKeyPrefix,
@@ -358,7 +352,7 @@ export class OdspDocumentService implements IDocumentService {
358
352
  // Given that most reconnects result in reusing socket and happen very quickly,
359
353
  // report event only if it took longer than threshold.
360
354
  if (duration >= 2000) {
361
- this.logger.sendPerformanceEvent({
355
+ this.mc.logger.sendPerformanceEvent({
362
356
  eventName: "ConnectionSuccess",
363
357
  duration,
364
358
  });
@@ -395,7 +389,7 @@ export class OdspDocumentService implements IDocumentService {
395
389
  };
396
390
  this._opsCache = new OpsCache(
397
391
  seqNumber,
398
- this.logger,
392
+ this.mc.logger,
399
393
  // ICache
400
394
  {
401
395
  write: async (key: string, opsData: string) => {
@@ -9,7 +9,7 @@ import { ISummaryContext } from "@fluidframework/driver-definitions";
9
9
  import { getGitType } from "@fluidframework/protocol-base";
10
10
  import * as api from "@fluidframework/protocol-definitions";
11
11
  import { InstrumentedStorageTokenFetcher } from "@fluidframework/odsp-driver-definitions";
12
- import { PerformanceEvent } from "@fluidframework/telemetry-utils";
12
+ import { loggerToMonitoringContext, MonitoringContext, PerformanceEvent } from "@fluidframework/telemetry-utils";
13
13
  import {
14
14
  IOdspSummaryPayload,
15
15
  IWriteSummaryResponse,
@@ -24,23 +24,6 @@ import { getWithRetryForTokenRefresh } from "./odspUtils";
24
24
 
25
25
  /* eslint-disable max-len */
26
26
 
27
- // Gate that when flipped, instructs to mark unreferenced nodes as such in the summary sent to SPO.
28
- function gatesMarkUnreferencedNodes() {
29
- try {
30
- // Leave override for testing purposes
31
- if (typeof localStorage === "object" && localStorage !== null) {
32
- if (localStorage.FluidMarkUnreferencedNodes === "1") {
33
- return true;
34
- }
35
- if (localStorage.FluidMarkUnreferencedNodes === "0") {
36
- return false;
37
- }
38
- }
39
- } catch (e) {}
40
-
41
- return true;
42
- }
43
-
44
27
  /**
45
28
  * This class manages a summary upload. When it receives a call to upload summary, it converts the summary tree into
46
29
  * a snapshot tree and then uploads that to the server.
@@ -48,20 +31,22 @@ function gatesMarkUnreferencedNodes() {
48
31
  export class OdspSummaryUploadManager {
49
32
  // Last proposed handle of the uploaded app summary.
50
33
  private lastSummaryProposalHandle: string | undefined;
34
+ private readonly mc: MonitoringContext;
51
35
 
52
36
  constructor(
53
37
  private readonly snapshotUrl: string,
54
38
  private readonly getStorageToken: InstrumentedStorageTokenFetcher,
55
- private readonly logger: ITelemetryLogger,
39
+ logger: ITelemetryLogger,
56
40
  private readonly epochTracker: EpochTracker,
57
41
  ) {
42
+ this.mc = loggerToMonitoringContext(logger);
58
43
  }
59
44
 
60
45
  public async writeSummaryTree(tree: api.ISummaryTree, context: ISummaryContext) {
61
46
  // If the last proposed handle is not the proposed handle of the acked summary(could happen when the last summary get nacked),
62
47
  // then re-initialize the caches with the previous ones else just update the previous caches with the caches from acked summary.
63
48
  if (context.proposalHandle !== this.lastSummaryProposalHandle) {
64
- this.logger.sendTelemetryEvent({
49
+ this.mc.logger.sendTelemetryEvent({
65
50
  eventName: "LastSummaryProposedHandleMismatch",
66
51
  ackedSummaryProposedHandle: context.proposalHandle,
67
52
  lastSummaryProposalHandle: this.lastSummaryProposalHandle,
@@ -107,7 +92,7 @@ export class OdspSummaryUploadManager {
107
92
 
108
93
  const postBody = JSON.stringify(snapshot);
109
94
 
110
- return PerformanceEvent.timedExecAsync(this.logger,
95
+ return PerformanceEvent.timedExecAsync(this.mc.logger,
111
96
  {
112
97
  eventName: "uploadSummary",
113
98
  attempt: options.refresh ? 2 : 1,
@@ -145,7 +130,7 @@ export class OdspSummaryUploadManager {
145
130
  tree: api.ISummaryTree,
146
131
  rootNodeName: string,
147
132
  path: string = "",
148
- markUnreferencedNodes: boolean = gatesMarkUnreferencedNodes(),
133
+ markUnreferencedNodes: boolean = this.mc.config.getBoolean("Fluid.Driver.Odsp.MarkUnreferencedNodes") ?? true,
149
134
  ) {
150
135
  const snapshotTree: IOdspSummaryTree = {
151
136
  type: "tree",
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/odsp-driver";
9
- export const pkgVersion = "0.53.0";
9
+ export const pkgVersion = "0.54.0-47413";
package/src/vroom.ts CHANGED
@@ -88,11 +88,16 @@ export async function fetchJoinSession(
88
88
  logger,
89
89
  );
90
90
 
91
+ const socketUrl = response.content.deltaStreamSocketUrl;
92
+ // expecting socketUrl to be something like https://{hostName}/...
93
+ const webSocketHostName = socketUrl.split("/")[2];
94
+
91
95
  // TODO SPO-specific telemetry
92
96
  event.end({
93
97
  ...response.commonSpoHeaders,
94
98
  // pushV2 websocket urls will contain pushf
95
- pushv2: response.content.deltaStreamSocketUrl.includes("pushf"),
99
+ pushv2: socketUrl.includes("pushf"),
100
+ webSocketHostName,
96
101
  });
97
102
 
98
103
  if (response.content.runtimeTenantId && !response.content.tenantId) {