@fluidframework/telemetry-utils 2.100.0 → 2.101.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 +4 -0
- package/api-report/telemetry-utils.legacy.beta.api.md +2 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -1
- package/dist/config.js.map +1 -1
- package/dist/logger.d.ts +21 -16
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +32 -25
- package/dist/logger.js.map +1 -1
- package/dist/mockLogger.js +2 -2
- package/dist/mockLogger.js.map +1 -1
- package/dist/sampledTelemetryHelper.d.ts +3 -0
- package/dist/sampledTelemetryHelper.d.ts.map +1 -1
- package/dist/sampledTelemetryHelper.js +6 -1
- package/dist/sampledTelemetryHelper.js.map +1 -1
- package/dist/telemetryTypes.d.ts +12 -8
- package/dist/telemetryTypes.d.ts.map +1 -1
- package/dist/telemetryTypes.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +8 -8
- package/dist/utils.js.map +1 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +2 -1
- package/lib/config.js.map +1 -1
- package/lib/logger.d.ts +21 -16
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +32 -25
- package/lib/logger.js.map +1 -1
- package/lib/mockLogger.js +2 -2
- package/lib/mockLogger.js.map +1 -1
- package/lib/sampledTelemetryHelper.d.ts +3 -0
- package/lib/sampledTelemetryHelper.d.ts.map +1 -1
- package/lib/sampledTelemetryHelper.js +6 -1
- package/lib/sampledTelemetryHelper.js.map +1 -1
- package/lib/telemetryTypes.d.ts +12 -8
- package/lib/telemetryTypes.d.ts.map +1 -1
- package/lib/telemetryTypes.js.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +8 -8
- package/lib/utils.js.map +1 -1
- package/package.json +6 -6
- package/src/config.ts +12 -8
- package/src/logger.ts +41 -23
- package/src/mockLogger.ts +2 -2
- package/src/sampledTelemetryHelper.ts +9 -1
- package/src/telemetryTypes.ts +12 -8
- package/src/utils.ts +17 -9
|
@@ -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 type { 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 * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\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 * @legacy @beta\n */\nexport type TelemetryEventPropertyTypeExt =\n\t| string\n\t| number\n\t| boolean\n\t| undefined\n\t| (string | number | boolean)[]\n\t| Record<string, string | number | boolean | undefined | (string | number | boolean)[]>;\n\n/**\n * JSON-serializable properties, which will be logged with telemetry.\n * @legacy @beta\n */\nexport type ITelemetryPropertiesExt = Record<\n\tstring,\n\tTelemetryEventPropertyTypeExt | 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\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.category}\n\t */\n\tcategory: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n}\n\n/**\n * Informational (non-error) telemetry event\n * @remarks Maps to category = \"generic\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n\n\t/**\n\t * Optional event {@link @fluidframework/core-interfaces#ITelemetryBaseEvent.category}.\n\t * @defaultValue \"generic\"\n\t */\n\tcategory?: TelemetryEventCategory;\n}\n\n/**\n * Error telemetry event.\n * @remarks Maps to category = \"error\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n}\n\n/**\n * Performance telemetry event.\n * @remarks Maps to category = \"performance\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {\n\t/**\n\t * Duration of event (optional)\n\t */\n\tduration?: number;\n}\n\n/**\n * This is the externally facing type for a FluidFramework internal telemetry logger wrapper.\n *\n * @remarks\n * The methods if this interface are not to be used directly by consumers and are all\n * deprecated to removed without replacement. This type is not deprecated and will\n * transition to an erased type to handle cases where \"internal\" `ITelemetryLoggerExt`\n * previously leaked out.\n *\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for deprecation and breaking change details.\n *\n * @privateRemarks\n * External APIs taking in an `ITelemetryLoggerExt` ideally should be updated to\n * accept `ITelemetryBaseLogger` instead.\n *\n * @sealed\n * @legacy\n * @beta\n */\nexport interface ITelemetryLoggerExt extends ITelemetryBaseLogger {\n\t/**\n\t * Send an 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.
|
|
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 type { 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 * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\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 * @legacy @beta\n */\nexport type TelemetryEventPropertyTypeExt =\n\t| string\n\t| number\n\t| boolean\n\t| undefined\n\t| (string | number | boolean)[]\n\t| Record<string, string | number | boolean | undefined | (string | number | boolean)[]>;\n\n/**\n * JSON-serializable properties, which will be logged with telemetry.\n * @legacy @beta\n */\nexport type ITelemetryPropertiesExt = Record<\n\tstring,\n\tTelemetryEventPropertyTypeExt | 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\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.category}\n\t */\n\tcategory: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n}\n\n/**\n * Informational (non-error) telemetry event\n * @remarks Maps to category = \"generic\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n\n\t/**\n\t * Optional event {@link @fluidframework/core-interfaces#ITelemetryBaseEvent.category}.\n\t * @defaultValue \"generic\"\n\t */\n\tcategory?: TelemetryEventCategory;\n}\n\n/**\n * Error telemetry event.\n * @remarks Maps to category = \"error\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {\n\t/**\n\t * {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseEvent.eventName}\n\t */\n\teventName: string;\n}\n\n/**\n * Performance telemetry event.\n * @remarks Maps to category = \"performance\"\n * @deprecated This type is being removed without a replacement.\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n * @legacy @beta\n */\nexport interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {\n\t/**\n\t * Duration of event (optional)\n\t */\n\tduration?: number;\n}\n\n/**\n * This is the externally facing type for a FluidFramework internal telemetry logger wrapper.\n *\n * @remarks\n * The methods if this interface are not to be used directly by consumers and are all\n * deprecated to removed without replacement. This type is not deprecated and will\n * transition to an erased type to handle cases where \"internal\" `ITelemetryLoggerExt`\n * previously leaked out.\n *\n * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for deprecation and breaking change details.\n *\n * @privateRemarks\n * External APIs taking in an `ITelemetryLoggerExt` ideally should be updated to\n * accept `ITelemetryBaseLogger` instead.\n *\n * @sealed\n * @legacy\n * @beta\n */\nexport interface ITelemetryLoggerExt extends ITelemetryBaseLogger {\n\t/**\n\t * Send an 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. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * @deprecated This method is being removed without a replacement.\n\t * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n\t */\n\tsendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void;\n\n\t/**\n\t * Send an error telemetry event.\n\t * @param event - Event to send.\n\t * @param error - Optional error object to log.\n\t * @deprecated This method is being removed without a replacement.\n\t * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n\t */\n\tsendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;\n\n\t/**\n\t * Send a 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. If undefined, the logLevel should be treated as {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevel.essential}.\n\t * @deprecated This method is being removed without a replacement.\n\t * @see {@link https://github.com/microsoft/FluidFramework/issues/26910 | Issue #26910} for details.\n\t */\n\tsendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void;\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 * @internal\n */\nexport interface TelemetryLoggerExt extends ITelemetryBaseLogger {\n\t/**\n\t * Send an 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. If undefined, the logLevel will be treated as {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t */\n\tsendTelemetryEvent(\n\t\tevent: ITelemetryGenericEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void;\n\n\t/**\n\t * Send an 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 a 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. If undefined, the logLevel will be treated as {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t * If the event's category is `error`, the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.\n\t */\n\tsendPerformanceEvent(\n\t\tevent: ITelemetryPerformanceEventExt,\n\t\terror?: unknown,\n\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t): void;\n}\n"]}
|
package/dist/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,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,
|
|
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,CAsDzB;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/dist/utils.js
CHANGED
|
@@ -26,7 +26,7 @@ function createSampledLogger(logger, eventSampler, skipLoggingWhenSamplingIsDisa
|
|
|
26
26
|
const monitoringContext = (0, config_js_1.loggerToMonitoringContext)(logger);
|
|
27
27
|
const isSamplingDisabled = monitoringContext.config.getBoolean("Fluid.Telemetry.DisableSampling") ?? false;
|
|
28
28
|
const sampledLogger = {
|
|
29
|
-
send: (event) => {
|
|
29
|
+
send: (event, logLevel) => {
|
|
30
30
|
// The sampler uses the following logic for sending events:
|
|
31
31
|
// 1. If isSamplingDisabled is true, then this means events should be unsampled. Therefore we send the event without any checks.
|
|
32
32
|
// 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.
|
|
@@ -35,31 +35,31 @@ function createSampledLogger(logger, eventSampler, skipLoggingWhenSamplingIsDisa
|
|
|
35
35
|
if (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
logger.send(event);
|
|
38
|
+
logger.send(event, logLevel);
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
|
-
sendTelemetryEvent: (event) => {
|
|
41
|
+
sendTelemetryEvent: (event, error, logLevel) => {
|
|
42
42
|
if (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {
|
|
43
43
|
if (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
logger.sendTelemetryEvent(event);
|
|
46
|
+
logger.sendTelemetryEvent(event, error, logLevel);
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
|
-
sendErrorEvent: (event) => {
|
|
49
|
+
sendErrorEvent: (event, error) => {
|
|
50
50
|
if (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {
|
|
51
51
|
if (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
logger.sendErrorEvent(event);
|
|
54
|
+
logger.sendErrorEvent(event, error);
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
|
-
sendPerformanceEvent: (event) => {
|
|
57
|
+
sendPerformanceEvent: (event, error, logLevel) => {
|
|
58
58
|
if (isSamplingDisabled || eventSampler === undefined || eventSampler.sample()) {
|
|
59
59
|
if (isSamplingDisabled && (skipLoggingWhenSamplingIsDisabled ?? false)) {
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
logger.sendPerformanceEvent(event);
|
|
62
|
+
logger.sendPerformanceEvent(event, error, logLevel);
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
isSamplingDisabled,
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,2CAAwD;AAmCxD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,mBAAmB,CAClC,MAA0B,EAC1B,YAA4B,EAC5B,iCAA2C;IAE3C,MAAM,iBAAiB,GAAG,IAAA,qCAAyB,EAAC,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;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,2CAAwD;AAmCxD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,mBAAmB,CAClC,MAA0B,EAC1B,YAA4B,EAC5B,iCAA2C;IAE3C,MAAM,iBAAiB,GAAG,IAAA,qCAAyB,EAAC,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,EAAE,QAAmB,EAAQ,EAAE;YAC/D,2DAA2D;YAC3D,gIAAgI;YAChI,2LAA2L;YAC3L,0EAA0E;YAC1E,IAAI,kBAAkB,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC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CAAC;IAEF,OAAO,aAAa,CAAC;AACtB,CAAC;AA1DD,kDA0DC;AAED;;;;;;;GAOG;AACH,SAAgB,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;AALD,0BAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseEvent, LogLevel } 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, logLevel?: LogLevel): 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, logLevel);\n\t\t\t}\n\t\t},\n\t\tsendTelemetryEvent: (\n\t\t\tevent: ITelemetryGenericEventExt,\n\t\t\terror?: unknown,\n\t\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t\t): 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, error, logLevel);\n\t\t\t}\n\t\t},\n\t\tsendErrorEvent: (event: ITelemetryGenericEventExt, error?: unknown): 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, error);\n\t\t\t}\n\t\t},\n\t\tsendPerformanceEvent: (\n\t\t\tevent: ITelemetryGenericEventExt,\n\t\t\terror?: unknown,\n\t\t\tlogLevel?: typeof LogLevel.verbose | typeof LogLevel.info,\n\t\t): 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, error, logLevel);\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/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,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AKG;AACH,wBAAgB,4BAA4B,CAC3C,KAAK,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC,GAC5C,iBAAiB,CAEnB;AAED;;KAEK;AACL,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,MAAM,IAAI;KAClD,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAC9B,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,MAAM,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,GAC3E,SAAS;CACZ,CAAC;AAEF;;;;;;;;;;KAUK;AACL,wBAAgB,6BAA6B,CAAC,CAAC,SAAS,MAAM,EAC7D,MAAM,EAAE,mBAAmB,EAC3B,SAAS,EAAE,SAAS,MAAM,EAAE,EAC5B,aAAa,EAAE,mBAAmB,CAAC,CAAC,CAAC,EACrC,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GACzB,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CA6BtB"}
|
package/lib/config.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
import { LogLevel } from "@fluidframework/core-interfaces";
|
|
5
6
|
import { Lazy } from "@fluidframework/core-utils/internal";
|
|
6
7
|
import { createChildLogger, tagCodeArtifacts } from "./logger.js";
|
|
7
8
|
/**
|
|
@@ -197,7 +198,7 @@ export class CachedConfigProvider {
|
|
|
197
198
|
configName: name,
|
|
198
199
|
configValue: JSON.stringify(parsed),
|
|
199
200
|
}),
|
|
200
|
-
});
|
|
201
|
+
}, LogLevel.info);
|
|
201
202
|
return parsed;
|
|
202
203
|
}
|
|
203
204
|
}
|
package/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":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AAG,SAAS,IAAI,IAAI,EAAE,CAAC,CAAC;YAC3D,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACzB,OAAO,KAAK,CAAC;YACd,CAAC;YACD,OAAO,cAAc,EAAE,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;QACD,GAAG,EAAE,CAAC,CAAC,EAAE,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;QACjD,yDAAyD;QACzD,sDAAsD;QACtD,oDAAoD;QACpD,0BAA0B;QAC1B,OAAO,EAAE,GAAwB,EAAE;YAClC,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAC;QAC7D,CAAC;KACD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tConfigTypes,\n\tIConfigProviderBase,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { Lazy } from \"@fluidframework/core-utils/internal\";\n\nimport { createChildLogger, tagCodeArtifacts } from \"./logger.js\";\nimport type { ITelemetryLoggerExt, TelemetryLoggerExt } from \"./telemetryTypes.js\";\n\n/**\n * Explicitly typed interface for reading configurations.\n *\n * @internal\n */\nexport interface IConfigProvider extends IConfigProviderBase {\n\tgetBoolean(name: string): boolean | undefined;\n\tgetNumber(name: string): number | undefined;\n\tgetString(name: string): string | undefined;\n\tgetBooleanArray(name: string): boolean[] | undefined;\n\tgetNumberArray(name: string): number[] | undefined;\n\tgetStringArray(name: string): string[] | undefined;\n}\n/**\n * Creates a base configuration provider based on `sessionStorage`\n *\n * @returns A lazy initialized base configuration provider with `sessionStorage` as the underlying config store\n *\n * @internal\n */\nexport const sessionStorageConfigProvider = new Lazy<IConfigProviderBase>(() =>\n\tinMemoryConfigProvider(safeSessionStorage()),\n);\n\nconst NullConfigProvider: IConfigProviderBase = {\n\tgetRawConfig: () => undefined,\n};\n\n/**\n * Creates a base configuration provider based on the supplied `Storage` instance\n *\n * @param storage - instance of `Storage` to be used as storage media for the config\n * @returns A base configuration provider with\n * the supplied `Storage` instance as the underlying config store\n */\nexport const inMemoryConfigProvider = (storage: Storage | undefined): IConfigProviderBase => {\n\tif (storage !== undefined && storage !== null) {\n\t\treturn new CachedConfigProvider(undefined, {\n\t\t\tgetRawConfig: (name: string): ConfigTypes | undefined => {\n\t\t\t\ttry {\n\t\t\t\t\treturn stronglyTypedParse(storage.getItem(name) ?? undefined)?.raw;\n\t\t\t\t} catch {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n\treturn NullConfigProvider;\n};\n\ninterface ConfigTypeStringToType {\n\tnumber: number;\n\tstring: string;\n\tboolean: boolean;\n\t[\"number[]\"]: number[];\n\t[\"string[]\"]: string[];\n\t[\"boolean[]\"]: boolean[];\n}\n\ntype PrimitiveTypeStrings = \"number\" | \"string\" | \"boolean\";\n\nfunction isPrimitiveType(type: string): type is PrimitiveTypeStrings {\n\tswitch (type) {\n\t\tcase \"boolean\":\n\t\tcase \"number\":\n\t\tcase \"string\": {\n\t\t\treturn true;\n\t\t}\n\t\tdefault: {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n\ninterface StronglyTypedValue extends Partial<ConfigTypeStringToType> {\n\traw: ConfigTypes;\n}\n/**\n * Takes any supported config type, and returns the value with a strong type. If the type of\n * the config is not a supported type undefined will be returned.\n * The user of this function should cache the result to avoid duplicated work.\n *\n * Strings will be attempted to be parsed and coerced into a strong config type.\n * if it is not possible to parsed and coerce a string to a strong config type the original string\n * will be return with a string type for the consumer to handle further if necessary.\n */\nfunction stronglyTypedParse(input: ConfigTypes): StronglyTypedValue | undefined {\n\tlet output: ConfigTypes = input;\n\tlet defaultReturn: Pick<StronglyTypedValue, \"raw\" | \"string\"> | undefined;\n\t// we do special handling for strings to try and coerce\n\t// them into a config type if we can. This makes it easy\n\t// for config sources like sessionStorage which only\n\t// holds strings\n\tif (typeof input === \"string\") {\n\t\ttry {\n\t\t\toutput = JSON.parse(input) as ConfigTypes;\n\t\t\t// we succeeded in parsing, but we don't support parsing\n\t\t\t// for any object as we can't do it type safely\n\t\t\t// so in this case, the default return will be string\n\t\t\t// rather than undefined, and the consumer\n\t\t\t// can parse, as we don't want to provide\n\t\t\t// a false sense of security by just\n\t\t\t// casting.\n\t\t\tdefaultReturn = { raw: input, string: input };\n\t\t} catch {\n\t\t\t// No-op\n\t\t}\n\t}\n\n\tif (output === undefined) {\n\t\treturn defaultReturn;\n\t}\n\n\tconst outputType = typeof output;\n\tif (isPrimitiveType(outputType)) {\n\t\treturn { ...defaultReturn, raw: input, [outputType]: output };\n\t}\n\n\tif (Array.isArray(output)) {\n\t\tconst firstType = typeof output[0];\n\t\t// ensure the first elements is a primitive type\n\t\tif (!isPrimitiveType(firstType)) {\n\t\t\treturn defaultReturn;\n\t\t}\n\t\t// ensue all the elements types are homogeneous\n\t\t// aka they all have the same type as the first\n\t\tfor (const v of output) {\n\t\t\tif (typeof v !== firstType) {\n\t\t\t\treturn defaultReturn;\n\t\t\t}\n\t\t}\n\t\treturn { ...defaultReturn, raw: input, [`${firstType}[]`]: output };\n\t}\n\n\treturn defaultReturn;\n}\n\n/**\n * `sessionStorage` is undefined in some environments such as Node and web pages with session storage disabled.\n */\nconst safeSessionStorage = (): Storage | undefined => {\n\t// For some configurations accessing \"globalThis.sessionStorage\" throws\n\t// \"'sessionStorage' property from 'Window': Access is denied for this document\" rather than returning undefined.\n\t// Therefor check for it before accessing.\n\ttry {\n\t\t// Using globalThis and checking for undefined is preferred over just accessing global sessionStorage\n\t\t// since it avoids an exception when running in node.\n\t\t// In some cases this has returned null when disabled in the browser, so ensure its undefined in that case:\n\t\treturn globalThis.sessionStorage ?? undefined;\n\t} catch {\n\t\t// For browsers which error on the above when session storage is disabled:\n\t\treturn undefined;\n\t}\n};\n\n/**\n * Creates a wrapper on top of an existing config provider which allows for\n * specifying feature gates if not present in the original provider.\n *\n * @param original - the original config provider\n * @param defaults - default feature gate configs to be used if not specified by the original provider\n * @returns A config provider that looks for any requested feature gates in the original provider and falls\n * back to the values specified in the `defaults` feature gates if they're not present in the original.\n *\n * @internal\n */\nexport const wrapConfigProviderWithDefaults = (\n\toriginal: IConfigProviderBase | undefined,\n\tdefaults: Record<string, ConfigTypes>,\n): IConfigProviderBase => ({\n\tgetRawConfig: (name: string): ConfigTypes => original?.getRawConfig(name) ?? defaults[name],\n});\n\n/**\n * Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances\n */\nexport class CachedConfigProvider implements IConfigProvider {\n\tprivate readonly configCache = new Map<string, StronglyTypedValue>();\n\tprivate readonly orderedBaseProviders: (IConfigProviderBase | undefined)[];\n\n\tpublic constructor(\n\t\tprivate readonly logger?: ITelemetryBaseLogger,\n\t\t...orderedBaseProviders: (IConfigProviderBase | undefined)[]\n\t) {\n\t\tthis.orderedBaseProviders = [];\n\t\tconst knownProviders = new Set<IConfigProviderBase>();\n\t\tconst candidateProviders = [...orderedBaseProviders];\n\t\twhile (candidateProviders.length > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst baseProvider = candidateProviders.shift()!;\n\t\t\tif (\n\t\t\t\tbaseProvider !== undefined &&\n\t\t\t\tisConfigProviderBase(baseProvider) &&\n\t\t\t\t!knownProviders.has(baseProvider)\n\t\t\t) {\n\t\t\t\tknownProviders.add(baseProvider);\n\t\t\t\tif (baseProvider instanceof CachedConfigProvider) {\n\t\t\t\t\tcandidateProviders.push(...baseProvider.orderedBaseProviders);\n\t\t\t\t} else {\n\t\t\t\t\tthis.orderedBaseProviders.push(baseProvider);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tpublic getBoolean(name: string): boolean | undefined {\n\t\treturn this.getCacheEntry(name)?.boolean;\n\t}\n\tpublic getNumber(name: string): number | undefined {\n\t\treturn this.getCacheEntry(name)?.number;\n\t}\n\tpublic getString(name: string): string | undefined {\n\t\treturn this.getCacheEntry(name)?.string;\n\t}\n\tpublic getBooleanArray(name: string): boolean[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"boolean[]\"];\n\t}\n\tpublic getNumberArray(name: string): number[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"number[]\"];\n\t}\n\tpublic getStringArray(name: string): string[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"string[]\"];\n\t}\n\n\tpublic getRawConfig(name: string): ConfigTypes {\n\t\treturn this.getCacheEntry(name)?.raw;\n\t}\n\n\tprivate getCacheEntry(name: string): StronglyTypedValue | undefined {\n\t\tif (!this.configCache.has(name)) {\n\t\t\tfor (const provider of this.orderedBaseProviders) {\n\t\t\t\tconst parsed = stronglyTypedParse(provider?.getRawConfig(name));\n\t\t\t\tif (parsed !== undefined) {\n\t\t\t\t\tthis.configCache.set(name, parsed);\n\t\t\t\t\tthis.logger?.send({\n\t\t\t\t\t\tcategory: \"generic\",\n\t\t\t\t\t\teventName: \"ConfigRead\",\n\t\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\t\tconfigName: name,\n\t\t\t\t\t\t\tconfigValue: JSON.stringify(parsed),\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t\treturn parsed;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// configs are immutable, if the first lookup returned no results, all lookups should\n\t\t\tthis.configCache.set(name, { raw: undefined });\n\t\t}\n\t\treturn this.configCache.get(name);\n\t}\n}\n\n/**\n * A type containing both a telemetry logger and a configuration provider.\n *\n * @internal\n */\nexport interface MonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt> {\n\tconfig: IConfigProvider;\n\t// Since this is an internal context, assume that any external logger type\n\t// (`ITelemetryLoggerExt`) is just the internal `TelemetryLoggerExt` type.\n\t// `extractTelemetryLoggerExt` can be used to extract the internal type, but\n\t// we'll just \"cast\" it here.\n\tlogger: L extends ITelemetryLoggerExt ? TelemetryLoggerExt : L;\n}\n\n/**\n * Determines whether or not the provided object is a {@link MonitoringContext}.\n * @remarks Can be used for type-narrowing.\n *\n * @internal\n */\nexport function loggerIsMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(\n\tobj: L,\n): obj is L & MonitoringContext<L> {\n\tconst maybeConfig = obj as Partial<MonitoringContext<L>> | undefined;\n\treturn isConfigProviderBase(maybeConfig?.config) && maybeConfig?.logger !== undefined;\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger, if it isn't already one.\n *\n * @internal\n */\nexport function loggerToMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(\n\tlogger: L,\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\treturn logger;\n\t}\n\treturn mixinMonitoringContext<L>(logger, sessionStorageConfigProvider.value);\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger.\n *\n * @remarks\n * Assumes that the provided logger is not itself already a {@link MonitoringContext}, and will throw an error if it is.\n * If you are unsure, use {@link loggerToMonitoringContext} instead.\n *\n * @throws If the provided logger is already a {@link MonitoringContext}.\n *\n * @internal\n */\nexport function mixinMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(\n\tlogger: L,\n\t...configs: (IConfigProviderBase | undefined)[]\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\tthrow new Error(\"Logger is already a monitoring context\");\n\t}\n\t/**\n\t * this is the tricky bit we use for now to smuggle monitoring context around.\n\t * To the logger we mixin both config and itself, so mc.logger === logger as it is self-referential.\n\t * We then expose it as a Monitoring context, so via types we hide the outer logger methods.\n\t * To layers that expect just a logger we can pass mc.logger, but this is still a MonitoringContext\n\t * so if a deeper layer then converts that logger to a monitoring context it can find the smuggled properties\n\t * of the MonitoringContext and get the config provider.\n\t */\n\tconst mc: L & Partial<MonitoringContext<L>> = logger;\n\tmc.config = new CachedConfigProvider(logger, ...configs);\n\t// Cast is similar to `extractTelemetryLoggerExt` but preserves other\n\t// logger types rather than just returning `TelemetryLoggerExt`.\n\tmc.logger = logger as L extends ITelemetryLoggerExt ? TelemetryLoggerExt : L;\n\treturn mc as MonitoringContext<L>;\n}\n\nfunction isConfigProviderBase(obj: unknown): obj is IConfigProviderBase {\n\tconst maybeConfig = obj as Partial<IConfigProviderBase> | undefined;\n\treturn typeof maybeConfig?.getRawConfig === \"function\";\n}\n\n/**\n * Creates a child logger with a {@link MonitoringContext}.\n *\n * @see {@link loggerToMonitoringContext}\n * @internal\n */\nexport function createChildMonitoringContext(\n\tprops: Parameters<typeof createChildLogger>[0],\n): MonitoringContext {\n\treturn loggerToMonitoringContext(createChildLogger(props));\n}\n\n/**\n * @internal\n * */\nexport type OptionConfigReaders<T extends object> = {\n\t[K in keyof T]?: K extends string\n\t\t? (config: IConfigProvider, name: `Fluid.${string}.${K}`) => T[K] | undefined\n\t\t: undefined;\n};\n\n/**\n * Creates a proxy object that allows for reading configuration values from a IConfigProviderBase,\n * and default to the provided options if the configuration value is not present.\n *\n * @param config - the configuration provider to read values from.\n * @param namespace - the namespace to use when reading configuration values.\n * @param configReaders - a mapping of option keys to configuration value readers.\n * @param defaultOptions - the default options to use if the configuration value is not present.\n *\n * @internal\n * */\nexport function createConfigBasedOptionsProxy<T extends object>(\n\tconfig: IConfigProviderBase,\n\tnamespace: `Fluid.${string}`,\n\tconfigReaders: OptionConfigReaders<T>,\n\tdefaultOptions?: Partial<T>,\n): Readonly<Partial<T>> {\n\tconst realConfig =\n\t\tconfig instanceof CachedConfigProvider\n\t\t\t? config\n\t\t\t: new CachedConfigProvider(undefined, config);\n\n\tconst keys = new Set<string>([\n\t\t...Object.keys(defaultOptions ?? {}),\n\t\t...Object.keys(configReaders),\n\t]);\n\n\treturn new Proxy<Partial<T>>(Object.freeze({}), {\n\t\tget: (_, prop: string & keyof T): unknown => {\n\t\t\tconst reader = configReaders[prop];\n\t\t\tconst value = reader?.(realConfig, `${namespace}.${prop}`);\n\t\t\tif (value !== undefined) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\treturn defaultOptions?.[prop];\n\t\t},\n\t\thas: (_, prop: string): boolean => keys.has(prop),\n\t\t// we don't want the keys of this object to be enumerable\n\t\t// as accessing them will trigger a config read, which\n\t\t// should only happen when the value is accessed via\n\t\t// a previously known key.\n\t\townKeys: (): (string | symbol)[] => {\n\t\t\tthrow new TypeError(\"OptionsProxy keys are not enumerable\");\n\t\t},\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAgBlE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,IAAI,CAAsB,GAAG,EAAE,CAC9E,sBAAsB,CAAC,kBAAkB,EAAE,CAAC,CAC5C,CAAC;AAEF,MAAM,kBAAkB,GAAwB;IAC/C,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS;CAC7B,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,OAA4B,EAAuB,EAAE;IAC3F,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAC/C,OAAO,IAAI,oBAAoB,CAAC,SAAS,EAAE;YAC1C,YAAY,EAAE,CAAC,IAAY,EAA2B,EAAE;gBACvD,IAAI,CAAC;oBACJ,OAAO,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,EAAE,GAAG,CAAC;gBACpE,CAAC;gBAAC,MAAM,CAAC;oBACR,OAAO,SAAS,CAAC;gBAClB,CAAC;YACF,CAAC;SACD,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,kBAAkB,C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AAG,MAAM,CAAC,IAAI,CAAC,cAAc,IAAI,EAAE,CAAC;QACpC,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;KAC7B,CAAC,CAAC;IAEH,OAAO,IAAI,KAAK,CAAa,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;QAC/C,GAAG,EAAE,CAAC,CAAC,EAAE,IAAsB,EAAW,EAAE;YAC3C,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;YACnC,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,UAAU,EAAE,GAAG,SAAS,IAAI,IAAI,EAAE,CAAC,CAAC;YAC3D,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACzB,OAAO,KAAK,CAAC;YACd,CAAC;YACD,OAAO,cAAc,EAAE,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;QACD,GAAG,EAAE,CAAC,CAAC,EAAE,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;QACjD,yDAAyD;QACzD,sDAAsD;QACtD,oDAAoD;QACpD,0BAA0B;QAC1B,OAAO,EAAE,GAAwB,EAAE;YAClC,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAC;QAC7D,CAAC;KACD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tConfigTypes,\n\tIConfigProviderBase,\n\tITelemetryBaseLogger,\n} from \"@fluidframework/core-interfaces\";\nimport { LogLevel } from \"@fluidframework/core-interfaces\";\nimport { Lazy } from \"@fluidframework/core-utils/internal\";\n\nimport { createChildLogger, tagCodeArtifacts } from \"./logger.js\";\nimport type { ITelemetryLoggerExt, TelemetryLoggerExt } from \"./telemetryTypes.js\";\n\n/**\n * Explicitly typed interface for reading configurations.\n *\n * @internal\n */\nexport interface IConfigProvider extends IConfigProviderBase {\n\tgetBoolean(name: string): boolean | undefined;\n\tgetNumber(name: string): number | undefined;\n\tgetString(name: string): string | undefined;\n\tgetBooleanArray(name: string): boolean[] | undefined;\n\tgetNumberArray(name: string): number[] | undefined;\n\tgetStringArray(name: string): string[] | undefined;\n}\n/**\n * Creates a base configuration provider based on `sessionStorage`\n *\n * @returns A lazy initialized base configuration provider with `sessionStorage` as the underlying config store\n *\n * @internal\n */\nexport const sessionStorageConfigProvider = new Lazy<IConfigProviderBase>(() =>\n\tinMemoryConfigProvider(safeSessionStorage()),\n);\n\nconst NullConfigProvider: IConfigProviderBase = {\n\tgetRawConfig: () => undefined,\n};\n\n/**\n * Creates a base configuration provider based on the supplied `Storage` instance\n *\n * @param storage - instance of `Storage` to be used as storage media for the config\n * @returns A base configuration provider with\n * the supplied `Storage` instance as the underlying config store\n */\nexport const inMemoryConfigProvider = (storage: Storage | undefined): IConfigProviderBase => {\n\tif (storage !== undefined && storage !== null) {\n\t\treturn new CachedConfigProvider(undefined, {\n\t\t\tgetRawConfig: (name: string): ConfigTypes | undefined => {\n\t\t\t\ttry {\n\t\t\t\t\treturn stronglyTypedParse(storage.getItem(name) ?? undefined)?.raw;\n\t\t\t\t} catch {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n\treturn NullConfigProvider;\n};\n\ninterface ConfigTypeStringToType {\n\tnumber: number;\n\tstring: string;\n\tboolean: boolean;\n\t[\"number[]\"]: number[];\n\t[\"string[]\"]: string[];\n\t[\"boolean[]\"]: boolean[];\n}\n\ntype PrimitiveTypeStrings = \"number\" | \"string\" | \"boolean\";\n\nfunction isPrimitiveType(type: string): type is PrimitiveTypeStrings {\n\tswitch (type) {\n\t\tcase \"boolean\":\n\t\tcase \"number\":\n\t\tcase \"string\": {\n\t\t\treturn true;\n\t\t}\n\t\tdefault: {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n\ninterface StronglyTypedValue extends Partial<ConfigTypeStringToType> {\n\traw: ConfigTypes;\n}\n/**\n * Takes any supported config type, and returns the value with a strong type. If the type of\n * the config is not a supported type undefined will be returned.\n * The user of this function should cache the result to avoid duplicated work.\n *\n * Strings will be attempted to be parsed and coerced into a strong config type.\n * if it is not possible to parsed and coerce a string to a strong config type the original string\n * will be return with a string type for the consumer to handle further if necessary.\n */\nfunction stronglyTypedParse(input: ConfigTypes): StronglyTypedValue | undefined {\n\tlet output: ConfigTypes = input;\n\tlet defaultReturn: Pick<StronglyTypedValue, \"raw\" | \"string\"> | undefined;\n\t// we do special handling for strings to try and coerce\n\t// them into a config type if we can. This makes it easy\n\t// for config sources like sessionStorage which only\n\t// holds strings\n\tif (typeof input === \"string\") {\n\t\ttry {\n\t\t\toutput = JSON.parse(input) as ConfigTypes;\n\t\t\t// we succeeded in parsing, but we don't support parsing\n\t\t\t// for any object as we can't do it type safely\n\t\t\t// so in this case, the default return will be string\n\t\t\t// rather than undefined, and the consumer\n\t\t\t// can parse, as we don't want to provide\n\t\t\t// a false sense of security by just\n\t\t\t// casting.\n\t\t\tdefaultReturn = { raw: input, string: input };\n\t\t} catch {\n\t\t\t// No-op\n\t\t}\n\t}\n\n\tif (output === undefined) {\n\t\treturn defaultReturn;\n\t}\n\n\tconst outputType = typeof output;\n\tif (isPrimitiveType(outputType)) {\n\t\treturn { ...defaultReturn, raw: input, [outputType]: output };\n\t}\n\n\tif (Array.isArray(output)) {\n\t\tconst firstType = typeof output[0];\n\t\t// ensure the first elements is a primitive type\n\t\tif (!isPrimitiveType(firstType)) {\n\t\t\treturn defaultReturn;\n\t\t}\n\t\t// ensue all the elements types are homogeneous\n\t\t// aka they all have the same type as the first\n\t\tfor (const v of output) {\n\t\t\tif (typeof v !== firstType) {\n\t\t\t\treturn defaultReturn;\n\t\t\t}\n\t\t}\n\t\treturn { ...defaultReturn, raw: input, [`${firstType}[]`]: output };\n\t}\n\n\treturn defaultReturn;\n}\n\n/**\n * `sessionStorage` is undefined in some environments such as Node and web pages with session storage disabled.\n */\nconst safeSessionStorage = (): Storage | undefined => {\n\t// For some configurations accessing \"globalThis.sessionStorage\" throws\n\t// \"'sessionStorage' property from 'Window': Access is denied for this document\" rather than returning undefined.\n\t// Therefor check for it before accessing.\n\ttry {\n\t\t// Using globalThis and checking for undefined is preferred over just accessing global sessionStorage\n\t\t// since it avoids an exception when running in node.\n\t\t// In some cases this has returned null when disabled in the browser, so ensure its undefined in that case:\n\t\treturn globalThis.sessionStorage ?? undefined;\n\t} catch {\n\t\t// For browsers which error on the above when session storage is disabled:\n\t\treturn undefined;\n\t}\n};\n\n/**\n * Creates a wrapper on top of an existing config provider which allows for\n * specifying feature gates if not present in the original provider.\n *\n * @param original - the original config provider\n * @param defaults - default feature gate configs to be used if not specified by the original provider\n * @returns A config provider that looks for any requested feature gates in the original provider and falls\n * back to the values specified in the `defaults` feature gates if they're not present in the original.\n *\n * @internal\n */\nexport const wrapConfigProviderWithDefaults = (\n\toriginal: IConfigProviderBase | undefined,\n\tdefaults: Record<string, ConfigTypes>,\n): IConfigProviderBase => ({\n\tgetRawConfig: (name: string): ConfigTypes => original?.getRawConfig(name) ?? defaults[name],\n});\n\n/**\n * Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances\n */\nexport class CachedConfigProvider implements IConfigProvider {\n\tprivate readonly configCache = new Map<string, StronglyTypedValue>();\n\tprivate readonly orderedBaseProviders: (IConfigProviderBase | undefined)[];\n\n\tpublic constructor(\n\t\tprivate readonly logger?: ITelemetryBaseLogger,\n\t\t...orderedBaseProviders: (IConfigProviderBase | undefined)[]\n\t) {\n\t\tthis.orderedBaseProviders = [];\n\t\tconst knownProviders = new Set<IConfigProviderBase>();\n\t\tconst candidateProviders = [...orderedBaseProviders];\n\t\twhile (candidateProviders.length > 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst baseProvider = candidateProviders.shift()!;\n\t\t\tif (\n\t\t\t\tbaseProvider !== undefined &&\n\t\t\t\tisConfigProviderBase(baseProvider) &&\n\t\t\t\t!knownProviders.has(baseProvider)\n\t\t\t) {\n\t\t\t\tknownProviders.add(baseProvider);\n\t\t\t\tif (baseProvider instanceof CachedConfigProvider) {\n\t\t\t\t\tcandidateProviders.push(...baseProvider.orderedBaseProviders);\n\t\t\t\t} else {\n\t\t\t\t\tthis.orderedBaseProviders.push(baseProvider);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tpublic getBoolean(name: string): boolean | undefined {\n\t\treturn this.getCacheEntry(name)?.boolean;\n\t}\n\tpublic getNumber(name: string): number | undefined {\n\t\treturn this.getCacheEntry(name)?.number;\n\t}\n\tpublic getString(name: string): string | undefined {\n\t\treturn this.getCacheEntry(name)?.string;\n\t}\n\tpublic getBooleanArray(name: string): boolean[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"boolean[]\"];\n\t}\n\tpublic getNumberArray(name: string): number[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"number[]\"];\n\t}\n\tpublic getStringArray(name: string): string[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"string[]\"];\n\t}\n\n\tpublic getRawConfig(name: string): ConfigTypes {\n\t\treturn this.getCacheEntry(name)?.raw;\n\t}\n\n\tprivate getCacheEntry(name: string): StronglyTypedValue | undefined {\n\t\tif (!this.configCache.has(name)) {\n\t\t\tfor (const provider of this.orderedBaseProviders) {\n\t\t\t\tconst parsed = stronglyTypedParse(provider?.getRawConfig(name));\n\t\t\t\tif (parsed !== undefined) {\n\t\t\t\t\tthis.configCache.set(name, parsed);\n\t\t\t\t\tthis.logger?.send(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcategory: \"generic\",\n\t\t\t\t\t\t\teventName: \"ConfigRead\",\n\t\t\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\t\t\tconfigName: name,\n\t\t\t\t\t\t\t\tconfigValue: JSON.stringify(parsed),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tLogLevel.info,\n\t\t\t\t\t);\n\t\t\t\t\treturn parsed;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// configs are immutable, if the first lookup returned no results, all lookups should\n\t\t\tthis.configCache.set(name, { raw: undefined });\n\t\t}\n\t\treturn this.configCache.get(name);\n\t}\n}\n\n/**\n * A type containing both a telemetry logger and a configuration provider.\n *\n * @internal\n */\nexport interface MonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt> {\n\tconfig: IConfigProvider;\n\t// Since this is an internal context, assume that any external logger type\n\t// (`ITelemetryLoggerExt`) is just the internal `TelemetryLoggerExt` type.\n\t// `extractTelemetryLoggerExt` can be used to extract the internal type, but\n\t// we'll just \"cast\" it here.\n\tlogger: L extends ITelemetryLoggerExt ? TelemetryLoggerExt : L;\n}\n\n/**\n * Determines whether or not the provided object is a {@link MonitoringContext}.\n * @remarks Can be used for type-narrowing.\n *\n * @internal\n */\nexport function loggerIsMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(\n\tobj: L,\n): obj is L & MonitoringContext<L> {\n\tconst maybeConfig = obj as Partial<MonitoringContext<L>> | undefined;\n\treturn isConfigProviderBase(maybeConfig?.config) && maybeConfig?.logger !== undefined;\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger, if it isn't already one.\n *\n * @internal\n */\nexport function loggerToMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(\n\tlogger: L,\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\treturn logger;\n\t}\n\treturn mixinMonitoringContext<L>(logger, sessionStorageConfigProvider.value);\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger.\n *\n * @remarks\n * Assumes that the provided logger is not itself already a {@link MonitoringContext}, and will throw an error if it is.\n * If you are unsure, use {@link loggerToMonitoringContext} instead.\n *\n * @throws If the provided logger is already a {@link MonitoringContext}.\n *\n * @internal\n */\nexport function mixinMonitoringContext<L extends ITelemetryBaseLogger = TelemetryLoggerExt>(\n\tlogger: L,\n\t...configs: (IConfigProviderBase | undefined)[]\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\tthrow new Error(\"Logger is already a monitoring context\");\n\t}\n\t/**\n\t * this is the tricky bit we use for now to smuggle monitoring context around.\n\t * To the logger we mixin both config and itself, so mc.logger === logger as it is self-referential.\n\t * We then expose it as a Monitoring context, so via types we hide the outer logger methods.\n\t * To layers that expect just a logger we can pass mc.logger, but this is still a MonitoringContext\n\t * so if a deeper layer then converts that logger to a monitoring context it can find the smuggled properties\n\t * of the MonitoringContext and get the config provider.\n\t */\n\tconst mc: L & Partial<MonitoringContext<L>> = logger;\n\tmc.config = new CachedConfigProvider(logger, ...configs);\n\t// Cast is similar to `extractTelemetryLoggerExt` but preserves other\n\t// logger types rather than just returning `TelemetryLoggerExt`.\n\tmc.logger = logger as L extends ITelemetryLoggerExt ? TelemetryLoggerExt : L;\n\treturn mc as MonitoringContext<L>;\n}\n\nfunction isConfigProviderBase(obj: unknown): obj is IConfigProviderBase {\n\tconst maybeConfig = obj as Partial<IConfigProviderBase> | undefined;\n\treturn typeof maybeConfig?.getRawConfig === \"function\";\n}\n\n/**\n * Creates a child logger with a {@link MonitoringContext}.\n *\n * @see {@link loggerToMonitoringContext}\n * @internal\n */\nexport function createChildMonitoringContext(\n\tprops: Parameters<typeof createChildLogger>[0],\n): MonitoringContext {\n\treturn loggerToMonitoringContext(createChildLogger(props));\n}\n\n/**\n * @internal\n * */\nexport type OptionConfigReaders<T extends object> = {\n\t[K in keyof T]?: K extends string\n\t\t? (config: IConfigProvider, name: `Fluid.${string}.${K}`) => T[K] | undefined\n\t\t: undefined;\n};\n\n/**\n * Creates a proxy object that allows for reading configuration values from a IConfigProviderBase,\n * and default to the provided options if the configuration value is not present.\n *\n * @param config - the configuration provider to read values from.\n * @param namespace - the namespace to use when reading configuration values.\n * @param configReaders - a mapping of option keys to configuration value readers.\n * @param defaultOptions - the default options to use if the configuration value is not present.\n *\n * @internal\n * */\nexport function createConfigBasedOptionsProxy<T extends object>(\n\tconfig: IConfigProviderBase,\n\tnamespace: `Fluid.${string}`,\n\tconfigReaders: OptionConfigReaders<T>,\n\tdefaultOptions?: Partial<T>,\n): Readonly<Partial<T>> {\n\tconst realConfig =\n\t\tconfig instanceof CachedConfigProvider\n\t\t\t? config\n\t\t\t: new CachedConfigProvider(undefined, config);\n\n\tconst keys = new Set<string>([\n\t\t...Object.keys(defaultOptions ?? {}),\n\t\t...Object.keys(configReaders),\n\t]);\n\n\treturn new Proxy<Partial<T>>(Object.freeze({}), {\n\t\tget: (_, prop: string & keyof T): unknown => {\n\t\t\tconst reader = configReaders[prop];\n\t\t\tconst value = reader?.(realConfig, `${namespace}.${prop}`);\n\t\t\tif (value !== undefined) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\treturn defaultOptions?.[prop];\n\t\t},\n\t\thas: (_, prop: string): boolean => keys.has(prop),\n\t\t// we don't want the keys of this object to be enumerable\n\t\t// as accessing them will trigger a config read, which\n\t\t// should only happen when the value is accessed via\n\t\t// a previously known key.\n\t\townKeys: (): (string | symbol)[] => {\n\t\t\tthrow new TypeError(\"OptionsProxy keys are not enumerable\");\n\t\t},\n\t});\n}\n"]}
|
package/lib/logger.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { type ITelemetryBaseEvent, type ITelemetryBaseLogger, LogLevel, type Tagged, type TelemetryBaseEventPropertyType } from "@fluidframework/core-interfaces";
|
|
6
6
|
import type { ITelemetryLoggerExt, ITelemetryPropertiesExt, TelemetryLoggerExt, TelemetryEventPropertyTypeExt } from "./telemetryTypes.js";
|
|
7
|
-
import type { ITelemetryErrorEventExt, ITelemetryGenericEventExt, ITelemetryPerformanceEventExt
|
|
7
|
+
import type { ITelemetryErrorEventExt, ITelemetryGenericEventExt, ITelemetryPerformanceEventExt } from "./telemetryTypesUndeprecated.js";
|
|
8
8
|
/**
|
|
9
9
|
* Type erase a {@link TelemetryLoggerExt} to an {@link ITelemetryLoggerExt}.
|
|
10
10
|
* @internal
|
|
@@ -119,20 +119,18 @@ export declare abstract class TelemetryLogger implements TelemetryLoggerExt {
|
|
|
119
119
|
*
|
|
120
120
|
* @param event - the event to send
|
|
121
121
|
* @param error - optional error object to log
|
|
122
|
-
* @param logLevel - optional level of the log.
|
|
123
|
-
*
|
|
122
|
+
* @param logLevel - optional level of the log. If the event's category is `error`,
|
|
123
|
+
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
|
|
124
124
|
*/
|
|
125
|
-
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.
|
|
125
|
+
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
|
|
126
126
|
/**
|
|
127
127
|
* Send a telemetry event with the logger
|
|
128
128
|
*
|
|
129
129
|
* @param event - the event to send
|
|
130
130
|
* @param error - optional error object to log
|
|
131
|
-
* @param logLevel -
|
|
131
|
+
* @param logLevel - level of the log.
|
|
132
132
|
*/
|
|
133
|
-
|
|
134
|
-
category: TelemetryEventCategory;
|
|
135
|
-
}, error?: unknown, logLevel?: LogLevel): void;
|
|
133
|
+
private sendTelemetryEventCore;
|
|
136
134
|
/**
|
|
137
135
|
* Send an error telemetry event with the logger
|
|
138
136
|
*
|
|
@@ -145,10 +143,10 @@ export declare abstract class TelemetryLogger implements TelemetryLoggerExt {
|
|
|
145
143
|
*
|
|
146
144
|
* @param event - Event to send
|
|
147
145
|
* @param error - optional error object to log
|
|
148
|
-
* @param logLevel - optional level of the log.
|
|
149
|
-
*
|
|
146
|
+
* @param logLevel - optional level of the log. If the event's category is `error`,
|
|
147
|
+
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
|
|
150
148
|
*/
|
|
151
|
-
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.
|
|
149
|
+
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
|
|
152
150
|
protected prepareEvent(event: ITelemetryBaseEvent): ITelemetryBaseEvent;
|
|
153
151
|
private extendProperties;
|
|
154
152
|
}
|
|
@@ -272,7 +270,7 @@ export declare class MultiSinkLogger extends TelemetryLogger {
|
|
|
272
270
|
*
|
|
273
271
|
* @param event - the event to send to all the registered logger
|
|
274
272
|
*/
|
|
275
|
-
send(event: ITelemetryBaseEvent): void;
|
|
273
|
+
send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void;
|
|
276
274
|
}
|
|
277
275
|
/**
|
|
278
276
|
* Describes what events {@link PerformanceEvent} should log.
|
|
@@ -299,6 +297,7 @@ export declare class PerformanceEvent {
|
|
|
299
297
|
private readonly logger;
|
|
300
298
|
private readonly markers;
|
|
301
299
|
private readonly emitLogs;
|
|
300
|
+
private readonly logLevel;
|
|
302
301
|
/**
|
|
303
302
|
* Creates an instance of {@link PerformanceEvent} and starts measurements
|
|
304
303
|
* @param logger - the logger to be used for publishing events
|
|
@@ -307,9 +306,11 @@ export declare class PerformanceEvent {
|
|
|
307
306
|
* @param recordHeapSize - whether or not to also record memory performance
|
|
308
307
|
* @param emitLogs - should this instance emit logs. If set to false, logs will not be emitted to the logger,
|
|
309
308
|
* but measurements will still be performed and any specified markers will be generated.
|
|
309
|
+
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
|
|
310
|
+
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
|
|
310
311
|
* @returns An instance of {@link PerformanceEvent}
|
|
311
312
|
*/
|
|
312
|
-
static start(logger: TelemetryLoggerExt | ITelemetryLoggerExt, event: ITelemetryGenericEventExt, markers?: IPerformanceEventMarkers, emitLogs?: boolean): PerformanceEvent;
|
|
313
|
+
static start(logger: TelemetryLoggerExt | ITelemetryLoggerExt, event: ITelemetryGenericEventExt, markers?: IPerformanceEventMarkers, emitLogs?: boolean, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): PerformanceEvent;
|
|
313
314
|
/**
|
|
314
315
|
* Measure a synchronous task
|
|
315
316
|
* @param logger - the logger to be used for publishing events
|
|
@@ -318,6 +319,8 @@ export declare class PerformanceEvent {
|
|
|
318
319
|
* @param markers - See {@link IPerformanceEventMarkers}
|
|
319
320
|
* @param sampleThreshold - events with the same name and category will be sent to the logger
|
|
320
321
|
* only when we hit this many executions of the task. If unspecified, all events will be sent.
|
|
322
|
+
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
|
|
323
|
+
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
|
|
321
324
|
* @returns The results of the executed task
|
|
322
325
|
*
|
|
323
326
|
* @remarks Note that if the "same" event (category + eventName) would be emitted by different
|
|
@@ -325,7 +328,7 @@ export declare class PerformanceEvent {
|
|
|
325
328
|
* so executing either of the tasks will increase the internal counter and they
|
|
326
329
|
* effectively "share" the sampling rate for the event.
|
|
327
330
|
*/
|
|
328
|
-
static timedExec<T>(logger: TelemetryLoggerExt, event: ITelemetryGenericEventExt, callback: (event: PerformanceEvent) => T, markers?: IPerformanceEventMarkers, sampleThreshold?: number): T;
|
|
331
|
+
static timedExec<T>(logger: TelemetryLoggerExt, event: ITelemetryGenericEventExt, callback: (event: PerformanceEvent) => T, markers?: IPerformanceEventMarkers, sampleThreshold?: number, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): T;
|
|
329
332
|
/**
|
|
330
333
|
* Measure an asynchronous task
|
|
331
334
|
* @param logger - the logger to be used for publishing events
|
|
@@ -335,6 +338,8 @@ export declare class PerformanceEvent {
|
|
|
335
338
|
* @param recordHeapSize - whether or not to also record memory performance
|
|
336
339
|
* @param sampleThreshold - events with the same name and category will be sent to the logger
|
|
337
340
|
* only when we hit this many executions of the task. If unspecified, all events will be sent.
|
|
341
|
+
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
|
|
342
|
+
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
|
|
338
343
|
* @returns The results of the executed task
|
|
339
344
|
*
|
|
340
345
|
* @remarks Note that if the "same" event (category + eventName) would be emitted by different
|
|
@@ -342,12 +347,12 @@ export declare class PerformanceEvent {
|
|
|
342
347
|
* so executing either of the tasks will increase the internal counter and they
|
|
343
348
|
* effectively "share" the sampling rate for the event.
|
|
344
349
|
*/
|
|
345
|
-
static timedExecAsync<T>(logger: TelemetryLoggerExt | ITelemetryLoggerExt, event: ITelemetryGenericEventExt, callback: (event: PerformanceEvent) => Promise<T>, markers?: IPerformanceEventMarkers, sampleThreshold?: number): Promise<T>;
|
|
350
|
+
static timedExecAsync<T>(logger: TelemetryLoggerExt | ITelemetryLoggerExt, event: ITelemetryGenericEventExt, callback: (event: PerformanceEvent) => Promise<T>, markers?: IPerformanceEventMarkers, sampleThreshold?: number, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): Promise<T>;
|
|
346
351
|
get duration(): number;
|
|
347
352
|
private event?;
|
|
348
353
|
private readonly startTime;
|
|
349
354
|
private startMark?;
|
|
350
|
-
|
|
355
|
+
private constructor();
|
|
351
356
|
reportProgress(props?: ITelemetryPropertiesExt, eventNameSuffix?: string): void;
|
|
352
357
|
private autoEnd;
|
|
353
358
|
end(props?: ITelemetryPropertiesExt): void;
|
package/lib/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,QAAQ,EACR,KAAK,MAAM,EACX,KAAK,8BAA8B,EACnC,MAAM,iCAAiC,CAAC;AAazC,OAAO,KAAK,EAEX,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,6BAA6B,EAC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AkB;IASnB,MAAM,CAAC,KAAK,CAAC,EAAE,uBAAuB,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;IASrE;;OAEG;IACI,WAAW,CACjB,eAAe,EAAE,MAAM,EACvB,KAAK,CAAC,EAAE,uBAAuB,EAC/B,KAAK,CAAC,EAAE,OAAO,GACb,IAAI;IAoBP,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAA6B;IAC9D,OAAO,CAAC,MAAM,CAAC,YAAY;CAS3B;AAmBD;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACxC,CAAC,EAAE,6BAA6B,GAAG,MAAM,CAAC,6BAA6B,CAAC,GACtE,8BAA8B,GAAG,MAAM,CAAC,8BAA8B,CAAC,CAOzE;AA0BD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,OAAO,gGAIsB,8BAA8B,SAGlE,CAAC,UACE,CAAC,2CAGc,8BAA8B;;SAG3C,CAAC;;;SAID,CAAC;oDAoB0B,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,gBAAgB,oEAGa,8BAA8B,YAG/D,CAAC,2CAGc,8BAA8B;;SAG3C,iBAAiB,YAAY;;;SAI7B,iBAAiB,YAAY;oDAG6C,CAAC"}
|
package/lib/logger.js
CHANGED
|
@@ -127,18 +127,18 @@ export class TelemetryLogger {
|
|
|
127
127
|
*
|
|
128
128
|
* @param event - the event to send
|
|
129
129
|
* @param error - optional error object to log
|
|
130
|
-
* @param logLevel - optional level of the log.
|
|
131
|
-
*
|
|
130
|
+
* @param logLevel - optional level of the log. If the event's category is `error`,
|
|
131
|
+
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
|
|
132
132
|
*/
|
|
133
|
-
sendTelemetryEvent(event, error, logLevel
|
|
134
|
-
this.sendTelemetryEventCore({ ...event, category: event.category ?? "generic" }, error, event.category === "error" ? LogLevel.
|
|
133
|
+
sendTelemetryEvent(event, error, logLevel) {
|
|
134
|
+
this.sendTelemetryEventCore({ ...event, category: event.category ?? "generic" }, error, event.category === "error" ? LogLevel.essential : (logLevel ?? LogLevel.essential));
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
137
|
* Send a telemetry event with the logger
|
|
138
138
|
*
|
|
139
139
|
* @param event - the event to send
|
|
140
140
|
* @param error - optional error object to log
|
|
141
|
-
* @param logLevel -
|
|
141
|
+
* @param logLevel - level of the log.
|
|
142
142
|
*/
|
|
143
143
|
sendTelemetryEventCore(event, error, logLevel) {
|
|
144
144
|
const newEvent = convertToBaseEvent(event);
|
|
@@ -164,22 +164,22 @@ export class TelemetryLogger {
|
|
|
164
164
|
error: event.eventName,
|
|
165
165
|
...event,
|
|
166
166
|
category: "error",
|
|
167
|
-
}, error, LogLevel.
|
|
167
|
+
}, error, LogLevel.essential);
|
|
168
168
|
}
|
|
169
169
|
/**
|
|
170
170
|
* Send a performance telemetry event with the logger
|
|
171
171
|
*
|
|
172
172
|
* @param event - Event to send
|
|
173
173
|
* @param error - optional error object to log
|
|
174
|
-
* @param logLevel - optional level of the log.
|
|
175
|
-
*
|
|
174
|
+
* @param logLevel - optional level of the log. If the event's category is `error`,
|
|
175
|
+
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
|
|
176
176
|
*/
|
|
177
|
-
sendPerformanceEvent(event, error, logLevel
|
|
177
|
+
sendPerformanceEvent(event, error, logLevel) {
|
|
178
178
|
const perfEvent = {
|
|
179
179
|
...event,
|
|
180
180
|
category: event.category ?? "performance",
|
|
181
181
|
};
|
|
182
|
-
this.sendTelemetryEventCore(perfEvent, error, perfEvent.category === "error" ? LogLevel.
|
|
182
|
+
this.sendTelemetryEventCore(perfEvent, error, perfEvent.category === "error" ? LogLevel.essential : (logLevel ?? LogLevel.essential));
|
|
183
183
|
}
|
|
184
184
|
prepareEvent(event) {
|
|
185
185
|
const includeErrorProps = event.category === "error" || event.error !== undefined;
|
|
@@ -358,8 +358,8 @@ export class ChildLogger extends TelemetryLogger {
|
|
|
358
358
|
return this.baseLogger.minLogLevel;
|
|
359
359
|
}
|
|
360
360
|
shouldFilterOutEvent(event, logLevel) {
|
|
361
|
-
const eventLogLevel = logLevel ?? LogLevel.
|
|
362
|
-
const configLogLevel = this.baseLogger.minLogLevel ?? LogLevel.
|
|
361
|
+
const eventLogLevel = logLevel ?? LogLevel.essential;
|
|
362
|
+
const configLogLevel = this.baseLogger.minLogLevel ?? LogLevel.info;
|
|
363
363
|
// Filter out in case event log level is below what is wanted in config.
|
|
364
364
|
return eventLogLevel < configLogLevel;
|
|
365
365
|
}
|
|
@@ -372,7 +372,7 @@ export class ChildLogger extends TelemetryLogger {
|
|
|
372
372
|
if (this.shouldFilterOutEvent(event, logLevel)) {
|
|
373
373
|
return;
|
|
374
374
|
}
|
|
375
|
-
this.baseLogger.send(this.prepareEvent(event), logLevel);
|
|
375
|
+
this.baseLogger.send(this.prepareEvent(event), logLevel ?? LogLevel.essential);
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
/**
|
|
@@ -413,7 +413,7 @@ export class MultiSinkLogger extends TelemetryLogger {
|
|
|
413
413
|
}
|
|
414
414
|
super(namespace, realProperties);
|
|
415
415
|
this.loggers = loggers;
|
|
416
|
-
this._minLogLevelOfAllLoggers = LogLevel.
|
|
416
|
+
this._minLogLevelOfAllLoggers = LogLevel.info;
|
|
417
417
|
this.calculateMinLogLevel();
|
|
418
418
|
}
|
|
419
419
|
get minLogLevel() {
|
|
@@ -423,7 +423,7 @@ export class MultiSinkLogger extends TelemetryLogger {
|
|
|
423
423
|
if (this.loggers.length > 0) {
|
|
424
424
|
const logLevels = [];
|
|
425
425
|
for (const logger of this.loggers) {
|
|
426
|
-
logLevels.push(logger.minLogLevel ?? LogLevel.
|
|
426
|
+
logLevels.push(logger.minLogLevel ?? LogLevel.info);
|
|
427
427
|
}
|
|
428
428
|
this._minLogLevelOfAllLoggers = Math.min(...logLevels);
|
|
429
429
|
}
|
|
@@ -444,10 +444,10 @@ export class MultiSinkLogger extends TelemetryLogger {
|
|
|
444
444
|
*
|
|
445
445
|
* @param event - the event to send to all the registered logger
|
|
446
446
|
*/
|
|
447
|
-
send(event) {
|
|
447
|
+
send(event, logLevel) {
|
|
448
448
|
const newEvent = this.prepareEvent(event);
|
|
449
449
|
for (const logger of this.loggers) {
|
|
450
|
-
logger.send(newEvent);
|
|
450
|
+
logger.send(newEvent, logLevel ?? LogLevel.essential);
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
453
|
}
|
|
@@ -465,10 +465,12 @@ export class PerformanceEvent {
|
|
|
465
465
|
* @param recordHeapSize - whether or not to also record memory performance
|
|
466
466
|
* @param emitLogs - should this instance emit logs. If set to false, logs will not be emitted to the logger,
|
|
467
467
|
* but measurements will still be performed and any specified markers will be generated.
|
|
468
|
+
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
|
|
469
|
+
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
|
|
468
470
|
* @returns An instance of {@link PerformanceEvent}
|
|
469
471
|
*/
|
|
470
|
-
static start(logger, event, markers, emitLogs = true) {
|
|
471
|
-
return new PerformanceEvent(extractTelemetryLoggerExt(logger), event, markers, emitLogs);
|
|
472
|
+
static start(logger, event, markers, emitLogs = true, logLevel) {
|
|
473
|
+
return new PerformanceEvent(extractTelemetryLoggerExt(logger), event, markers, emitLogs, logLevel);
|
|
472
474
|
}
|
|
473
475
|
/**
|
|
474
476
|
* Measure a synchronous task
|
|
@@ -478,6 +480,8 @@ export class PerformanceEvent {
|
|
|
478
480
|
* @param markers - See {@link IPerformanceEventMarkers}
|
|
479
481
|
* @param sampleThreshold - events with the same name and category will be sent to the logger
|
|
480
482
|
* only when we hit this many executions of the task. If unspecified, all events will be sent.
|
|
483
|
+
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
|
|
484
|
+
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
|
|
481
485
|
* @returns The results of the executed task
|
|
482
486
|
*
|
|
483
487
|
* @remarks Note that if the "same" event (category + eventName) would be emitted by different
|
|
@@ -485,8 +489,8 @@ export class PerformanceEvent {
|
|
|
485
489
|
* so executing either of the tasks will increase the internal counter and they
|
|
486
490
|
* effectively "share" the sampling rate for the event.
|
|
487
491
|
*/
|
|
488
|
-
static timedExec(logger, event, callback, markers, sampleThreshold = 1) {
|
|
489
|
-
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold));
|
|
492
|
+
static timedExec(logger, event, callback, markers, sampleThreshold = 1, logLevel) {
|
|
493
|
+
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold), logLevel);
|
|
490
494
|
try {
|
|
491
495
|
const ret = callback(perfEvent);
|
|
492
496
|
perfEvent.autoEnd();
|
|
@@ -506,6 +510,8 @@ export class PerformanceEvent {
|
|
|
506
510
|
* @param recordHeapSize - whether or not to also record memory performance
|
|
507
511
|
* @param sampleThreshold - events with the same name and category will be sent to the logger
|
|
508
512
|
* only when we hit this many executions of the task. If unspecified, all events will be sent.
|
|
513
|
+
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
|
|
514
|
+
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
|
|
509
515
|
* @returns The results of the executed task
|
|
510
516
|
*
|
|
511
517
|
* @remarks Note that if the "same" event (category + eventName) would be emitted by different
|
|
@@ -513,8 +519,8 @@ export class PerformanceEvent {
|
|
|
513
519
|
* so executing either of the tasks will increase the internal counter and they
|
|
514
520
|
* effectively "share" the sampling rate for the event.
|
|
515
521
|
*/
|
|
516
|
-
static async timedExecAsync(logger, event, callback, markers, sampleThreshold = 1) {
|
|
517
|
-
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold));
|
|
522
|
+
static async timedExecAsync(logger, event, callback, markers, sampleThreshold = 1, logLevel) {
|
|
523
|
+
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold), logLevel);
|
|
518
524
|
try {
|
|
519
525
|
const ret = await callback(perfEvent);
|
|
520
526
|
perfEvent.autoEnd();
|
|
@@ -528,10 +534,11 @@ export class PerformanceEvent {
|
|
|
528
534
|
get duration() {
|
|
529
535
|
return performanceNow() - this.startTime;
|
|
530
536
|
}
|
|
531
|
-
constructor(logger, event, markers = { end: true, cancel: "generic" }, emitLogs = true) {
|
|
537
|
+
constructor(logger, event, markers = { end: true, cancel: "generic" }, emitLogs = true, logLevel) {
|
|
532
538
|
this.logger = logger;
|
|
533
539
|
this.markers = markers;
|
|
534
540
|
this.emitLogs = emitLogs;
|
|
541
|
+
this.logLevel = logLevel;
|
|
535
542
|
this.startTime = performanceNow();
|
|
536
543
|
this.event = { ...event };
|
|
537
544
|
if (this.markers.start) {
|
|
@@ -594,7 +601,7 @@ export class PerformanceEvent {
|
|
|
594
601
|
if (eventNameSuffix !== "start") {
|
|
595
602
|
event.duration = this.duration;
|
|
596
603
|
}
|
|
597
|
-
this.logger.sendPerformanceEvent(event, error);
|
|
604
|
+
this.logger.sendPerformanceEvent(event, error, this.logLevel);
|
|
598
605
|
}
|
|
599
606
|
static shouldReport(event, sampleThreshold) {
|
|
600
607
|
const eventKey = `.${event.category}.${event.eventName}`;
|