@fluidframework/telemetry-utils 2.93.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 +26 -0
- package/DEV.md +33 -0
- package/api-extractor/api-extractor-lint-api-bundle.json +5 -0
- package/api-extractor/api-extractor-lint-bundle.json +1 -1
- package/api-extractor.json +2 -1
- package/api-report/telemetry-utils.legacy.beta.api.md +10 -7
- package/dist/api.d.ts +26 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +40 -0
- package/dist/api.js.map +1 -0
- package/dist/config.d.ts +6 -6
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -1
- package/dist/config.js.map +1 -1
- package/dist/errorLogging.d.ts +2 -2
- package/dist/errorLogging.d.ts.map +1 -1
- package/dist/errorLogging.js.map +1 -1
- package/dist/events.d.ts +3 -3
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/{index.d.ts → internal.d.ts} +16 -4
- package/dist/internal.d.ts.map +1 -0
- package/dist/{index.js → internal.js} +22 -5
- package/dist/internal.js.map +1 -0
- package/dist/legacy.d.ts +2 -2
- package/dist/logger.d.ts +61 -21
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +74 -29
- package/dist/logger.js.map +1 -1
- package/dist/main.d.ts +8 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +13 -0
- package/dist/main.js.map +1 -0
- package/dist/mockLogger.d.ts +5 -4
- package/dist/mockLogger.d.ts.map +1 -1
- package/dist/mockLogger.js +2 -2
- package/dist/mockLogger.js.map +1 -1
- package/dist/public.d.ts +1 -1
- package/dist/sampledTelemetryHelper.d.ts +5 -2
- package/dist/sampledTelemetryHelper.d.ts.map +1 -1
- package/dist/sampledTelemetryHelper.js +6 -1
- package/dist/sampledTelemetryHelper.js.map +1 -1
- package/dist/telemetryEventBatcher.d.ts +2 -2
- package/dist/telemetryEventBatcher.d.ts.map +1 -1
- package/dist/telemetryEventBatcher.js.map +1 -1
- package/dist/telemetryTypes.d.ts +65 -6
- package/dist/telemetryTypes.d.ts.map +1 -1
- package/dist/telemetryTypes.js.map +1 -1
- package/dist/telemetryTypesUndeprecated.d.ts +36 -0
- package/dist/telemetryTypesUndeprecated.d.ts.map +1 -0
- package/dist/telemetryTypesUndeprecated.js +7 -0
- package/dist/telemetryTypesUndeprecated.js.map +1 -0
- package/dist/thresholdCounter.d.ts +2 -2
- package/dist/thresholdCounter.d.ts.map +1 -1
- package/dist/thresholdCounter.js.map +1 -1
- package/dist/utils.d.ts +4 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +9 -9
- package/dist/utils.js.map +1 -1
- package/internal.d.ts +2 -2
- package/legacy.d.ts +1 -1
- package/lib/api.d.ts +26 -0
- package/lib/api.d.ts.map +1 -0
- package/lib/api.js +22 -0
- package/lib/api.js.map +1 -0
- package/lib/config.d.ts +6 -6
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +4 -1
- package/lib/config.js.map +1 -1
- package/lib/errorLogging.d.ts +2 -2
- package/lib/errorLogging.d.ts.map +1 -1
- package/lib/errorLogging.js.map +1 -1
- package/lib/events.d.ts +3 -3
- package/lib/events.d.ts.map +1 -1
- package/lib/events.js.map +1 -1
- package/lib/{index.d.ts → internal.d.ts} +16 -4
- package/lib/internal.d.ts.map +1 -0
- package/lib/{index.js → internal.js} +5 -3
- package/lib/internal.js.map +1 -0
- package/lib/legacy.d.ts +2 -2
- package/lib/logger.d.ts +61 -21
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +71 -28
- package/lib/logger.js.map +1 -1
- package/lib/main.d.ts +8 -0
- package/lib/main.d.ts.map +1 -0
- package/lib/main.js +9 -0
- package/lib/main.js.map +1 -0
- package/lib/mockLogger.d.ts +5 -4
- package/lib/mockLogger.d.ts.map +1 -1
- package/lib/mockLogger.js +2 -2
- package/lib/mockLogger.js.map +1 -1
- package/lib/public.d.ts +1 -1
- package/lib/sampledTelemetryHelper.d.ts +5 -2
- package/lib/sampledTelemetryHelper.d.ts.map +1 -1
- package/lib/sampledTelemetryHelper.js +6 -1
- package/lib/sampledTelemetryHelper.js.map +1 -1
- package/lib/telemetryEventBatcher.d.ts +2 -2
- package/lib/telemetryEventBatcher.d.ts.map +1 -1
- package/lib/telemetryEventBatcher.js.map +1 -1
- package/lib/telemetryTypes.d.ts +65 -6
- package/lib/telemetryTypes.d.ts.map +1 -1
- package/lib/telemetryTypes.js.map +1 -1
- package/lib/telemetryTypesUndeprecated.d.ts +36 -0
- package/lib/telemetryTypesUndeprecated.d.ts.map +1 -0
- package/lib/telemetryTypesUndeprecated.js +6 -0
- package/lib/telemetryTypesUndeprecated.js.map +1 -0
- package/lib/thresholdCounter.d.ts +2 -2
- package/lib/thresholdCounter.d.ts.map +1 -1
- package/lib/thresholdCounter.js.map +1 -1
- package/lib/utils.d.ts +4 -4
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +9 -9
- package/lib/utils.js.map +1 -1
- package/package.json +21 -19
- package/src/api.ts +44 -0
- package/src/config.ts +29 -19
- package/src/errorLogging.ts +2 -2
- package/src/events.ts +3 -3
- package/src/{index.ts → internal.ts} +23 -8
- package/src/logger.ts +114 -37
- package/src/main.ts +19 -0
- package/src/mockLogger.ts +6 -6
- package/src/sampledTelemetryHelper.ts +12 -4
- package/src/telemetryEventBatcher.ts +3 -3
- package/src/telemetryTypes.ts +76 -6
- package/src/telemetryTypesUndeprecated.ts +51 -0
- package/src/thresholdCounter.ts +2 -2
- package/src/utils.ts +24 -13
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
package/dist/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH;;;GAGG;AAEH;;GAEG;AACU,QAAA,kBAAkB,GAAG,WAAW,CAAC;AAE9C;;GAEG;AACU,QAAA,qBAAqB,GAAG,cAAc,CAAC;AAEpD,qDAAqD;AACrD;;GAEG;AACH,SAAgB,cAAc,CAC7B,OAAqB,EACrB,
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH;;;GAGG;AAEH;;GAEG;AACU,QAAA,kBAAkB,GAAG,WAAW,CAAC;AAE9C;;GAEG;AACU,QAAA,qBAAqB,GAAG,cAAc,CAAC;AAEpD,qDAAqD;AACrD;;GAEG;AACH,SAAgB,cAAc,CAC7B,OAAqB,EACrB,MAA0B,EAC1B,KAAa,EACb,GAAG,IAAe;IAElB,IAAI,CAAC;QACJ,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IACvE,CAAC;AACF,CAAC;AAXD,wCAWC;AAED;;;;;;;;;GASG;AACH,SAAgB,mBAAmB,CAClC,MAA0B,EAC1B,OAAqB,EACrB,SAAkB,EAClB,QAAiB,EACjB,kBAA2B;IAE3B,IAAI,CAAC;QACJ,IAAI,SAAS,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,0BAAkB,EAAE,QAAQ,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACP,OAAO,CAAC,IAAI,CAAC,6BAAqB,EAAE,kBAAkB,CAAC,CAAC;QACzD,CAAC;IACF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,0BAA0B,EAAE,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC;AACF,CAAC;AAhBD,kDAgBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { EventEmitter } from \"@fluid-internal/client-utils\";\n\nimport type { TelemetryLoggerExt } from \"./telemetryTypes.js\";\n\n/**\n * Note: The contents of this file really don't belong in this package, as they are only intended for internal use.\n * They should be moved into the `core-utils` package in the future.\n */\n\n/**\n * @internal\n */\nexport const connectedEventName = \"connected\";\n\n/**\n * @internal\n */\nexport const disconnectedEventName = \"disconnected\";\n\n// eslint-disable-next-line jsdoc/require-description\n/**\n * @internal\n */\nexport function safeRaiseEvent(\n\temitter: EventEmitter,\n\tlogger: TelemetryLoggerExt,\n\tevent: string,\n\t...args: unknown[]\n): void {\n\ttry {\n\t\temitter.emit(event, ...args);\n\t} catch (error) {\n\t\tlogger.sendErrorEvent({ eventName: \"RaiseEventError\", event }, error);\n\t}\n}\n\n/**\n * Raises events pertaining to the connection\n * @param logger - The logger to log telemetry\n * @param emitter - The event emitter instance\n * @param connected - A boolean tracking whether the connection was in a connected state or not\n * @param clientId - The connected/disconnected clientId\n * @param disconnectedReason - The reason for the connection to be disconnected (Used for telemetry purposes only)\n *\n * @internal\n */\nexport function raiseConnectedEvent(\n\tlogger: TelemetryLoggerExt,\n\temitter: EventEmitter,\n\tconnected: boolean,\n\tclientId?: string,\n\tdisconnectedReason?: string,\n): void {\n\ttry {\n\t\tif (connected) {\n\t\t\temitter.emit(connectedEventName, clientId);\n\t\t} else {\n\t\t\temitter.emit(disconnectedEventName, disconnectedReason);\n\t\t}\n\t} catch (error) {\n\t\tlogger.sendErrorEvent({ eventName: \"RaiseConnectedEventError\" }, error);\n\t}\n}\n"]}
|
|
@@ -2,18 +2,30 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
export * from "./main.js";
|
|
5
6
|
export { createChildMonitoringContext, type MonitoringContext, sessionStorageConfigProvider, mixinMonitoringContext, type IConfigProvider, loggerToMonitoringContext, wrapConfigProviderWithDefaults, createConfigBasedOptionsProxy, type OptionConfigReaders, } from "./config.js";
|
|
6
7
|
export { DataCorruptionError, DataProcessingError, extractSafePropertiesFromMessage, GenericError, UsageError, validatePrecondition, LayerIncompatibilityError, type MessageLike, } from "./error.js";
|
|
7
8
|
export { extractLogSafeErrorProperties, generateErrorWithStack, generateStack, getCircularReplacer, type IFluidErrorAnnotations, isExternalError, isILoggingError, isTaggedTelemetryPropertyValue, LoggingError, NORMALIZED_ERROR_TYPE, normalizeError, overwriteStack, wrapError, wrapErrorAndLog, } from "./errorLogging.js";
|
|
8
|
-
export { EventEmitterWithErrorHandling } from "./eventEmitterWithErrorHandling.js";
|
|
9
9
|
export { connectedEventName, disconnectedEventName, raiseConnectedEvent, safeRaiseEvent, } from "./events.js";
|
|
10
10
|
export { hasErrorInstanceId, type IFluidErrorBase, isFluidError, isLayerIncompatibilityError, } from "./fluidErrorBase.js";
|
|
11
|
-
export { eventNamespaceSeparator, createChildLogger, createMultiSinkLogger, formatTick, type IPerformanceEventMarkers, type
|
|
11
|
+
export { eventNamespaceSeparator, createChildLogger, createMultiSinkLogger, extractTelemetryLoggerExt, formatTick, type IPerformanceEventMarkers, type MultiSinkLoggerProperties, numberFromString, PerformanceEvent, TaggedLoggerAdapter, tagData, tagCodeArtifacts, TelemetryDataTag, toITelemetryLoggerExt, } from "./logger.js";
|
|
12
12
|
export { createMockLoggerExt, type IMockLoggerExt, MockLogger, } from "./mockLogger.js";
|
|
13
13
|
export { ThresholdCounter } from "./thresholdCounter.js";
|
|
14
14
|
export { SampledTelemetryHelper, type CustomMetrics, type ICustomData, type MeasureReturnType, } from "./sampledTelemetryHelper.js";
|
|
15
15
|
export { createSampledLogger, type IEventSampler, type ISampledTelemetryLogger, measure, } from "./utils.js";
|
|
16
|
-
export type {
|
|
16
|
+
export type { ITelemetryEventExt, TelemetryLoggerExt, } from "./telemetryTypes.js";
|
|
17
|
+
export type { ITelemetryGenericEventExt, ITelemetryErrorEventExt, ITelemetryPerformanceEventExt, TelemetryEventCategory, } from "./telemetryTypesUndeprecated.js";
|
|
17
18
|
export { TelemetryEventBatcher } from "./telemetryEventBatcher.js";
|
|
18
19
|
export { allowIncompatibleLayersKey, validateLayerCompatibility } from "./layerCompatError.js";
|
|
19
|
-
|
|
20
|
+
import type { TelemetryLoggerExt } from "./telemetryTypes.js";
|
|
21
|
+
/**
|
|
22
|
+
* Renamed version of TelemetryLoggerExt for convenience of internal use.
|
|
23
|
+
* Where "`ITelemetryLoggerExt`" is exposed in customer API surface, true
|
|
24
|
+
* `ITelemetryLoggerExt` (that is an erased type) must be used. To access
|
|
25
|
+
* use `@fluidframework/telemetry-utils/legacy` import spec. All internal
|
|
26
|
+
* usages should be promoted to `TelemetryLoggerExt` naming.
|
|
27
|
+
*
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export type ITelemetryLoggerExt = TelemetryLoggerExt;
|
|
31
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,cAAc,WAAW,CAAC;AAE1B,OAAO,EACN,4BAA4B,EAC5B,KAAK,iBAAiB,EACtB,4BAA4B,EAC5B,sBAAsB,EACtB,KAAK,eAAe,EACpB,yBAAyB,EACzB,8BAA8B,EAC9B,6BAA6B,EAC7B,KAAK,mBAAmB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,gCAAgC,EAChC,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,yBAAyB,EACzB,KAAK,WAAW,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,6BAA6B,EAC7B,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,KAAK,sBAAsB,EAC3B,eAAe,EACf,eAAe,EACf,8BAA8B,EAC9B,YAAY,EACZ,qBAAqB,EACrB,c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G,kBAAkB,CAAC"}
|
|
@@ -3,9 +3,26 @@
|
|
|
3
3
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
6
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
8
|
-
exports.validateLayerCompatibility = exports.allowIncompatibleLayersKey = exports.TelemetryEventBatcher = void 0;
|
|
21
|
+
exports.createSampledLogger = exports.SampledTelemetryHelper = exports.ThresholdCounter = exports.MockLogger = exports.createMockLoggerExt = exports.toITelemetryLoggerExt = exports.TelemetryDataTag = exports.tagCodeArtifacts = exports.tagData = exports.TaggedLoggerAdapter = exports.PerformanceEvent = exports.numberFromString = exports.formatTick = exports.extractTelemetryLoggerExt = exports.createMultiSinkLogger = exports.createChildLogger = exports.eventNamespaceSeparator = exports.isLayerIncompatibilityError = exports.isFluidError = exports.hasErrorInstanceId = exports.safeRaiseEvent = exports.raiseConnectedEvent = exports.disconnectedEventName = exports.connectedEventName = exports.wrapErrorAndLog = exports.wrapError = exports.overwriteStack = exports.normalizeError = exports.NORMALIZED_ERROR_TYPE = exports.LoggingError = exports.isTaggedTelemetryPropertyValue = exports.isILoggingError = exports.isExternalError = exports.getCircularReplacer = exports.generateStack = exports.generateErrorWithStack = exports.extractLogSafeErrorProperties = exports.LayerIncompatibilityError = exports.validatePrecondition = exports.UsageError = exports.GenericError = exports.extractSafePropertiesFromMessage = exports.DataProcessingError = exports.DataCorruptionError = exports.createConfigBasedOptionsProxy = exports.wrapConfigProviderWithDefaults = exports.loggerToMonitoringContext = exports.mixinMonitoringContext = exports.sessionStorageConfigProvider = exports.createChildMonitoringContext = void 0;
|
|
22
|
+
exports.validateLayerCompatibility = exports.allowIncompatibleLayersKey = exports.TelemetryEventBatcher = exports.measure = void 0;
|
|
23
|
+
// The "internal" exports are a superset of the standard ones. So, we want to export everything from the standard barrel file.
|
|
24
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
25
|
+
__exportStar(require("./main.js"), exports);
|
|
9
26
|
var config_js_1 = require("./config.js");
|
|
10
27
|
Object.defineProperty(exports, "createChildMonitoringContext", { enumerable: true, get: function () { return config_js_1.createChildMonitoringContext; } });
|
|
11
28
|
Object.defineProperty(exports, "sessionStorageConfigProvider", { enumerable: true, get: function () { return config_js_1.sessionStorageConfigProvider; } });
|
|
@@ -35,8 +52,6 @@ Object.defineProperty(exports, "normalizeError", { enumerable: true, get: functi
|
|
|
35
52
|
Object.defineProperty(exports, "overwriteStack", { enumerable: true, get: function () { return errorLogging_js_1.overwriteStack; } });
|
|
36
53
|
Object.defineProperty(exports, "wrapError", { enumerable: true, get: function () { return errorLogging_js_1.wrapError; } });
|
|
37
54
|
Object.defineProperty(exports, "wrapErrorAndLog", { enumerable: true, get: function () { return errorLogging_js_1.wrapErrorAndLog; } });
|
|
38
|
-
var eventEmitterWithErrorHandling_js_1 = require("./eventEmitterWithErrorHandling.js");
|
|
39
|
-
Object.defineProperty(exports, "EventEmitterWithErrorHandling", { enumerable: true, get: function () { return eventEmitterWithErrorHandling_js_1.EventEmitterWithErrorHandling; } });
|
|
40
55
|
var events_js_1 = require("./events.js");
|
|
41
56
|
Object.defineProperty(exports, "connectedEventName", { enumerable: true, get: function () { return events_js_1.connectedEventName; } });
|
|
42
57
|
Object.defineProperty(exports, "disconnectedEventName", { enumerable: true, get: function () { return events_js_1.disconnectedEventName; } });
|
|
@@ -50,6 +65,7 @@ var logger_js_1 = require("./logger.js");
|
|
|
50
65
|
Object.defineProperty(exports, "eventNamespaceSeparator", { enumerable: true, get: function () { return logger_js_1.eventNamespaceSeparator; } });
|
|
51
66
|
Object.defineProperty(exports, "createChildLogger", { enumerable: true, get: function () { return logger_js_1.createChildLogger; } });
|
|
52
67
|
Object.defineProperty(exports, "createMultiSinkLogger", { enumerable: true, get: function () { return logger_js_1.createMultiSinkLogger; } });
|
|
68
|
+
Object.defineProperty(exports, "extractTelemetryLoggerExt", { enumerable: true, get: function () { return logger_js_1.extractTelemetryLoggerExt; } });
|
|
53
69
|
Object.defineProperty(exports, "formatTick", { enumerable: true, get: function () { return logger_js_1.formatTick; } });
|
|
54
70
|
Object.defineProperty(exports, "numberFromString", { enumerable: true, get: function () { return logger_js_1.numberFromString; } });
|
|
55
71
|
Object.defineProperty(exports, "PerformanceEvent", { enumerable: true, get: function () { return logger_js_1.PerformanceEvent; } });
|
|
@@ -57,6 +73,7 @@ Object.defineProperty(exports, "TaggedLoggerAdapter", { enumerable: true, get: f
|
|
|
57
73
|
Object.defineProperty(exports, "tagData", { enumerable: true, get: function () { return logger_js_1.tagData; } });
|
|
58
74
|
Object.defineProperty(exports, "tagCodeArtifacts", { enumerable: true, get: function () { return logger_js_1.tagCodeArtifacts; } });
|
|
59
75
|
Object.defineProperty(exports, "TelemetryDataTag", { enumerable: true, get: function () { return logger_js_1.TelemetryDataTag; } });
|
|
76
|
+
Object.defineProperty(exports, "toITelemetryLoggerExt", { enumerable: true, get: function () { return logger_js_1.toITelemetryLoggerExt; } });
|
|
60
77
|
var mockLogger_js_1 = require("./mockLogger.js");
|
|
61
78
|
Object.defineProperty(exports, "createMockLoggerExt", { enumerable: true, get: function () { return mockLogger_js_1.createMockLoggerExt; } });
|
|
62
79
|
Object.defineProperty(exports, "MockLogger", { enumerable: true, get: function () { return mockLogger_js_1.MockLogger; } });
|
|
@@ -72,4 +89,4 @@ Object.defineProperty(exports, "TelemetryEventBatcher", { enumerable: true, get:
|
|
|
72
89
|
var layerCompatError_js_1 = require("./layerCompatError.js");
|
|
73
90
|
Object.defineProperty(exports, "allowIncompatibleLayersKey", { enumerable: true, get: function () { return layerCompatError_js_1.allowIncompatibleLayersKey; } });
|
|
74
91
|
Object.defineProperty(exports, "validateLayerCompatibility", { enumerable: true, get: function () { return layerCompatError_js_1.validateLayerCompatibility; } });
|
|
75
|
-
//# sourceMappingURL=
|
|
92
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;AAEH,8HAA8H;AAC9H,gDAAgD;AAChD,4CAA0B;AAE1B,yCAUqB;AATpB,yHAAA,4BAA4B,OAAA;AAE5B,yHAAA,4BAA4B,OAAA;AAC5B,mHAAA,sBAAsB,OAAA;AAEtB,sHAAA,yBAAyB,OAAA;AACzB,2HAAA,8BAA8B,OAAA;AAC9B,0HAAA,6BAA6B,OAAA;AAG9B,uCASoB;AARnB,+GAAA,mBAAmB,OAAA;AACnB,+GAAA,mBAAmB,OAAA;AACnB,4HAAA,gCAAgC,OAAA;AAChC,wGAAA,YAAY,OAAA;AACZ,sGAAA,UAAU,OAAA;AACV,gHAAA,oBAAoB,OAAA;AACpB,qHAAA,yBAAyB,OAAA;AAG1B,qDAe2B;AAd1B,gIAAA,6BAA6B,OAAA;AAC7B,yHAAA,sBAAsB,OAAA;AACtB,gHAAA,aAAa,OAAA;AACb,sHAAA,mBAAmB,OAAA;AAEnB,kHAAA,eAAe,OAAA;AACf,kHAAA,eAAe,OAAA;AACf,iIAAA,8BAA8B,OAAA;AAC9B,+GAAA,YAAY,OAAA;AACZ,wHAAA,qBAAqB,OAAA;AACrB,iHAAA,cAAc,OAAA;AACd,iHAAA,cAAc,OAAA;AACd,4GAAA,SAAS,OAAA;AACT,kHAAA,eAAe,OAAA;AAEhB,yCAKqB;AAJpB,+GAAA,kBAAkB,OAAA;AAClB,kHAAA,qBAAqB,OAAA;AACrB,gHAAA,mBAAmB,OAAA;AACnB,2GAAA,cAAc,OAAA;AAEf,yDAK6B;AAJ5B,uHAAA,kBAAkB,OAAA;AAElB,iHAAA,YAAY,OAAA;AACZ,gIAAA,2BAA2B,OAAA;AAE5B,yCAeqB;AAdpB,oHAAA,uBAAuB,OAAA;AACvB,8GAAA,iBAAiB,OAAA;AACjB,kHAAA,qBAAqB,OAAA;AACrB,sHAAA,yBAAyB,OAAA;AACzB,uGAAA,UAAU,OAAA;AAGV,6GAAA,gBAAgB,OAAA;AAChB,6GAAA,gBAAgB,OAAA;AAChB,gHAAA,mBAAmB,OAAA;AACnB,oGAAA,OAAO,OAAA;AACP,6GAAA,gBAAgB,OAAA;AAChB,6GAAA,gBAAgB,OAAA;AAChB,kHAAA,qBAAqB,OAAA;AAEtB,iDAIyB;AAHxB,oHAAA,mBAAmB,OAAA;AAEnB,2GAAA,UAAU,OAAA;AAEX,6DAAyD;AAAhD,uHAAA,gBAAgB,OAAA;AACzB,yEAKqC;AAJpC,mIAAA,sBAAsB,OAAA;AAKvB,uCAKoB;AAJnB,+GAAA,mBAAmB,OAAA;AAGnB,mGAAA,OAAO,OAAA;AAYR,uEAAmE;AAA1D,iIAAA,qBAAqB,OAAA;AAC9B,6DAA+F;AAAtF,iIAAA,0BAA0B,OAAA;AAAE,iIAAA,0BAA0B,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// The \"internal\" exports are a superset of the standard ones. So, we want to export everything from the standard barrel file.\n// eslint-disable-next-line no-restricted-syntax\nexport * from \"./main.js\";\n\nexport {\n\tcreateChildMonitoringContext,\n\ttype MonitoringContext,\n\tsessionStorageConfigProvider,\n\tmixinMonitoringContext,\n\ttype IConfigProvider,\n\tloggerToMonitoringContext,\n\twrapConfigProviderWithDefaults,\n\tcreateConfigBasedOptionsProxy,\n\ttype OptionConfigReaders,\n} from \"./config.js\";\nexport {\n\tDataCorruptionError,\n\tDataProcessingError,\n\textractSafePropertiesFromMessage,\n\tGenericError,\n\tUsageError,\n\tvalidatePrecondition,\n\tLayerIncompatibilityError,\n\ttype MessageLike,\n} from \"./error.js\";\nexport {\n\textractLogSafeErrorProperties,\n\tgenerateErrorWithStack,\n\tgenerateStack,\n\tgetCircularReplacer,\n\ttype IFluidErrorAnnotations,\n\tisExternalError,\n\tisILoggingError,\n\tisTaggedTelemetryPropertyValue,\n\tLoggingError,\n\tNORMALIZED_ERROR_TYPE,\n\tnormalizeError,\n\toverwriteStack,\n\twrapError,\n\twrapErrorAndLog,\n} from \"./errorLogging.js\";\nexport {\n\tconnectedEventName,\n\tdisconnectedEventName,\n\traiseConnectedEvent,\n\tsafeRaiseEvent,\n} from \"./events.js\";\nexport {\n\thasErrorInstanceId,\n\ttype IFluidErrorBase,\n\tisFluidError,\n\tisLayerIncompatibilityError,\n} from \"./fluidErrorBase.js\";\nexport {\n\teventNamespaceSeparator,\n\tcreateChildLogger,\n\tcreateMultiSinkLogger,\n\textractTelemetryLoggerExt,\n\tformatTick,\n\ttype IPerformanceEventMarkers,\n\ttype MultiSinkLoggerProperties,\n\tnumberFromString,\n\tPerformanceEvent,\n\tTaggedLoggerAdapter,\n\ttagData,\n\ttagCodeArtifacts,\n\tTelemetryDataTag,\n\ttoITelemetryLoggerExt,\n} from \"./logger.js\";\nexport {\n\tcreateMockLoggerExt,\n\ttype IMockLoggerExt,\n\tMockLogger,\n} from \"./mockLogger.js\";\nexport { ThresholdCounter } from \"./thresholdCounter.js\";\nexport {\n\tSampledTelemetryHelper,\n\ttype CustomMetrics,\n\ttype ICustomData,\n\ttype MeasureReturnType,\n} from \"./sampledTelemetryHelper.js\";\nexport {\n\tcreateSampledLogger,\n\ttype IEventSampler,\n\ttype ISampledTelemetryLogger,\n\tmeasure,\n} from \"./utils.js\";\nexport type {\n\tITelemetryEventExt,\n\tTelemetryLoggerExt,\n} from \"./telemetryTypes.js\";\nexport type {\n\tITelemetryGenericEventExt,\n\tITelemetryErrorEventExt,\n\tITelemetryPerformanceEventExt,\n\tTelemetryEventCategory,\n} from \"./telemetryTypesUndeprecated.js\";\nexport { TelemetryEventBatcher } from \"./telemetryEventBatcher.js\";\nexport { allowIncompatibleLayersKey, validateLayerCompatibility } from \"./layerCompatError.js\";\n\nimport type { TelemetryLoggerExt } from \"./telemetryTypes.js\";\n\n/**\n * Renamed version of TelemetryLoggerExt for convenience of internal use.\n * Where \"`ITelemetryLoggerExt`\" is exposed in customer API surface, true\n * `ITelemetryLoggerExt` (that is an erased type) must be used. To access\n * use `@fluidframework/telemetry-utils/legacy` import spec. All internal\n * usages should be promoted to `TelemetryLoggerExt` naming.\n *\n * @internal\n */\nexport type ITelemetryLoggerExt = TelemetryLoggerExt;\n"]}
|
package/dist/legacy.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
-
* Generated by "flub generate entrypoints --resolutionConditions require --outFileLegacyBeta legacy --outDir ./dist" in @fluid-tools/build-cli.
|
|
8
|
+
* Generated by "flub generate entrypoints --resolutionConditions require --mainEntrypoint ./src/api.ts --outFileLegacyBeta legacy --outDir ./dist" in @fluid-tools/build-cli.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export {
|
|
@@ -23,4 +23,4 @@ export {
|
|
|
23
23
|
TelemetryEventPropertyTypes,
|
|
24
24
|
createChildLogger
|
|
25
25
|
// #endregion
|
|
26
|
-
} from "./
|
|
26
|
+
} from "./api.js";
|
package/dist/logger.d.ts
CHANGED
|
@@ -3,7 +3,31 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { type ITelemetryBaseEvent, type ITelemetryBaseLogger, LogLevel, type Tagged, type TelemetryBaseEventPropertyType } from "@fluidframework/core-interfaces";
|
|
6
|
-
import type {
|
|
6
|
+
import type { ITelemetryLoggerExt, ITelemetryPropertiesExt, TelemetryLoggerExt, TelemetryEventPropertyTypeExt } from "./telemetryTypes.js";
|
|
7
|
+
import type { ITelemetryErrorEventExt, ITelemetryGenericEventExt, ITelemetryPerformanceEventExt } from "./telemetryTypesUndeprecated.js";
|
|
8
|
+
/**
|
|
9
|
+
* Type erase a {@link TelemetryLoggerExt} to an {@link ITelemetryLoggerExt}.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function toITelemetryLoggerExt(logger: TelemetryLoggerExt): ITelemetryLoggerExt;
|
|
13
|
+
/**
|
|
14
|
+
* Un-type-erase the {@link ITelemetryLoggerExt}.
|
|
15
|
+
* @remarks
|
|
16
|
+
* This is the extraction helper as documented by {@link @fluidframework/core-interfaces#BrandedType}.
|
|
17
|
+
*
|
|
18
|
+
* @typeParam options - options for the extraction, currently only supports making
|
|
19
|
+
* the output possibly undefined (when `PossiblyUndefined: true`), which is useful
|
|
20
|
+
* for cases where we want to allow passing `undefined` through.
|
|
21
|
+
*
|
|
22
|
+
* @privateRemarks `ITelemetryLoggerExt` is not currently a branded type, but will
|
|
23
|
+
* be when the breaking change is made. At that time, use of this helper will be
|
|
24
|
+
* required.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export declare function extractTelemetryLoggerExt<options extends {
|
|
29
|
+
PossiblyUndefined?: true;
|
|
30
|
+
} = {}>(input: ITelemetryLoggerExt | TelemetryLoggerExt | (options["PossiblyUndefined"] extends true ? undefined : never)): TelemetryLoggerExt | (options["PossiblyUndefined"] extends true ? undefined : never);
|
|
7
31
|
/**
|
|
8
32
|
* Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.
|
|
9
33
|
*
|
|
@@ -34,6 +58,9 @@ export type ITelemetryLoggerPropertyBag = Record<string, TelemetryEventPropertyT
|
|
|
34
58
|
/**
|
|
35
59
|
* @legacy
|
|
36
60
|
* @beta
|
|
61
|
+
*
|
|
62
|
+
* @privateRemarks
|
|
63
|
+
* This is exposed to support {@link createChildLogger} properties parameter.
|
|
37
64
|
*/
|
|
38
65
|
export interface ITelemetryLoggerPropertyBags {
|
|
39
66
|
all?: ITelemetryLoggerPropertyBag;
|
|
@@ -64,7 +91,7 @@ export declare const eventNamespaceSeparator = ":";
|
|
|
64
91
|
* encoding in one place schemas for various types of Fluid telemetry events.
|
|
65
92
|
* Creates sub-logger that appends properties to all events
|
|
66
93
|
*/
|
|
67
|
-
export declare abstract class TelemetryLogger implements
|
|
94
|
+
export declare abstract class TelemetryLogger implements TelemetryLoggerExt {
|
|
68
95
|
protected readonly namespace?: string | undefined;
|
|
69
96
|
protected readonly properties?: ITelemetryLoggerPropertyBags | undefined;
|
|
70
97
|
/**
|
|
@@ -92,20 +119,18 @@ export declare abstract class TelemetryLogger implements ITelemetryLoggerExt {
|
|
|
92
119
|
*
|
|
93
120
|
* @param event - the event to send
|
|
94
121
|
* @param error - optional error object to log
|
|
95
|
-
* @param logLevel - optional level of the log.
|
|
96
|
-
*
|
|
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}.
|
|
97
124
|
*/
|
|
98
|
-
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;
|
|
99
126
|
/**
|
|
100
127
|
* Send a telemetry event with the logger
|
|
101
128
|
*
|
|
102
129
|
* @param event - the event to send
|
|
103
130
|
* @param error - optional error object to log
|
|
104
|
-
* @param logLevel -
|
|
131
|
+
* @param logLevel - level of the log.
|
|
105
132
|
*/
|
|
106
|
-
|
|
107
|
-
category: TelemetryEventCategory;
|
|
108
|
-
}, error?: unknown, logLevel?: LogLevel): void;
|
|
133
|
+
private sendTelemetryEventCore;
|
|
109
134
|
/**
|
|
110
135
|
* Send an error telemetry event with the logger
|
|
111
136
|
*
|
|
@@ -118,10 +143,10 @@ export declare abstract class TelemetryLogger implements ITelemetryLoggerExt {
|
|
|
118
143
|
*
|
|
119
144
|
* @param event - Event to send
|
|
120
145
|
* @param error - optional error object to log
|
|
121
|
-
* @param logLevel - optional level of the log.
|
|
122
|
-
*
|
|
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}.
|
|
123
148
|
*/
|
|
124
|
-
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;
|
|
125
150
|
protected prepareEvent(event: ITelemetryBaseEvent): ITelemetryBaseEvent;
|
|
126
151
|
private extendProperties;
|
|
127
152
|
}
|
|
@@ -148,14 +173,22 @@ export declare class TaggedLoggerAdapter implements ITelemetryBaseLogger {
|
|
|
148
173
|
*
|
|
149
174
|
* @param props - logger is the base logger the child will log to after it's processing, namespace will be prefixed to all event names, properties are default properties that will be applied events.
|
|
150
175
|
*
|
|
151
|
-
* @
|
|
152
|
-
*
|
|
176
|
+
* @internal
|
|
177
|
+
*
|
|
178
|
+
* @privateRemarks
|
|
179
|
+
* Return type is both TelemetryLoggerExt and ITelemetryLoggerExt to allow for
|
|
180
|
+
* easier internal usage without needing to type erase or un-type-erase the
|
|
181
|
+
* logger.
|
|
182
|
+
*
|
|
183
|
+
* If always creating a child logger for direct external exposure, consider
|
|
184
|
+
* using {@link createChildLogger} from /legacy API instead, which returns
|
|
185
|
+
* exactly an {@link ITelemetryLoggerExt}.
|
|
153
186
|
*/
|
|
154
187
|
export declare function createChildLogger(props?: {
|
|
155
188
|
logger?: ITelemetryBaseLogger;
|
|
156
189
|
namespace?: string;
|
|
157
190
|
properties?: ITelemetryLoggerPropertyBags;
|
|
158
|
-
}): ITelemetryLoggerExt;
|
|
191
|
+
}): TelemetryLoggerExt & ITelemetryLoggerExt;
|
|
159
192
|
/**
|
|
160
193
|
* ChildLogger class contains various helper telemetry methods,
|
|
161
194
|
* encoding in one place schemas for various types of Fluid telemetry events.
|
|
@@ -209,7 +242,7 @@ export interface MultiSinkLoggerProperties {
|
|
|
209
242
|
*
|
|
210
243
|
* @internal
|
|
211
244
|
*/
|
|
212
|
-
export declare function createMultiSinkLogger(props: MultiSinkLoggerProperties):
|
|
245
|
+
export declare function createMultiSinkLogger(props: MultiSinkLoggerProperties): TelemetryLoggerExt;
|
|
213
246
|
/**
|
|
214
247
|
* Multi-sink logger
|
|
215
248
|
* Takes multiple ITelemetryBaseLogger objects (sinks) and logs all events into each sink
|
|
@@ -237,7 +270,7 @@ export declare class MultiSinkLogger extends TelemetryLogger {
|
|
|
237
270
|
*
|
|
238
271
|
* @param event - the event to send to all the registered logger
|
|
239
272
|
*/
|
|
240
|
-
send(event: ITelemetryBaseEvent): void;
|
|
273
|
+
send(event: ITelemetryBaseEvent, logLevel?: LogLevel): void;
|
|
241
274
|
}
|
|
242
275
|
/**
|
|
243
276
|
* Describes what events {@link PerformanceEvent} should log.
|
|
@@ -264,6 +297,7 @@ export declare class PerformanceEvent {
|
|
|
264
297
|
private readonly logger;
|
|
265
298
|
private readonly markers;
|
|
266
299
|
private readonly emitLogs;
|
|
300
|
+
private readonly logLevel;
|
|
267
301
|
/**
|
|
268
302
|
* Creates an instance of {@link PerformanceEvent} and starts measurements
|
|
269
303
|
* @param logger - the logger to be used for publishing events
|
|
@@ -272,9 +306,11 @@ export declare class PerformanceEvent {
|
|
|
272
306
|
* @param recordHeapSize - whether or not to also record memory performance
|
|
273
307
|
* @param emitLogs - should this instance emit logs. If set to false, logs will not be emitted to the logger,
|
|
274
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.
|
|
275
311
|
* @returns An instance of {@link PerformanceEvent}
|
|
276
312
|
*/
|
|
277
|
-
static start(logger: 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;
|
|
278
314
|
/**
|
|
279
315
|
* Measure a synchronous task
|
|
280
316
|
* @param logger - the logger to be used for publishing events
|
|
@@ -283,6 +319,8 @@ export declare class PerformanceEvent {
|
|
|
283
319
|
* @param markers - See {@link IPerformanceEventMarkers}
|
|
284
320
|
* @param sampleThreshold - events with the same name and category will be sent to the logger
|
|
285
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.
|
|
286
324
|
* @returns The results of the executed task
|
|
287
325
|
*
|
|
288
326
|
* @remarks Note that if the "same" event (category + eventName) would be emitted by different
|
|
@@ -290,7 +328,7 @@ export declare class PerformanceEvent {
|
|
|
290
328
|
* so executing either of the tasks will increase the internal counter and they
|
|
291
329
|
* effectively "share" the sampling rate for the event.
|
|
292
330
|
*/
|
|
293
|
-
static timedExec<T>(logger:
|
|
331
|
+
static timedExec<T>(logger: TelemetryLoggerExt, event: ITelemetryGenericEventExt, callback: (event: PerformanceEvent) => T, markers?: IPerformanceEventMarkers, sampleThreshold?: number, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): T;
|
|
294
332
|
/**
|
|
295
333
|
* Measure an asynchronous task
|
|
296
334
|
* @param logger - the logger to be used for publishing events
|
|
@@ -300,6 +338,8 @@ export declare class PerformanceEvent {
|
|
|
300
338
|
* @param recordHeapSize - whether or not to also record memory performance
|
|
301
339
|
* @param sampleThreshold - events with the same name and category will be sent to the logger
|
|
302
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.
|
|
303
343
|
* @returns The results of the executed task
|
|
304
344
|
*
|
|
305
345
|
* @remarks Note that if the "same" event (category + eventName) would be emitted by different
|
|
@@ -307,12 +347,12 @@ export declare class PerformanceEvent {
|
|
|
307
347
|
* so executing either of the tasks will increase the internal counter and they
|
|
308
348
|
* effectively "share" the sampling rate for the event.
|
|
309
349
|
*/
|
|
310
|
-
static timedExecAsync<T>(logger: 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>;
|
|
311
351
|
get duration(): number;
|
|
312
352
|
private event?;
|
|
313
353
|
private readonly startTime;
|
|
314
354
|
private startMark?;
|
|
315
|
-
|
|
355
|
+
private constructor();
|
|
316
356
|
reportProgress(props?: ITelemetryPropertiesExt, eventNameSuffix?: string): void;
|
|
317
357
|
private autoEnd;
|
|
318
358
|
end(props?: ITelemetryPropertiesExt): void;
|
package/dist/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,
|
|
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,EAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACX,uBAAuB,EACvB,yBAAyB,EACzB,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAEzC;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,GAAG,mBAAmB,CAErF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CACxC,OAAO,SAAS;IACf,iBAAiB,CAAC,EAAE,IAAI,CAAC;CACzB,GACD,EAAE,EAEF,KAAK,EACF,mBAAmB,GACnB,kBAAkB,GAClB,CAAC,OAAO,CAAC,mBAAmB,CAAC,SAAS,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC,GAChE,kBAAkB,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,SAAS,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC,CAEtF;AAED;;;;;;GAMG;AAC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7
|
-
exports.tagCodeArtifacts = exports.tagData = exports.convertToBasePropertyType = exports.PerformanceEvent = exports.MultiSinkLogger = exports.createMultiSinkLogger = exports.ChildLogger = exports.createChildLogger = exports.TaggedLoggerAdapter = exports.TelemetryLogger = exports.eventNamespaceSeparator = exports.formatTick = exports.numberFromString = exports.TelemetryDataTag = void 0;
|
|
7
|
+
exports.tagCodeArtifacts = exports.tagData = exports.convertToBasePropertyType = exports.PerformanceEvent = exports.MultiSinkLogger = exports.createMultiSinkLogger = exports.ChildLogger = exports.createChildLogger = exports.TaggedLoggerAdapter = exports.TelemetryLogger = exports.eventNamespaceSeparator = exports.formatTick = exports.numberFromString = exports.TelemetryDataTag = exports.extractTelemetryLoggerExt = exports.toITelemetryLoggerExt = void 0;
|
|
8
8
|
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
9
9
|
const core_interfaces_1 = require("@fluidframework/core-interfaces");
|
|
10
10
|
const config_js_1 = require("./config.js");
|
|
11
11
|
const errorLogging_js_1 = require("./errorLogging.js");
|
|
12
|
+
/**
|
|
13
|
+
* Type erase a {@link TelemetryLoggerExt} to an {@link ITelemetryLoggerExt}.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
function toITelemetryLoggerExt(logger) {
|
|
17
|
+
return logger;
|
|
18
|
+
}
|
|
19
|
+
exports.toITelemetryLoggerExt = toITelemetryLoggerExt;
|
|
20
|
+
/**
|
|
21
|
+
* Un-type-erase the {@link ITelemetryLoggerExt}.
|
|
22
|
+
* @remarks
|
|
23
|
+
* This is the extraction helper as documented by {@link @fluidframework/core-interfaces#BrandedType}.
|
|
24
|
+
*
|
|
25
|
+
* @typeParam options - options for the extraction, currently only supports making
|
|
26
|
+
* the output possibly undefined (when `PossiblyUndefined: true`), which is useful
|
|
27
|
+
* for cases where we want to allow passing `undefined` through.
|
|
28
|
+
*
|
|
29
|
+
* @privateRemarks `ITelemetryLoggerExt` is not currently a branded type, but will
|
|
30
|
+
* be when the breaking change is made. At that time, use of this helper will be
|
|
31
|
+
* required.
|
|
32
|
+
*
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
function extractTelemetryLoggerExt(input) {
|
|
36
|
+
return input;
|
|
37
|
+
}
|
|
38
|
+
exports.extractTelemetryLoggerExt = extractTelemetryLoggerExt;
|
|
12
39
|
/**
|
|
13
40
|
* Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.
|
|
14
41
|
*
|
|
@@ -107,18 +134,18 @@ class TelemetryLogger {
|
|
|
107
134
|
*
|
|
108
135
|
* @param event - the event to send
|
|
109
136
|
* @param error - optional error object to log
|
|
110
|
-
* @param logLevel - optional level of the log.
|
|
111
|
-
*
|
|
137
|
+
* @param logLevel - optional level of the log. If the event's category is `error`,
|
|
138
|
+
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
|
|
112
139
|
*/
|
|
113
|
-
sendTelemetryEvent(event, error, logLevel
|
|
114
|
-
this.sendTelemetryEventCore({ ...event, category: event.category ?? "generic" }, error, event.category === "error" ? core_interfaces_1.LogLevel.
|
|
140
|
+
sendTelemetryEvent(event, error, logLevel) {
|
|
141
|
+
this.sendTelemetryEventCore({ ...event, category: event.category ?? "generic" }, error, event.category === "error" ? core_interfaces_1.LogLevel.essential : (logLevel ?? core_interfaces_1.LogLevel.essential));
|
|
115
142
|
}
|
|
116
143
|
/**
|
|
117
144
|
* Send a telemetry event with the logger
|
|
118
145
|
*
|
|
119
146
|
* @param event - the event to send
|
|
120
147
|
* @param error - optional error object to log
|
|
121
|
-
* @param logLevel -
|
|
148
|
+
* @param logLevel - level of the log.
|
|
122
149
|
*/
|
|
123
150
|
sendTelemetryEventCore(event, error, logLevel) {
|
|
124
151
|
const newEvent = convertToBaseEvent(event);
|
|
@@ -144,22 +171,22 @@ class TelemetryLogger {
|
|
|
144
171
|
error: event.eventName,
|
|
145
172
|
...event,
|
|
146
173
|
category: "error",
|
|
147
|
-
}, error, core_interfaces_1.LogLevel.
|
|
174
|
+
}, error, core_interfaces_1.LogLevel.essential);
|
|
148
175
|
}
|
|
149
176
|
/**
|
|
150
177
|
* Send a performance telemetry event with the logger
|
|
151
178
|
*
|
|
152
179
|
* @param event - Event to send
|
|
153
180
|
* @param error - optional error object to log
|
|
154
|
-
* @param logLevel - optional level of the log.
|
|
155
|
-
*
|
|
181
|
+
* @param logLevel - optional level of the log. If the event's category is `error`,
|
|
182
|
+
* the logLevel will be upgraded to {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential}.
|
|
156
183
|
*/
|
|
157
|
-
sendPerformanceEvent(event, error, logLevel
|
|
184
|
+
sendPerformanceEvent(event, error, logLevel) {
|
|
158
185
|
const perfEvent = {
|
|
159
186
|
...event,
|
|
160
187
|
category: event.category ?? "performance",
|
|
161
188
|
};
|
|
162
|
-
this.sendTelemetryEventCore(perfEvent, error, perfEvent.category === "error" ? core_interfaces_1.LogLevel.
|
|
189
|
+
this.sendTelemetryEventCore(perfEvent, error, perfEvent.category === "error" ? core_interfaces_1.LogLevel.essential : (logLevel ?? core_interfaces_1.LogLevel.essential));
|
|
163
190
|
}
|
|
164
191
|
prepareEvent(event) {
|
|
165
192
|
const includeErrorProps = event.category === "error" || event.error !== undefined;
|
|
@@ -256,6 +283,9 @@ class TaggedLoggerAdapter {
|
|
|
256
283
|
}
|
|
257
284
|
}
|
|
258
285
|
exports.TaggedLoggerAdapter = TaggedLoggerAdapter;
|
|
286
|
+
function toEitherTelemetryLoggerExt(logger) {
|
|
287
|
+
return logger;
|
|
288
|
+
}
|
|
259
289
|
/**
|
|
260
290
|
* Create a child logger based on the provided props object.
|
|
261
291
|
*
|
|
@@ -264,11 +294,19 @@ exports.TaggedLoggerAdapter = TaggedLoggerAdapter;
|
|
|
264
294
|
*
|
|
265
295
|
* @param props - logger is the base logger the child will log to after it's processing, namespace will be prefixed to all event names, properties are default properties that will be applied events.
|
|
266
296
|
*
|
|
267
|
-
* @
|
|
268
|
-
*
|
|
297
|
+
* @internal
|
|
298
|
+
*
|
|
299
|
+
* @privateRemarks
|
|
300
|
+
* Return type is both TelemetryLoggerExt and ITelemetryLoggerExt to allow for
|
|
301
|
+
* easier internal usage without needing to type erase or un-type-erase the
|
|
302
|
+
* logger.
|
|
303
|
+
*
|
|
304
|
+
* If always creating a child logger for direct external exposure, consider
|
|
305
|
+
* using {@link createChildLogger} from /legacy API instead, which returns
|
|
306
|
+
* exactly an {@link ITelemetryLoggerExt}.
|
|
269
307
|
*/
|
|
270
308
|
function createChildLogger(props) {
|
|
271
|
-
return ChildLogger.create(props?.logger, props?.namespace, props?.properties);
|
|
309
|
+
return toEitherTelemetryLoggerExt(ChildLogger.create(props?.logger, props?.namespace, props?.properties));
|
|
272
310
|
}
|
|
273
311
|
exports.createChildLogger = createChildLogger;
|
|
274
312
|
/**
|
|
@@ -330,8 +368,8 @@ class ChildLogger extends TelemetryLogger {
|
|
|
330
368
|
return this.baseLogger.minLogLevel;
|
|
331
369
|
}
|
|
332
370
|
shouldFilterOutEvent(event, logLevel) {
|
|
333
|
-
const eventLogLevel = logLevel ?? core_interfaces_1.LogLevel.
|
|
334
|
-
const configLogLevel = this.baseLogger.minLogLevel ?? core_interfaces_1.LogLevel.
|
|
371
|
+
const eventLogLevel = logLevel ?? core_interfaces_1.LogLevel.essential;
|
|
372
|
+
const configLogLevel = this.baseLogger.minLogLevel ?? core_interfaces_1.LogLevel.info;
|
|
335
373
|
// Filter out in case event log level is below what is wanted in config.
|
|
336
374
|
return eventLogLevel < configLogLevel;
|
|
337
375
|
}
|
|
@@ -344,7 +382,7 @@ class ChildLogger extends TelemetryLogger {
|
|
|
344
382
|
if (this.shouldFilterOutEvent(event, logLevel)) {
|
|
345
383
|
return;
|
|
346
384
|
}
|
|
347
|
-
this.baseLogger.send(this.prepareEvent(event), logLevel);
|
|
385
|
+
this.baseLogger.send(this.prepareEvent(event), logLevel ?? core_interfaces_1.LogLevel.essential);
|
|
348
386
|
}
|
|
349
387
|
}
|
|
350
388
|
exports.ChildLogger = ChildLogger;
|
|
@@ -387,7 +425,7 @@ class MultiSinkLogger extends TelemetryLogger {
|
|
|
387
425
|
}
|
|
388
426
|
super(namespace, realProperties);
|
|
389
427
|
this.loggers = loggers;
|
|
390
|
-
this._minLogLevelOfAllLoggers = core_interfaces_1.LogLevel.
|
|
428
|
+
this._minLogLevelOfAllLoggers = core_interfaces_1.LogLevel.info;
|
|
391
429
|
this.calculateMinLogLevel();
|
|
392
430
|
}
|
|
393
431
|
get minLogLevel() {
|
|
@@ -397,7 +435,7 @@ class MultiSinkLogger extends TelemetryLogger {
|
|
|
397
435
|
if (this.loggers.length > 0) {
|
|
398
436
|
const logLevels = [];
|
|
399
437
|
for (const logger of this.loggers) {
|
|
400
|
-
logLevels.push(logger.minLogLevel ?? core_interfaces_1.LogLevel.
|
|
438
|
+
logLevels.push(logger.minLogLevel ?? core_interfaces_1.LogLevel.info);
|
|
401
439
|
}
|
|
402
440
|
this._minLogLevelOfAllLoggers = Math.min(...logLevels);
|
|
403
441
|
}
|
|
@@ -418,10 +456,10 @@ class MultiSinkLogger extends TelemetryLogger {
|
|
|
418
456
|
*
|
|
419
457
|
* @param event - the event to send to all the registered logger
|
|
420
458
|
*/
|
|
421
|
-
send(event) {
|
|
459
|
+
send(event, logLevel) {
|
|
422
460
|
const newEvent = this.prepareEvent(event);
|
|
423
461
|
for (const logger of this.loggers) {
|
|
424
|
-
logger.send(newEvent);
|
|
462
|
+
logger.send(newEvent, logLevel ?? core_interfaces_1.LogLevel.essential);
|
|
425
463
|
}
|
|
426
464
|
}
|
|
427
465
|
}
|
|
@@ -440,10 +478,12 @@ class PerformanceEvent {
|
|
|
440
478
|
* @param recordHeapSize - whether or not to also record memory performance
|
|
441
479
|
* @param emitLogs - should this instance emit logs. If set to false, logs will not be emitted to the logger,
|
|
442
480
|
* but measurements will still be performed and any specified markers will be generated.
|
|
481
|
+
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
|
|
482
|
+
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
|
|
443
483
|
* @returns An instance of {@link PerformanceEvent}
|
|
444
484
|
*/
|
|
445
|
-
static start(logger, event, markers, emitLogs = true) {
|
|
446
|
-
return new PerformanceEvent(logger, event, markers, emitLogs);
|
|
485
|
+
static start(logger, event, markers, emitLogs = true, logLevel) {
|
|
486
|
+
return new PerformanceEvent(extractTelemetryLoggerExt(logger), event, markers, emitLogs, logLevel);
|
|
447
487
|
}
|
|
448
488
|
/**
|
|
449
489
|
* Measure a synchronous task
|
|
@@ -453,6 +493,8 @@ class PerformanceEvent {
|
|
|
453
493
|
* @param markers - See {@link IPerformanceEventMarkers}
|
|
454
494
|
* @param sampleThreshold - events with the same name and category will be sent to the logger
|
|
455
495
|
* only when we hit this many executions of the task. If unspecified, all events will be sent.
|
|
496
|
+
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
|
|
497
|
+
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
|
|
456
498
|
* @returns The results of the executed task
|
|
457
499
|
*
|
|
458
500
|
* @remarks Note that if the "same" event (category + eventName) would be emitted by different
|
|
@@ -460,8 +502,8 @@ class PerformanceEvent {
|
|
|
460
502
|
* so executing either of the tasks will increase the internal counter and they
|
|
461
503
|
* effectively "share" the sampling rate for the event.
|
|
462
504
|
*/
|
|
463
|
-
static timedExec(logger, event, callback, markers, sampleThreshold = 1) {
|
|
464
|
-
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold));
|
|
505
|
+
static timedExec(logger, event, callback, markers, sampleThreshold = 1, logLevel) {
|
|
506
|
+
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold), logLevel);
|
|
465
507
|
try {
|
|
466
508
|
const ret = callback(perfEvent);
|
|
467
509
|
perfEvent.autoEnd();
|
|
@@ -481,6 +523,8 @@ class PerformanceEvent {
|
|
|
481
523
|
* @param recordHeapSize - whether or not to also record memory performance
|
|
482
524
|
* @param sampleThreshold - events with the same name and category will be sent to the logger
|
|
483
525
|
* only when we hit this many executions of the task. If unspecified, all events will be sent.
|
|
526
|
+
* @param logLevel - optional {@link LogLevel} for events emitted by this performance event.
|
|
527
|
+
* If unspecified, {@link @fluidframework/core-interfaces#LogLevelConst.essential | LogLevel.essential} will be used.
|
|
484
528
|
* @returns The results of the executed task
|
|
485
529
|
*
|
|
486
530
|
* @remarks Note that if the "same" event (category + eventName) would be emitted by different
|
|
@@ -488,8 +532,8 @@ class PerformanceEvent {
|
|
|
488
532
|
* so executing either of the tasks will increase the internal counter and they
|
|
489
533
|
* effectively "share" the sampling rate for the event.
|
|
490
534
|
*/
|
|
491
|
-
static async timedExecAsync(logger, event, callback, markers, sampleThreshold = 1) {
|
|
492
|
-
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold));
|
|
535
|
+
static async timedExecAsync(logger, event, callback, markers, sampleThreshold = 1, logLevel) {
|
|
536
|
+
const perfEvent = PerformanceEvent.start(logger, event, markers, PerformanceEvent.shouldReport(event, sampleThreshold), logLevel);
|
|
493
537
|
try {
|
|
494
538
|
const ret = await callback(perfEvent);
|
|
495
539
|
perfEvent.autoEnd();
|
|
@@ -503,10 +547,11 @@ class PerformanceEvent {
|
|
|
503
547
|
get duration() {
|
|
504
548
|
return (0, client_utils_1.performanceNow)() - this.startTime;
|
|
505
549
|
}
|
|
506
|
-
constructor(logger, event, markers = { end: true, cancel: "generic" }, emitLogs = true) {
|
|
550
|
+
constructor(logger, event, markers = { end: true, cancel: "generic" }, emitLogs = true, logLevel) {
|
|
507
551
|
this.logger = logger;
|
|
508
552
|
this.markers = markers;
|
|
509
553
|
this.emitLogs = emitLogs;
|
|
554
|
+
this.logLevel = logLevel;
|
|
510
555
|
this.startTime = (0, client_utils_1.performanceNow)();
|
|
511
556
|
this.event = { ...event };
|
|
512
557
|
if (this.markers.start) {
|
|
@@ -569,7 +614,7 @@ class PerformanceEvent {
|
|
|
569
614
|
if (eventNameSuffix !== "start") {
|
|
570
615
|
event.duration = this.duration;
|
|
571
616
|
}
|
|
572
|
-
this.logger.sendPerformanceEvent(event, error);
|
|
617
|
+
this.logger.sendPerformanceEvent(event, error, this.logLevel);
|
|
573
618
|
}
|
|
574
619
|
static shouldReport(event, sampleThreshold) {
|
|
575
620
|
const eventKey = `.${event.category}.${event.eventName}`;
|