@fluidframework/telemetry-utils 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.225277
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/.eslintrc.js +12 -13
- package/.mocharc.js +12 -0
- package/CHANGELOG.md +249 -0
- package/README.md +68 -1
- package/api-extractor-esm.json +5 -0
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/telemetry-utils.api.md +444 -0
- package/dist/config.d.ts +47 -16
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +88 -38
- package/dist/config.js.map +1 -1
- package/dist/error.d.ts +112 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +159 -0
- package/dist/error.js.map +1 -0
- package/dist/errorLogging.d.ts +86 -20
- package/dist/errorLogging.d.ts.map +1 -1
- package/dist/errorLogging.js +190 -60
- package/dist/errorLogging.js.map +1 -1
- package/dist/eventEmitterWithErrorHandling.d.ts +9 -3
- package/dist/eventEmitterWithErrorHandling.d.ts.map +1 -1
- package/dist/eventEmitterWithErrorHandling.js +16 -3
- package/dist/eventEmitterWithErrorHandling.js.map +1 -1
- package/dist/events.d.ts +27 -3
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +26 -2
- package/dist/events.js.map +1 -1
- package/dist/fluidErrorBase.d.ts +57 -16
- package/dist/fluidErrorBase.d.ts.map +1 -1
- package/dist/fluidErrorBase.js +27 -14
- package/dist/fluidErrorBase.js.map +1 -1
- package/dist/index.d.ts +12 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -21
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +269 -53
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +423 -132
- package/dist/logger.js.map +1 -1
- package/dist/mockLogger.d.ts +39 -12
- package/dist/mockLogger.d.ts.map +1 -1
- package/dist/mockLogger.js +105 -22
- package/dist/mockLogger.js.map +1 -1
- package/dist/sampledTelemetryHelper.d.ts +18 -12
- package/dist/sampledTelemetryHelper.d.ts.map +1 -1
- package/dist/sampledTelemetryHelper.js +28 -19
- package/dist/sampledTelemetryHelper.js.map +1 -1
- package/dist/telemetry-utils-alpha.d.ts +290 -0
- package/dist/telemetry-utils-beta.d.ts +264 -0
- package/dist/telemetry-utils-public.d.ts +264 -0
- package/dist/telemetry-utils-untrimmed.d.ts +1102 -0
- package/dist/telemetryTypes.d.ts +115 -0
- package/dist/telemetryTypes.d.ts.map +1 -0
- package/dist/telemetryTypes.js +7 -0
- package/dist/telemetryTypes.js.map +1 -0
- package/dist/thresholdCounter.d.ts +6 -5
- package/dist/thresholdCounter.d.ts.map +1 -1
- package/dist/thresholdCounter.js +4 -3
- package/dist/thresholdCounter.js.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/utils.d.ts +54 -3
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +58 -3
- package/dist/utils.js.map +1 -1
- package/lib/config.d.ts +47 -16
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +85 -36
- package/lib/config.js.map +1 -1
- package/lib/error.d.ts +112 -0
- package/lib/error.d.ts.map +1 -0
- package/lib/error.js +150 -0
- package/lib/error.js.map +1 -0
- package/lib/errorLogging.d.ts +86 -20
- package/lib/errorLogging.d.ts.map +1 -1
- package/lib/errorLogging.js +189 -60
- package/lib/errorLogging.js.map +1 -1
- package/lib/eventEmitterWithErrorHandling.d.ts +9 -3
- package/lib/eventEmitterWithErrorHandling.d.ts.map +1 -1
- package/lib/eventEmitterWithErrorHandling.js +15 -2
- package/lib/eventEmitterWithErrorHandling.js.map +1 -1
- package/lib/events.d.ts +27 -3
- package/lib/events.d.ts.map +1 -1
- package/lib/events.js +26 -2
- package/lib/events.js.map +1 -1
- package/lib/fluidErrorBase.d.ts +57 -16
- package/lib/fluidErrorBase.d.ts.map +1 -1
- package/lib/fluidErrorBase.js +27 -14
- package/lib/fluidErrorBase.js.map +1 -1
- package/lib/index.d.ts +12 -11
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +11 -11
- package/lib/index.js.map +1 -1
- package/lib/logger.d.ts +269 -53
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +415 -131
- package/lib/logger.js.map +1 -1
- package/lib/mockLogger.d.ts +39 -12
- package/lib/mockLogger.d.ts.map +1 -1
- package/lib/mockLogger.js +106 -23
- package/lib/mockLogger.js.map +1 -1
- package/lib/sampledTelemetryHelper.d.ts +18 -12
- package/lib/sampledTelemetryHelper.d.ts.map +1 -1
- package/lib/sampledTelemetryHelper.js +26 -17
- package/lib/sampledTelemetryHelper.js.map +1 -1
- package/lib/telemetry-utils-alpha.d.mts +290 -0
- package/lib/telemetry-utils-beta.d.mts +264 -0
- package/lib/telemetry-utils-public.d.mts +264 -0
- package/lib/telemetry-utils-untrimmed.d.mts +1102 -0
- package/lib/telemetryTypes.d.ts +115 -0
- package/lib/telemetryTypes.d.ts.map +1 -0
- package/lib/telemetryTypes.js +6 -0
- package/lib/telemetryTypes.js.map +1 -0
- package/lib/thresholdCounter.d.ts +6 -5
- package/lib/thresholdCounter.d.ts.map +1 -1
- package/lib/thresholdCounter.js +4 -3
- package/lib/thresholdCounter.js.map +1 -1
- package/lib/utils.d.ts +54 -3
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +56 -2
- package/lib/utils.js.map +1 -1
- package/package.json +86 -57
- package/prettier.config.cjs +8 -0
- package/src/config.ts +254 -189
- package/src/error.ts +235 -0
- package/src/errorLogging.ts +440 -290
- package/src/eventEmitterWithErrorHandling.ts +26 -14
- package/src/events.ts +54 -25
- package/src/fluidErrorBase.ts +94 -46
- package/src/index.ts +76 -17
- package/src/logger.ts +972 -505
- package/src/mockLogger.ts +225 -83
- package/src/sampledTelemetryHelper.ts +136 -128
- package/src/telemetryTypes.ts +140 -0
- package/src/thresholdCounter.ts +38 -37
- package/src/utils.ts +108 -17
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +9 -13
- package/dist/debugLogger.d.ts +0 -39
- package/dist/debugLogger.d.ts.map +0 -1
- package/dist/debugLogger.js +0 -101
- package/dist/debugLogger.js.map +0 -1
- package/dist/packageVersion.d.ts +0 -9
- package/dist/packageVersion.d.ts.map +0 -1
- package/dist/packageVersion.js +0 -12
- package/dist/packageVersion.js.map +0 -1
- package/lib/debugLogger.d.ts +0 -39
- package/lib/debugLogger.d.ts.map +0 -1
- package/lib/debugLogger.js +0 -97
- package/lib/debugLogger.js.map +0 -1
- package/lib/packageVersion.d.ts +0 -9
- package/lib/packageVersion.d.ts.map +0 -1
- package/lib/packageVersion.js +0 -9
- package/lib/packageVersion.js.map +0 -1
- package/src/debugLogger.ts +0 -126
- package/src/packageVersion.ts +0 -9
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ITelemetryBaseLogger, LogLevel, Tagged } from "@fluidframework/core-interfaces";
|
|
6
|
+
/**
|
|
7
|
+
* The categories FF uses when instrumenting the code.
|
|
8
|
+
*
|
|
9
|
+
* generic - Informational log event
|
|
10
|
+
*
|
|
11
|
+
* error - Error log event, ideally 0 of these are logged during a session
|
|
12
|
+
*
|
|
13
|
+
* performance - Includes duration, and often has _start, _end, or _cancel suffixes for activity tracking
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export type TelemetryEventCategory = "generic" | "error" | "performance";
|
|
17
|
+
/**
|
|
18
|
+
* Property types that can be logged.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Includes extra types beyond {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType}, which must be
|
|
22
|
+
* converted before sending to a base logger.
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export type TelemetryEventPropertyTypeExt = string | number | boolean | undefined | (string | number | boolean)[] | {
|
|
26
|
+
[key: string]: // Flat objects can have the same properties as the event itself
|
|
27
|
+
string | number | boolean | undefined | (string | number | boolean)[];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* A property to be logged to telemetry containing both the value and a tag. Tags are generic strings that can be used
|
|
31
|
+
* to mark pieces of information that should be organized or handled differently by loggers in various first or third
|
|
32
|
+
* party scenarios. For example, tags are used to mark personal information that should not be stored in logs.
|
|
33
|
+
*
|
|
34
|
+
* @deprecated Use {@link @fluidframework/core-interfaces#Tagged}\<{@link TelemetryEventPropertyTypeExt}\>
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export interface ITaggedTelemetryPropertyTypeExt {
|
|
38
|
+
value: TelemetryEventPropertyTypeExt;
|
|
39
|
+
tag: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* JSON-serializable properties, which will be logged with telemetry.
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
export interface ITelemetryPropertiesExt {
|
|
46
|
+
[index: string]: TelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Interface for logging telemetry statements.
|
|
50
|
+
* @remarks May contain any number of properties that get serialized as json payload.
|
|
51
|
+
* @param category - category of the event, like "error", "performance", "generic", etc.
|
|
52
|
+
* @param eventName - name of the event.
|
|
53
|
+
*
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
export interface ITelemetryEventExt extends ITelemetryPropertiesExt {
|
|
57
|
+
category: string;
|
|
58
|
+
eventName: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Informational (non-error) telemetry event
|
|
62
|
+
* @remarks Maps to category = "generic"
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
export interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {
|
|
66
|
+
eventName: string;
|
|
67
|
+
category?: TelemetryEventCategory;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Error telemetry event.
|
|
71
|
+
* @remarks Maps to category = "error"
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
export interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {
|
|
75
|
+
eventName: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Performance telemetry event.
|
|
79
|
+
* @remarks Maps to category = "performance"
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
export interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {
|
|
83
|
+
duration?: number;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* An extended {@link @fluidframework/core-interfaces#ITelemetryBaseLogger} which allows for more lenient event types.
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* This interface is meant to be used internally within the Fluid Framework,
|
|
90
|
+
* and `ITelemetryBaseLogger` should be used when loggers are passed between layers.
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
93
|
+
export interface ITelemetryLoggerExt extends ITelemetryBaseLogger {
|
|
94
|
+
/**
|
|
95
|
+
* Send information telemetry event
|
|
96
|
+
* @param event - Event to send
|
|
97
|
+
* @param error - optional error object to log
|
|
98
|
+
* @param logLevel - optional level of the log.
|
|
99
|
+
*/
|
|
100
|
+
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
|
|
101
|
+
/**
|
|
102
|
+
* Send error telemetry event
|
|
103
|
+
* @param event - Event to send
|
|
104
|
+
* @param error - optional error object to log
|
|
105
|
+
*/
|
|
106
|
+
sendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;
|
|
107
|
+
/**
|
|
108
|
+
* Send performance telemetry event
|
|
109
|
+
* @param event - Event to send
|
|
110
|
+
* @param error - optional error object to log
|
|
111
|
+
* @param logLevel - optional level of the log.
|
|
112
|
+
*/
|
|
113
|
+
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=telemetryTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetryTypes.d.ts","sourceRoot":"","sources":["../src/telemetryTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAEzF;;;;;;;;;GASG;AACH,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,OAAO,GAAG,aAAa,CAAC;AAEzE;;;;;;;GAOG;AACH,MAAM,MAAM,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;;;;;;;GAOG;AACH,MAAM,WAAW,+BAA+B;IAC/C,KAAK,EAAE,6BAA6B,CAAC;IACrC,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACvC,CAAC,KAAK,EAAE,MAAM,GAAG,6BAA6B,GAAG,MAAM,CAAC,6BAA6B,CAAC,CAAC;CACvF;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAmB,SAAQ,uBAAuB;IAClE,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAA0B,SAAQ,uBAAuB;IACzE,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,sBAAsB,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,uBAAuB;IACvE,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,6BAA8B,SAAQ,yBAAyB;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAChE;;;;;OAKG;IACH,kBAAkB,CACjB,KAAK,EAAE,yBAAyB,EAChC,KAAK,CAAC,EAAE,OAAO,EACf,QAAQ,CAAC,EAAE,OAAO,QAAQ,CAAC,OAAO,GAAG,OAAO,QAAQ,CAAC,OAAO,GAC1D,IAAI,CAAC;IAER;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,uBAAuB,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEtE;;;;;OAKG;IACH,oBAAoB,CACnB,KAAK,EAAE,6BAA6B,EACpC,KAAK,CAAC,EAAE,OAAO,EACf,QAAQ,CAAC,EAAE,OAAO,QAAQ,CAAC,OAAO,GAAG,OAAO,QAAQ,CAAC,OAAO,GAC1D,IAAI,CAAC;CACR"}
|
|
@@ -0,0 +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, LogLevel, Tagged } from \"@fluidframework/core-interfaces\";\n\n/**\n * The categories FF uses when instrumenting the code.\n *\n * generic - Informational log event\n *\n * error - Error log event, ideally 0 of these are logged during a session\n *\n * performance - Includes duration, and often has _start, _end, or _cancel suffixes for activity tracking\n * @public\n */\nexport type TelemetryEventCategory = \"generic\" | \"error\" | \"performance\";\n\n/**\n * Property types that can be logged.\n *\n * @remarks\n * Includes extra types beyond {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType}, which must be\n * converted before sending to a base logger.\n * @public\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 *\n * @deprecated Use {@link @fluidframework/core-interfaces#Tagged}\\<{@link TelemetryEventPropertyTypeExt}\\>\n * @internal\n */\nexport interface ITaggedTelemetryPropertyTypeExt {\n\tvalue: TelemetryEventPropertyTypeExt;\n\ttag: string;\n}\n\n/**\n * JSON-serializable properties, which will be logged with telemetry.\n * @public\n */\nexport interface ITelemetryPropertiesExt {\n\t[index: string]: TelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>;\n}\n\n/**\n * Interface for logging telemetry statements.\n * @remarks May 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 *\n * @internal\n */\nexport interface ITelemetryEventExt extends ITelemetryPropertiesExt {\n\tcategory: string;\n\teventName: string;\n}\n\n/**\n * Informational (non-error) telemetry event\n * @remarks Maps to category = \"generic\"\n * @public\n */\nexport interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {\n\teventName: string;\n\tcategory?: TelemetryEventCategory;\n}\n\n/**\n * Error telemetry event.\n * @remarks Maps to category = \"error\"\n * @public\n */\nexport interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {\n\teventName: string;\n}\n\n/**\n * Performance telemetry event.\n * @remarks Maps to category = \"performance\"\n * @public\n */\nexport interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {\n\tduration?: number; // Duration of event (optional)\n}\n\n/**\n * An extended {@link @fluidframework/core-interfaces#ITelemetryBaseLogger} which allows for more lenient event types.\n *\n * @remarks\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 * @public\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 * @param logLevel - optional level of the log.\n\t */\n\tsendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.default,\n\t): void;\n\n\t/**\n\t * Send error telemetry event\n\t * @param event - Event to send\n\t * @param error - optional error object to log\n\t */\n\tsendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;\n\n\t/**\n\t * Send performance telemetry event\n\t * @param event - Event to send\n\t * @param error - optional error object to log\n\t * @param logLevel - optional level of the log.\n\t */\n\tsendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.default,\n\t): void;\n}\n"]}
|
|
@@ -2,22 +2,23 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { ITelemetryLoggerExt } from "./telemetryTypes";
|
|
6
6
|
/**
|
|
7
|
-
* Utility counter which will send event only if the provided value
|
|
8
|
-
*
|
|
7
|
+
* Utility counter which will send event only if the provided value is above a configured threshold.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
9
10
|
*/
|
|
10
11
|
export declare class ThresholdCounter {
|
|
11
12
|
private readonly threshold;
|
|
12
13
|
private readonly logger;
|
|
13
14
|
private thresholdMultiple;
|
|
14
|
-
constructor(threshold: number, logger:
|
|
15
|
+
constructor(threshold: number, logger: ITelemetryLoggerExt, thresholdMultiple?: number);
|
|
15
16
|
/**
|
|
16
17
|
* Sends the value if it's above the treshold.
|
|
17
18
|
*/
|
|
18
19
|
send(eventName: string, value: number): void;
|
|
19
20
|
/**
|
|
20
|
-
* Sends the value if it's above the
|
|
21
|
+
* Sends the value if it's above the threshold
|
|
21
22
|
* and a multiple of the threshold.
|
|
22
23
|
*
|
|
23
24
|
* To be used in scenarios where we'd like to record a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thresholdCounter.d.ts","sourceRoot":"","sources":["../src/thresholdCounter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"thresholdCounter.d.ts","sourceRoot":"","sources":["../src/thresholdCounter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;GAIG;AACH,qBAAa,gBAAgB;IAE3B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,iBAAiB;gBAFR,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,mBAAmB,EACpC,iBAAiB,SAAY;IAGtC;;OAEG;IACI,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAUnD;;;;;;OAMG;IACI,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAU7D"}
|
package/lib/thresholdCounter.js
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Utility counter which will send event only if the provided value
|
|
7
|
-
*
|
|
6
|
+
* Utility counter which will send event only if the provided value is above a configured threshold.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
8
9
|
*/
|
|
9
10
|
export class ThresholdCounter {
|
|
10
11
|
constructor(threshold, logger, thresholdMultiple = threshold) {
|
|
@@ -25,7 +26,7 @@ export class ThresholdCounter {
|
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
|
-
* Sends the value if it's above the
|
|
29
|
+
* Sends the value if it's above the threshold
|
|
29
30
|
* and a multiple of the threshold.
|
|
30
31
|
*
|
|
31
32
|
* To be used in scenarios where we'd like to record a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thresholdCounter.js","sourceRoot":"","sources":["../src/thresholdCounter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH
|
|
1
|
+
{"version":3,"file":"thresholdCounter.js","sourceRoot":"","sources":["../src/thresholdCounter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAC5B,YACkB,SAAiB,EACjB,MAA2B,EACpC,oBAAoB,SAAS;QAFpB,cAAS,GAAT,SAAS,CAAQ;QACjB,WAAM,GAAN,MAAM,CAAqB;QACpC,sBAAiB,GAAjB,iBAAiB,CAAY;IACnC,CAAC;IAEJ;;OAEG;IACI,IAAI,CAAC,SAAiB,EAAE,KAAa;QAC3C,IAAI,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE;YAC3B,OAAO;SACP;QACD,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;YAChC,SAAS;YACT,KAAK;SACL,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACI,cAAc,CAAC,SAAiB,EAAE,KAAa;QACrD,IAAI,KAAK,KAAK,IAAI,CAAC,iBAAiB,EAAE;YACrC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;gBAChC,SAAS;gBACT,KAAK;aACL,CAAC,CAAC;YACH,sCAAsC;YACtC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC;SACpD;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt } from \"./telemetryTypes\";\n\n/**\n * Utility counter which will send event only if the provided value is above a configured threshold.\n *\n * @internal\n */\nexport class ThresholdCounter {\n\tpublic constructor(\n\t\tprivate readonly threshold: number,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate thresholdMultiple = threshold,\n\t) {}\n\n\t/**\n\t * Sends the value if it's above the treshold.\n\t */\n\tpublic send(eventName: string, value: number): void {\n\t\tif (value < this.threshold) {\n\t\t\treturn;\n\t\t}\n\t\tthis.logger.sendPerformanceEvent({\n\t\t\teventName,\n\t\t\tvalue,\n\t\t});\n\t}\n\n\t/**\n\t * Sends the value if it's above the threshold\n\t * and a multiple of the threshold.\n\t *\n\t * To be used in scenarios where we'd like to record a\n\t * threshold violation while reducing telemetry noise.\n\t */\n\tpublic sendIfMultiple(eventName: string, value: number): void {\n\t\tif (value === this.thresholdMultiple) {\n\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\teventName,\n\t\t\t\tvalue,\n\t\t\t});\n\t\t\t// reduce number of \"multiple\" events.\n\t\t\tthis.thresholdMultiple = this.thresholdMultiple * 2;\n\t\t}\n\t}\n}\n"]}
|
package/lib/utils.d.ts
CHANGED
|
@@ -2,13 +2,64 @@
|
|
|
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
|
+
import { ITelemetryLoggerExt } from "./telemetryTypes";
|
|
6
7
|
/**
|
|
7
8
|
* Like assert, but logs only if the condition is false, rather than throwing
|
|
8
9
|
* @param condition - The condition to attest too
|
|
9
10
|
* @param logger - The logger to log with
|
|
10
11
|
* @param event - The string or event to log
|
|
11
|
-
* @returns
|
|
12
|
+
* @returns The outcome of the condition
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*
|
|
16
|
+
* @deprecated
|
|
17
|
+
* This API will be removed in a future release.
|
|
18
|
+
* No replacement API is intended, but reproducing its behavior should be trivial for anyone who needs it.
|
|
12
19
|
*/
|
|
13
|
-
export declare function logIfFalse(condition:
|
|
20
|
+
export declare function logIfFalse(condition: unknown, logger: ITelemetryBaseLogger, event: string | ITelemetryGenericEvent): condition is true;
|
|
21
|
+
/**
|
|
22
|
+
* An object that contains a callback used in conjunction with the {@link createSampledLogger} utility function to provide custom logic for sampling events.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export interface IEventSampler {
|
|
27
|
+
/**
|
|
28
|
+
* @returns true if the event should be sampled or false if not
|
|
29
|
+
*/
|
|
30
|
+
sample: () => boolean | undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A telemetry logger that has sampling capabilities
|
|
34
|
+
*
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export interface ISampledTelemetryLogger extends ITelemetryLoggerExt {
|
|
38
|
+
/**
|
|
39
|
+
* Indicates if the feature flag to disable sampling is set.
|
|
40
|
+
*
|
|
41
|
+
* @remarks Exposed to enable some advanced scenarios where the code using the sampled logger
|
|
42
|
+
* could take advantage of skipping the execution of some logic when it can determine
|
|
43
|
+
* it won't be necessary because the telemetry event that needs it wouldn't be
|
|
44
|
+
* emitted anyway.
|
|
45
|
+
*/
|
|
46
|
+
isSamplingDisabled: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Wraps around an existing logger matching the {@link ITelemetryLoggerExt} interface and provides the ability to only log a subset of events using a sampling strategy provided by an ${@link IEventSampler}.
|
|
50
|
+
* 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.
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* The sampling functionality uses the Fluid telemetry logging configuration along with the optionally provided event sampling callback to determine whether an event should
|
|
54
|
+
* be logged or not.
|
|
55
|
+
*
|
|
56
|
+
* Configuration object parameters:
|
|
57
|
+
* 'Fluid.Telemetry.DisableSampling': if this config value is set to true, all events will be unsampled and therefore logged.
|
|
58
|
+
* Otherwise only a sample will be logged according to the provided event sampler callback.
|
|
59
|
+
*
|
|
60
|
+
* 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.
|
|
61
|
+
*
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
export declare function createSampledLogger(logger: ITelemetryLoggerExt, eventSampler?: IEventSampler): ISampledTelemetryLogger;
|
|
14
65
|
//# sourceMappingURL=utils.d.ts.map
|
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,
|
|
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,OAAO,EAA6B,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAElF;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CACzB,SAAS,EAAE,OAAO,EAClB,MAAM,EAAE,oBAAoB,EAC5B,KAAK,EAAE,MAAM,GAAG,sBAAsB,GACpC,SAAS,IAAI,IAAI,CAUnB;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,OAAO,GAAG,SAAS,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;IACnE;;;;;;;OAOG;IACH,kBAAkB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,mBAAmB,EAC3B,YAAY,CAAC,EAAE,aAAa,GAC1B,uBAAuB,CAiCzB"}
|
package/lib/utils.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import { loggerToMonitoringContext } from "./config";
|
|
1
2
|
/**
|
|
2
3
|
* Like assert, but logs only if the condition is false, rather than throwing
|
|
3
4
|
* @param condition - The condition to attest too
|
|
4
5
|
* @param logger - The logger to log with
|
|
5
6
|
* @param event - The string or event to log
|
|
6
|
-
* @returns
|
|
7
|
+
* @returns The outcome of the condition
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*
|
|
11
|
+
* @deprecated
|
|
12
|
+
* This API will be removed in a future release.
|
|
13
|
+
* No replacement API is intended, but reproducing its behavior should be trivial for anyone who needs it.
|
|
7
14
|
*/
|
|
8
15
|
export function logIfFalse(condition, logger, event) {
|
|
9
16
|
if (condition) {
|
|
@@ -11,8 +18,55 @@ export function logIfFalse(condition, logger, event) {
|
|
|
11
18
|
}
|
|
12
19
|
const newEvent = typeof event === "string"
|
|
13
20
|
? { eventName: event, category: "error" }
|
|
14
|
-
:
|
|
21
|
+
: { category: "error", ...event };
|
|
15
22
|
logger.send(newEvent);
|
|
16
23
|
return false;
|
|
17
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Wraps around an existing logger matching the {@link ITelemetryLoggerExt} interface and provides the ability to only log a subset of events using a sampling strategy provided by an ${@link IEventSampler}.
|
|
27
|
+
* 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.
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* The sampling functionality uses the Fluid telemetry logging configuration along with the optionally provided event sampling callback to determine whether an event should
|
|
31
|
+
* be logged or not.
|
|
32
|
+
*
|
|
33
|
+
* Configuration object parameters:
|
|
34
|
+
* 'Fluid.Telemetry.DisableSampling': if this config value is set to true, all events will be unsampled and therefore logged.
|
|
35
|
+
* Otherwise only a sample will be logged according to the provided event sampler callback.
|
|
36
|
+
*
|
|
37
|
+
* 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.
|
|
38
|
+
*
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export function createSampledLogger(logger, eventSampler) {
|
|
42
|
+
const monitoringContext = loggerToMonitoringContext(logger);
|
|
43
|
+
const isSamplingDisabled = monitoringContext.config.getBoolean("Fluid.Telemetry.DisableSampling") ?? false;
|
|
44
|
+
const sampledLogger = {
|
|
45
|
+
send: (event) => {
|
|
46
|
+
// The sampler uses the following logic for sending events:
|
|
47
|
+
// 1. If isSamplingDisabled is true, then this means events should be unsampled. Therefore we send the event without any checks.
|
|
48
|
+
// 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.
|
|
49
|
+
if (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {
|
|
50
|
+
logger.send(event);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
sendTelemetryEvent: (event) => {
|
|
54
|
+
if (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {
|
|
55
|
+
logger.sendTelemetryEvent(event);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
sendErrorEvent: (event) => {
|
|
59
|
+
if (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {
|
|
60
|
+
logger.sendErrorEvent(event);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
sendPerformanceEvent: (event) => {
|
|
64
|
+
if (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {
|
|
65
|
+
logger.sendPerformanceEvent(event);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
isSamplingDisabled,
|
|
69
|
+
};
|
|
70
|
+
return sampledLogger;
|
|
71
|
+
}
|
|
18
72
|
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAGrD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,UAAU,CACzB,SAAkB,EAClB,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,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC;IACpC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtB,OAAO,KAAK,CAAC;AACd,CAAC;AA+BD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CAClC,MAA2B,EAC3B,YAA4B;IAE5B,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,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE;gBAC9E,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACnB;QACF,CAAC;QACD,kBAAkB,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAC9D,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE;gBAC9E,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;aACjC;QACF,CAAC;QACD,cAAc,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAC1D,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE;gBAC9E,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;aAC7B;QACF,CAAC;QACD,oBAAoB,EAAE,CAAC,KAAgC,EAAQ,EAAE;YAChE,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE;gBAC9E,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;aACnC;QACF,CAAC;QACD,kBAAkB;KAClB,CAAC;IAEF,OAAO,aAAa,CAAC;AACtB,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\";\nimport { loggerToMonitoringContext } from \"./config\";\nimport { ITelemetryGenericEventExt, ITelemetryLoggerExt } from \"./telemetryTypes\";\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 *\n * @internal\n *\n * @deprecated\n * This API will be removed in a future release.\n * No replacement API is intended, but reproducing its behavior should be trivial for anyone who needs it.\n */\nexport function logIfFalse(\n\tcondition: unknown,\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\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 | undefined;\n}\n\n/**\n * A telemetry logger that has sampling capabilities\n *\n * @internal\n */\nexport interface ISampledTelemetryLogger extends ITelemetryLoggerExt {\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 ITelemetryLoggerExt} 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: ITelemetryLoggerExt,\n\teventSampler?: IEventSampler,\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\tif (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {\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\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\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\tlogger.sendPerformanceEvent(event);\n\t\t\t}\n\t\t},\n\t\tisSamplingDisabled,\n\t};\n\n\treturn sampledLogger;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/telemetry-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.0.0-dev-rc.1.0.0.225277",
|
|
4
4
|
"description": "Collection of telemetry relates utilities for Fluid",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -18,43 +18,17 @@
|
|
|
18
18
|
"./lib/indexNode.js": "./lib/indexBrowser.js"
|
|
19
19
|
},
|
|
20
20
|
"types": "dist/index.d.ts",
|
|
21
|
-
"
|
|
22
|
-
"build": "npm run build:genver && concurrently npm:build:compile npm:lint && npm run build:docs",
|
|
23
|
-
"build:commonjs": "npm run tsc && npm run typetests:gen && npm run build:test",
|
|
24
|
-
"build:compile": "concurrently npm:build:commonjs npm:build:esnext",
|
|
25
|
-
"build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
|
|
26
|
-
"build:esnext": "tsc --project ./tsconfig.esnext.json",
|
|
27
|
-
"build:full": "npm run build",
|
|
28
|
-
"build:full:compile": "npm run build:compile",
|
|
29
|
-
"build:genver": "gen-version",
|
|
30
|
-
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
31
|
-
"bump-version": "npm version minor --no-push --no-git-tag-version && npm run build:genver",
|
|
32
|
-
"ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
|
|
33
|
-
"clean": "rimraf dist lib *.tsbuildinfo *.build.log",
|
|
34
|
-
"eslint": "eslint --format stylish src",
|
|
35
|
-
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
36
|
-
"lint": "npm run eslint",
|
|
37
|
-
"lint:fix": "npm run eslint:fix",
|
|
38
|
-
"test": "npm run test:mocha",
|
|
39
|
-
"test:coverage": "nyc npm run test:report",
|
|
40
|
-
"test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
|
|
41
|
-
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
42
|
-
"test:report": "npm test -- -- --reporter xunit --reporter-option output=nyc/mocha-junit-report.xml",
|
|
43
|
-
"tsc": "tsc",
|
|
44
|
-
"typetests:gen": "flub generate typetests --generate --dir . --no-generateInName",
|
|
45
|
-
"typetests:prepare": "flub generate typetests --prepare --dir . --pin"
|
|
46
|
-
},
|
|
47
|
-
"nyc": {
|
|
21
|
+
"c8": {
|
|
48
22
|
"all": true,
|
|
49
23
|
"cache-dir": "nyc/.cache",
|
|
50
24
|
"exclude": [
|
|
51
|
-
"src/test
|
|
52
|
-
"dist/test
|
|
25
|
+
"src/test/**/*.*ts",
|
|
26
|
+
"dist/test/**/*.*js"
|
|
53
27
|
],
|
|
54
28
|
"exclude-after-remap": false,
|
|
55
29
|
"include": [
|
|
56
|
-
"src
|
|
57
|
-
"dist
|
|
30
|
+
"src/**/*.*ts",
|
|
31
|
+
"dist/**/*.*js"
|
|
58
32
|
],
|
|
59
33
|
"report-dir": "nyc/report",
|
|
60
34
|
"reporter": [
|
|
@@ -65,38 +39,93 @@
|
|
|
65
39
|
"temp-directory": "nyc/.nyc_output"
|
|
66
40
|
},
|
|
67
41
|
"dependencies": {
|
|
68
|
-
"@
|
|
69
|
-
"@fluidframework/
|
|
70
|
-
"
|
|
42
|
+
"@fluid-internal/client-utils": "2.0.0-dev-rc.1.0.0.225277",
|
|
43
|
+
"@fluidframework/core-interfaces": "2.0.0-dev-rc.1.0.0.225277",
|
|
44
|
+
"@fluidframework/core-utils": "2.0.0-dev-rc.1.0.0.225277",
|
|
45
|
+
"@fluidframework/protocol-definitions": "^3.1.0-223007",
|
|
46
|
+
"debug": "^4.3.4",
|
|
71
47
|
"events": "^3.1.0",
|
|
72
|
-
"uuid": "^
|
|
48
|
+
"uuid": "^9.0.0"
|
|
73
49
|
},
|
|
74
50
|
"devDependencies": {
|
|
75
|
-
"@
|
|
76
|
-
"@
|
|
77
|
-
"@fluidframework/
|
|
78
|
-
"@fluidframework/
|
|
79
|
-
"@fluidframework/
|
|
80
|
-
"@
|
|
81
|
-
"@
|
|
51
|
+
"@arethetypeswrong/cli": "^0.13.3",
|
|
52
|
+
"@fluid-tools/build-cli": "0.29.0-222379",
|
|
53
|
+
"@fluidframework/build-common": "^2.0.3",
|
|
54
|
+
"@fluidframework/build-tools": "0.29.0-222379",
|
|
55
|
+
"@fluidframework/eslint-config-fluid": "^3.1.0",
|
|
56
|
+
"@fluidframework/mocha-test-setup": "2.0.0-dev-rc.1.0.0.225277",
|
|
57
|
+
"@fluidframework/telemetry-utils-previous": "npm:@fluidframework/telemetry-utils@2.0.0-internal.8.0.0",
|
|
58
|
+
"@microsoft/api-extractor": "^7.38.3",
|
|
82
59
|
"@types/debug": "^4.1.5",
|
|
83
60
|
"@types/events": "^3.0.0",
|
|
84
61
|
"@types/mocha": "^9.1.1",
|
|
85
|
-
"@types/node": "^
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
62
|
+
"@types/node": "^18.19.0",
|
|
63
|
+
"@types/uuid": "^9.0.2",
|
|
64
|
+
"c8": "^8.0.1",
|
|
65
|
+
"copyfiles": "^2.4.1",
|
|
66
|
+
"cross-env": "^7.0.3",
|
|
67
|
+
"eslint": "~8.50.0",
|
|
68
|
+
"mocha": "^10.2.0",
|
|
69
|
+
"mocha-json-output-reporter": "^2.0.1",
|
|
70
|
+
"mocha-multi-reporters": "^1.5.1",
|
|
71
|
+
"moment": "^2.21.0",
|
|
72
|
+
"prettier": "~3.0.3",
|
|
73
|
+
"rimraf": "^4.4.0",
|
|
93
74
|
"sinon": "^7.4.2",
|
|
94
|
-
"typescript": "~
|
|
75
|
+
"typescript": "~5.1.6"
|
|
76
|
+
},
|
|
77
|
+
"fluidBuild": {
|
|
78
|
+
"tasks": {
|
|
79
|
+
"build:docs": {
|
|
80
|
+
"dependsOn": [
|
|
81
|
+
"...",
|
|
82
|
+
"api-extractor:commonjs",
|
|
83
|
+
"api-extractor:esnext"
|
|
84
|
+
],
|
|
85
|
+
"script": false
|
|
86
|
+
}
|
|
87
|
+
}
|
|
95
88
|
},
|
|
96
89
|
"typeValidation": {
|
|
97
|
-
"
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
90
|
+
"broken": {
|
|
91
|
+
"RemovedInterfaceDeclaration_IConfigProviderBase": {
|
|
92
|
+
"forwardCompat": false,
|
|
93
|
+
"backCompat": false
|
|
94
|
+
},
|
|
95
|
+
"RemovedTypeAliasDeclaration_ConfigTypes": {
|
|
96
|
+
"backCompat": false,
|
|
97
|
+
"forwardCompat": false
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"scripts": {
|
|
102
|
+
"api": "fluid-build . --task api",
|
|
103
|
+
"api-extractor:commonjs": "api-extractor run --local",
|
|
104
|
+
"api-extractor:esnext": "api-extractor run --config ./api-extractor-esm.json",
|
|
105
|
+
"build": "fluid-build . --task build",
|
|
106
|
+
"build:commonjs": "fluid-build . --task commonjs",
|
|
107
|
+
"build:compile": "fluid-build . --task compile",
|
|
108
|
+
"build:docs": "fluid-build . --task api",
|
|
109
|
+
"build:esnext": "tsc --project ./tsconfig.esnext.json",
|
|
110
|
+
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
111
|
+
"bump-version": "npm version minor --no-push --no-git-tag-version && npm run build:genver",
|
|
112
|
+
"check:are-the-types-wrong": "attw --pack",
|
|
113
|
+
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
|
|
114
|
+
"ci:build:docs": "api-extractor run",
|
|
115
|
+
"clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
|
|
116
|
+
"eslint": "eslint --format stylish src",
|
|
117
|
+
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
118
|
+
"format": "npm run prettier:fix",
|
|
119
|
+
"lint": "npm run prettier && npm run check:release-tags && npm run eslint",
|
|
120
|
+
"lint:fix": "npm run prettier:fix && npm run eslint:fix",
|
|
121
|
+
"prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
|
|
122
|
+
"prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
123
|
+
"test": "npm run test:mocha",
|
|
124
|
+
"test:coverage": "c8 npm test",
|
|
125
|
+
"test:mocha": "mocha --ignore \"dist/test/types/*\" --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup",
|
|
126
|
+
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
127
|
+
"tsc": "tsc",
|
|
128
|
+
"typetests:gen": "fluid-type-test-generator",
|
|
129
|
+
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
|
|
101
130
|
}
|
|
102
|
-
}
|
|
131
|
+
}
|