@fluidframework/telemetry-utils 2.0.0-internal.5.1.1 → 2.0.0-internal.5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/config.d.ts +2 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -2
- package/dist/config.js.map +1 -1
- package/dist/debugLogger.d.ts +1 -1
- package/dist/debugLogger.d.ts.map +1 -1
- package/dist/debugLogger.js.map +1 -1
- package/dist/errorLogging.d.ts +1 -1
- package/dist/errorLogging.d.ts.map +1 -1
- package/dist/errorLogging.js.map +1 -1
- package/dist/fluidErrorBase.d.ts +1 -1
- package/dist/fluidErrorBase.d.ts.map +1 -1
- package/dist/fluidErrorBase.js.map +1 -1
- package/dist/logger.d.ts +13 -4
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +18 -5
- package/dist/logger.js.map +1 -1
- package/dist/mockLogger.d.ts +1 -1
- package/dist/mockLogger.d.ts.map +1 -1
- package/dist/mockLogger.js.map +1 -1
- package/dist/sampledTelemetryHelper.d.ts +1 -1
- package/dist/sampledTelemetryHelper.d.ts.map +1 -1
- package/dist/sampledTelemetryHelper.js.map +1 -1
- package/dist/telemetryTypes.d.ts +1 -1
- package/dist/telemetryTypes.d.ts.map +1 -1
- package/dist/telemetryTypes.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js.map +1 -1
- package/lib/config.d.ts +2 -2
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +1 -1
- package/lib/config.js.map +1 -1
- package/lib/debugLogger.d.ts +1 -1
- package/lib/debugLogger.d.ts.map +1 -1
- package/lib/debugLogger.js.map +1 -1
- package/lib/errorLogging.d.ts +1 -1
- package/lib/errorLogging.d.ts.map +1 -1
- package/lib/errorLogging.js.map +1 -1
- package/lib/fluidErrorBase.d.ts +1 -1
- package/lib/fluidErrorBase.d.ts.map +1 -1
- package/lib/fluidErrorBase.js.map +1 -1
- package/lib/logger.d.ts +13 -4
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +18 -5
- package/lib/logger.js.map +1 -1
- package/lib/mockLogger.d.ts +1 -1
- package/lib/mockLogger.d.ts.map +1 -1
- package/lib/mockLogger.js.map +1 -1
- package/lib/sampledTelemetryHelper.d.ts +1 -1
- package/lib/sampledTelemetryHelper.d.ts.map +1 -1
- package/lib/sampledTelemetryHelper.js.map +1 -1
- package/lib/telemetryTypes.d.ts +1 -1
- package/lib/telemetryTypes.d.ts.map +1 -1
- package/lib/telemetryTypes.js.map +1 -1
- package/lib/utils.d.ts +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +9 -29
- package/src/config.ts +2 -2
- package/src/debugLogger.ts +1 -1
- package/src/errorLogging.ts +1 -1
- package/src/fluidErrorBase.ts +1 -1
- package/src/logger.ts +29 -4
- package/src/mockLogger.ts +1 -1
- package/src/sampledTelemetryHelper.ts +2 -2
- package/src/telemetryTypes.ts +1 -1
- package/src/utils.ts +1 -1
package/lib/telemetryTypes.d.ts
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 { ITelemetryBaseLogger, TelemetryEventCategory } from "@fluidframework/
|
|
5
|
+
import { ITelemetryBaseLogger, TelemetryEventCategory } from "@fluidframework/core-interfaces";
|
|
6
6
|
/**
|
|
7
7
|
* Property types that can be logged.
|
|
8
8
|
* Includes extra types beyond TelemetryEventPropertyType (which will be deprecated in favor of this one)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetryTypes.d.ts","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"telemetryTypes.d.ts","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAE/F;;;GAGG;AACH,oBAAY,6BAA6B,GACtC,MAAM,GACN,MAAM,GACN,OAAO,GACP,SAAS,GACT,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,GAC7B;IACA,CAAC,GAAG,EAAE,MAAM,GACZ,AADe,gEAAgE;IAC/E,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;CACrE,CAAC;AAEL;;;;GAIG;AACH,MAAM,WAAW,+BAA+B;IAC/C,KAAK,EAAE,6BAA6B,CAAC;IACrC,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,CAAC,KAAK,EAAE,MAAM,GAAG,6BAA6B,GAAG,+BAA+B,CAAC;CACjF;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAmB,SAAQ,uBAAuB;IAClE,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,yBAA0B,SAAQ,uBAAuB;IACzE,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,sBAAsB,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,uBAAuB;IACvE,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,6BAA8B,SAAQ,yBAAyB;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAChE;;;;OAIG;IACH,kBAAkB,CAAC,KAAK,EAAE,yBAAyB,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IAExE;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,uBAAuB,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IAElE;;;OAGG;IACH,oBAAoB,CAAC,KAAK,EAAE,6BAA6B,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;CAC9E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetryTypes.js","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger, TelemetryEventCategory } from \"@fluidframework/
|
|
1
|
+
{"version":3,"file":"telemetryTypes.js","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger, TelemetryEventCategory } from \"@fluidframework/core-interfaces\";\n\n/**\n * Property types that can be logged.\n * Includes extra types beyond TelemetryEventPropertyType (which will be deprecated in favor of this one)\n */\nexport type TelemetryEventPropertyTypeExt =\n\t| string\n\t| number\n\t| boolean\n\t| undefined\n\t| (string | number | boolean)[]\n\t| {\n\t\t\t[key: string]: // Flat objects can have the same properties as the event itself\n\t\t\tstring | number | boolean | undefined | (string | number | boolean)[];\n\t };\n\n/**\n * A property to be logged to telemetry containing both the value and a tag. Tags are generic strings that can be used\n * to mark pieces of information that should be organized or handled differently by loggers in various first or third\n * party scenarios. For example, tags are used to mark personal information that should not be stored in logs.\n */\nexport interface ITaggedTelemetryPropertyTypeExt {\n\tvalue: TelemetryEventPropertyTypeExt;\n\ttag: string;\n}\n\n/**\n * JSON-serializable properties, which will be logged with telemetry.\n */\nexport interface ITelemetryPropertiesExt {\n\t[index: string]: TelemetryEventPropertyTypeExt | ITaggedTelemetryPropertyTypeExt;\n}\n\n/**\n * Interface for logging telemetry statements.\n * Can contain any number of properties that get serialized as json payload.\n * @param category - category of the event, like \"error\", \"performance\", \"generic\", etc.\n * @param eventName - name of the event.\n */\nexport interface ITelemetryEventExt extends ITelemetryPropertiesExt {\n\tcategory: string;\n\teventName: string;\n}\n\n/**\n * Informational (non-error) telemetry event\n * Maps to category = \"generic\"\n */\nexport interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {\n\teventName: string;\n\tcategory?: TelemetryEventCategory;\n}\n\n/**\n * Error telemetry event.\n * Maps to category = \"error\"\n */\nexport interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {\n\teventName: string;\n}\n\n/**\n * Performance telemetry event.\n * Maps to category = \"performance\"\n */\nexport interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {\n\tduration?: number; // Duration of event (optional)\n}\n\n/**\n * An extended TelemetryLogger interface which allows for more lenient event types.\n * This interface is meant to be used internally within the Fluid Framework,\n * and ITelemetryBaseLogger should be used when loggers are passed between layers.\n */\nexport interface ITelemetryLoggerExt extends ITelemetryBaseLogger {\n\t/**\n\t * Send information telemetry event\n\t * @param event - Event to send\n\t * @param error - optional error object to log\n\t */\n\tsendTelemetryEvent(event: ITelemetryGenericEventExt, error?: any): void;\n\n\t/**\n\t * Send error telemetry event\n\t * @param event - Event to send\n\t */\n\tsendErrorEvent(event: ITelemetryErrorEventExt, error?: any): void;\n\n\t/**\n\t * Send performance telemetry event\n\t * @param event - Event to send\n\t */\n\tsendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: any): void;\n}\n"]}
|
package/lib/utils.d.ts
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 { ITelemetryBaseLogger, ITelemetryGenericEvent } from "@fluidframework/
|
|
5
|
+
import { ITelemetryBaseLogger, ITelemetryGenericEvent } from "@fluidframework/core-interfaces";
|
|
6
6
|
/**
|
|
7
7
|
* Like assert, but logs only if the condition is false, rather than throwing
|
|
8
8
|
* @param condition - The condition to attest too
|
package/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAEN,oBAAoB,EACpB,sBAAsB,EACtB,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAEN,oBAAoB,EACpB,sBAAsB,EACtB,MAAM,iCAAiC,CAAC;AAEzC;;;;;;GAMG;AACH,wBAAgB,UAAU,CACzB,SAAS,EAAE,GAAG,EACd,MAAM,EAAE,oBAAoB,EAC5B,KAAK,EAAE,MAAM,GAAG,sBAAsB,GACpC,SAAS,IAAI,IAAI,CAUnB"}
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACzB,SAAc,EACd,MAA4B,EAC5B,KAAsC;IAEtC,IAAI,SAAS,EAAE;QACd,OAAO,IAAI,CAAC;KACZ;IACD,MAAM,QAAQ,GACb,OAAO,KAAK,KAAK,QAAQ;QACxB,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE;QACzC,CAAC,iBAAG,QAAQ,EAAE,OAAO,IAAK,KAAK,CAAE,CAAC;IACpC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtB,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n\tITelemetryBaseEvent,\n\tITelemetryBaseLogger,\n\tITelemetryGenericEvent,\n} from \"@fluidframework/
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACzB,SAAc,EACd,MAA4B,EAC5B,KAAsC;IAEtC,IAAI,SAAS,EAAE;QACd,OAAO,IAAI,CAAC;KACZ;IACD,MAAM,QAAQ,GACb,OAAO,KAAK,KAAK,QAAQ;QACxB,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE;QACzC,CAAC,iBAAG,QAAQ,EAAE,OAAO,IAAK,KAAK,CAAE,CAAC;IACpC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtB,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n\tITelemetryBaseEvent,\n\tITelemetryBaseLogger,\n\tITelemetryGenericEvent,\n} from \"@fluidframework/core-interfaces\";\n\n/**\n * Like assert, but logs only if the condition is false, rather than throwing\n * @param condition - The condition to attest too\n * @param logger - The logger to log with\n * @param event - The string or event to log\n * @returns - The outcome of the condition\n */\nexport function logIfFalse(\n\tcondition: any,\n\tlogger: ITelemetryBaseLogger,\n\tevent: string | ITelemetryGenericEvent,\n): condition is true {\n\tif (condition) {\n\t\treturn true;\n\t}\n\tconst newEvent: ITelemetryBaseEvent =\n\t\ttypeof event === \"string\"\n\t\t\t? { eventName: event, category: \"error\" }\n\t\t\t: { category: \"error\", ...event };\n\tlogger.send(newEvent);\n\treturn false;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/telemetry-utils",
|
|
3
|
-
"version": "2.0.0-internal.5.
|
|
3
|
+
"version": "2.0.0-internal.5.3.0",
|
|
4
4
|
"description": "Collection of telemetry relates utilities for Fluid",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -41,17 +41,19 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
43
43
|
"@fluidframework/common-utils": "^1.1.1",
|
|
44
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.5.3.0 <2.0.0-internal.5.4.0",
|
|
45
|
+
"@fluidframework/core-utils": ">=2.0.0-internal.5.3.0 <2.0.0-internal.5.4.0",
|
|
44
46
|
"debug": "^4.1.1",
|
|
45
47
|
"events": "^3.1.0",
|
|
46
48
|
"uuid": "^8.3.1"
|
|
47
49
|
},
|
|
48
50
|
"devDependencies": {
|
|
49
|
-
"@fluid-tools/build-cli": "^0.
|
|
51
|
+
"@fluid-tools/build-cli": "^0.21.0",
|
|
50
52
|
"@fluidframework/build-common": "^1.2.0",
|
|
51
|
-
"@fluidframework/build-tools": "^0.
|
|
53
|
+
"@fluidframework/build-tools": "^0.21.0",
|
|
52
54
|
"@fluidframework/eslint-config-fluid": "^2.0.0",
|
|
53
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.5.
|
|
54
|
-
"@fluidframework/telemetry-utils-previous": "npm:@fluidframework/telemetry-utils@2.0.0-internal.5.
|
|
55
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.5.3.0 <2.0.0-internal.5.4.0",
|
|
56
|
+
"@fluidframework/telemetry-utils-previous": "npm:@fluidframework/telemetry-utils@2.0.0-internal.5.2.0",
|
|
55
57
|
"@microsoft/api-extractor": "^7.34.4",
|
|
56
58
|
"@types/debug": "^4.1.5",
|
|
57
59
|
"@types/events": "^3.0.0",
|
|
@@ -73,29 +75,7 @@
|
|
|
73
75
|
"typescript": "~4.5.5"
|
|
74
76
|
},
|
|
75
77
|
"typeValidation": {
|
|
76
|
-
"broken": {
|
|
77
|
-
"InterfaceDeclaration_ITaggedTelemetryPropertyTypeExt": {
|
|
78
|
-
"backCompat": false
|
|
79
|
-
},
|
|
80
|
-
"InterfaceDeclaration_ITelemetryErrorEventExt": {
|
|
81
|
-
"backCompat": false
|
|
82
|
-
},
|
|
83
|
-
"InterfaceDeclaration_ITelemetryEventExt": {
|
|
84
|
-
"backCompat": false
|
|
85
|
-
},
|
|
86
|
-
"InterfaceDeclaration_ITelemetryGenericEventExt": {
|
|
87
|
-
"backCompat": false
|
|
88
|
-
},
|
|
89
|
-
"InterfaceDeclaration_ITelemetryPerformanceEventExt": {
|
|
90
|
-
"backCompat": false
|
|
91
|
-
},
|
|
92
|
-
"InterfaceDeclaration_ITelemetryPropertiesExt": {
|
|
93
|
-
"backCompat": false
|
|
94
|
-
},
|
|
95
|
-
"TypeAliasDeclaration_TelemetryEventPropertyTypeExt": {
|
|
96
|
-
"backCompat": false
|
|
97
|
-
}
|
|
98
|
-
}
|
|
78
|
+
"broken": {}
|
|
99
79
|
},
|
|
100
80
|
"scripts": {
|
|
101
81
|
"build": "fluid-build . --task build",
|
|
@@ -122,6 +102,6 @@
|
|
|
122
102
|
"test:report": "npm test -- -- --reporter xunit --reporter-option output=nyc/mocha-junit-report.xml",
|
|
123
103
|
"tsc": "tsc",
|
|
124
104
|
"typetests:gen": "fluid-type-test-generator",
|
|
125
|
-
"typetests:prepare": "flub
|
|
105
|
+
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
|
|
126
106
|
}
|
|
127
107
|
}
|
package/src/config.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ITelemetryBaseLogger } from "@fluidframework/
|
|
6
|
-
import { Lazy } from "@fluidframework/
|
|
5
|
+
import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
6
|
+
import { Lazy } from "@fluidframework/core-utils";
|
|
7
7
|
import { TelemetryDataTag } from "./logger";
|
|
8
8
|
import { ITelemetryLoggerExt } from "./telemetryTypes";
|
|
9
9
|
|
package/src/debugLogger.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
ITelemetryBaseEvent,
|
|
8
8
|
ITelemetryBaseLogger,
|
|
9
9
|
ITelemetryProperties,
|
|
10
|
-
} from "@fluidframework/
|
|
10
|
+
} from "@fluidframework/core-interfaces";
|
|
11
11
|
import { performance } from "@fluidframework/common-utils";
|
|
12
12
|
import { debug as registerDebug, IDebugger } from "debug";
|
|
13
13
|
import {
|
package/src/errorLogging.ts
CHANGED
package/src/fluidErrorBase.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { ITelemetryProperties } from "@fluidframework/
|
|
6
|
+
import { ITelemetryProperties } from "@fluidframework/core-interfaces";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* All normalized errors flowing through the Fluid Framework adhere to this readonly interface.
|
package/src/logger.ts
CHANGED
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
TelemetryEventPropertyType,
|
|
14
14
|
ITaggedTelemetryPropertyType,
|
|
15
15
|
TelemetryEventCategory,
|
|
16
|
-
} from "@fluidframework/
|
|
17
|
-
import { performance } from "@fluidframework/common-utils";
|
|
16
|
+
} from "@fluidframework/core-interfaces";
|
|
17
|
+
import { IsomorphicPerformance, performance } from "@fluidframework/common-utils";
|
|
18
18
|
import { CachedConfigProvider, loggerIsMonitoringContext, mixinMonitoringContext } from "./config";
|
|
19
19
|
import {
|
|
20
20
|
isILoggingError,
|
|
@@ -31,6 +31,13 @@ import {
|
|
|
31
31
|
TelemetryEventPropertyTypeExt,
|
|
32
32
|
} from "./telemetryTypes";
|
|
33
33
|
|
|
34
|
+
export interface Memory {
|
|
35
|
+
usedJSHeapSize: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface PerformanceWithMemory extends IsomorphicPerformance {
|
|
39
|
+
readonly memory: Memory;
|
|
40
|
+
}
|
|
34
41
|
/**
|
|
35
42
|
* Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.
|
|
36
43
|
* Please do not modify existing entries for backwards compatibility.
|
|
@@ -415,8 +422,9 @@ export class PerformanceEvent {
|
|
|
415
422
|
logger: ITelemetryLoggerExt,
|
|
416
423
|
event: ITelemetryGenericEvent,
|
|
417
424
|
markers?: IPerformanceEventMarkers,
|
|
425
|
+
recordHeapSize: boolean = false,
|
|
418
426
|
) {
|
|
419
|
-
return new PerformanceEvent(logger, event, markers);
|
|
427
|
+
return new PerformanceEvent(logger, event, markers, recordHeapSize);
|
|
420
428
|
}
|
|
421
429
|
|
|
422
430
|
public static timedExec<T>(
|
|
@@ -441,8 +449,9 @@ export class PerformanceEvent {
|
|
|
441
449
|
event: ITelemetryGenericEvent,
|
|
442
450
|
callback: (event: PerformanceEvent) => Promise<T>,
|
|
443
451
|
markers?: IPerformanceEventMarkers,
|
|
452
|
+
recordHeapSize?: boolean,
|
|
444
453
|
) {
|
|
445
|
-
const perfEvent = PerformanceEvent.start(logger, event, markers);
|
|
454
|
+
const perfEvent = PerformanceEvent.start(logger, event, markers, recordHeapSize);
|
|
446
455
|
try {
|
|
447
456
|
const ret = await callback(perfEvent);
|
|
448
457
|
perfEvent.autoEnd();
|
|
@@ -460,11 +469,13 @@ export class PerformanceEvent {
|
|
|
460
469
|
private event?: ITelemetryGenericEvent;
|
|
461
470
|
private readonly startTime = performance.now();
|
|
462
471
|
private startMark?: string;
|
|
472
|
+
private startMemoryCollection: number | undefined = 0;
|
|
463
473
|
|
|
464
474
|
protected constructor(
|
|
465
475
|
private readonly logger: ITelemetryLoggerExt,
|
|
466
476
|
event: ITelemetryGenericEvent,
|
|
467
477
|
private readonly markers: IPerformanceEventMarkers = { end: true, cancel: "generic" },
|
|
478
|
+
private readonly recordHeapSize: boolean = false,
|
|
468
479
|
) {
|
|
469
480
|
this.event = { ...event };
|
|
470
481
|
if (this.markers.start) {
|
|
@@ -527,6 +538,20 @@ export class PerformanceEvent {
|
|
|
527
538
|
event.eventName = `${event.eventName}_${eventNameSuffix}`;
|
|
528
539
|
if (eventNameSuffix !== "start") {
|
|
529
540
|
event.duration = this.duration;
|
|
541
|
+
if (this.startMemoryCollection) {
|
|
542
|
+
const currentMemory = (performance as PerformanceWithMemory)?.memory
|
|
543
|
+
?.usedJSHeapSize;
|
|
544
|
+
const differenceInKBytes = Math.floor(
|
|
545
|
+
(currentMemory - this.startMemoryCollection) / 1024,
|
|
546
|
+
);
|
|
547
|
+
if (differenceInKBytes > 0) {
|
|
548
|
+
event.usedJSHeapSize = differenceInKBytes;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
} else if (this.recordHeapSize) {
|
|
552
|
+
this.startMemoryCollection = (
|
|
553
|
+
performance as PerformanceWithMemory
|
|
554
|
+
)?.memory?.usedJSHeapSize;
|
|
530
555
|
}
|
|
531
556
|
|
|
532
557
|
this.logger.sendPerformanceEvent(event, error);
|
package/src/mockLogger.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { ITelemetryBaseEvent } from "@fluidframework/
|
|
6
|
+
import { ITelemetryBaseEvent } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { assert } from "@fluidframework/common-utils";
|
|
8
8
|
import { TelemetryLogger } from "./logger";
|
|
9
9
|
import { ITelemetryLoggerExt } from "./telemetryTypes";
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
IDisposable,
|
|
8
7
|
ITelemetryGenericEvent,
|
|
9
8
|
ITelemetryPerformanceEvent,
|
|
10
9
|
ITelemetryProperties,
|
|
11
|
-
|
|
10
|
+
IDisposable,
|
|
11
|
+
} from "@fluidframework/core-interfaces";
|
|
12
12
|
import { performance } from "@fluidframework/common-utils";
|
|
13
13
|
import { ITelemetryLoggerExt } from "./telemetryTypes";
|
|
14
14
|
|
package/src/telemetryTypes.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { ITelemetryBaseLogger, TelemetryEventCategory } from "@fluidframework/
|
|
6
|
+
import { ITelemetryBaseLogger, TelemetryEventCategory } from "@fluidframework/core-interfaces";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Property types that can be logged.
|
package/src/utils.ts
CHANGED