@fluidframework/fluid-telemetry 2.0.0-dev-rc.3.0.0.253463

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 (135) hide show
  1. package/.eslintrc.cjs +11 -0
  2. package/.mocharc.cjs +12 -0
  3. package/LICENSE +21 -0
  4. package/README.md +118 -0
  5. package/api-extractor-cjs.json +30 -0
  6. package/api-extractor-lint.json +4 -0
  7. package/api-extractor.json +26 -0
  8. package/api-report/external-telemetry.api.md +68 -0
  9. package/api-report/fluid-telemetry.api.md +68 -0
  10. package/dist/app-insights/appInsightsTelemetryConsumer.d.ts +16 -0
  11. package/dist/app-insights/appInsightsTelemetryConsumer.d.ts.map +1 -0
  12. package/dist/app-insights/appInsightsTelemetryConsumer.js +24 -0
  13. package/dist/app-insights/appInsightsTelemetryConsumer.js.map +1 -0
  14. package/dist/app-insights/index.d.ts +6 -0
  15. package/dist/app-insights/index.d.ts.map +1 -0
  16. package/dist/app-insights/index.js +10 -0
  17. package/dist/app-insights/index.js.map +1 -0
  18. package/dist/common/consumers/index.d.ts +35 -0
  19. package/dist/common/consumers/index.d.ts.map +1 -0
  20. package/dist/common/consumers/index.js +7 -0
  21. package/dist/common/consumers/index.js.map +1 -0
  22. package/dist/common/index.d.ts +7 -0
  23. package/dist/common/index.d.ts.map +1 -0
  24. package/dist/common/index.js +7 -0
  25. package/dist/common/index.js.map +1 -0
  26. package/dist/common/telemetry/index.d.ts +31 -0
  27. package/dist/common/telemetry/index.d.ts.map +1 -0
  28. package/dist/common/telemetry/index.js +7 -0
  29. package/dist/common/telemetry/index.js.map +1 -0
  30. package/dist/container/containerSystemEvents.d.ts +21 -0
  31. package/dist/container/containerSystemEvents.d.ts.map +1 -0
  32. package/dist/container/containerSystemEvents.js +20 -0
  33. package/dist/container/containerSystemEvents.js.map +1 -0
  34. package/dist/container/containerTelemetry.d.ts +118 -0
  35. package/dist/container/containerTelemetry.d.ts.map +1 -0
  36. package/dist/container/containerTelemetry.js +36 -0
  37. package/dist/container/containerTelemetry.js.map +1 -0
  38. package/dist/container/index.d.ts +9 -0
  39. package/dist/container/index.d.ts.map +1 -0
  40. package/dist/container/index.js +16 -0
  41. package/dist/container/index.js.map +1 -0
  42. package/dist/container/telemetryManager.d.ts +34 -0
  43. package/dist/container/telemetryManager.d.ts.map +1 -0
  44. package/dist/container/telemetryManager.js +62 -0
  45. package/dist/container/telemetryManager.js.map +1 -0
  46. package/dist/container/telemetryProducer.d.ts +25 -0
  47. package/dist/container/telemetryProducer.d.ts.map +1 -0
  48. package/dist/container/telemetryProducer.js +68 -0
  49. package/dist/container/telemetryProducer.js.map +1 -0
  50. package/dist/factory/index.d.ts +36 -0
  51. package/dist/factory/index.d.ts.map +1 -0
  52. package/dist/factory/index.js +20 -0
  53. package/dist/factory/index.js.map +1 -0
  54. package/dist/fluid-telemetry-alpha.d.ts +213 -0
  55. package/dist/fluid-telemetry-beta.d.ts +213 -0
  56. package/dist/fluid-telemetry-public.d.ts +32 -0
  57. package/dist/fluid-telemetry-untrimmed.d.ts +213 -0
  58. package/dist/index.d.ts +13 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +12 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/package.json +3 -0
  63. package/dist/tsdoc-metadata.json +11 -0
  64. package/lib/app-insights/appInsightsTelemetryConsumer.d.ts +16 -0
  65. package/lib/app-insights/appInsightsTelemetryConsumer.d.ts.map +1 -0
  66. package/lib/app-insights/appInsightsTelemetryConsumer.js +20 -0
  67. package/lib/app-insights/appInsightsTelemetryConsumer.js.map +1 -0
  68. package/lib/app-insights/index.d.ts +6 -0
  69. package/lib/app-insights/index.d.ts.map +1 -0
  70. package/lib/app-insights/index.js +6 -0
  71. package/lib/app-insights/index.js.map +1 -0
  72. package/lib/common/consumers/index.d.ts +35 -0
  73. package/lib/common/consumers/index.d.ts.map +1 -0
  74. package/lib/common/consumers/index.js +6 -0
  75. package/lib/common/consumers/index.js.map +1 -0
  76. package/lib/common/index.d.ts +7 -0
  77. package/lib/common/index.d.ts.map +1 -0
  78. package/lib/common/index.js +6 -0
  79. package/lib/common/index.js.map +1 -0
  80. package/lib/common/telemetry/index.d.ts +31 -0
  81. package/lib/common/telemetry/index.d.ts.map +1 -0
  82. package/lib/common/telemetry/index.js +6 -0
  83. package/lib/common/telemetry/index.js.map +1 -0
  84. package/lib/container/containerSystemEvents.d.ts +21 -0
  85. package/lib/container/containerSystemEvents.d.ts.map +1 -0
  86. package/lib/container/containerSystemEvents.js +17 -0
  87. package/lib/container/containerSystemEvents.js.map +1 -0
  88. package/lib/container/containerTelemetry.d.ts +118 -0
  89. package/lib/container/containerTelemetry.d.ts.map +1 -0
  90. package/lib/container/containerTelemetry.js +33 -0
  91. package/lib/container/containerTelemetry.js.map +1 -0
  92. package/lib/container/index.d.ts +9 -0
  93. package/lib/container/index.d.ts.map +1 -0
  94. package/lib/container/index.js +9 -0
  95. package/lib/container/index.js.map +1 -0
  96. package/lib/container/telemetryManager.d.ts +34 -0
  97. package/lib/container/telemetryManager.d.ts.map +1 -0
  98. package/lib/container/telemetryManager.js +58 -0
  99. package/lib/container/telemetryManager.js.map +1 -0
  100. package/lib/container/telemetryProducer.d.ts +25 -0
  101. package/lib/container/telemetryProducer.d.ts.map +1 -0
  102. package/lib/container/telemetryProducer.js +64 -0
  103. package/lib/container/telemetryProducer.js.map +1 -0
  104. package/lib/factory/index.d.ts +36 -0
  105. package/lib/factory/index.d.ts.map +1 -0
  106. package/lib/factory/index.js +16 -0
  107. package/lib/factory/index.js.map +1 -0
  108. package/lib/fluid-telemetry-alpha.d.ts +213 -0
  109. package/lib/fluid-telemetry-beta.d.ts +213 -0
  110. package/lib/fluid-telemetry-public.d.ts +32 -0
  111. package/lib/fluid-telemetry-untrimmed.d.ts +213 -0
  112. package/lib/index.d.ts +13 -0
  113. package/lib/index.d.ts.map +1 -0
  114. package/lib/index.js +7 -0
  115. package/lib/index.js.map +1 -0
  116. package/lib/test/containerTelemetry.spec.d.ts +2 -0
  117. package/lib/test/containerTelemetry.spec.d.ts.map +1 -0
  118. package/lib/test/containerTelemetry.spec.js +138 -0
  119. package/lib/test/containerTelemetry.spec.js.map +1 -0
  120. package/lib/tsdoc-metadata.json +11 -0
  121. package/package.json +145 -0
  122. package/src/app-insights/appInsightsTelemetryConsumer.ts +22 -0
  123. package/src/app-insights/index.ts +6 -0
  124. package/src/common/consumers/index.ts +36 -0
  125. package/src/common/index.ts +7 -0
  126. package/src/common/telemetry/index.ts +33 -0
  127. package/src/container/containerSystemEvents.ts +23 -0
  128. package/src/container/containerTelemetry.ts +126 -0
  129. package/src/container/index.ts +22 -0
  130. package/src/container/telemetryManager.ts +85 -0
  131. package/src/container/telemetryProducer.ts +87 -0
  132. package/src/factory/index.ts +42 -0
  133. package/src/index.ts +24 -0
  134. package/tsconfig.cjs.json +8 -0
  135. package/tsconfig.json +12 -0
@@ -0,0 +1,25 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { IFluidTelemetry } from "../index.js";
6
+ import { type IContainerTelemetry } from "./containerTelemetry.js";
7
+ import { type IFluidContainerSystemEventName } from "./containerSystemEvents.js";
8
+ /**
9
+ * This class produces {@link IContainerTelemetry} from raw container system events {@link @fluidframework/fluid-static#IFluidContainerEvents}.
10
+ * The class contains different helper methods for simplifying and standardizing logic for adding additional information necessary
11
+ * to produce different {@link IContainerTelemetry}.
12
+ */
13
+ export declare class ContainerEventTelemetryProducer {
14
+ private readonly containerId;
15
+ /**
16
+ * Unique identifier for the instance of the container that this class is generating telemetry for.
17
+ */
18
+ private readonly containerInstanceId;
19
+ constructor(containerId: string);
20
+ produceFromSystemEvent(eventName: IFluidContainerSystemEventName, payload?: unknown): IContainerTelemetry | undefined;
21
+ produceHeartbeatTelemetry: () => IFluidTelemetry;
22
+ private readonly produceBaseContainerTelemetry;
23
+ private readonly produceDiposedTelemetry;
24
+ }
25
+ //# sourceMappingURL=telemetryProducer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetryProducer.d.ts","sourceRoot":"","sources":["../../src/container/telemetryProducer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAGN,KAAK,mBAAmB,EAExB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,KAAK,8BAA8B,EAEnC,MAAM,4BAA4B,CAAC;AAEpC;;;;GAIG;AACH,qBAAa,+BAA+B;IAMxB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAL/C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAU;gBAEV,WAAW,EAAE,MAAM;IAEhD,sBAAsB,CAC5B,SAAS,EAAE,8BAA8B,EACzC,OAAO,CAAC,EAAE,OAAO,GACf,mBAAmB,GAAG,SAAS;IAoB3B,yBAAyB,QAAO,eAAe,CAMpD;IAEF,OAAO,CAAC,QAAQ,CAAC,6BAA6B,CAQ5C;IAEF,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAYtC;CACF"}
@@ -0,0 +1,64 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { v4 as uuid } from "uuid";
6
+ import { ContainerTelemetryEventNames, } from "./containerTelemetry.js";
7
+ import { IFluidContainerSystemEventNames, } from "./containerSystemEvents.js";
8
+ /**
9
+ * This class produces {@link IContainerTelemetry} from raw container system events {@link @fluidframework/fluid-static#IFluidContainerEvents}.
10
+ * The class contains different helper methods for simplifying and standardizing logic for adding additional information necessary
11
+ * to produce different {@link IContainerTelemetry}.
12
+ */
13
+ export class ContainerEventTelemetryProducer {
14
+ constructor(containerId) {
15
+ this.containerId = containerId;
16
+ /**
17
+ * Unique identifier for the instance of the container that this class is generating telemetry for.
18
+ */
19
+ this.containerInstanceId = uuid();
20
+ this.produceHeartbeatTelemetry = () => {
21
+ return {
22
+ eventName: "fluidframework.container.heartbeat",
23
+ containerId: this.containerId,
24
+ containerInstanceId: this.containerInstanceId,
25
+ };
26
+ };
27
+ this.produceBaseContainerTelemetry = (eventName) => {
28
+ return {
29
+ eventName,
30
+ containerId: this.containerId,
31
+ containerInstanceId: this.containerInstanceId,
32
+ };
33
+ };
34
+ this.produceDiposedTelemetry = (payload) => {
35
+ const telemetry = {
36
+ eventName: ContainerTelemetryEventNames.DISPOSED,
37
+ containerId: this.containerId,
38
+ containerInstanceId: this.containerInstanceId,
39
+ };
40
+ if (payload?.error !== undefined) {
41
+ telemetry.error = payload.error;
42
+ }
43
+ return telemetry;
44
+ };
45
+ }
46
+ produceFromSystemEvent(eventName, payload) {
47
+ switch (eventName) {
48
+ case IFluidContainerSystemEventNames.CONNECTED: {
49
+ return this.produceBaseContainerTelemetry(ContainerTelemetryEventNames.CONNECTED);
50
+ }
51
+ case IFluidContainerSystemEventNames.DISCONNECTED: {
52
+ return this.produceBaseContainerTelemetry(ContainerTelemetryEventNames.DISCONNECTED);
53
+ }
54
+ case IFluidContainerSystemEventNames.DISPOSED: {
55
+ const typedPayload = payload;
56
+ return this.produceDiposedTelemetry(typedPayload);
57
+ }
58
+ default: {
59
+ break;
60
+ }
61
+ }
62
+ }
63
+ }
64
+ //# sourceMappingURL=telemetryProducer.js.map
@@ -0,0 +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;AAElC,OAAO,EACN,4BAA4B,GAI5B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEN,+BAA+B,GAC/B,MAAM,4BAA4B,CAAC;AAEpC;;;;GAIG;AACH,MAAM,OAAO,+BAA+B;IAM3C,YAAoC,WAAmB;QAAnB,gBAAW,GAAX,WAAW,CAAQ;QALvD;;WAEG;QACc,wBAAmB,GAAG,IAAI,EAAE,CAAC;QA2BvC,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;gBACjC,SAAS,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;aAChC;YACD,OAAO,SAAS,CAAC;QAClB,CAAC,CAAC;IAvDwD,CAAC;IAEpD,sBAAsB,CAC5B,SAAyC,EACzC,OAAiB;QAEjB,QAAQ,SAAS,EAAE;YAClB,KAAK,+BAA+B,CAAC,SAAS,CAAC,CAAC;gBAC/C,OAAO,IAAI,CAAC,6BAA6B,CAAC,4BAA4B,CAAC,SAAS,CAAC,CAAC;aAClF;YACD,KAAK,+BAA+B,CAAC,YAAY,CAAC,CAAC;gBAClD,OAAO,IAAI,CAAC,6BAA6B,CACxC,4BAA4B,CAAC,YAAY,CACzC,CAAC;aACF;YACD,KAAK,+BAA+B,CAAC,QAAQ,CAAC,CAAC;gBAC9C,MAAM,YAAY,GAAG,OAA8C,CAAC;gBACpE,OAAO,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;aAClD;YACD,OAAO,CAAC,CAAC;gBACR,MAAM;aACN;SACD;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\";\nimport type { IFluidTelemetry } from \"../index.js\";\nimport {\n\tContainerTelemetryEventNames,\n\ttype ContainerTelemetryEventName,\n\ttype IContainerTelemetry,\n\ttype ContainerDisposedTelemetry,\n} from \"./containerTelemetry.js\";\nimport {\n\ttype IFluidContainerSystemEventName,\n\tIFluidContainerSystemEventNames,\n} from \"./containerSystemEvents.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(\n\t\t\t\t\tContainerTelemetryEventNames.DISCONNECTED,\n\t\t\t\t);\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"]}
@@ -0,0 +1,36 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { IFluidContainer } from "@fluidframework/fluid-static";
6
+ import { type ITelemetryConsumer } from "../common/index.js";
7
+ /**
8
+ * Configuration object for subscribing to {@link @fluidframework/fluid-telemetry#IFluidTelemetry} and consuming said telemetry via one or more {@link ITelemetryConsumer}
9
+ *
10
+ * @beta
11
+ */
12
+ export interface TelemetryConfig {
13
+ /**
14
+ * The container whose events should be monitored, transformed into Fluid telemetry, and sent to a {@link ITelemetryConsumer}.
15
+ */
16
+ container: IFluidContainer;
17
+ /**
18
+ * Unique identifier for the passed in container, i.e. the return value of a call
19
+ * to {@link @fluidframework/fluid-static#IFluidContainer.attach | `IFluidContainer.attach()`} when creating a new
20
+ * Fluid container, or the id used to load a pre-existing one.
21
+ */
22
+ containerId: string;
23
+ /**
24
+ * Conusmers take incoming produced {@link @fluidframework/fluid-telemetry#IFluidTelemetry} and do something of your choice with it.
25
+ * This could be sending the telemetry to a cloud platform or just console logging.
26
+ */
27
+ consumers: ITelemetryConsumer[];
28
+ }
29
+ /**
30
+ * Starts creating {@link @fluidframework/fluid-telemetry#IFluidTelemetry} by transforming raw system events emitted by the specified container
31
+ * into said telemetry and passing it onto to the specified {@link ITelemetryConsumer}
32
+ *
33
+ * @beta
34
+ */
35
+ export declare const startTelemetry: (config: TelemetryConfig) => void;
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D;;;;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"}
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ContainerTelemetryManager, ContainerEventTelemetryProducer } from "../container/index.js";
6
+ /**
7
+ * Starts creating {@link @fluidframework/fluid-telemetry#IFluidTelemetry} by transforming raw system events emitted by the specified container
8
+ * into said telemetry and passing it onto to the specified {@link ITelemetryConsumer}
9
+ *
10
+ * @beta
11
+ */
12
+ export const startTelemetry = (config) => {
13
+ const telemetryProducer = new ContainerEventTelemetryProducer(config.containerId);
14
+ new ContainerTelemetryManager(config.container, telemetryProducer, config.consumers);
15
+ };
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/factory/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AA0BnG;;;;;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\";\nimport { ContainerTelemetryManager, ContainerEventTelemetryProducer } from \"../container/index.js\";\nimport { type ITelemetryConsumer } from \"../common/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"]}
@@ -0,0 +1,213 @@
1
+ /**
2
+ * This package provides an implementation and types for producing and consuming telemetry for Fluid Framework applications
3
+ * @packageDocumentation
4
+ */
5
+
6
+ import { ICriticalContainerError } from '@fluidframework/container-definitions';
7
+ import type { IFluidContainer } from '@fluidframework/fluid-static';
8
+
9
+ /**
10
+ * The container "connected" telemetry event.
11
+ * It is produced from an internal Fluid container system event {@link @fluidframework/container-definitions#IContainerEvents} which is emitted when the {@link @fluidframework/container-definitions#IContainer} completes connecting to the Fluid service.
12
+ *
13
+ * @see More details about {@link @fluidframework/container-definitions#IContainer.connectionState | the containers connection state}
14
+ * @see More details about {@link @fluidframework/container-definitions#IContainer.connect | the function to connect a container }
15
+ * @see More details about {@link @fluidframework/container-definitions#IContainer.connectionState | the containers connection state}
16
+ *
17
+ * @beta
18
+ */
19
+ export declare interface ContainerConnectedTelemetry extends IContainerTelemetry {
20
+ /**
21
+ * {@inheritDoc IFluidTelemetry.eventName}
22
+ */
23
+ eventName: "fluidframework.container.connected";
24
+ }
25
+
26
+ /**
27
+ * The container "disconnected" telemetry event. This telemetry is produced from an internal Fluid container system event
28
+ * {@link @fluidframework/container-definitions#IContainerEvents} which is emitted when the {@link @fluidframework/container-definitions#IContainer}
29
+ * becomes disconnected from the Fluid service.
30
+ *
31
+ * @see More details about{@link @fluidframework/container-definitions#IContainer.connectionState | the containers connection state}
32
+ *
33
+ * @see More details about{@link @fluidframework/container-definitions#IContainer.disconnect | the function to disconnect a container}
34
+ *
35
+ * @beta
36
+ */
37
+ export declare interface ContainerDisconnectedTelemetry extends IContainerTelemetry {
38
+ /**
39
+ * {@inheritDoc IFluidTelemetry.eventName}
40
+ */
41
+ eventName: "fluidframework.container.disconnected";
42
+ }
43
+
44
+ /**
45
+ *
46
+ * The Fluid container "disposed" telemetry event. This telemetry is produced from the "disposed" Fluid container system event
47
+ * which is emitted when the {@link @fluidframework/fluid-static#IFluidContainer} is closed, which permanently disables it.
48
+ *
49
+ * @see More details about{@link @fluidframework/container-definitions#IContainer.close | the container close event}
50
+ *
51
+ * @beta
52
+ */
53
+ export declare interface ContainerDisposedTelemetry extends IContainerTelemetry {
54
+ /**
55
+ * {@inheritDoc IFluidTelemetry.eventName}
56
+ */
57
+ eventName: "fluidframework.container.disposed";
58
+ /**
59
+ * If the container was closed due to error (as opposed to an explicit call to
60
+ * {@link @fluidframework/fluid-static#IFluidContainer."dispose"}), this will contain details about the error that caused it.
61
+ */
62
+ error?: ICriticalContainerError;
63
+ }
64
+
65
+ /**
66
+ * The aggregate type for all values within {@link ContainerTelemetryEventNames}
67
+ * @beta
68
+ */
69
+ export declare type ContainerTelemetryEventName = (typeof ContainerTelemetryEventNames)[keyof typeof ContainerTelemetryEventNames];
70
+
71
+ /**
72
+ * This object contains names for Container Telemetry. Unlike the raw {@link @fluidframework/fluid-static#IFluidContainerEvents | IFluidContainer system event names} they contain more information such as the scope
73
+ *
74
+ * @beta
75
+ */
76
+ export declare const ContainerTelemetryEventNames: {
77
+ /**
78
+ * Name for the container telemetry event that is intended to be produced from the IFluidContainer "connected" {@link @fluidframework/fluid-static#IFluidContainerEvents | system event}
79
+ *
80
+ * @see {@link ContainerConnectedTelemetry}
81
+ */
82
+ readonly CONNECTED: "fluidframework.container.connected";
83
+ /**
84
+ * Name for the container telemetry event that is intended to be produced from the IFluidContainer "disconnected" {@link @fluidframework/fluid-static#IFluidContainerEvents | system event}
85
+ *
86
+ * @see {@link ContainerDisconnectedTelemetry}
87
+ */
88
+ readonly DISCONNECTED: "fluidframework.container.disconnected";
89
+ /**
90
+ * Name for the container telemetry event that is intended to be produced from the IFluidContainer "disposed" {@link @fluidframework/fluid-static#IFluidContainerEvents | system event}
91
+ *
92
+ * @see {@link ContainerDisposedTelemetry}
93
+ */
94
+ readonly DISPOSED: "fluidframework.container.disposed";
95
+ };
96
+
97
+ /**
98
+ * Aggregate type for all the different types of Fluid telemetry event names.
99
+ *
100
+ * @privateremarks This only looks odd right now because {@link ContainerTelemetryEventName} is the only aggregation at the moment.
101
+ *
102
+ * @beta
103
+ */
104
+ export declare type FluidTelemetryEventName = ContainerTelemetryEventName;
105
+
106
+ /**
107
+ * The base interface for all Container telemetry
108
+ * @beta
109
+ */
110
+ export declare interface IContainerTelemetry extends IFluidTelemetry {
111
+ /**
112
+ * {@inheritdoc IFluidTelemetry.eventName}
113
+ */
114
+ eventName: ContainerTelemetryEventName;
115
+ /**
116
+ * Unique identifier for a container, stable across creation and load.
117
+ * I.e. different clients loading the same container (or the same client loading the container two separate times)
118
+ * will agree on this value.
119
+ *
120
+ * @remarks This can be undefined for a container that has not been attached.
121
+ */
122
+ containerId?: string;
123
+ /**
124
+ * Unique identifier for the container instance that generated the telemetry.
125
+ * This is not a stable identifier for the container across clients/time.
126
+ * Every load of the container will result in a different value.
127
+ *
128
+ */
129
+ containerInstanceId: string;
130
+ }
131
+
132
+ export { ICriticalContainerError }
133
+
134
+ /**
135
+ * The base interface extended by all Fluid telemetry
136
+ *
137
+ * @see {@link @fluidframework/fluid-telemetry#IContainerTelemetry} for an extension of this interface for all container related telemetry.
138
+ *
139
+ * @beta
140
+ */
141
+ export declare interface IFluidTelemetry {
142
+ /**
143
+ * The unique name of the telemetry event. The event name contains scope concatenated together
144
+ * with periods to enable more granular log searching
145
+ *
146
+ * @example
147
+ * "fluidframework.container.connected"
148
+ */
149
+ eventName: FluidTelemetryEventName;
150
+ }
151
+
152
+ /**
153
+ * Base interface for all telemetry consumers.
154
+ * Conusmers are intended to take incoming produced {@link IFluidTelemetry} and do something of your choice with it.
155
+ * This could be sending the telemetry to a cloud platform or just console logging.
156
+ *
157
+ * @example
158
+ * Here is an example of how we construct a consumer to send telemetry to Azure App Insights, a cloud logging platform:
159
+ * ```ts
160
+ * class AppInsightsTelemetryConsumer implements ITelemetryConsumer {
161
+ * constructor(private readonly appInsightsClient: ApplicationInsights) {}
162
+ *
163
+ * consume(event: IFluidTelemetry) {
164
+ * this.appInsightsClient.trackEvent({
165
+ * name: event.eventName,
166
+ * properties: event,
167
+ * });
168
+ * }
169
+ * }
170
+ *```
171
+ *
172
+ * @beta
173
+ */
174
+ export declare interface ITelemetryConsumer {
175
+ /**
176
+ * This method is intended to take created {@link IFluidTelemetry} and do something with it.
177
+ * This could be sending the telemetry to a cloud platform, just console logging or something else of your choice.
178
+ */
179
+ consume(event: IFluidTelemetry): any;
180
+ }
181
+
182
+ /**
183
+ * Starts creating {@link @fluidframework/fluid-telemetry#IFluidTelemetry} by transforming raw system events emitted by the specified container
184
+ * into said telemetry and passing it onto to the specified {@link ITelemetryConsumer}
185
+ *
186
+ * @beta
187
+ */
188
+ export declare const startTelemetry: (config: TelemetryConfig) => void;
189
+
190
+ /**
191
+ * Configuration object for subscribing to {@link @fluidframework/fluid-telemetry#IFluidTelemetry} and consuming said telemetry via one or more {@link ITelemetryConsumer}
192
+ *
193
+ * @beta
194
+ */
195
+ export declare interface TelemetryConfig {
196
+ /**
197
+ * The container whose events should be monitored, transformed into Fluid telemetry, and sent to a {@link ITelemetryConsumer}.
198
+ */
199
+ container: IFluidContainer;
200
+ /**
201
+ * Unique identifier for the passed in container, i.e. the return value of a call
202
+ * to {@link @fluidframework/fluid-static#IFluidContainer.attach | `IFluidContainer.attach()`} when creating a new
203
+ * Fluid container, or the id used to load a pre-existing one.
204
+ */
205
+ containerId: string;
206
+ /**
207
+ * Conusmers take incoming produced {@link @fluidframework/fluid-telemetry#IFluidTelemetry} and do something of your choice with it.
208
+ * This could be sending the telemetry to a cloud platform or just console logging.
209
+ */
210
+ consumers: ITelemetryConsumer[];
211
+ }
212
+
213
+ export { }
@@ -0,0 +1,213 @@
1
+ /**
2
+ * This package provides an implementation and types for producing and consuming telemetry for Fluid Framework applications
3
+ * @packageDocumentation
4
+ */
5
+
6
+ import { ICriticalContainerError } from '@fluidframework/container-definitions';
7
+ import type { IFluidContainer } from '@fluidframework/fluid-static';
8
+
9
+ /**
10
+ * The container "connected" telemetry event.
11
+ * It is produced from an internal Fluid container system event {@link @fluidframework/container-definitions#IContainerEvents} which is emitted when the {@link @fluidframework/container-definitions#IContainer} completes connecting to the Fluid service.
12
+ *
13
+ * @see More details about {@link @fluidframework/container-definitions#IContainer.connectionState | the containers connection state}
14
+ * @see More details about {@link @fluidframework/container-definitions#IContainer.connect | the function to connect a container }
15
+ * @see More details about {@link @fluidframework/container-definitions#IContainer.connectionState | the containers connection state}
16
+ *
17
+ * @beta
18
+ */
19
+ export declare interface ContainerConnectedTelemetry extends IContainerTelemetry {
20
+ /**
21
+ * {@inheritDoc IFluidTelemetry.eventName}
22
+ */
23
+ eventName: "fluidframework.container.connected";
24
+ }
25
+
26
+ /**
27
+ * The container "disconnected" telemetry event. This telemetry is produced from an internal Fluid container system event
28
+ * {@link @fluidframework/container-definitions#IContainerEvents} which is emitted when the {@link @fluidframework/container-definitions#IContainer}
29
+ * becomes disconnected from the Fluid service.
30
+ *
31
+ * @see More details about{@link @fluidframework/container-definitions#IContainer.connectionState | the containers connection state}
32
+ *
33
+ * @see More details about{@link @fluidframework/container-definitions#IContainer.disconnect | the function to disconnect a container}
34
+ *
35
+ * @beta
36
+ */
37
+ export declare interface ContainerDisconnectedTelemetry extends IContainerTelemetry {
38
+ /**
39
+ * {@inheritDoc IFluidTelemetry.eventName}
40
+ */
41
+ eventName: "fluidframework.container.disconnected";
42
+ }
43
+
44
+ /**
45
+ *
46
+ * The Fluid container "disposed" telemetry event. This telemetry is produced from the "disposed" Fluid container system event
47
+ * which is emitted when the {@link @fluidframework/fluid-static#IFluidContainer} is closed, which permanently disables it.
48
+ *
49
+ * @see More details about{@link @fluidframework/container-definitions#IContainer.close | the container close event}
50
+ *
51
+ * @beta
52
+ */
53
+ export declare interface ContainerDisposedTelemetry extends IContainerTelemetry {
54
+ /**
55
+ * {@inheritDoc IFluidTelemetry.eventName}
56
+ */
57
+ eventName: "fluidframework.container.disposed";
58
+ /**
59
+ * If the container was closed due to error (as opposed to an explicit call to
60
+ * {@link @fluidframework/fluid-static#IFluidContainer."dispose"}), this will contain details about the error that caused it.
61
+ */
62
+ error?: ICriticalContainerError;
63
+ }
64
+
65
+ /**
66
+ * The aggregate type for all values within {@link ContainerTelemetryEventNames}
67
+ * @beta
68
+ */
69
+ export declare type ContainerTelemetryEventName = (typeof ContainerTelemetryEventNames)[keyof typeof ContainerTelemetryEventNames];
70
+
71
+ /**
72
+ * This object contains names for Container Telemetry. Unlike the raw {@link @fluidframework/fluid-static#IFluidContainerEvents | IFluidContainer system event names} they contain more information such as the scope
73
+ *
74
+ * @beta
75
+ */
76
+ export declare const ContainerTelemetryEventNames: {
77
+ /**
78
+ * Name for the container telemetry event that is intended to be produced from the IFluidContainer "connected" {@link @fluidframework/fluid-static#IFluidContainerEvents | system event}
79
+ *
80
+ * @see {@link ContainerConnectedTelemetry}
81
+ */
82
+ readonly CONNECTED: "fluidframework.container.connected";
83
+ /**
84
+ * Name for the container telemetry event that is intended to be produced from the IFluidContainer "disconnected" {@link @fluidframework/fluid-static#IFluidContainerEvents | system event}
85
+ *
86
+ * @see {@link ContainerDisconnectedTelemetry}
87
+ */
88
+ readonly DISCONNECTED: "fluidframework.container.disconnected";
89
+ /**
90
+ * Name for the container telemetry event that is intended to be produced from the IFluidContainer "disposed" {@link @fluidframework/fluid-static#IFluidContainerEvents | system event}
91
+ *
92
+ * @see {@link ContainerDisposedTelemetry}
93
+ */
94
+ readonly DISPOSED: "fluidframework.container.disposed";
95
+ };
96
+
97
+ /**
98
+ * Aggregate type for all the different types of Fluid telemetry event names.
99
+ *
100
+ * @privateremarks This only looks odd right now because {@link ContainerTelemetryEventName} is the only aggregation at the moment.
101
+ *
102
+ * @beta
103
+ */
104
+ export declare type FluidTelemetryEventName = ContainerTelemetryEventName;
105
+
106
+ /**
107
+ * The base interface for all Container telemetry
108
+ * @beta
109
+ */
110
+ export declare interface IContainerTelemetry extends IFluidTelemetry {
111
+ /**
112
+ * {@inheritdoc IFluidTelemetry.eventName}
113
+ */
114
+ eventName: ContainerTelemetryEventName;
115
+ /**
116
+ * Unique identifier for a container, stable across creation and load.
117
+ * I.e. different clients loading the same container (or the same client loading the container two separate times)
118
+ * will agree on this value.
119
+ *
120
+ * @remarks This can be undefined for a container that has not been attached.
121
+ */
122
+ containerId?: string;
123
+ /**
124
+ * Unique identifier for the container instance that generated the telemetry.
125
+ * This is not a stable identifier for the container across clients/time.
126
+ * Every load of the container will result in a different value.
127
+ *
128
+ */
129
+ containerInstanceId: string;
130
+ }
131
+
132
+ export { ICriticalContainerError }
133
+
134
+ /**
135
+ * The base interface extended by all Fluid telemetry
136
+ *
137
+ * @see {@link @fluidframework/fluid-telemetry#IContainerTelemetry} for an extension of this interface for all container related telemetry.
138
+ *
139
+ * @beta
140
+ */
141
+ export declare interface IFluidTelemetry {
142
+ /**
143
+ * The unique name of the telemetry event. The event name contains scope concatenated together
144
+ * with periods to enable more granular log searching
145
+ *
146
+ * @example
147
+ * "fluidframework.container.connected"
148
+ */
149
+ eventName: FluidTelemetryEventName;
150
+ }
151
+
152
+ /**
153
+ * Base interface for all telemetry consumers.
154
+ * Conusmers are intended to take incoming produced {@link IFluidTelemetry} and do something of your choice with it.
155
+ * This could be sending the telemetry to a cloud platform or just console logging.
156
+ *
157
+ * @example
158
+ * Here is an example of how we construct a consumer to send telemetry to Azure App Insights, a cloud logging platform:
159
+ * ```ts
160
+ * class AppInsightsTelemetryConsumer implements ITelemetryConsumer {
161
+ * constructor(private readonly appInsightsClient: ApplicationInsights) {}
162
+ *
163
+ * consume(event: IFluidTelemetry) {
164
+ * this.appInsightsClient.trackEvent({
165
+ * name: event.eventName,
166
+ * properties: event,
167
+ * });
168
+ * }
169
+ * }
170
+ *```
171
+ *
172
+ * @beta
173
+ */
174
+ export declare interface ITelemetryConsumer {
175
+ /**
176
+ * This method is intended to take created {@link IFluidTelemetry} and do something with it.
177
+ * This could be sending the telemetry to a cloud platform, just console logging or something else of your choice.
178
+ */
179
+ consume(event: IFluidTelemetry): any;
180
+ }
181
+
182
+ /**
183
+ * Starts creating {@link @fluidframework/fluid-telemetry#IFluidTelemetry} by transforming raw system events emitted by the specified container
184
+ * into said telemetry and passing it onto to the specified {@link ITelemetryConsumer}
185
+ *
186
+ * @beta
187
+ */
188
+ export declare const startTelemetry: (config: TelemetryConfig) => void;
189
+
190
+ /**
191
+ * Configuration object for subscribing to {@link @fluidframework/fluid-telemetry#IFluidTelemetry} and consuming said telemetry via one or more {@link ITelemetryConsumer}
192
+ *
193
+ * @beta
194
+ */
195
+ export declare interface TelemetryConfig {
196
+ /**
197
+ * The container whose events should be monitored, transformed into Fluid telemetry, and sent to a {@link ITelemetryConsumer}.
198
+ */
199
+ container: IFluidContainer;
200
+ /**
201
+ * Unique identifier for the passed in container, i.e. the return value of a call
202
+ * to {@link @fluidframework/fluid-static#IFluidContainer.attach | `IFluidContainer.attach()`} when creating a new
203
+ * Fluid container, or the id used to load a pre-existing one.
204
+ */
205
+ containerId: string;
206
+ /**
207
+ * Conusmers take incoming produced {@link @fluidframework/fluid-telemetry#IFluidTelemetry} and do something of your choice with it.
208
+ * This could be sending the telemetry to a cloud platform or just console logging.
209
+ */
210
+ consumers: ITelemetryConsumer[];
211
+ }
212
+
213
+ export { }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * This package provides an implementation and types for producing and consuming telemetry for Fluid Framework applications
3
+ * @packageDocumentation
4
+ */
5
+
6
+ import { ICriticalContainerError } from '@fluidframework/container-definitions';
7
+ import type { IFluidContainer } from '@fluidframework/fluid-static';
8
+
9
+ /* Excluded from this release type: ContainerConnectedTelemetry */
10
+
11
+ /* Excluded from this release type: ContainerDisconnectedTelemetry */
12
+
13
+ /* Excluded from this release type: ContainerDisposedTelemetry */
14
+
15
+ /* Excluded from this release type: ContainerTelemetryEventName */
16
+
17
+ /* Excluded from this release type: ContainerTelemetryEventNames */
18
+
19
+ /* Excluded from this release type: FluidTelemetryEventName */
20
+
21
+ /* Excluded from this release type: IContainerTelemetry */
22
+ export { ICriticalContainerError }
23
+
24
+ /* Excluded from this release type: IFluidTelemetry */
25
+
26
+ /* Excluded from this release type: ITelemetryConsumer */
27
+
28
+ /* Excluded from this release type: startTelemetry */
29
+
30
+ /* Excluded from this release type: TelemetryConfig */
31
+
32
+ export { }