@fluidframework/telemetry-utils 2.93.0 → 2.100.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 +22 -0
- package/DEV.md +33 -0
- package/api-extractor/api-extractor-lint-api-bundle.json +5 -0
- package/api-extractor/api-extractor-lint-bundle.json +1 -1
- package/api-extractor.json +2 -1
- package/api-report/telemetry-utils.legacy.beta.api.md +8 -5
- package/dist/api.d.ts +26 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +40 -0
- package/dist/api.js.map +1 -0
- package/dist/config.d.ts +6 -6
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -1
- package/dist/errorLogging.d.ts +2 -2
- package/dist/errorLogging.d.ts.map +1 -1
- package/dist/errorLogging.js.map +1 -1
- package/dist/events.d.ts +3 -3
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/{index.d.ts → internal.d.ts} +16 -4
- package/dist/internal.d.ts.map +1 -0
- package/dist/{index.js → internal.js} +22 -5
- package/dist/internal.js.map +1 -0
- package/dist/legacy.d.ts +2 -2
- package/dist/logger.d.ts +45 -10
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +43 -5
- package/dist/logger.js.map +1 -1
- package/dist/main.d.ts +8 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +13 -0
- package/dist/main.js.map +1 -0
- package/dist/mockLogger.d.ts +5 -4
- package/dist/mockLogger.d.ts.map +1 -1
- package/dist/mockLogger.js.map +1 -1
- package/dist/public.d.ts +1 -1
- package/dist/sampledTelemetryHelper.d.ts +2 -2
- package/dist/sampledTelemetryHelper.d.ts.map +1 -1
- package/dist/sampledTelemetryHelper.js.map +1 -1
- package/dist/telemetryEventBatcher.d.ts +2 -2
- package/dist/telemetryEventBatcher.d.ts.map +1 -1
- package/dist/telemetryEventBatcher.js.map +1 -1
- package/dist/telemetryTypes.d.ts +58 -3
- package/dist/telemetryTypes.d.ts.map +1 -1
- package/dist/telemetryTypes.js.map +1 -1
- package/dist/telemetryTypesUndeprecated.d.ts +36 -0
- package/dist/telemetryTypesUndeprecated.d.ts.map +1 -0
- package/dist/telemetryTypesUndeprecated.js +7 -0
- package/dist/telemetryTypesUndeprecated.js.map +1 -0
- package/dist/thresholdCounter.d.ts +2 -2
- package/dist/thresholdCounter.d.ts.map +1 -1
- package/dist/thresholdCounter.js.map +1 -1
- package/dist/utils.d.ts +4 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/internal.d.ts +2 -2
- package/legacy.d.ts +1 -1
- package/lib/api.d.ts +26 -0
- package/lib/api.d.ts.map +1 -0
- package/lib/api.js +22 -0
- package/lib/api.js.map +1 -0
- package/lib/config.d.ts +6 -6
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +2 -0
- package/lib/config.js.map +1 -1
- package/lib/errorLogging.d.ts +2 -2
- package/lib/errorLogging.d.ts.map +1 -1
- package/lib/errorLogging.js.map +1 -1
- package/lib/events.d.ts +3 -3
- package/lib/events.d.ts.map +1 -1
- package/lib/events.js.map +1 -1
- package/lib/{index.d.ts → internal.d.ts} +16 -4
- package/lib/internal.d.ts.map +1 -0
- package/lib/{index.js → internal.js} +5 -3
- package/lib/internal.js.map +1 -0
- package/lib/legacy.d.ts +2 -2
- package/lib/logger.d.ts +45 -10
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +40 -4
- package/lib/logger.js.map +1 -1
- package/lib/main.d.ts +8 -0
- package/lib/main.d.ts.map +1 -0
- package/lib/main.js +9 -0
- package/lib/main.js.map +1 -0
- package/lib/mockLogger.d.ts +5 -4
- package/lib/mockLogger.d.ts.map +1 -1
- package/lib/mockLogger.js.map +1 -1
- package/lib/public.d.ts +1 -1
- package/lib/sampledTelemetryHelper.d.ts +2 -2
- package/lib/sampledTelemetryHelper.d.ts.map +1 -1
- package/lib/sampledTelemetryHelper.js.map +1 -1
- package/lib/telemetryEventBatcher.d.ts +2 -2
- package/lib/telemetryEventBatcher.d.ts.map +1 -1
- package/lib/telemetryEventBatcher.js.map +1 -1
- package/lib/telemetryTypes.d.ts +58 -3
- package/lib/telemetryTypes.d.ts.map +1 -1
- package/lib/telemetryTypes.js.map +1 -1
- package/lib/telemetryTypesUndeprecated.d.ts +36 -0
- package/lib/telemetryTypesUndeprecated.d.ts.map +1 -0
- package/lib/telemetryTypesUndeprecated.js +6 -0
- package/lib/telemetryTypesUndeprecated.js.map +1 -0
- package/lib/thresholdCounter.d.ts +2 -2
- package/lib/thresholdCounter.d.ts.map +1 -1
- package/lib/thresholdCounter.js.map +1 -1
- package/lib/utils.d.ts +4 -4
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +21 -19
- package/src/api.ts +44 -0
- package/src/config.ts +17 -11
- package/src/errorLogging.ts +2 -2
- package/src/events.ts +3 -3
- package/src/{index.ts → internal.ts} +23 -8
- package/src/logger.ts +74 -15
- package/src/main.ts +19 -0
- package/src/mockLogger.ts +4 -4
- package/src/sampledTelemetryHelper.ts +3 -3
- package/src/telemetryEventBatcher.ts +3 -3
- package/src/telemetryTypes.ts +69 -3
- package/src/telemetryTypesUndeprecated.ts +51 -0
- package/src/thresholdCounter.ts +2 -2
- package/src/utils.ts +7 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
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;AAKH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAEX,kBAAkB,EAClB,MAAM,iCAAiC,CAAC;AAEzC;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,OAAO,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IAClE;;;;;;;OAOG;IACH,kBAAkB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,kBAAkB,EAC1B,YAAY,CAAC,EAAE,aAAa,EAC5B,iCAAiC,CAAC,EAAE,OAAO,GACzC,uBAAuB,CA8CzB;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,CAAA;CAAE,CAKlF"}
|
package/lib/utils.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { loggerToMonitoringContext } from "./config.js";
|
|
6
6
|
/**
|
|
7
|
-
* Wraps around an existing logger matching the {@link
|
|
7
|
+
* Wraps around an existing logger matching the {@link TelemetryLoggerExt} interface and provides the ability to only log a subset of events using a sampling strategy provided by an {@link IEventSampler}.
|
|
8
8
|
* You can chose to not provide an event sampler which is effectively a no-op, meaning that it will be treated as if the sampler always returns true.
|
|
9
9
|
*
|
|
10
10
|
* @remarks
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAmCxD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CAClC,MAA0B,EAC1B,YAA4B,EAC5B,iCAA2C;IAE3C,MAAM,iBAAiB,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAC5D,MAAM,kBAAkB,GACvB,iBAAiB,CAAC,MAAM,CAAC,UAAU,CAAC,iCAAiC,CAAC,IAAI,KAAK,CAAC;IAEjF,MAAM,aAAa,GAAG;QACrB,IAAI,EAAE,CAAC,KAA0B,EAAQ,EAAE;YAC1C,2DAA2D;YAC3D,gIAAgI;YAChI,2LAA2L;YAC3L,0EAA0E;YAC1E,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC;QACF,CAAC;QACD,kBAAkB,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAC9D,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAClC,CAAC;QACF,CAAC;QACD,cAAc,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAC1D,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC;QACF,CAAC;QACD,oBAAoB,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAChE,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC/E,IAAI,kBAAkB,IAAI,CAAC,iCAAiC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACxE,OAAO;gBACR,CAAC;gBACD,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;YACpC,CAAC;QACF,CAAC;QACD,kBAAkB;KAClB,CAAC;IAEF,OAAO,aAAa,CAAC;AACtB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO,CAAI,aAAsB;IAChD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAC/B,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\n\nimport { loggerToMonitoringContext } from \"./config.js\";\nimport type {\n\tITelemetryGenericEventExt,\n\tTelemetryLoggerExt,\n} from \"./telemetryTypesUndeprecated.js\";\n\n/**\n * An object that contains a callback used in conjunction with the {@link createSampledLogger} utility function to provide custom logic for sampling events.\n *\n * @internal\n */\nexport interface IEventSampler {\n\t/**\n\t * @returns true if the event should be sampled or false if not\n\t */\n\tsample: () => boolean;\n}\n\n/**\n * A telemetry logger that has sampling capabilities\n *\n * @internal\n */\nexport interface ISampledTelemetryLogger extends TelemetryLoggerExt {\n\t/**\n\t * Indicates if the feature flag to disable sampling is set.\n\t *\n\t * @remarks Exposed to enable some advanced scenarios where the code using the sampled logger\n\t * could take advantage of skipping the execution of some logic when it can determine\n\t * it won't be necessary because the telemetry event that needs it wouldn't be\n\t * emitted anyway.\n\t */\n\tisSamplingDisabled: boolean;\n}\n\n/**\n * Wraps around an existing logger matching the {@link TelemetryLoggerExt} interface and provides the ability to only log a subset of events using a sampling strategy provided by an {@link IEventSampler}.\n * You can chose to not provide an event sampler which is effectively a no-op, meaning that it will be treated as if the sampler always returns true.\n *\n * @remarks\n * The sampling functionality uses the Fluid telemetry logging configuration along with the optionally provided event sampling callback to determine whether an event should\n * be logged or not.\n *\n * Configuration object parameters:\n * 'Fluid.Telemetry.DisableSampling': if this config value is set to true, all events will be unsampled and therefore logged.\n * Otherwise only a sample will be logged according to the provided event sampler callback.\n *\n * Note that the same sampler is used for all APIs of the returned logger. If you want separate events flowing through the returned logger to be sampled separately, the {@link IEventSampler} you provide should track them separately.\n *\n * @internal\n */\nexport function createSampledLogger(\n\tlogger: TelemetryLoggerExt,\n\teventSampler?: IEventSampler,\n\tskipLoggingWhenSamplingIsDisabled?: boolean,\n): ISampledTelemetryLogger {\n\tconst monitoringContext = loggerToMonitoringContext(logger);\n\tconst isSamplingDisabled =\n\t\tmonitoringContext.config.getBoolean(\"Fluid.Telemetry.DisableSampling\") ?? false;\n\n\tconst sampledLogger = {\n\t\tsend: (event: ITelemetryBaseEvent): void => {\n\t\t\t// The sampler uses the following logic for sending events:\n\t\t\t// 1. If isSamplingDisabled is true, then this means events should be unsampled. Therefore we send the event without any checks.\n\t\t\t// 2. If isSamplingDisabled is false, then event should be sampled using the event sampler, if the sampler is not defined just send all events, other use the eventSampler.sample() method.\n\t\t\t// 3. If skipLoggingWhenSamplingIsDisabled is true, then no event is sent.\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.send(event);\n\t\t\t}\n\t\t},\n\t\tsendTelemetryEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendTelemetryEvent(event);\n\t\t\t}\n\t\t},\n\t\tsendErrorEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendErrorEvent(event);\n\t\t\t}\n\t\t},\n\t\tsendPerformanceEvent: (event: ITelemetryGenericEventExt): void => {\n\t\t\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\n\t\t\t\tif (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.sendPerformanceEvent(event);\n\t\t\t}\n\t\t},\n\t\tisSamplingDisabled,\n\t};\n\n\treturn sampledLogger;\n}\n\n/**\n * Runs the specified function and returns an object with the time it took to run as well as any output from it.\n * @remarks Useful in conjunction with {@link TelemetryEventBatcher}.\n *\n * @param codeToMeasure - The code to be executed and measured.\n * @returns The total duration of the code execution and whatever the passed-in code block returns.\n * @internal\n */\nexport function measure<T>(codeToMeasure: () => T): { duration: number; output: T } {\n\tconst start = performance.now();\n\tconst output = codeToMeasure();\n\tconst duration = performance.now() - start;\n\treturn { duration, output };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/telemetry-utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.100.1",
|
|
4
4
|
"description": "Collection of telemetry relates utilities for Fluid",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -16,35 +16,35 @@
|
|
|
16
16
|
".": {
|
|
17
17
|
"import": {
|
|
18
18
|
"types": "./lib/public.d.ts",
|
|
19
|
-
"default": "./lib/
|
|
19
|
+
"default": "./lib/api.js"
|
|
20
20
|
},
|
|
21
21
|
"require": {
|
|
22
22
|
"types": "./dist/public.d.ts",
|
|
23
|
-
"default": "./dist/
|
|
23
|
+
"default": "./dist/api.js"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"./legacy": {
|
|
27
27
|
"import": {
|
|
28
28
|
"types": "./lib/legacy.d.ts",
|
|
29
|
-
"default": "./lib/
|
|
29
|
+
"default": "./lib/api.js"
|
|
30
30
|
},
|
|
31
31
|
"require": {
|
|
32
32
|
"types": "./dist/legacy.d.ts",
|
|
33
|
-
"default": "./dist/
|
|
33
|
+
"default": "./dist/api.js"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"./internal": {
|
|
37
37
|
"import": {
|
|
38
|
-
"types": "./lib/
|
|
39
|
-
"default": "./lib/
|
|
38
|
+
"types": "./lib/internal.d.ts",
|
|
39
|
+
"default": "./lib/internal.js"
|
|
40
40
|
},
|
|
41
41
|
"require": {
|
|
42
|
-
"types": "./dist/
|
|
43
|
-
"default": "./dist/
|
|
42
|
+
"types": "./dist/internal.d.ts",
|
|
43
|
+
"default": "./dist/internal.js"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
|
-
"main": "lib/
|
|
47
|
+
"main": "lib/api.js",
|
|
48
48
|
"types": "lib/public.d.ts",
|
|
49
49
|
"c8": {
|
|
50
50
|
"all": true,
|
|
@@ -69,20 +69,20 @@
|
|
|
69
69
|
"temp-directory": "nyc/.nyc_output"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@fluid-internal/client-utils": "~2.
|
|
73
|
-
"@fluidframework/core-interfaces": "~2.
|
|
74
|
-
"@fluidframework/core-utils": "~2.
|
|
75
|
-
"@fluidframework/driver-definitions": "~2.
|
|
72
|
+
"@fluid-internal/client-utils": "~2.100.1",
|
|
73
|
+
"@fluidframework/core-interfaces": "~2.100.1",
|
|
74
|
+
"@fluidframework/core-utils": "~2.100.1",
|
|
75
|
+
"@fluidframework/driver-definitions": "~2.100.1",
|
|
76
76
|
"debug": "^4.3.4",
|
|
77
77
|
"uuid": "^11.1.0"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
81
81
|
"@biomejs/biome": "~2.4.5",
|
|
82
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
83
|
-
"@fluid-tools/build-cli": "^0.
|
|
82
|
+
"@fluid-internal/mocha-test-setup": "~2.100.1",
|
|
83
|
+
"@fluid-tools/build-cli": "^0.65.0",
|
|
84
84
|
"@fluidframework/build-common": "^2.0.3",
|
|
85
|
-
"@fluidframework/build-tools": "^0.
|
|
85
|
+
"@fluidframework/build-tools": "^0.65.0",
|
|
86
86
|
"@fluidframework/eslint-config-fluid": "^9.0.0",
|
|
87
87
|
"@fluidframework/telemetry-utils-previous": "npm:@fluidframework/telemetry-utils@2.92.0",
|
|
88
88
|
"@microsoft/api-extractor": "7.58.1",
|
|
@@ -108,8 +108,8 @@
|
|
|
108
108
|
},
|
|
109
109
|
"scripts": {
|
|
110
110
|
"api": "fluid-build . --task api",
|
|
111
|
-
"api-extractor:commonjs": "flub generate entrypoints --resolutionConditions require --outFileLegacyBeta legacy --outDir ./dist",
|
|
112
|
-
"api-extractor:esnext": "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib
|
|
111
|
+
"api-extractor:commonjs": "flub generate entrypoints --resolutionConditions require --mainEntrypoint ./src/api.ts --outFileLegacyBeta legacy --outDir ./dist",
|
|
112
|
+
"api-extractor:esnext": "flub generate entrypoints --mainEntrypoint ./src/api.ts --outFileLegacyBeta legacy --outDir ./lib",
|
|
113
113
|
"build": "fluid-build . --task build",
|
|
114
114
|
"build:api-reports": "concurrently \"npm:build:api-reports:*\"",
|
|
115
115
|
"build:api-reports:current": "api-extractor run --local --config api-extractor/api-extractor.current.json",
|
|
@@ -117,6 +117,7 @@
|
|
|
117
117
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
118
118
|
"build:compile": "fluid-build . --task compile",
|
|
119
119
|
"build:docs": "api-extractor run --local",
|
|
120
|
+
"build:entrypoints:node10": "flub generate node10Entrypoints",
|
|
120
121
|
"build:esnext": "tsc --project ./tsconfig.json",
|
|
121
122
|
"build:test": "npm run build:test:esm && npm run build:test:cjs",
|
|
122
123
|
"build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
|
|
@@ -125,6 +126,7 @@
|
|
|
125
126
|
"check:are-the-types-wrong": "attw --pack .",
|
|
126
127
|
"check:biome": "biome check .",
|
|
127
128
|
"check:exports": "concurrently \"npm:check:exports:*\"",
|
|
129
|
+
"check:exports:api-bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-api-bundle.json",
|
|
128
130
|
"check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
|
|
129
131
|
"check:exports:cjs:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.cjs.json",
|
|
130
132
|
"check:exports:cjs:public": "api-extractor run --config api-extractor/api-extractor-lint-public.cjs.json",
|
package/src/api.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
7
|
+
export * from "./main.js";
|
|
8
|
+
|
|
9
|
+
// Additional APIs that are deprecated and thus left out of the common export set.
|
|
10
|
+
export type {
|
|
11
|
+
ITelemetryErrorEventExt,
|
|
12
|
+
ITelemetryGenericEventExt,
|
|
13
|
+
ITelemetryLoggerExt,
|
|
14
|
+
ITelemetryPerformanceEventExt,
|
|
15
|
+
TelemetryEventCategory,
|
|
16
|
+
} from "./telemetryTypes.js";
|
|
17
|
+
|
|
18
|
+
// ----------------------------------------------------------------------------
|
|
19
|
+
// Export `createChildLogger` helper without internal `TelemetryLoggerExt`
|
|
20
|
+
|
|
21
|
+
import type { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
22
|
+
|
|
23
|
+
import type { ITelemetryLoggerPropertyBags } from "./logger.js";
|
|
24
|
+
import { createChildLogger as createChildLoggerInternal } from "./logger.js";
|
|
25
|
+
import type { ITelemetryLoggerExt } from "./telemetryTypes.js";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Create a child logger based on the provided props object.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Passing in no props object (i.e. undefined) will return a logger that is effectively a no-op.
|
|
32
|
+
*
|
|
33
|
+
* @param props - logger is the base logger the child will log to after it's processing, namespace will be prefixed to all event names, properties are default properties that will be applied events.
|
|
34
|
+
*
|
|
35
|
+
* @legacy
|
|
36
|
+
* @beta
|
|
37
|
+
*/
|
|
38
|
+
export function createChildLogger(props?: {
|
|
39
|
+
logger?: ITelemetryBaseLogger;
|
|
40
|
+
namespace?: string;
|
|
41
|
+
properties?: ITelemetryLoggerPropertyBags;
|
|
42
|
+
}): ITelemetryLoggerExt {
|
|
43
|
+
return createChildLoggerInternal(props);
|
|
44
|
+
}
|
package/src/config.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type {
|
|
|
11
11
|
import { Lazy } from "@fluidframework/core-utils/internal";
|
|
12
12
|
|
|
13
13
|
import { createChildLogger, tagCodeArtifacts } from "./logger.js";
|
|
14
|
-
import type { ITelemetryLoggerExt } from "./telemetryTypes.js";
|
|
14
|
+
import type { ITelemetryLoggerExt, TelemetryLoggerExt } from "./telemetryTypes.js";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Explicitly typed interface for reading configurations.
|
|
@@ -269,9 +269,13 @@ export class CachedConfigProvider implements IConfigProvider {
|
|
|
269
269
|
*
|
|
270
270
|
* @internal
|
|
271
271
|
*/
|
|
272
|
-
export interface MonitoringContext<L extends ITelemetryBaseLogger =
|
|
272
|
+
export interface MonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt> {
|
|
273
273
|
config: IConfigProvider;
|
|
274
|
-
logger
|
|
274
|
+
// Since this is an internal context, assume that any external logger type
|
|
275
|
+
// (`ITelemetryLoggerExt`) is just the internal `TelemetryLoggerExt` type.
|
|
276
|
+
// `extractTelemetryLoggerExt` can be used to extract the internal type, but
|
|
277
|
+
// we'll just "cast" it here.
|
|
278
|
+
logger: L extends ITelemetryLoggerExt ? TelemetryLoggerExt : L;
|
|
275
279
|
}
|
|
276
280
|
|
|
277
281
|
/**
|
|
@@ -280,9 +284,9 @@ export interface MonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLo
|
|
|
280
284
|
*
|
|
281
285
|
* @internal
|
|
282
286
|
*/
|
|
283
|
-
export function loggerIsMonitoringContext<
|
|
284
|
-
L
|
|
285
|
-
|
|
287
|
+
export function loggerIsMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(
|
|
288
|
+
obj: L,
|
|
289
|
+
): obj is L & MonitoringContext<L> {
|
|
286
290
|
const maybeConfig = obj as Partial<MonitoringContext<L>> | undefined;
|
|
287
291
|
return isConfigProviderBase(maybeConfig?.config) && maybeConfig?.logger !== undefined;
|
|
288
292
|
}
|
|
@@ -292,9 +296,9 @@ export function loggerIsMonitoringContext<
|
|
|
292
296
|
*
|
|
293
297
|
* @internal
|
|
294
298
|
*/
|
|
295
|
-
export function loggerToMonitoringContext<
|
|
296
|
-
L
|
|
297
|
-
|
|
299
|
+
export function loggerToMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(
|
|
300
|
+
logger: L,
|
|
301
|
+
): MonitoringContext<L> {
|
|
298
302
|
if (loggerIsMonitoringContext<L>(logger)) {
|
|
299
303
|
return logger;
|
|
300
304
|
}
|
|
@@ -312,7 +316,7 @@ export function loggerToMonitoringContext<
|
|
|
312
316
|
*
|
|
313
317
|
* @internal
|
|
314
318
|
*/
|
|
315
|
-
export function mixinMonitoringContext<L extends ITelemetryBaseLogger =
|
|
319
|
+
export function mixinMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(
|
|
316
320
|
logger: L,
|
|
317
321
|
...configs: (IConfigProviderBase | undefined)[]
|
|
318
322
|
): MonitoringContext<L> {
|
|
@@ -329,7 +333,9 @@ export function mixinMonitoringContext<L extends ITelemetryBaseLogger = ITelemet
|
|
|
329
333
|
*/
|
|
330
334
|
const mc: L & Partial<MonitoringContext<L>> = logger;
|
|
331
335
|
mc.config = new CachedConfigProvider(logger, ...configs);
|
|
332
|
-
|
|
336
|
+
// Cast is similar to `extractTelemetryLoggerExt` but preserves other
|
|
337
|
+
// logger types rather than just returning `TelemetryLoggerExt`.
|
|
338
|
+
mc.logger = logger as L extends ITelemetryLoggerExt ? TelemetryLoggerExt : L;
|
|
333
339
|
return mc as MonitoringContext<L>;
|
|
334
340
|
}
|
|
335
341
|
|
package/src/errorLogging.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { v4 as uuid } from "uuid";
|
|
|
10
10
|
import { type IFluidErrorBase, hasErrorInstanceId, isFluidError } from "./fluidErrorBase.js";
|
|
11
11
|
import { convertToBasePropertyType } from "./logger.js";
|
|
12
12
|
import type {
|
|
13
|
-
|
|
13
|
+
TelemetryLoggerExt,
|
|
14
14
|
ITelemetryPropertiesExt,
|
|
15
15
|
TelemetryEventPropertyTypeExt,
|
|
16
16
|
} from "./telemetryTypes.js";
|
|
@@ -286,7 +286,7 @@ export function wrapError<T extends LoggingError>(
|
|
|
286
286
|
export function wrapErrorAndLog<T extends LoggingError>(
|
|
287
287
|
innerError: unknown,
|
|
288
288
|
newErrorFn: (message: string) => T,
|
|
289
|
-
logger:
|
|
289
|
+
logger: TelemetryLoggerExt,
|
|
290
290
|
): T {
|
|
291
291
|
const newError = wrapError(innerError, newErrorFn);
|
|
292
292
|
|
package/src/events.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import type { EventEmitter } from "@fluid-internal/client-utils";
|
|
7
7
|
|
|
8
|
-
import type {
|
|
8
|
+
import type { TelemetryLoggerExt } from "./telemetryTypes.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Note: The contents of this file really don't belong in this package, as they are only intended for internal use.
|
|
@@ -28,7 +28,7 @@ export const disconnectedEventName = "disconnected";
|
|
|
28
28
|
*/
|
|
29
29
|
export function safeRaiseEvent(
|
|
30
30
|
emitter: EventEmitter,
|
|
31
|
-
logger:
|
|
31
|
+
logger: TelemetryLoggerExt,
|
|
32
32
|
event: string,
|
|
33
33
|
...args: unknown[]
|
|
34
34
|
): void {
|
|
@@ -50,7 +50,7 @@ export function safeRaiseEvent(
|
|
|
50
50
|
* @internal
|
|
51
51
|
*/
|
|
52
52
|
export function raiseConnectedEvent(
|
|
53
|
-
logger:
|
|
53
|
+
logger: TelemetryLoggerExt,
|
|
54
54
|
emitter: EventEmitter,
|
|
55
55
|
connected: boolean,
|
|
56
56
|
clientId?: string,
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
// The "internal" exports are a superset of the standard ones. So, we want to export everything from the standard barrel file.
|
|
7
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
8
|
+
export * from "./main.js";
|
|
9
|
+
|
|
6
10
|
export {
|
|
7
11
|
createChildMonitoringContext,
|
|
8
12
|
type MonitoringContext,
|
|
@@ -40,7 +44,6 @@ export {
|
|
|
40
44
|
wrapError,
|
|
41
45
|
wrapErrorAndLog,
|
|
42
46
|
} from "./errorLogging.js";
|
|
43
|
-
export { EventEmitterWithErrorHandling } from "./eventEmitterWithErrorHandling.js";
|
|
44
47
|
export {
|
|
45
48
|
connectedEventName,
|
|
46
49
|
disconnectedEventName,
|
|
@@ -57,10 +60,9 @@ export {
|
|
|
57
60
|
eventNamespaceSeparator,
|
|
58
61
|
createChildLogger,
|
|
59
62
|
createMultiSinkLogger,
|
|
63
|
+
extractTelemetryLoggerExt,
|
|
60
64
|
formatTick,
|
|
61
65
|
type IPerformanceEventMarkers,
|
|
62
|
-
type ITelemetryLoggerPropertyBag,
|
|
63
|
-
type ITelemetryLoggerPropertyBags,
|
|
64
66
|
type MultiSinkLoggerProperties,
|
|
65
67
|
numberFromString,
|
|
66
68
|
PerformanceEvent,
|
|
@@ -68,7 +70,7 @@ export {
|
|
|
68
70
|
tagData,
|
|
69
71
|
tagCodeArtifacts,
|
|
70
72
|
TelemetryDataTag,
|
|
71
|
-
|
|
73
|
+
toITelemetryLoggerExt,
|
|
72
74
|
} from "./logger.js";
|
|
73
75
|
export {
|
|
74
76
|
createMockLoggerExt,
|
|
@@ -89,14 +91,27 @@ export {
|
|
|
89
91
|
measure,
|
|
90
92
|
} from "./utils.js";
|
|
91
93
|
export type {
|
|
92
|
-
TelemetryEventPropertyTypeExt,
|
|
93
94
|
ITelemetryEventExt,
|
|
95
|
+
TelemetryLoggerExt,
|
|
96
|
+
} from "./telemetryTypes.js";
|
|
97
|
+
export type {
|
|
94
98
|
ITelemetryGenericEventExt,
|
|
95
99
|
ITelemetryErrorEventExt,
|
|
96
100
|
ITelemetryPerformanceEventExt,
|
|
97
|
-
ITelemetryLoggerExt,
|
|
98
|
-
ITelemetryPropertiesExt,
|
|
99
101
|
TelemetryEventCategory,
|
|
100
|
-
} from "./
|
|
102
|
+
} from "./telemetryTypesUndeprecated.js";
|
|
101
103
|
export { TelemetryEventBatcher } from "./telemetryEventBatcher.js";
|
|
102
104
|
export { allowIncompatibleLayersKey, validateLayerCompatibility } from "./layerCompatError.js";
|
|
105
|
+
|
|
106
|
+
import type { TelemetryLoggerExt } from "./telemetryTypes.js";
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Renamed version of TelemetryLoggerExt for convenience of internal use.
|
|
110
|
+
* Where "`ITelemetryLoggerExt`" is exposed in customer API surface, true
|
|
111
|
+
* `ITelemetryLoggerExt` (that is an erased type) must be used. To access
|
|
112
|
+
* use `@fluidframework/telemetry-utils/legacy` import spec. All internal
|
|
113
|
+
* usages should be promoted to `TelemetryLoggerExt` naming.
|
|
114
|
+
*
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
117
|
+
export type ITelemetryLoggerExt = TelemetryLoggerExt;
|
package/src/logger.ts
CHANGED
|
@@ -24,15 +24,55 @@ import {
|
|
|
24
24
|
isTaggedTelemetryPropertyValue,
|
|
25
25
|
} from "./errorLogging.js";
|
|
26
26
|
import type {
|
|
27
|
-
ITelemetryErrorEventExt,
|
|
28
27
|
ITelemetryEventExt,
|
|
29
|
-
ITelemetryGenericEventExt,
|
|
30
28
|
ITelemetryLoggerExt,
|
|
31
|
-
ITelemetryPerformanceEventExt,
|
|
32
29
|
ITelemetryPropertiesExt,
|
|
33
|
-
|
|
30
|
+
TelemetryLoggerExt,
|
|
34
31
|
TelemetryEventPropertyTypeExt,
|
|
35
32
|
} from "./telemetryTypes.js";
|
|
33
|
+
import type {
|
|
34
|
+
ITelemetryErrorEventExt,
|
|
35
|
+
ITelemetryGenericEventExt,
|
|
36
|
+
ITelemetryPerformanceEventExt,
|
|
37
|
+
TelemetryEventCategory,
|
|
38
|
+
} from "./telemetryTypesUndeprecated.js";
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Type erase a {@link TelemetryLoggerExt} to an {@link ITelemetryLoggerExt}.
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
export function toITelemetryLoggerExt(logger: TelemetryLoggerExt): ITelemetryLoggerExt {
|
|
45
|
+
return logger as unknown as ITelemetryLoggerExt;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Un-type-erase the {@link ITelemetryLoggerExt}.
|
|
50
|
+
* @remarks
|
|
51
|
+
* This is the extraction helper as documented by {@link @fluidframework/core-interfaces#BrandedType}.
|
|
52
|
+
*
|
|
53
|
+
* @typeParam options - options for the extraction, currently only supports making
|
|
54
|
+
* the output possibly undefined (when `PossiblyUndefined: true`), which is useful
|
|
55
|
+
* for cases where we want to allow passing `undefined` through.
|
|
56
|
+
*
|
|
57
|
+
* @privateRemarks `ITelemetryLoggerExt` is not currently a branded type, but will
|
|
58
|
+
* be when the breaking change is made. At that time, use of this helper will be
|
|
59
|
+
* required.
|
|
60
|
+
*
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
export function extractTelemetryLoggerExt<
|
|
64
|
+
options extends {
|
|
65
|
+
PossiblyUndefined?: true;
|
|
66
|
+
} = // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- empty object without PossiblyUndefined is the correct type
|
|
67
|
+
{},
|
|
68
|
+
>(
|
|
69
|
+
input:
|
|
70
|
+
| ITelemetryLoggerExt
|
|
71
|
+
| TelemetryLoggerExt
|
|
72
|
+
| (options["PossiblyUndefined"] extends true ? undefined : never),
|
|
73
|
+
): TelemetryLoggerExt | (options["PossiblyUndefined"] extends true ? undefined : never) {
|
|
74
|
+
return input as unknown as TelemetryLoggerExt;
|
|
75
|
+
}
|
|
36
76
|
|
|
37
77
|
/**
|
|
38
78
|
* Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.
|
|
@@ -70,6 +110,9 @@ export type ITelemetryLoggerPropertyBag = Record<
|
|
|
70
110
|
/**
|
|
71
111
|
* @legacy
|
|
72
112
|
* @beta
|
|
113
|
+
*
|
|
114
|
+
* @privateRemarks
|
|
115
|
+
* This is exposed to support {@link createChildLogger} properties parameter.
|
|
73
116
|
*/
|
|
74
117
|
export interface ITelemetryLoggerPropertyBags {
|
|
75
118
|
all?: ITelemetryLoggerPropertyBag;
|
|
@@ -115,7 +158,7 @@ export const eventNamespaceSeparator = ":";
|
|
|
115
158
|
* encoding in one place schemas for various types of Fluid telemetry events.
|
|
116
159
|
* Creates sub-logger that appends properties to all events
|
|
117
160
|
*/
|
|
118
|
-
export abstract class TelemetryLogger implements
|
|
161
|
+
export abstract class TelemetryLogger implements TelemetryLoggerExt {
|
|
119
162
|
/**
|
|
120
163
|
* {@inheritDoc eventNamespaceSeparator}
|
|
121
164
|
*/
|
|
@@ -361,6 +404,12 @@ export class TaggedLoggerAdapter implements ITelemetryBaseLogger {
|
|
|
361
404
|
}
|
|
362
405
|
}
|
|
363
406
|
|
|
407
|
+
function toEitherTelemetryLoggerExt(
|
|
408
|
+
logger: TelemetryLoggerExt,
|
|
409
|
+
): TelemetryLoggerExt & ITelemetryLoggerExt {
|
|
410
|
+
return logger as TelemetryLoggerExt & ITelemetryLoggerExt;
|
|
411
|
+
}
|
|
412
|
+
|
|
364
413
|
/**
|
|
365
414
|
* Create a child logger based on the provided props object.
|
|
366
415
|
*
|
|
@@ -369,15 +418,25 @@ export class TaggedLoggerAdapter implements ITelemetryBaseLogger {
|
|
|
369
418
|
*
|
|
370
419
|
* @param props - logger is the base logger the child will log to after it's processing, namespace will be prefixed to all event names, properties are default properties that will be applied events.
|
|
371
420
|
*
|
|
372
|
-
* @
|
|
373
|
-
*
|
|
421
|
+
* @internal
|
|
422
|
+
*
|
|
423
|
+
* @privateRemarks
|
|
424
|
+
* Return type is both TelemetryLoggerExt and ITelemetryLoggerExt to allow for
|
|
425
|
+
* easier internal usage without needing to type erase or un-type-erase the
|
|
426
|
+
* logger.
|
|
427
|
+
*
|
|
428
|
+
* If always creating a child logger for direct external exposure, consider
|
|
429
|
+
* using {@link createChildLogger} from /legacy API instead, which returns
|
|
430
|
+
* exactly an {@link ITelemetryLoggerExt}.
|
|
374
431
|
*/
|
|
375
432
|
export function createChildLogger(props?: {
|
|
376
433
|
logger?: ITelemetryBaseLogger;
|
|
377
434
|
namespace?: string;
|
|
378
435
|
properties?: ITelemetryLoggerPropertyBags;
|
|
379
|
-
}): ITelemetryLoggerExt {
|
|
380
|
-
return
|
|
436
|
+
}): TelemetryLoggerExt & ITelemetryLoggerExt {
|
|
437
|
+
return toEitherTelemetryLoggerExt(
|
|
438
|
+
ChildLogger.create(props?.logger, props?.namespace, props?.properties),
|
|
439
|
+
);
|
|
381
440
|
}
|
|
382
441
|
|
|
383
442
|
/**
|
|
@@ -510,7 +569,7 @@ export interface MultiSinkLoggerProperties {
|
|
|
510
569
|
*
|
|
511
570
|
* @internal
|
|
512
571
|
*/
|
|
513
|
-
export function createMultiSinkLogger(props: MultiSinkLoggerProperties):
|
|
572
|
+
export function createMultiSinkLogger(props: MultiSinkLoggerProperties): TelemetryLoggerExt {
|
|
514
573
|
return new MultiSinkLogger(
|
|
515
574
|
props.namespace,
|
|
516
575
|
props.properties,
|
|
@@ -636,12 +695,12 @@ export class PerformanceEvent {
|
|
|
636
695
|
* @returns An instance of {@link PerformanceEvent}
|
|
637
696
|
*/
|
|
638
697
|
public static start(
|
|
639
|
-
logger: ITelemetryLoggerExt,
|
|
698
|
+
logger: TelemetryLoggerExt | ITelemetryLoggerExt,
|
|
640
699
|
event: ITelemetryGenericEventExt,
|
|
641
700
|
markers?: IPerformanceEventMarkers,
|
|
642
701
|
emitLogs: boolean = true,
|
|
643
702
|
): PerformanceEvent {
|
|
644
|
-
return new PerformanceEvent(logger, event, markers, emitLogs);
|
|
703
|
+
return new PerformanceEvent(extractTelemetryLoggerExt(logger), event, markers, emitLogs);
|
|
645
704
|
}
|
|
646
705
|
|
|
647
706
|
/**
|
|
@@ -660,7 +719,7 @@ export class PerformanceEvent {
|
|
|
660
719
|
* effectively "share" the sampling rate for the event.
|
|
661
720
|
*/
|
|
662
721
|
public static timedExec<T>(
|
|
663
|
-
logger:
|
|
722
|
+
logger: TelemetryLoggerExt,
|
|
664
723
|
event: ITelemetryGenericEventExt,
|
|
665
724
|
callback: (event: PerformanceEvent) => T,
|
|
666
725
|
markers?: IPerformanceEventMarkers,
|
|
@@ -699,7 +758,7 @@ export class PerformanceEvent {
|
|
|
699
758
|
* effectively "share" the sampling rate for the event.
|
|
700
759
|
*/
|
|
701
760
|
public static async timedExecAsync<T>(
|
|
702
|
-
logger: ITelemetryLoggerExt,
|
|
761
|
+
logger: TelemetryLoggerExt | ITelemetryLoggerExt,
|
|
703
762
|
event: ITelemetryGenericEventExt,
|
|
704
763
|
callback: (event: PerformanceEvent) => Promise<T>,
|
|
705
764
|
markers?: IPerformanceEventMarkers,
|
|
@@ -730,7 +789,7 @@ export class PerformanceEvent {
|
|
|
730
789
|
private startMark?: string;
|
|
731
790
|
|
|
732
791
|
protected constructor(
|
|
733
|
-
private readonly logger:
|
|
792
|
+
private readonly logger: TelemetryLoggerExt,
|
|
734
793
|
event: ITelemetryGenericEventExt,
|
|
735
794
|
private readonly markers: IPerformanceEventMarkers = { end: true, cancel: "generic" },
|
|
736
795
|
private readonly emitLogs: boolean = true,
|
package/src/main.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// This export set contains public APIs that don't have any special treatment
|
|
7
|
+
// when exposed internally. APIs deprecated for external use but still needed
|
|
8
|
+
// internally are re-exported from /internal with alternate tagging.
|
|
9
|
+
|
|
10
|
+
export { EventEmitterWithErrorHandling } from "./eventEmitterWithErrorHandling.js";
|
|
11
|
+
export type {
|
|
12
|
+
ITelemetryLoggerPropertyBag,
|
|
13
|
+
ITelemetryLoggerPropertyBags,
|
|
14
|
+
TelemetryEventPropertyTypes,
|
|
15
|
+
} from "./logger.js";
|
|
16
|
+
export type {
|
|
17
|
+
ITelemetryPropertiesExt,
|
|
18
|
+
TelemetryEventPropertyTypeExt,
|
|
19
|
+
} from "./telemetryTypes.js";
|
package/src/mockLogger.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { assert } from "@fluidframework/core-utils/internal";
|
|
|
13
13
|
import { createChildLogger } from "./logger.js";
|
|
14
14
|
import type {
|
|
15
15
|
ITelemetryEventExt,
|
|
16
|
-
|
|
16
|
+
TelemetryLoggerExt,
|
|
17
17
|
ITelemetryPropertiesExt,
|
|
18
18
|
} from "./telemetryTypes.js";
|
|
19
19
|
|
|
@@ -51,7 +51,7 @@ export class MockLogger implements ITelemetryBaseLogger {
|
|
|
51
51
|
this._events = [];
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
public toTelemetryLogger():
|
|
54
|
+
public toTelemetryLogger(): ReturnType<typeof createChildLogger> {
|
|
55
55
|
return createChildLogger({ logger: this });
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -357,13 +357,13 @@ function matchObjects(
|
|
|
357
357
|
}
|
|
358
358
|
|
|
359
359
|
/**
|
|
360
|
-
* Mock {@link
|
|
360
|
+
* Mock {@link TelemetryLoggerExt} implementation.
|
|
361
361
|
*
|
|
362
362
|
* @remarks Can be created via {@link createMockLoggerExt}.
|
|
363
363
|
*
|
|
364
364
|
* @internal
|
|
365
365
|
*/
|
|
366
|
-
export interface IMockLoggerExt extends
|
|
366
|
+
export interface IMockLoggerExt extends TelemetryLoggerExt {
|
|
367
367
|
/**
|
|
368
368
|
* Gets the events that have been logged so far.
|
|
369
369
|
*/
|
|
@@ -10,9 +10,9 @@ import { assert } from "@fluidframework/core-utils/internal";
|
|
|
10
10
|
import { roundToDecimalPlaces } from "./mathTools.js";
|
|
11
11
|
import type {
|
|
12
12
|
ITelemetryGenericEventExt,
|
|
13
|
-
|
|
13
|
+
TelemetryLoggerExt,
|
|
14
14
|
ITelemetryPerformanceEventExt,
|
|
15
|
-
} from "./
|
|
15
|
+
} from "./telemetryTypesUndeprecated.js";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @privateRemarks
|
|
@@ -163,7 +163,7 @@ export class SampledTelemetryHelper<
|
|
|
163
163
|
*/
|
|
164
164
|
public constructor(
|
|
165
165
|
private readonly eventBase: ITelemetryGenericEventExt,
|
|
166
|
-
private readonly logger:
|
|
166
|
+
private readonly logger: TelemetryLoggerExt,
|
|
167
167
|
private readonly sampleThreshold: number,
|
|
168
168
|
private readonly includeAggregateMetrics: boolean = false,
|
|
169
169
|
private readonly perBucketProperties = new Map<string, ITelemetryBaseProperties>(),
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
import { roundToDecimalPlaces } from "./mathTools.js";
|
|
7
7
|
import type {
|
|
8
8
|
ITelemetryGenericEventExt,
|
|
9
|
-
|
|
9
|
+
TelemetryLoggerExt,
|
|
10
10
|
ITelemetryPerformanceEventExt,
|
|
11
|
-
} from "./
|
|
11
|
+
} from "./telemetryTypesUndeprecated.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Telemetry class that accumulates measurements which are eventually logged in a telemetry event through the provided
|
|
@@ -46,7 +46,7 @@ export class TelemetryEventBatcher<TMetrics extends string> {
|
|
|
46
46
|
/**
|
|
47
47
|
* The logger to use to write the telemetry performance event.
|
|
48
48
|
*/
|
|
49
|
-
private readonly logger:
|
|
49
|
+
private readonly logger: TelemetryLoggerExt,
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* The number of logs to accumulate before sending the data to the logger.
|