@fluidframework/fluid-telemetry 2.0.0-rc.4.0.6 → 2.0.0-rc.5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/api-extractor/api-extractor-lint-beta.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-beta.esm.json +5 -0
- package/api-extractor/api-extractor-lint-bundle.json +5 -0
- package/api-extractor/api-extractor-lint-legacy.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-legacy.esm.json +5 -0
- package/api-extractor/api-extractor-lint-public.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-public.esm.json +5 -0
- package/api-extractor.json +1 -1
- package/api-report/fluid-telemetry.alpha.api.md +75 -0
- package/api-report/{fluid-telemetry.api.md → fluid-telemetry.beta.api.md} +2 -2
- package/api-report/fluid-telemetry.public.api.md +13 -0
- package/biome.jsonc +4 -0
- package/dist/app-insights/appInsightsTelemetryConsumer.d.ts +1 -1
- package/dist/app-insights/appInsightsTelemetryConsumer.d.ts.map +1 -1
- package/dist/app-insights/appInsightsTelemetryConsumer.js.map +1 -1
- package/dist/container/containerTelemetry.d.ts +2 -2
- package/dist/container/containerTelemetry.d.ts.map +1 -1
- package/dist/container/containerTelemetry.js.map +1 -1
- package/dist/container/telemetryManager.d.ts +1 -1
- package/dist/container/telemetryManager.d.ts.map +1 -1
- package/dist/container/telemetryManager.js.map +1 -1
- package/dist/container/telemetryProducer.d.ts +1 -1
- package/dist/container/telemetryProducer.d.ts.map +1 -1
- package/dist/container/telemetryProducer.js +1 -1
- package/dist/container/telemetryProducer.js.map +1 -1
- package/dist/factory/index.d.ts +1 -1
- package/dist/factory/index.d.ts.map +1 -1
- package/dist/factory/index.js.map +1 -1
- package/dist/legacy.d.ts +1 -15
- package/lib/app-insights/appInsightsTelemetryConsumer.d.ts +1 -1
- package/lib/app-insights/appInsightsTelemetryConsumer.d.ts.map +1 -1
- package/lib/app-insights/appInsightsTelemetryConsumer.js.map +1 -1
- package/lib/container/containerTelemetry.d.ts +2 -2
- package/lib/container/containerTelemetry.d.ts.map +1 -1
- package/lib/container/containerTelemetry.js.map +1 -1
- package/lib/container/telemetryManager.d.ts +1 -1
- package/lib/container/telemetryManager.d.ts.map +1 -1
- package/lib/container/telemetryManager.js.map +1 -1
- package/lib/container/telemetryProducer.d.ts +1 -1
- package/lib/container/telemetryProducer.d.ts.map +1 -1
- package/lib/container/telemetryProducer.js +1 -1
- package/lib/container/telemetryProducer.js.map +1 -1
- package/lib/factory/index.d.ts +1 -1
- package/lib/factory/index.d.ts.map +1 -1
- package/lib/factory/index.js +1 -1
- package/lib/factory/index.js.map +1 -1
- package/lib/legacy.d.ts +1 -15
- package/lib/test/containerTelemetry.spec.js +16 -19
- package/lib/test/containerTelemetry.spec.js.map +1 -1
- package/lib/test/containerTelemetryEndToEnd.spec.realsvc.d.ts +6 -0
- package/lib/test/containerTelemetryEndToEnd.spec.realsvc.d.ts.map +1 -0
- package/lib/test/containerTelemetryEndToEnd.spec.realsvc.js +160 -0
- package/lib/test/containerTelemetryEndToEnd.spec.realsvc.js.map +1 -0
- package/lib/tsdoc-metadata.json +1 -1
- package/package.json +44 -16
- package/src/app-insights/appInsightsTelemetryConsumer.ts +2 -1
- package/src/container/containerTelemetry.ts +3 -2
- package/src/container/telemetryManager.ts +7 -5
- package/src/container/telemetryProducer.ts +8 -8
- package/src/factory/index.ts +6 -2
- package/tsconfig.json +1 -0
- package/tsdoc.json +4 -0
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { v4 as uuid } from "uuid";
|
|
6
|
-
import { ContainerTelemetryEventNames, } from "./containerTelemetry.js";
|
|
7
6
|
import { IFluidContainerSystemEventNames, } from "./containerSystemEvents.js";
|
|
7
|
+
import { ContainerTelemetryEventNames, } from "./containerTelemetry.js";
|
|
8
8
|
/**
|
|
9
9
|
* This class produces {@link IContainerTelemetry} from raw container system events {@link @fluidframework/fluid-static#IFluidContainerEvents}.
|
|
10
10
|
* The class contains different helper methods for simplifying and standardizing logic for adding additional information necessary
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetryProducer.js","sourceRoot":"","sources":["../../src/container/telemetryProducer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"telemetryProducer.js","sourceRoot":"","sources":["../../src/container/telemetryProducer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAIlC,OAAO,EAEN,+BAA+B,GAC/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACN,4BAA4B,GAI5B,MAAM,yBAAyB,CAAC;AAEjC;;;;GAIG;AACH,MAAM,OAAO,+BAA+B;IAM3C,YAAoC,WAAmB;QAAnB,gBAAW,GAAX,WAAW,CAAQ;QALvD;;WAEG;QACc,wBAAmB,GAAG,IAAI,EAAE,CAAC;QAyBvC,8BAAyB,GAAG,GAAoB,EAAE;YACxD,OAAO;gBACN,SAAS,EAAE,oCAAoC;gBAC/C,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;aACf,CAAC;QACjC,CAAC,CAAC;QAEe,kCAA6B,GAAG,CAChD,SAAsC,EAChB,EAAE;YACxB,OAAO;gBACN,SAAS;gBACT,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;aACf,CAAC;QACjC,CAAC,CAAC;QAEe,4BAAuB,GAAG,CAAC,OAE3C,EAA8B,EAAE;YAChC,MAAM,SAAS,GAA+B;gBAC7C,SAAS,EAAE,4BAA4B,CAAC,QAAQ;gBAChD,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;aAC7C,CAAC;YACF,IAAI,OAAO,EAAE,KAAK,KAAK,SAAS,EAAE,CAAC;gBAClC,SAAS,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;YACjC,CAAC;YACD,OAAO,SAAS,CAAC;QAClB,CAAC,CAAC;IArDwD,CAAC;IAEpD,sBAAsB,CAC5B,SAAyC,EACzC,OAAiB;QAEjB,QAAQ,SAAS,EAAE,CAAC;YACnB,KAAK,+BAA+B,CAAC,SAAS,CAAC,CAAC,CAAC;gBAChD,OAAO,IAAI,CAAC,6BAA6B,CAAC,4BAA4B,CAAC,SAAS,CAAC,CAAC;YACnF,CAAC;YACD,KAAK,+BAA+B,CAAC,YAAY,CAAC,CAAC,CAAC;gBACnD,OAAO,IAAI,CAAC,6BAA6B,CAAC,4BAA4B,CAAC,YAAY,CAAC,CAAC;YACtF,CAAC;YACD,KAAK,+BAA+B,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAC/C,MAAM,YAAY,GAAG,OAA8C,CAAC;gBACpE,OAAO,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;YACnD,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACT,MAAM;YACP,CAAC;QACF,CAAC;IACF,CAAC;CAiCD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport { v4 as uuid } from \"uuid\";\n\nimport type { IFluidTelemetry } from \"../index.js\";\n\nimport {\n\ttype IFluidContainerSystemEventName,\n\tIFluidContainerSystemEventNames,\n} from \"./containerSystemEvents.js\";\nimport {\n\tContainerTelemetryEventNames,\n\ttype ContainerTelemetryEventName,\n\ttype IContainerTelemetry,\n\ttype ContainerDisposedTelemetry,\n} from \"./containerTelemetry.js\";\n\n/**\n * This class produces {@link IContainerTelemetry} from raw container system events {@link @fluidframework/fluid-static#IFluidContainerEvents}.\n * The class contains different helper methods for simplifying and standardizing logic for adding additional information necessary\n * to produce different {@link IContainerTelemetry}.\n */\nexport class ContainerEventTelemetryProducer {\n\t/**\n\t * Unique identifier for the instance of the container that this class is generating telemetry for.\n\t */\n\tprivate readonly containerInstanceId = uuid();\n\n\tpublic constructor(private readonly containerId: string) {}\n\n\tpublic produceFromSystemEvent(\n\t\teventName: IFluidContainerSystemEventName,\n\t\tpayload?: unknown,\n\t): IContainerTelemetry | undefined {\n\t\tswitch (eventName) {\n\t\t\tcase IFluidContainerSystemEventNames.CONNECTED: {\n\t\t\t\treturn this.produceBaseContainerTelemetry(ContainerTelemetryEventNames.CONNECTED);\n\t\t\t}\n\t\t\tcase IFluidContainerSystemEventNames.DISCONNECTED: {\n\t\t\t\treturn this.produceBaseContainerTelemetry(ContainerTelemetryEventNames.DISCONNECTED);\n\t\t\t}\n\t\t\tcase IFluidContainerSystemEventNames.DISPOSED: {\n\t\t\t\tconst typedPayload = payload as { error?: ICriticalContainerError };\n\t\t\t\treturn this.produceDiposedTelemetry(typedPayload);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic produceHeartbeatTelemetry = (): IFluidTelemetry => {\n\t\treturn {\n\t\t\teventName: \"fluidframework.container.heartbeat\",\n\t\t\tcontainerId: this.containerId,\n\t\t\tcontainerInstanceId: this.containerInstanceId,\n\t\t} as unknown as IFluidTelemetry;\n\t};\n\n\tprivate readonly produceBaseContainerTelemetry = (\n\t\teventName: ContainerTelemetryEventName,\n\t): IContainerTelemetry => {\n\t\treturn {\n\t\t\teventName,\n\t\t\tcontainerId: this.containerId,\n\t\t\tcontainerInstanceId: this.containerInstanceId,\n\t\t} satisfies IContainerTelemetry;\n\t};\n\n\tprivate readonly produceDiposedTelemetry = (payload?: {\n\t\terror?: ICriticalContainerError;\n\t}): ContainerDisposedTelemetry => {\n\t\tconst telemetry: ContainerDisposedTelemetry = {\n\t\t\teventName: ContainerTelemetryEventNames.DISPOSED,\n\t\t\tcontainerId: this.containerId,\n\t\t\tcontainerInstanceId: this.containerInstanceId,\n\t\t};\n\t\tif (payload?.error !== undefined) {\n\t\t\ttelemetry.error = payload.error;\n\t\t}\n\t\treturn telemetry;\n\t};\n}\n"]}
|
package/lib/factory/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import type { IFluidContainer } from "@fluidframework/fluid-static";
|
|
6
|
-
import {
|
|
6
|
+
import type { ITelemetryConsumer } from "../common/index.js";
|
|
7
7
|
/**
|
|
8
8
|
* Configuration object for subscribing to {@link @fluidframework/fluid-telemetry#IFluidTelemetry} and consuming said telemetry via one or more {@link ITelemetryConsumer}
|
|
9
9
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/factory/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/factory/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAM7D;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC/B;;OAEG;IACH,SAAS,EAAE,eAAe,CAAC;IAC3B;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,SAAS,EAAE,kBAAkB,EAAE,CAAC;CAChC;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,WAAY,eAAe,KAAG,IAGxD,CAAC"}
|
package/lib/factory/index.js
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 { ContainerTelemetryManager, ContainerEventTelemetryProducer } from "../container/index.js";
|
|
5
|
+
import { ContainerTelemetryManager, ContainerEventTelemetryProducer, } from "../container/index.js";
|
|
6
6
|
/**
|
|
7
7
|
* Starts creating {@link @fluidframework/fluid-telemetry#IFluidTelemetry} by transforming raw system events emitted by the specified container
|
|
8
8
|
* into said telemetry and passing it onto to the specified {@link ITelemetryConsumer}
|
package/lib/factory/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/factory/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/factory/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,yBAAyB,EACzB,+BAA+B,GAC/B,MAAM,uBAAuB,CAAC;AAyB/B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAuB,EAAQ,EAAE;IAC/D,MAAM,iBAAiB,GAAG,IAAI,+BAA+B,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAClF,IAAI,yBAAyB,CAAC,MAAM,CAAC,SAAS,EAAE,iBAAiB,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;AACtF,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidContainer } from \"@fluidframework/fluid-static\";\n\nimport type { ITelemetryConsumer } from \"../common/index.js\";\nimport {\n\tContainerTelemetryManager,\n\tContainerEventTelemetryProducer,\n} from \"../container/index.js\";\n\n/**\n * Configuration object for subscribing to {@link @fluidframework/fluid-telemetry#IFluidTelemetry} and consuming said telemetry via one or more {@link ITelemetryConsumer}\n *\n * @beta\n */\nexport interface TelemetryConfig {\n\t/**\n\t * The container whose events should be monitored, transformed into Fluid telemetry, and sent to a {@link ITelemetryConsumer}.\n\t */\n\tcontainer: IFluidContainer;\n\t/**\n\t * Unique identifier for the passed in container, i.e. the return value of a call\n\t * to {@link @fluidframework/fluid-static#IFluidContainer.attach | `IFluidContainer.attach()`} when creating a new\n\t * Fluid container, or the id used to load a pre-existing one.\n\t */\n\tcontainerId: string;\n\t/**\n\t * Conusmers take incoming produced {@link @fluidframework/fluid-telemetry#IFluidTelemetry} and do something of your choice with it.\n\t * This could be sending the telemetry to a cloud platform or just console logging.\n\t */\n\tconsumers: ITelemetryConsumer[];\n}\n\n/**\n * Starts creating {@link @fluidframework/fluid-telemetry#IFluidTelemetry} by transforming raw system events emitted by the specified container\n * into said telemetry and passing it onto to the specified {@link ITelemetryConsumer}\n *\n * @beta\n */\nexport const startTelemetry = (config: TelemetryConfig): void => {\n\tconst telemetryProducer = new ContainerEventTelemetryProducer(config.containerId);\n\tnew ContainerTelemetryManager(config.container, telemetryProducer, config.consumers);\n};\n"]}
|
package/lib/legacy.d.ts
CHANGED
|
@@ -10,19 +10,5 @@
|
|
|
10
10
|
|
|
11
11
|
export {
|
|
12
12
|
// @public APIs
|
|
13
|
-
ICriticalContainerError
|
|
14
|
-
|
|
15
|
-
// @beta APIs
|
|
16
|
-
AppInsightsTelemetryConsumer,
|
|
17
|
-
ContainerConnectedTelemetry,
|
|
18
|
-
ContainerDisconnectedTelemetry,
|
|
19
|
-
ContainerDisposedTelemetry,
|
|
20
|
-
ContainerTelemetryEventName,
|
|
21
|
-
ContainerTelemetryEventNames,
|
|
22
|
-
FluidTelemetryEventName,
|
|
23
|
-
IContainerTelemetry,
|
|
24
|
-
IFluidTelemetry,
|
|
25
|
-
ITelemetryConsumer,
|
|
26
|
-
TelemetryConfig,
|
|
27
|
-
startTelemetry
|
|
13
|
+
ICriticalContainerError
|
|
28
14
|
} from "./index.js";
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { spy } from "sinon";
|
|
6
|
-
import { expect } from "chai";
|
|
7
5
|
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
8
6
|
import { ApplicationInsights } from "@microsoft/applicationinsights-web";
|
|
7
|
+
import { expect } from "chai";
|
|
8
|
+
import { spy } from "sinon";
|
|
9
|
+
import { IFluidContainerSystemEventNames, } from "../container/index.js";
|
|
9
10
|
import { startTelemetry } from "../factory/index.js";
|
|
10
|
-
import {
|
|
11
|
-
import { ContainerTelemetryEventNames, } from "../index.js";
|
|
11
|
+
import { AppInsightsTelemetryConsumer, ContainerTelemetryEventNames, } from "../index.js";
|
|
12
12
|
/**
|
|
13
13
|
* For these unit tests, we are just interested in the event emitter part of the Fluid container.
|
|
14
14
|
* The rest of the functionality of IFluidContainer is irrelevant.
|
|
@@ -40,17 +40,6 @@ describe("container telemetry via", () => {
|
|
|
40
40
|
});
|
|
41
41
|
trackEventSpy = spy(appInsightsClient, "trackEvent");
|
|
42
42
|
mockFluidContainer = new MockFluidContainer();
|
|
43
|
-
class AppInsightsTelemetryConsumer {
|
|
44
|
-
constructor(client) {
|
|
45
|
-
this.client = client;
|
|
46
|
-
}
|
|
47
|
-
consume(event) {
|
|
48
|
-
this.client.trackEvent({
|
|
49
|
-
name: event.eventName,
|
|
50
|
-
properties: event,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
43
|
telemetryConfig = {
|
|
55
44
|
container: mockFluidContainer,
|
|
56
45
|
containerId: mockContainerId,
|
|
@@ -74,7 +63,9 @@ describe("container telemetry via", () => {
|
|
|
74
63
|
};
|
|
75
64
|
expect(expectedAppInsightsTelemetry).to.deep.equal(actualAppInsightsTelemetry);
|
|
76
65
|
// We won't know what the container containerInstanceId will be but we can still check that it is defined.
|
|
77
|
-
expect(actualContainerTelemetry.containerInstanceId)
|
|
66
|
+
expect(actualContainerTelemetry.containerInstanceId)
|
|
67
|
+
.to.be.a("string")
|
|
68
|
+
.with.length.above(0);
|
|
78
69
|
});
|
|
79
70
|
it("Emitting 'disconnected' container system event produces expected ContainerDisconnectedTelemetry using Azure App Insights", () => {
|
|
80
71
|
startTelemetry(telemetryConfig);
|
|
@@ -93,7 +84,9 @@ describe("container telemetry via", () => {
|
|
|
93
84
|
};
|
|
94
85
|
expect(expectedAppInsightsTelemetry).to.deep.equal(actualAppInsightsTelemetry);
|
|
95
86
|
// We won't know what the container containerInstanceId will be but we can still check that it is defined.
|
|
96
|
-
expect(actualContainerTelemetry.containerInstanceId)
|
|
87
|
+
expect(actualContainerTelemetry.containerInstanceId)
|
|
88
|
+
.to.be.a("string")
|
|
89
|
+
.with.length.above(0);
|
|
97
90
|
});
|
|
98
91
|
it("Emitting 'disposed' system event produces expected ContainerDisposedTelemetry using Azure App Insights", () => {
|
|
99
92
|
startTelemetry(telemetryConfig);
|
|
@@ -112,7 +105,9 @@ describe("container telemetry via", () => {
|
|
|
112
105
|
};
|
|
113
106
|
expect(expectedAppInsightsTelemetry).to.deep.equal(actualAppInsightsTelemetry);
|
|
114
107
|
// We won't know what the container containerInstanceId will be but we can still check that it is defined.
|
|
115
|
-
expect(actualContainerTelemetry.containerInstanceId)
|
|
108
|
+
expect(actualContainerTelemetry.containerInstanceId)
|
|
109
|
+
.to.be.a("string")
|
|
110
|
+
.with.length.above(0);
|
|
116
111
|
});
|
|
117
112
|
it("Emitting 'disposed' system event with an error produces expected ContainerDisposedTelemetry using Azure App Insights", () => {
|
|
118
113
|
startTelemetry(telemetryConfig);
|
|
@@ -136,7 +131,9 @@ describe("container telemetry via", () => {
|
|
|
136
131
|
};
|
|
137
132
|
expect(expectedAppInsightsTelemetry).to.deep.equal(actualAppInsightsTelemetry);
|
|
138
133
|
// We won't know what the container containerInstanceId will be but we can still check that it is defined.
|
|
139
|
-
expect(actualContainerTelemetry.containerInstanceId)
|
|
134
|
+
expect(actualContainerTelemetry.containerInstanceId)
|
|
135
|
+
.to.be.a("string")
|
|
136
|
+
.with.length.above(0);
|
|
140
137
|
});
|
|
141
138
|
});
|
|
142
139
|
//# sourceMappingURL=containerTelemetry.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerTelemetry.spec.js","sourceRoot":"","sources":["../../src/test/containerTelemetry.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAwB,MAAM,oCAAoC,CAAC;AAE/F,OAAO,EAAE,cAAc,EAAwB,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,+BAA+B,EAA4B,MAAM,uBAAuB,CAAC;AAClG,OAAO,EACN,4BAA4B,GAM5B,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,MAAM,kBAAmB,SAAQ,iBAAwC;IACjE,OAAO;QACb,IAAI,CAAC,IAAI,CAAC,+BAA+B,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC;IAEM,UAAU;QAChB,IAAI,CAAC,IAAI,CAAC,+BAA+B,CAAC,YAAY,CAAC,CAAC;IACzD,CAAC;IAEM,OAAO,CAAC,KAA+B;QAC7C,IAAI,CAAC,IAAI,CAAC,+BAA+B,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC5D,CAAC;CACD;AAED,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACxC,IAAI,kBAAsC,CAAC;IAC3C,MAAM,eAAe,GAAG,iBAAiB,CAAC;IAC1C,IAAI,iBAAsC,CAAC;IAC3C,IAAI,aAA6B,CAAC;IAClC,IAAI,eAAgC,CAAC;IAErC,UAAU,CAAC,GAAG,EAAE;QACf,iBAAiB,GAAG,IAAI,mBAAmB,CAAC;YAC3C,MAAM,EAAE;gBACP,gBA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C,UAAiC,CAAC;QAE9D,MAAM,4BAA4B,GAAoB;YACrD,IAAI,EAAE,4BAA4B,CAAC,QAAQ;YAC3C,UAAU,EAAE;gBACX,SAAS,EAAE,4BAA4B,CAAC,QAAQ;gBAChD,WAAW,EAAE,eAAe;gBAC5B,mBAAmB,EAAE,wBAAwB,CAAC,mBAAmB;gBACjE,KAAK,EAAE,cAAc;aACgB;SACtC,CAAC;QAEF,MAAM,CAAC,4BAA4B,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC/E,0GAA0G;QAC1G,MAAM,CAAC,wBAAwB,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7F,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type Sinon from \"sinon\";\nimport { spy } from \"sinon\";\nimport { expect } from \"chai\";\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport { ApplicationInsights, type IEventTelemetry } from \"@microsoft/applicationinsights-web\";\nimport type { IFluidContainer, IFluidContainerEvents } from \"@fluidframework/fluid-static\";\nimport { startTelemetry, type TelemetryConfig } from \"../factory/index.js\";\nimport { IFluidContainerSystemEventNames, type IContainerTelemetry } from \"../container/index.js\";\nimport {\n\tContainerTelemetryEventNames,\n\ttype ContainerConnectedTelemetry,\n\ttype ContainerDisconnectedTelemetry,\n\ttype ContainerDisposedTelemetry,\n\ttype IFluidTelemetry,\n\ttype ITelemetryConsumer,\n} from \"../index.js\";\n\n/**\n * For these unit tests, we are just interested in the event emitter part of the Fluid container.\n * The rest of the functionality of IFluidContainer is irrelevant.\n */\nclass MockFluidContainer extends TypedEventEmitter<IFluidContainerEvents> {\n\tpublic connect(): void {\n\t\tthis.emit(IFluidContainerSystemEventNames.CONNECTED);\n\t}\n\n\tpublic disconnect(): void {\n\t\tthis.emit(IFluidContainerSystemEventNames.DISCONNECTED);\n\t}\n\n\tpublic dispose(error?: ICriticalContainerError): void {\n\t\tthis.emit(IFluidContainerSystemEventNames.DISPOSED, error);\n\t}\n}\n\ndescribe(\"container telemetry via\", () => {\n\tlet mockFluidContainer: MockFluidContainer;\n\tconst mockContainerId = \"mockContainerId\";\n\tlet appInsightsClient: ApplicationInsights;\n\tlet trackEventSpy: Sinon.SinonSpy;\n\tlet telemetryConfig: TelemetryConfig;\n\n\tbeforeEach(() => {\n\t\tappInsightsClient = new ApplicationInsights({\n\t\t\tconfig: {\n\t\t\t\tconnectionString:\n\t\t\t\t\t// (this is an example string)\n\t\t\t\t\t\"InstrumentationKey=abcdefgh-ijkl-mnop-qrst-uvwxyz6ffd9c;IngestionEndpoint=https://westus2-2.in.applicationinsights.azure.com/;LiveEndpoint=https://westus2.livediagnostics.monitor.azure.com/\",\n\t\t\t},\n\t\t});\n\n\t\ttrackEventSpy = spy(appInsightsClient, \"trackEvent\");\n\t\tmockFluidContainer = new MockFluidContainer();\n\n\t\tclass AppInsightsTelemetryConsumer implements ITelemetryConsumer {\n\t\t\tpublic constructor(private readonly client: ApplicationInsights) {}\n\n\t\t\tpublic consume(event: IFluidTelemetry): void {\n\t\t\t\tthis.client.trackEvent({\n\t\t\t\t\tname: event.eventName,\n\t\t\t\t\tproperties: event,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\ttelemetryConfig = {\n\t\t\tcontainer: mockFluidContainer as unknown as IFluidContainer,\n\t\t\tcontainerId: mockContainerId,\n\t\t\tconsumers: [new AppInsightsTelemetryConsumer(appInsightsClient)],\n\t\t};\n\t});\n\n\tit(\"Emitting 'connected' container system event produces expected ContainerConnectedTelemetry using Azure App Insights\", () => {\n\t\tstartTelemetry(telemetryConfig);\n\n\t\tmockFluidContainer.connect();\n\n\t\texpect(trackEventSpy.callCount).to.equal(1);\n\n\t\t// Obtain the events from the method that the spy was called with\n\t\tconst actualAppInsightsTelemetry = trackEventSpy.getCall(0).args[0] as IEventTelemetry;\n\t\tconst actualContainerTelemetry =\n\t\t\tactualAppInsightsTelemetry.properties as IContainerTelemetry;\n\n\t\tconst expectedAppInsightsTelemetry: IEventTelemetry = {\n\t\t\tname: ContainerTelemetryEventNames.CONNECTED,\n\t\t\tproperties: {\n\t\t\t\teventName: ContainerTelemetryEventNames.CONNECTED,\n\t\t\t\tcontainerId: mockContainerId,\n\t\t\t\tcontainerInstanceId: actualContainerTelemetry.containerInstanceId,\n\t\t\t} satisfies ContainerConnectedTelemetry,\n\t\t};\n\n\t\texpect(expectedAppInsightsTelemetry).to.deep.equal(actualAppInsightsTelemetry);\n\t\t// We won't know what the container containerInstanceId will be but we can still check that it is defined.\n\t\texpect(actualContainerTelemetry.containerInstanceId).to.be.a(\"string\").with.length.above(0);\n\t});\n\n\tit(\"Emitting 'disconnected' container system event produces expected ContainerDisconnectedTelemetry using Azure App Insights\", () => {\n\t\tstartTelemetry(telemetryConfig);\n\n\t\tmockFluidContainer.disconnect();\n\n\t\texpect(trackEventSpy.callCount).to.equal(1);\n\n\t\t// Obtain the events from the method that the spy was called with\n\t\tconst actualAppInsightsTelemetry = trackEventSpy.getCall(0).args[0] as IEventTelemetry;\n\t\tconst actualContainerTelemetry =\n\t\t\tactualAppInsightsTelemetry.properties as IContainerTelemetry;\n\n\t\tconst expectedAppInsightsTelemetry: IEventTelemetry = {\n\t\t\tname: ContainerTelemetryEventNames.DISCONNECTED,\n\t\t\tproperties: {\n\t\t\t\teventName: ContainerTelemetryEventNames.DISCONNECTED,\n\t\t\t\tcontainerId: mockContainerId,\n\t\t\t\tcontainerInstanceId: actualContainerTelemetry.containerInstanceId,\n\t\t\t} satisfies ContainerDisconnectedTelemetry,\n\t\t};\n\n\t\texpect(expectedAppInsightsTelemetry).to.deep.equal(actualAppInsightsTelemetry);\n\t\t// We won't know what the container containerInstanceId will be but we can still check that it is defined.\n\t\texpect(actualContainerTelemetry.containerInstanceId).to.be.a(\"string\").with.length.above(0);\n\t});\n\n\tit(\"Emitting 'disposed' system event produces expected ContainerDisposedTelemetry using Azure App Insights\", () => {\n\t\tstartTelemetry(telemetryConfig);\n\n\t\tmockFluidContainer.dispose();\n\n\t\texpect(trackEventSpy.callCount).to.equal(1);\n\n\t\t// Obtain the events from the method that the spy was called with\n\t\tconst actualAppInsightsTelemetry = trackEventSpy.getCall(0).args[0] as IEventTelemetry;\n\t\tconst actualContainerTelemetry =\n\t\t\tactualAppInsightsTelemetry.properties as IContainerTelemetry;\n\n\t\tconst expectedAppInsightsTelemetry: IEventTelemetry = {\n\t\t\tname: ContainerTelemetryEventNames.DISPOSED,\n\t\t\tproperties: {\n\t\t\t\teventName: ContainerTelemetryEventNames.DISPOSED,\n\t\t\t\tcontainerId: mockContainerId,\n\t\t\t\tcontainerInstanceId: actualContainerTelemetry.containerInstanceId,\n\t\t\t} satisfies ContainerDisposedTelemetry,\n\t\t};\n\n\t\texpect(expectedAppInsightsTelemetry).to.deep.equal(actualAppInsightsTelemetry);\n\t\t// We won't know what the container containerInstanceId will be but we can still check that it is defined.\n\t\texpect(actualContainerTelemetry.containerInstanceId).to.be.a(\"string\").with.length.above(0);\n\t});\n\n\tit(\"Emitting 'disposed' system event with an error produces expected ContainerDisposedTelemetry using Azure App Insights\", () => {\n\t\tstartTelemetry(telemetryConfig);\n\n\t\tconst containerError: ICriticalContainerError = {\n\t\t\terrorType: \"unknown error\",\n\t\t\tmessage: \"An unknown error occured\",\n\t\t\tstack: \"example stack error at line 52 of Container.ts\",\n\t\t};\n\n\t\tmockFluidContainer.dispose(containerError);\n\n\t\t// Obtain the events from the method that the spy was called with\n\t\tconst actualAppInsightsTelemetry = trackEventSpy.getCall(0).args[0] as IEventTelemetry;\n\t\tconst actualContainerTelemetry =\n\t\t\tactualAppInsightsTelemetry.properties as IContainerTelemetry;\n\n\t\tconst expectedAppInsightsTelemetry: IEventTelemetry = {\n\t\t\tname: ContainerTelemetryEventNames.DISPOSED,\n\t\t\tproperties: {\n\t\t\t\teventName: ContainerTelemetryEventNames.DISPOSED,\n\t\t\t\tcontainerId: mockContainerId,\n\t\t\t\tcontainerInstanceId: actualContainerTelemetry.containerInstanceId,\n\t\t\t\terror: containerError,\n\t\t\t} satisfies ContainerDisposedTelemetry,\n\t\t};\n\n\t\texpect(expectedAppInsightsTelemetry).to.deep.equal(actualAppInsightsTelemetry);\n\t\t// We won't know what the container containerInstanceId will be but we can still check that it is defined.\n\t\texpect(actualContainerTelemetry.containerInstanceId).to.be.a(\"string\").with.length.above(0);\n\t});\n});\n"]}
|
|
1
|
+
{"version":3,"file":"containerTelemetry.spec.js","sourceRoot":"","sources":["../../src/test/containerTelemetry.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,OAAO,EAAE,mBAAmB,EAAwB,MAAM,oCAAoC,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAG5B,OAAO,EACN,+BAA+B,GAE/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAwB,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EACN,4BAA4B,EAC5B,4BAA4B,GAI5B,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,MAAM,kBAAmB,SAAQ,iBAAwC;IACjE,OAAO;QACb,IAAI,CAAC,IAAI,CAAC,+BAA+B,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC;IAEM,UAAU;QAChB,IAAI,CAAC,IAAI,CAAC,+BAA+B,CAAC,YAAY,CAAC,CAAC;IACzD,CAAC;IAEM,OAAO,CAAC,KAA+B;QAC7C,IAAI,CAAC,IAAI,CAAC,+BAA+B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AAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAoB,CAAC;QACvF,MAAM,wBAAwB,GAC7B,0BAA0B,CAAC,UAAiC,CAAC;QAE9D,MAAM,4BAA4B,GAAoB;YACrD,IAAI,EAAE,4BAA4B,CAAC,QAAQ;YAC3C,UAAU,EAAE;gBACX,SAAS,EAAE,4BAA4B,CAAC,QAAQ;gBAChD,WAAW,EAAE,eAAe;gBAC5B,mBAAmB,EAAE,wBAAwB,CAAC,mBAAmB;gBACjE,KAAK,EAAE,cAAc;aACgB;SACtC,CAAC;QAEF,MAAM,CAAC,4BAA4B,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC/E,0GAA0G;QAC1G,MAAM,CAAC,wBAAwB,CAAC,mBAAmB,CAAC;aAClD,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;aACjB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport type { IFluidContainer, IFluidContainerEvents } from \"@fluidframework/fluid-static\";\nimport { ApplicationInsights, type IEventTelemetry } from \"@microsoft/applicationinsights-web\";\nimport { expect } from \"chai\";\nimport { spy } from \"sinon\";\nimport type Sinon from \"sinon\";\n\nimport {\n\tIFluidContainerSystemEventNames,\n\ttype IContainerTelemetry,\n} from \"../container/index.js\";\nimport { startTelemetry, type TelemetryConfig } from \"../factory/index.js\";\nimport {\n\tAppInsightsTelemetryConsumer,\n\tContainerTelemetryEventNames,\n\ttype ContainerConnectedTelemetry,\n\ttype ContainerDisconnectedTelemetry,\n\ttype ContainerDisposedTelemetry,\n} from \"../index.js\";\n\n/**\n * For these unit tests, we are just interested in the event emitter part of the Fluid container.\n * The rest of the functionality of IFluidContainer is irrelevant.\n */\nclass MockFluidContainer extends TypedEventEmitter<IFluidContainerEvents> {\n\tpublic connect(): void {\n\t\tthis.emit(IFluidContainerSystemEventNames.CONNECTED);\n\t}\n\n\tpublic disconnect(): void {\n\t\tthis.emit(IFluidContainerSystemEventNames.DISCONNECTED);\n\t}\n\n\tpublic dispose(error?: ICriticalContainerError): void {\n\t\tthis.emit(IFluidContainerSystemEventNames.DISPOSED, error);\n\t}\n}\n\ndescribe(\"container telemetry via\", () => {\n\tlet mockFluidContainer: MockFluidContainer;\n\tconst mockContainerId = \"mockContainerId\";\n\tlet appInsightsClient: ApplicationInsights;\n\tlet trackEventSpy: Sinon.SinonSpy;\n\tlet telemetryConfig: TelemetryConfig;\n\n\tbeforeEach(() => {\n\t\tappInsightsClient = new ApplicationInsights({\n\t\t\tconfig: {\n\t\t\t\tconnectionString:\n\t\t\t\t\t// (this is an example string)\n\t\t\t\t\t\"InstrumentationKey=abcdefgh-ijkl-mnop-qrst-uvwxyz6ffd9c;IngestionEndpoint=https://westus2-2.in.applicationinsights.azure.com/;LiveEndpoint=https://westus2.livediagnostics.monitor.azure.com/\",\n\t\t\t},\n\t\t});\n\n\t\ttrackEventSpy = spy(appInsightsClient, \"trackEvent\");\n\t\tmockFluidContainer = new MockFluidContainer();\n\n\t\ttelemetryConfig = {\n\t\t\tcontainer: mockFluidContainer as unknown as IFluidContainer,\n\t\t\tcontainerId: mockContainerId,\n\t\t\tconsumers: [new AppInsightsTelemetryConsumer(appInsightsClient)],\n\t\t};\n\t});\n\n\tit(\"Emitting 'connected' container system event produces expected ContainerConnectedTelemetry using Azure App Insights\", () => {\n\t\tstartTelemetry(telemetryConfig);\n\n\t\tmockFluidContainer.connect();\n\n\t\texpect(trackEventSpy.callCount).to.equal(1);\n\n\t\t// Obtain the events from the method that the spy was called with\n\t\tconst actualAppInsightsTelemetry = trackEventSpy.getCall(0).args[0] as IEventTelemetry;\n\t\tconst actualContainerTelemetry =\n\t\t\tactualAppInsightsTelemetry.properties as IContainerTelemetry;\n\n\t\tconst expectedAppInsightsTelemetry: IEventTelemetry = {\n\t\t\tname: ContainerTelemetryEventNames.CONNECTED,\n\t\t\tproperties: {\n\t\t\t\teventName: ContainerTelemetryEventNames.CONNECTED,\n\t\t\t\tcontainerId: mockContainerId,\n\t\t\t\tcontainerInstanceId: actualContainerTelemetry.containerInstanceId,\n\t\t\t} satisfies ContainerConnectedTelemetry,\n\t\t};\n\n\t\texpect(expectedAppInsightsTelemetry).to.deep.equal(actualAppInsightsTelemetry);\n\t\t// We won't know what the container containerInstanceId will be but we can still check that it is defined.\n\t\texpect(actualContainerTelemetry.containerInstanceId)\n\t\t\t.to.be.a(\"string\")\n\t\t\t.with.length.above(0);\n\t});\n\n\tit(\"Emitting 'disconnected' container system event produces expected ContainerDisconnectedTelemetry using Azure App Insights\", () => {\n\t\tstartTelemetry(telemetryConfig);\n\n\t\tmockFluidContainer.disconnect();\n\n\t\texpect(trackEventSpy.callCount).to.equal(1);\n\n\t\t// Obtain the events from the method that the spy was called with\n\t\tconst actualAppInsightsTelemetry = trackEventSpy.getCall(0).args[0] as IEventTelemetry;\n\t\tconst actualContainerTelemetry =\n\t\t\tactualAppInsightsTelemetry.properties as IContainerTelemetry;\n\n\t\tconst expectedAppInsightsTelemetry: IEventTelemetry = {\n\t\t\tname: ContainerTelemetryEventNames.DISCONNECTED,\n\t\t\tproperties: {\n\t\t\t\teventName: ContainerTelemetryEventNames.DISCONNECTED,\n\t\t\t\tcontainerId: mockContainerId,\n\t\t\t\tcontainerInstanceId: actualContainerTelemetry.containerInstanceId,\n\t\t\t} satisfies ContainerDisconnectedTelemetry,\n\t\t};\n\n\t\texpect(expectedAppInsightsTelemetry).to.deep.equal(actualAppInsightsTelemetry);\n\t\t// We won't know what the container containerInstanceId will be but we can still check that it is defined.\n\t\texpect(actualContainerTelemetry.containerInstanceId)\n\t\t\t.to.be.a(\"string\")\n\t\t\t.with.length.above(0);\n\t});\n\n\tit(\"Emitting 'disposed' system event produces expected ContainerDisposedTelemetry using Azure App Insights\", () => {\n\t\tstartTelemetry(telemetryConfig);\n\n\t\tmockFluidContainer.dispose();\n\n\t\texpect(trackEventSpy.callCount).to.equal(1);\n\n\t\t// Obtain the events from the method that the spy was called with\n\t\tconst actualAppInsightsTelemetry = trackEventSpy.getCall(0).args[0] as IEventTelemetry;\n\t\tconst actualContainerTelemetry =\n\t\t\tactualAppInsightsTelemetry.properties as IContainerTelemetry;\n\n\t\tconst expectedAppInsightsTelemetry: IEventTelemetry = {\n\t\t\tname: ContainerTelemetryEventNames.DISPOSED,\n\t\t\tproperties: {\n\t\t\t\teventName: ContainerTelemetryEventNames.DISPOSED,\n\t\t\t\tcontainerId: mockContainerId,\n\t\t\t\tcontainerInstanceId: actualContainerTelemetry.containerInstanceId,\n\t\t\t} satisfies ContainerDisposedTelemetry,\n\t\t};\n\n\t\texpect(expectedAppInsightsTelemetry).to.deep.equal(actualAppInsightsTelemetry);\n\t\t// We won't know what the container containerInstanceId will be but we can still check that it is defined.\n\t\texpect(actualContainerTelemetry.containerInstanceId)\n\t\t\t.to.be.a(\"string\")\n\t\t\t.with.length.above(0);\n\t});\n\n\tit(\"Emitting 'disposed' system event with an error produces expected ContainerDisposedTelemetry using Azure App Insights\", () => {\n\t\tstartTelemetry(telemetryConfig);\n\n\t\tconst containerError: ICriticalContainerError = {\n\t\t\terrorType: \"unknown error\",\n\t\t\tmessage: \"An unknown error occured\",\n\t\t\tstack: \"example stack error at line 52 of Container.ts\",\n\t\t};\n\n\t\tmockFluidContainer.dispose(containerError);\n\n\t\t// Obtain the events from the method that the spy was called with\n\t\tconst actualAppInsightsTelemetry = trackEventSpy.getCall(0).args[0] as IEventTelemetry;\n\t\tconst actualContainerTelemetry =\n\t\t\tactualAppInsightsTelemetry.properties as IContainerTelemetry;\n\n\t\tconst expectedAppInsightsTelemetry: IEventTelemetry = {\n\t\t\tname: ContainerTelemetryEventNames.DISPOSED,\n\t\t\tproperties: {\n\t\t\t\teventName: ContainerTelemetryEventNames.DISPOSED,\n\t\t\t\tcontainerId: mockContainerId,\n\t\t\t\tcontainerInstanceId: actualContainerTelemetry.containerInstanceId,\n\t\t\t\terror: containerError,\n\t\t\t} satisfies ContainerDisposedTelemetry,\n\t\t};\n\n\t\texpect(expectedAppInsightsTelemetry).to.deep.equal(actualAppInsightsTelemetry);\n\t\t// We won't know what the container containerInstanceId will be but we can still check that it is defined.\n\t\texpect(actualContainerTelemetry.containerInstanceId)\n\t\t\t.to.be.a(\"string\")\n\t\t\t.with.length.above(0);\n\t});\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containerTelemetryEndToEnd.spec.realsvc.d.ts","sourceRoot":"","sources":["../../src/test/containerTelemetryEndToEnd.spec.realsvc.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { timeoutPromise } from "@fluidframework/test-utils/internal";
|
|
6
|
+
import { TinyliciousClient } from "@fluidframework/tinylicious-client/internal";
|
|
7
|
+
import { SharedTree } from "@fluidframework/tree/internal";
|
|
8
|
+
import { expect } from "chai";
|
|
9
|
+
import { spy } from "sinon";
|
|
10
|
+
import { startTelemetry } from "../factory/index.js";
|
|
11
|
+
import { ContainerTelemetryEventNames, } from "../index.js";
|
|
12
|
+
// This test suite creates an actual IFluidContainer and confirms events are fired with the expected names during the expected events
|
|
13
|
+
describe("container telemetry E2E", () => {
|
|
14
|
+
let schema;
|
|
15
|
+
let tinyliciousClient;
|
|
16
|
+
let telemetryConsumerConsumeSpy;
|
|
17
|
+
let testTelemetryConsumer;
|
|
18
|
+
// Simple test class that will be used as the telemetry consumer.
|
|
19
|
+
class TestTelemetryConsumer {
|
|
20
|
+
consume(event) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
before(() => {
|
|
25
|
+
tinyliciousClient = new TinyliciousClient({ connection: { port: 7070 } });
|
|
26
|
+
schema = {
|
|
27
|
+
initialObjects: {
|
|
28
|
+
sharedTree1: SharedTree,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
testTelemetryConsumer = new TestTelemetryConsumer();
|
|
32
|
+
telemetryConsumerConsumeSpy = spy(testTelemetryConsumer, "consume");
|
|
33
|
+
});
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
// We need to reset the telemetry consumer spy for each test so the trackEvent calls
|
|
36
|
+
// from the last test don't bleed into the next one.
|
|
37
|
+
telemetryConsumerConsumeSpy.resetHistory();
|
|
38
|
+
});
|
|
39
|
+
it("IFluid container's 'connected' system event produces expected ContainerConnectedTelemetry using ITelemetryConsumer", async () => {
|
|
40
|
+
const { container } = await tinyliciousClient.createContainer(schema, "2");
|
|
41
|
+
const containerId = await container.attach();
|
|
42
|
+
startTelemetry({
|
|
43
|
+
container,
|
|
44
|
+
containerId,
|
|
45
|
+
consumers: [testTelemetryConsumer],
|
|
46
|
+
});
|
|
47
|
+
// We don't know exactly when the given container events that we're looking for will fire so we have to
|
|
48
|
+
// wrap the container.on(...) event handler within a promise that will be awaited at the end of the test.
|
|
49
|
+
const { actualContainerTelemetry, expectedContainerTelemetry } = await timeoutPromise((resolve) => {
|
|
50
|
+
container.on("connected", () => {
|
|
51
|
+
// We are making an assumption here that the 'connected' event is the first and only event sent to the ITelemetryConsumer.
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
53
|
+
const containerTelemetryFromSpy = telemetryConsumerConsumeSpy.getCalls()[0]
|
|
54
|
+
.args[0];
|
|
55
|
+
resolve({
|
|
56
|
+
actualContainerTelemetry: containerTelemetryFromSpy,
|
|
57
|
+
expectedContainerTelemetry: {
|
|
58
|
+
eventName: ContainerTelemetryEventNames.CONNECTED,
|
|
59
|
+
containerId,
|
|
60
|
+
// containerInstanceId is a uniquely generated UUID by the fluid-telemetry's ContainerEventTelemetryProducer class.
|
|
61
|
+
// We can't use the underlying container's id because it is not exposed by IFluidContainer.
|
|
62
|
+
containerInstanceId: containerTelemetryFromSpy.containerInstanceId,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}, { durationMs: 5000, errorMsg: "timeout while waiting for container 'connected' event" });
|
|
67
|
+
expect(expectedContainerTelemetry).to.deep.equal(actualContainerTelemetry);
|
|
68
|
+
// We won't know what the container containerInstanceId will be but we can still check that it is defined.
|
|
69
|
+
expect(actualContainerTelemetry.containerInstanceId)
|
|
70
|
+
.to.be.a("string")
|
|
71
|
+
.with.length.above(0);
|
|
72
|
+
});
|
|
73
|
+
it("IFluid container's 'disconnected' system event produces expected ContainerDisconnectedTelemetry using ITelemetryConsumer", async () => {
|
|
74
|
+
const { container } = await tinyliciousClient.createContainer(schema, "2");
|
|
75
|
+
const containerId = await container.attach();
|
|
76
|
+
startTelemetry({
|
|
77
|
+
container,
|
|
78
|
+
containerId,
|
|
79
|
+
consumers: [testTelemetryConsumer],
|
|
80
|
+
});
|
|
81
|
+
// We don't know exactly when the given container events that we're looking for will fire so we have to
|
|
82
|
+
// wrap the container.on(...) event handler within a promise that will be awaited at the end of the test.
|
|
83
|
+
const { actualContainerTelemetry, expectedContainerTelemetry } = await timeoutPromise((resolve) => {
|
|
84
|
+
// Event handler 1: As soon as the container connects, we're ready to initiate a disconnect.
|
|
85
|
+
container.on("connected", () => {
|
|
86
|
+
container.disconnect();
|
|
87
|
+
});
|
|
88
|
+
container.on("disconnected", () => {
|
|
89
|
+
// We are making an assumption here that the 'disconnected' event is the second sent to the ITelemetryConsumer.
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
91
|
+
const containerTelemetryFromSpy = telemetryConsumerConsumeSpy.getCalls()[1]
|
|
92
|
+
.args[0];
|
|
93
|
+
resolve({
|
|
94
|
+
actualContainerTelemetry: containerTelemetryFromSpy,
|
|
95
|
+
expectedContainerTelemetry: {
|
|
96
|
+
eventName: ContainerTelemetryEventNames.DISCONNECTED,
|
|
97
|
+
containerId,
|
|
98
|
+
// containerInstanceId is a uniquely generated UUID by the fluid-telemetry's ContainerEventTelemetryProducer class.
|
|
99
|
+
// We can't use the underlying container's id because it is not exposed by IFluidContainer.
|
|
100
|
+
containerInstanceId: containerTelemetryFromSpy.containerInstanceId,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
}, {
|
|
105
|
+
durationMs: 5000,
|
|
106
|
+
errorMsg: "timeout while waiting for container 'connected' and/or 'disconnected' event",
|
|
107
|
+
});
|
|
108
|
+
expect(expectedContainerTelemetry).to.deep.equal(actualContainerTelemetry);
|
|
109
|
+
// We won't know what the container containerInstanceId will be but we can still check that it is defined.
|
|
110
|
+
expect(actualContainerTelemetry.containerInstanceId)
|
|
111
|
+
.to.be.a("string")
|
|
112
|
+
.with.length.above(0);
|
|
113
|
+
});
|
|
114
|
+
it("IFluid container's 'disposed' system event produces expected ContainerDisposedTelemetry using ITelemetryConsumer", async () => {
|
|
115
|
+
const { container } = await tinyliciousClient.createContainer(schema, "2");
|
|
116
|
+
const containerId = await container.attach();
|
|
117
|
+
startTelemetry({
|
|
118
|
+
container,
|
|
119
|
+
containerId,
|
|
120
|
+
consumers: [testTelemetryConsumer],
|
|
121
|
+
});
|
|
122
|
+
// We don't know exactly when the given container events that we're looking for will fire so we have to
|
|
123
|
+
// wrap the container.on(...) event handler within a promise that will be awaited at the end of the test.
|
|
124
|
+
const { actualContainerTelemetry, expectedContainerTelemetry } = await timeoutPromise((resolve, reject) => {
|
|
125
|
+
// Event handler 1: As soon as the container connects, we're ready to initiate a disconnect.
|
|
126
|
+
container.on("connected", () => {
|
|
127
|
+
container.disconnect();
|
|
128
|
+
});
|
|
129
|
+
// Event handler 2: As soon as the container disconnects, we're ready to initiate a dispose.
|
|
130
|
+
container.on("disconnected", () => {
|
|
131
|
+
container.dispose();
|
|
132
|
+
});
|
|
133
|
+
container.on("disposed", () => {
|
|
134
|
+
// We are making an assumption here that the 'disposed' event is the third sent to the ITelemetryConsumer.
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
136
|
+
const containerTelemetryFromSpy = telemetryConsumerConsumeSpy.getCalls()[2]
|
|
137
|
+
.args[0];
|
|
138
|
+
resolve({
|
|
139
|
+
actualContainerTelemetry: containerTelemetryFromSpy,
|
|
140
|
+
expectedContainerTelemetry: {
|
|
141
|
+
eventName: ContainerTelemetryEventNames.DISPOSED,
|
|
142
|
+
containerId,
|
|
143
|
+
// containerInstanceId is a uniquely generated UUID by the fluid-telemetry's ContainerEventTelemetryProducer class.
|
|
144
|
+
// We can't use the underlying container's id because it is not exposed by IFluidContainer.
|
|
145
|
+
containerInstanceId: containerTelemetryFromSpy.containerInstanceId,
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
}, {
|
|
150
|
+
durationMs: 5000,
|
|
151
|
+
errorMsg: "timeout while waiting for container 'connected' and/or 'disconnected' event",
|
|
152
|
+
});
|
|
153
|
+
expect(expectedContainerTelemetry).to.deep.equal(actualContainerTelemetry);
|
|
154
|
+
// We won't know what the container containerInstanceId will be but we can still check that it is defined.
|
|
155
|
+
expect(actualContainerTelemetry.containerInstanceId)
|
|
156
|
+
.to.be.a("string")
|
|
157
|
+
.with.length.above(0);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
//# sourceMappingURL=containerTelemetryEndToEnd.spec.realsvc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containerTelemetryEndToEnd.spec.realsvc.js","sourceRoot":"","sources":["../../src/test/containerTelemetryEndToEnd.spec.realsvc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE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;QAEF,MAAM,CAAC,0BAA0B,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC3E,0GAA0G;QAC1G,MAAM,CAAC,wBAAwB,CAAC,mBAAmB,CAAC;aAClD,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;aACjB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ContainerSchema } from \"@fluidframework/fluid-static\";\nimport { timeoutPromise } from \"@fluidframework/test-utils/internal\";\nimport { TinyliciousClient } from \"@fluidframework/tinylicious-client/internal\";\nimport { SharedTree } from \"@fluidframework/tree/internal\";\nimport { expect } from \"chai\";\nimport type Sinon from \"sinon\";\nimport { spy } from \"sinon\";\n\nimport { startTelemetry } from \"../factory/index.js\";\nimport {\n\tContainerTelemetryEventNames,\n\ttype ContainerConnectedTelemetry,\n\ttype ContainerDisconnectedTelemetry,\n\ttype ContainerDisposedTelemetry,\n\ttype IFluidTelemetry,\n\ttype ITelemetryConsumer,\n} from \"../index.js\";\n\n// This test suite creates an actual IFluidContainer and confirms events are fired with the expected names during the expected events\n\ndescribe(\"container telemetry E2E\", () => {\n\tlet schema: ContainerSchema;\n\tlet tinyliciousClient: TinyliciousClient;\n\tlet telemetryConsumerConsumeSpy: Sinon.SinonSpy;\n\tlet testTelemetryConsumer: ITelemetryConsumer;\n\n\t// Simple test class that will be used as the telemetry consumer.\n\tclass TestTelemetryConsumer implements ITelemetryConsumer {\n\t\tpublic consume(event: IFluidTelemetry): void {\n\t\t\treturn;\n\t\t}\n\t}\n\n\tbefore(() => {\n\t\ttinyliciousClient = new TinyliciousClient({ connection: { port: 7070 } });\n\t\tschema = {\n\t\t\tinitialObjects: {\n\t\t\t\tsharedTree1: SharedTree,\n\t\t\t},\n\t\t};\n\n\t\ttestTelemetryConsumer = new TestTelemetryConsumer();\n\t\ttelemetryConsumerConsumeSpy = spy(testTelemetryConsumer, \"consume\");\n\t});\n\n\tbeforeEach(() => {\n\t\t// We need to reset the telemetry consumer spy for each test so the trackEvent calls\n\t\t// from the last test don't bleed into the next one.\n\t\ttelemetryConsumerConsumeSpy.resetHistory();\n\t});\n\n\tit(\"IFluid container's 'connected' system event produces expected ContainerConnectedTelemetry using ITelemetryConsumer\", async () => {\n\t\tconst { container } = await tinyliciousClient.createContainer(schema, \"2\");\n\n\t\tconst containerId = await container.attach();\n\t\tstartTelemetry({\n\t\t\tcontainer,\n\t\t\tcontainerId,\n\t\t\tconsumers: [testTelemetryConsumer],\n\t\t});\n\n\t\t// We don't know exactly when the given container events that we're looking for will fire so we have to\n\t\t// wrap the container.on(...) event handler within a promise that will be awaited at the end of the test.\n\t\tconst { actualContainerTelemetry, expectedContainerTelemetry } = await timeoutPromise<{\n\t\t\tactualContainerTelemetry: ContainerConnectedTelemetry;\n\t\t\texpectedContainerTelemetry: ContainerConnectedTelemetry;\n\t\t}>(\n\t\t\t(resolve) => {\n\t\t\t\tcontainer.on(\"connected\", () => {\n\t\t\t\t\t// We are making an assumption here that the 'connected' event is the first and only event sent to the ITelemetryConsumer.\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tconst containerTelemetryFromSpy = telemetryConsumerConsumeSpy.getCalls()[0]!\n\t\t\t\t\t\t.args[0] as ContainerConnectedTelemetry;\n\n\t\t\t\t\tresolve({\n\t\t\t\t\t\tactualContainerTelemetry: containerTelemetryFromSpy,\n\t\t\t\t\t\texpectedContainerTelemetry: {\n\t\t\t\t\t\t\teventName: ContainerTelemetryEventNames.CONNECTED,\n\t\t\t\t\t\t\tcontainerId,\n\t\t\t\t\t\t\t// containerInstanceId is a uniquely generated UUID by the fluid-telemetry's ContainerEventTelemetryProducer class.\n\t\t\t\t\t\t\t// We can't use the underlying container's id because it is not exposed by IFluidContainer.\n\t\t\t\t\t\t\tcontainerInstanceId: containerTelemetryFromSpy.containerInstanceId,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\t{ durationMs: 5000, errorMsg: \"timeout while waiting for container 'connected' event\" },\n\t\t);\n\n\t\texpect(expectedContainerTelemetry).to.deep.equal(actualContainerTelemetry);\n\t\t// We won't know what the container containerInstanceId will be but we can still check that it is defined.\n\t\texpect(actualContainerTelemetry.containerInstanceId)\n\t\t\t.to.be.a(\"string\")\n\t\t\t.with.length.above(0);\n\t});\n\n\tit(\"IFluid container's 'disconnected' system event produces expected ContainerDisconnectedTelemetry using ITelemetryConsumer\", async () => {\n\t\tconst { container } = await tinyliciousClient.createContainer(schema, \"2\");\n\n\t\tconst containerId = await container.attach();\n\t\tstartTelemetry({\n\t\t\tcontainer,\n\t\t\tcontainerId,\n\t\t\tconsumers: [testTelemetryConsumer],\n\t\t});\n\n\t\t// We don't know exactly when the given container events that we're looking for will fire so we have to\n\t\t// wrap the container.on(...) event handler within a promise that will be awaited at the end of the test.\n\t\tconst { actualContainerTelemetry, expectedContainerTelemetry } = await timeoutPromise<{\n\t\t\tactualContainerTelemetry: ContainerDisconnectedTelemetry;\n\t\t\texpectedContainerTelemetry: ContainerDisconnectedTelemetry;\n\t\t}>(\n\t\t\t(resolve) => {\n\t\t\t\t// Event handler 1: As soon as the container connects, we're ready to initiate a disconnect.\n\t\t\t\tcontainer.on(\"connected\", () => {\n\t\t\t\t\tcontainer.disconnect();\n\t\t\t\t});\n\n\t\t\t\tcontainer.on(\"disconnected\", () => {\n\t\t\t\t\t// We are making an assumption here that the 'disconnected' event is the second sent to the ITelemetryConsumer.\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tconst containerTelemetryFromSpy = telemetryConsumerConsumeSpy.getCalls()[1]!\n\t\t\t\t\t\t.args[0] as ContainerDisconnectedTelemetry;\n\n\t\t\t\t\tresolve({\n\t\t\t\t\t\tactualContainerTelemetry: containerTelemetryFromSpy,\n\t\t\t\t\t\texpectedContainerTelemetry: {\n\t\t\t\t\t\t\teventName: ContainerTelemetryEventNames.DISCONNECTED,\n\t\t\t\t\t\t\tcontainerId,\n\t\t\t\t\t\t\t// containerInstanceId is a uniquely generated UUID by the fluid-telemetry's ContainerEventTelemetryProducer class.\n\t\t\t\t\t\t\t// We can't use the underlying container's id because it is not exposed by IFluidContainer.\n\t\t\t\t\t\t\tcontainerInstanceId: containerTelemetryFromSpy.containerInstanceId,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\t{\n\t\t\t\tdurationMs: 5000,\n\t\t\t\terrorMsg:\n\t\t\t\t\t\"timeout while waiting for container 'connected' and/or 'disconnected' event\",\n\t\t\t},\n\t\t);\n\n\t\texpect(expectedContainerTelemetry).to.deep.equal(actualContainerTelemetry);\n\t\t// We won't know what the container containerInstanceId will be but we can still check that it is defined.\n\t\texpect(actualContainerTelemetry.containerInstanceId)\n\t\t\t.to.be.a(\"string\")\n\t\t\t.with.length.above(0);\n\t});\n\n\tit(\"IFluid container's 'disposed' system event produces expected ContainerDisposedTelemetry using ITelemetryConsumer\", async () => {\n\t\tconst { container } = await tinyliciousClient.createContainer(schema, \"2\");\n\n\t\tconst containerId = await container.attach();\n\t\tstartTelemetry({\n\t\t\tcontainer,\n\t\t\tcontainerId,\n\t\t\tconsumers: [testTelemetryConsumer],\n\t\t});\n\n\t\t// We don't know exactly when the given container events that we're looking for will fire so we have to\n\t\t// wrap the container.on(...) event handler within a promise that will be awaited at the end of the test.\n\t\tconst { actualContainerTelemetry, expectedContainerTelemetry } = await timeoutPromise<{\n\t\t\tactualContainerTelemetry: ContainerDisposedTelemetry;\n\t\t\texpectedContainerTelemetry: ContainerDisposedTelemetry;\n\t\t}>(\n\t\t\t(resolve, reject) => {\n\t\t\t\t// Event handler 1: As soon as the container connects, we're ready to initiate a disconnect.\n\t\t\t\tcontainer.on(\"connected\", () => {\n\t\t\t\t\tcontainer.disconnect();\n\t\t\t\t});\n\n\t\t\t\t// Event handler 2: As soon as the container disconnects, we're ready to initiate a dispose.\n\t\t\t\tcontainer.on(\"disconnected\", () => {\n\t\t\t\t\tcontainer.dispose();\n\t\t\t\t});\n\n\t\t\t\tcontainer.on(\"disposed\", () => {\n\t\t\t\t\t// We are making an assumption here that the 'disposed' event is the third sent to the ITelemetryConsumer.\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tconst containerTelemetryFromSpy = telemetryConsumerConsumeSpy.getCalls()[2]!\n\t\t\t\t\t\t.args[0] as ContainerDisposedTelemetry;\n\n\t\t\t\t\tresolve({\n\t\t\t\t\t\tactualContainerTelemetry: containerTelemetryFromSpy,\n\t\t\t\t\t\texpectedContainerTelemetry: {\n\t\t\t\t\t\t\teventName: ContainerTelemetryEventNames.DISPOSED,\n\t\t\t\t\t\t\tcontainerId,\n\t\t\t\t\t\t\t// containerInstanceId is a uniquely generated UUID by the fluid-telemetry's ContainerEventTelemetryProducer class.\n\t\t\t\t\t\t\t// We can't use the underlying container's id because it is not exposed by IFluidContainer.\n\t\t\t\t\t\t\tcontainerInstanceId: containerTelemetryFromSpy.containerInstanceId,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\t{\n\t\t\t\tdurationMs: 5000,\n\t\t\t\terrorMsg:\n\t\t\t\t\t\"timeout while waiting for container 'connected' and/or 'disconnected' event\",\n\t\t\t},\n\t\t);\n\n\t\texpect(expectedContainerTelemetry).to.deep.equal(actualContainerTelemetry);\n\t\t// We won't know what the container containerInstanceId will be but we can still check that it is defined.\n\t\texpect(actualContainerTelemetry.containerInstanceId)\n\t\t\t.to.be.a(\"string\")\n\t\t\t.with.length.above(0);\n\t});\n});\n"]}
|
package/lib/tsdoc-metadata.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/fluid-telemetry",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.5.0.1",
|
|
4
4
|
"description": "Customer facing Fluid telemetry types and classes for both producing and consuming said telemetry",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -57,32 +57,39 @@
|
|
|
57
57
|
"main": "lib/index.js",
|
|
58
58
|
"types": "lib/index.d.ts",
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@fluidframework/container-definitions": ">=2.0.0-rc.
|
|
61
|
-
"@fluidframework/container-loader": ">=2.0.0-rc.
|
|
62
|
-
"@fluidframework/fluid-static": ">=2.0.0-rc.
|
|
60
|
+
"@fluidframework/container-definitions": ">=2.0.0-rc.5.0.1 <2.0.0-rc.5.1.0",
|
|
61
|
+
"@fluidframework/container-loader": ">=2.0.0-rc.5.0.1 <2.0.0-rc.5.1.0",
|
|
62
|
+
"@fluidframework/fluid-static": ">=2.0.0-rc.5.0.1 <2.0.0-rc.5.1.0",
|
|
63
63
|
"@microsoft/applicationinsights-web": "^2.8.11",
|
|
64
64
|
"uuid": "^9.0.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@arethetypeswrong/cli": "^0.15.2",
|
|
68
|
-
"@
|
|
69
|
-
"@fluid-internal/
|
|
70
|
-
"@fluid-
|
|
71
|
-
"@
|
|
72
|
-
"@
|
|
68
|
+
"@biomejs/biome": "^1.7.3",
|
|
69
|
+
"@fluid-internal/client-utils": ">=2.0.0-rc.5.0.1 <2.0.0-rc.5.1.0",
|
|
70
|
+
"@fluid-internal/mocha-test-setup": ">=2.0.0-rc.5.0.1 <2.0.0-rc.5.1.0",
|
|
71
|
+
"@fluid-tools/build-cli": "^0.39.0",
|
|
72
|
+
"@fluidframework/build-tools": "^0.39.0",
|
|
73
|
+
"@fluidframework/test-utils": ">=2.0.0-rc.5.0.1 <2.0.0-rc.5.1.0",
|
|
74
|
+
"@fluidframework/tinylicious-client": ">=2.0.0-rc.5.0.1 <2.0.0-rc.5.1.0",
|
|
75
|
+
"@fluidframework/tree": ">=2.0.0-rc.5.0.1 <2.0.0-rc.5.1.0",
|
|
76
|
+
"@microsoft/api-extractor": "^7.45.1",
|
|
73
77
|
"@types/chai": "^4.0.0",
|
|
74
78
|
"@types/mocha": "^9.1.1",
|
|
75
79
|
"@types/sinon": "^17.0.3",
|
|
76
80
|
"@types/uuid": "^9.0.2",
|
|
77
81
|
"chai": "^4.2.0",
|
|
82
|
+
"concurrently": "^8.2.1",
|
|
78
83
|
"copyfiles": "^2.4.1",
|
|
79
84
|
"eslint": "~8.55.0",
|
|
80
85
|
"mocha": "^10.2.0",
|
|
81
86
|
"prettier": "~3.0.3",
|
|
82
87
|
"rimraf": "^4.4.0",
|
|
83
88
|
"sinon": "^17.0.1",
|
|
89
|
+
"start-server-and-test": "^2.0.3",
|
|
90
|
+
"tinylicious": "^5.0.0",
|
|
84
91
|
"tslib": "^1.10.0",
|
|
85
|
-
"typescript": "~5.
|
|
92
|
+
"typescript": "~5.4.5"
|
|
86
93
|
},
|
|
87
94
|
"fluidBuild": {
|
|
88
95
|
"tasks": {
|
|
@@ -105,21 +112,42 @@
|
|
|
105
112
|
"build:docs": "api-extractor run --local",
|
|
106
113
|
"build:esnext": "tsc --project ./tsconfig.json",
|
|
107
114
|
"check:are-the-types-wrong": "attw --pack .",
|
|
108
|
-
"check:
|
|
115
|
+
"check:biome": "biome check . --formatter-enabled=true",
|
|
116
|
+
"check:exports": "concurrently \"npm:check:exports:*\"",
|
|
117
|
+
"check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
|
|
118
|
+
"check:exports:cjs:beta": "api-extractor run --config api-extractor/api-extractor-lint-beta.cjs.json",
|
|
119
|
+
"check:exports:cjs:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.cjs.json",
|
|
120
|
+
"check:exports:cjs:public": "api-extractor run --config api-extractor/api-extractor-lint-public.cjs.json",
|
|
121
|
+
"check:exports:esm:beta": "api-extractor run --config api-extractor/api-extractor-lint-beta.esm.json",
|
|
122
|
+
"check:exports:esm:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.esm.json",
|
|
123
|
+
"check:exports:esm:public": "api-extractor run --config api-extractor/api-extractor-lint-public.esm.json",
|
|
124
|
+
"check:format": "npm run check:biome",
|
|
125
|
+
"check:prettier": "prettier --check . --cache --ignore-path ../../../../.prettierignore",
|
|
109
126
|
"ci:build:docs": "api-extractor run",
|
|
110
127
|
"clean": "rimraf --glob _api-extractor-temp coverage dist lib \"*.d.ts\" nyc \"**/*.tsbuildinfo\" \"**/*.build.log\"",
|
|
111
128
|
"eslint": "eslint --format stylish src",
|
|
112
129
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
113
|
-
"format": "
|
|
130
|
+
"format": "npm run format:biome",
|
|
114
131
|
"format-and-build": "npm run format && npm run build",
|
|
115
132
|
"format-and-compile": "npm run format && npm run build:compile",
|
|
133
|
+
"format:biome": "biome check . --formatter-enabled=true --apply",
|
|
116
134
|
"format:prettier": "prettier --write . --cache --ignore-path ../../../../.prettierignore",
|
|
117
135
|
"lint": "fluid-build . --task lint",
|
|
118
136
|
"lint:fix": "fluid-build . --task eslint:fix --task format",
|
|
119
|
-
"test": "
|
|
120
|
-
"test
|
|
121
|
-
"test:mocha
|
|
122
|
-
"test:mocha:
|
|
137
|
+
"start:tinylicious:test": "tinylicious > tinylicious.log 2>&1",
|
|
138
|
+
"test": "start-server-and-test start:tinylicious:test 7070 test:mocha:all",
|
|
139
|
+
"test:mocha": "npm run test:mocha:esm:unit && echo skipping cjs to avoid overhead - npm run test:mocha:cjs:unit",
|
|
140
|
+
"test:mocha:all": "npm run test:mocha:esm:all && echo skipping cjs to avoid overhead - npm run test:mocha:cjs:all",
|
|
141
|
+
"test:mocha:cjs:all": "mocha --recursive \"dist/test/**/*.spec*.js\" --exit",
|
|
142
|
+
"test:mocha:cjs:end-to-end": "mocha --recursive \"dist/test/**/*.spec.realsvc.js\" --exit",
|
|
143
|
+
"test:mocha:cjs:unit": "mocha --recursive \"dist/test/**/*.spec.js\" --exit",
|
|
144
|
+
"test:mocha:end-to-end": "npm run test:mocha:esm:end-to-end && echo skipping cjs to avoid overhead - npm run test:mocha:cjs:end-to-end",
|
|
145
|
+
"test:mocha:esm:all": "mocha --recursive \"lib/test/**/*.spec*.js\" --exit",
|
|
146
|
+
"test:mocha:esm:end-to-end": "mocha --recursive \"lib/test/**/*.spec.realsvc.js\" --exit",
|
|
147
|
+
"test:mocha:esm:unit": "mocha --recursive \"lib/test/**/*.spec.js\" --exit",
|
|
148
|
+
"test:realsvc": "npm run test:realsvc:tinylicious",
|
|
149
|
+
"test:realsvc:tinylicious": "start-server-and-test start:tinylicious:test 7070 test:realsvc:tinylicious:run",
|
|
150
|
+
"test:realsvc:tinylicious:run": "npm run test:mocha:end-to-end",
|
|
123
151
|
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../../common/build/build-common/src/cjs/package.json ./dist",
|
|
124
152
|
"typetests:gen": "flub generate typetests --dir . -v --publicFallback",
|
|
125
153
|
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import type { ApplicationInsights } from "@microsoft/applicationinsights-web";
|
|
7
|
+
|
|
7
8
|
import type { IFluidTelemetry, ITelemetryConsumer } from "../common/index.js";
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import type { ICriticalContainerError } from "@fluidframework/container-definitions";
|
|
7
|
+
|
|
8
|
+
import type { IFluidTelemetry } from "../common/index.js";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* This file contains the types for container telemetry that can be produced.
|
|
@@ -3,16 +3,18 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import type { IFluidContainer } from "@fluidframework/fluid-static";
|
|
6
|
+
import type { ICriticalContainerError } from "@fluidframework/container-definitions";
|
|
8
7
|
import { ConnectionState } from "@fluidframework/container-loader";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
import type {
|
|
8
|
+
import type { IFluidContainer } from "@fluidframework/fluid-static";
|
|
9
|
+
|
|
10
|
+
import type { ITelemetryConsumer } from "../common/index.js";
|
|
11
|
+
|
|
12
12
|
import {
|
|
13
13
|
type IFluidContainerSystemEventName,
|
|
14
14
|
IFluidContainerSystemEventNames,
|
|
15
15
|
} from "./containerSystemEvents.js";
|
|
16
|
+
import type { IContainerTelemetry } from "./containerTelemetry.js";
|
|
17
|
+
import type { ContainerEventTelemetryProducer } from "./telemetryProducer.js";
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* This class manages container telemetry intended for customers to consume by wiring together the provided container system events, telemetry producers and consumers together.
|