@fluidframework/telemetry-utils 2.100.0 → 2.101.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +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
package/CHANGELOG.md
CHANGED
|
@@ -34,9 +34,9 @@ export interface ITelemetryLoggerExt extends ITelemetryBaseLogger {
|
|
|
34
34
|
// @deprecated
|
|
35
35
|
sendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;
|
|
36
36
|
// @deprecated
|
|
37
|
-
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.
|
|
37
|
+
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
|
|
38
38
|
// @deprecated
|
|
39
|
-
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.
|
|
39
|
+
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.info): void;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// @beta @legacy (undocumented)
|
package/dist/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,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAoB,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,M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AC,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/dist/config.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.createConfigBasedOptionsProxy = exports.createChildMonitoringContext = exports.mixinMonitoringContext = exports.loggerToMonitoringContext = exports.loggerIsMonitoringContext = exports.CachedConfigProvider = exports.wrapConfigProviderWithDefaults = exports.inMemoryConfigProvider = exports.sessionStorageConfigProvider = void 0;
|
|
8
|
+
const core_interfaces_1 = require("@fluidframework/core-interfaces");
|
|
8
9
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
10
|
const logger_js_1 = require("./logger.js");
|
|
10
11
|
/**
|
|
@@ -202,7 +203,7 @@ class CachedConfigProvider {
|
|
|
202
203
|
configName: name,
|
|
203
204
|
configValue: JSON.stringify(parsed),
|
|
204
205
|
}),
|
|
205
|
-
});
|
|
206
|
+
}, core_interfaces_1.LogLevel.info);
|
|
206
207
|
return parsed;
|
|
207
208
|
}
|
|
208
209
|
}
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH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,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;AAlCD,sEAkCC","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,qEAA2D;AAC3D,kEAA2D;AAE3D,2CAAkE;AAgBlE;;;;;;GAMG;AACU,QAAA,4BAA4B,GAAG,IAAI,eAAI,CAAsB,GAAG,EAAE,CAC9E,IAAA,8BAAsB,EAAC,kBAAkB,EAAE,CAAC,CAC5C,CAAC;AAEF,MAAM,kBAAkB,GAAwB;IAC/C,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS;CAC7B,CAAC;AAEF;;;;;;GAMG;AACI,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,CAAC;AAC3B,CAAC,CAAC;AAbW,QAAA,sBAAsB,0BAajC;AAaF,SAAS,eAAe,CAAC,IAAY;IACpC,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC,CAAC,CAAC;YACf,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B,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;AAlCD,sEAkCC","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/dist/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/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,EAEX,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,6BAA6B,EAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACX,uBAAuB,EACvB,yBAAyB,EACzB,6BAA6B,
|
|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;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/dist/logger.js
CHANGED
|
@@ -134,18 +134,18 @@ class TelemetryLogger {
|
|
|
134
134
|
*
|
|
135
135
|
* @param event - the event to send
|
|
136
136
|
* @param error - optional error object to log
|
|
137
|
-
* @param logLevel - optional level of the log.
|
|
138
|
-
*
|
|
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}.
|
|
139
139
|
*/
|
|
140
|
-
sendTelemetryEvent(event, error, logLevel
|
|
141
|
-
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));
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
144
|
* Send a telemetry event with the logger
|
|
145
145
|
*
|
|
146
146
|
* @param event - the event to send
|
|
147
147
|
* @param error - optional error object to log
|
|
148
|
-
* @param logLevel -
|
|
148
|
+
* @param logLevel - level of the log.
|
|
149
149
|
*/
|
|
150
150
|
sendTelemetryEventCore(event, error, logLevel) {
|
|
151
151
|
const newEvent = convertToBaseEvent(event);
|
|
@@ -171,22 +171,22 @@ class TelemetryLogger {
|
|
|
171
171
|
error: event.eventName,
|
|
172
172
|
...event,
|
|
173
173
|
category: "error",
|
|
174
|
-
}, error, core_interfaces_1.LogLevel.
|
|
174
|
+
}, error, core_interfaces_1.LogLevel.essential);
|
|
175
175
|
}
|
|
176
176
|
/**
|
|
177
177
|
* Send a performance telemetry event with the logger
|
|
178
178
|
*
|
|
179
179
|
* @param event - Event to send
|
|
180
180
|
* @param error - optional error object to log
|
|
181
|
-
* @param logLevel - optional level of the log.
|
|
182
|
-
*
|
|
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}.
|
|
183
183
|
*/
|
|
184
|
-
sendPerformanceEvent(event, error, logLevel
|
|
184
|
+
sendPerformanceEvent(event, error, logLevel) {
|
|
185
185
|
const perfEvent = {
|
|
186
186
|
...event,
|
|
187
187
|
category: event.category ?? "performance",
|
|
188
188
|
};
|
|
189
|
-
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));
|
|
190
190
|
}
|
|
191
191
|
prepareEvent(event) {
|
|
192
192
|
const includeErrorProps = event.category === "error" || event.error !== undefined;
|
|
@@ -368,8 +368,8 @@ class ChildLogger extends TelemetryLogger {
|
|
|
368
368
|
return this.baseLogger.minLogLevel;
|
|
369
369
|
}
|
|
370
370
|
shouldFilterOutEvent(event, logLevel) {
|
|
371
|
-
const eventLogLevel = logLevel ?? core_interfaces_1.LogLevel.
|
|
372
|
-
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;
|
|
373
373
|
// Filter out in case event log level is below what is wanted in config.
|
|
374
374
|
return eventLogLevel < configLogLevel;
|
|
375
375
|
}
|
|
@@ -382,7 +382,7 @@ class ChildLogger extends TelemetryLogger {
|
|
|
382
382
|
if (this.shouldFilterOutEvent(event, logLevel)) {
|
|
383
383
|
return;
|
|
384
384
|
}
|
|
385
|
-
this.baseLogger.send(this.prepareEvent(event), logLevel);
|
|
385
|
+
this.baseLogger.send(this.prepareEvent(event), logLevel ?? core_interfaces_1.LogLevel.essential);
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
exports.ChildLogger = ChildLogger;
|
|
@@ -425,7 +425,7 @@ class MultiSinkLogger extends TelemetryLogger {
|
|
|
425
425
|
}
|
|
426
426
|
super(namespace, realProperties);
|
|
427
427
|
this.loggers = loggers;
|
|
428
|
-
this._minLogLevelOfAllLoggers = core_interfaces_1.LogLevel.
|
|
428
|
+
this._minLogLevelOfAllLoggers = core_interfaces_1.LogLevel.info;
|
|
429
429
|
this.calculateMinLogLevel();
|
|
430
430
|
}
|
|
431
431
|
get minLogLevel() {
|
|
@@ -435,7 +435,7 @@ class MultiSinkLogger extends TelemetryLogger {
|
|
|
435
435
|
if (this.loggers.length > 0) {
|
|
436
436
|
const logLevels = [];
|
|
437
437
|
for (const logger of this.loggers) {
|
|
438
|
-
logLevels.push(logger.minLogLevel ?? core_interfaces_1.LogLevel.
|
|
438
|
+
logLevels.push(logger.minLogLevel ?? core_interfaces_1.LogLevel.info);
|
|
439
439
|
}
|
|
440
440
|
this._minLogLevelOfAllLoggers = Math.min(...logLevels);
|
|
441
441
|
}
|
|
@@ -456,10 +456,10 @@ class MultiSinkLogger extends TelemetryLogger {
|
|
|
456
456
|
*
|
|
457
457
|
* @param event - the event to send to all the registered logger
|
|
458
458
|
*/
|
|
459
|
-
send(event) {
|
|
459
|
+
send(event, logLevel) {
|
|
460
460
|
const newEvent = this.prepareEvent(event);
|
|
461
461
|
for (const logger of this.loggers) {
|
|
462
|
-
logger.send(newEvent);
|
|
462
|
+
logger.send(newEvent, logLevel ?? core_interfaces_1.LogLevel.essential);
|
|
463
463
|
}
|
|
464
464
|
}
|
|
465
465
|
}
|
|
@@ -478,10 +478,12 @@ class PerformanceEvent {
|
|
|
478
478
|
* @param recordHeapSize - whether or not to also record memory performance
|
|
479
479
|
* @param emitLogs - should this instance emit logs. If set to false, logs will not be emitted to the logger,
|
|
480
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.
|
|
481
483
|
* @returns An instance of {@link PerformanceEvent}
|
|
482
484
|
*/
|
|
483
|
-
static start(logger, event, markers, emitLogs = true) {
|
|
484
|
-
return new PerformanceEvent(extractTelemetryLoggerExt(logger), event, markers, emitLogs);
|
|
485
|
+
static start(logger, event, markers, emitLogs = true, logLevel) {
|
|
486
|
+
return new PerformanceEvent(extractTelemetryLoggerExt(logger), event, markers, emitLogs, logLevel);
|
|
485
487
|
}
|
|
486
488
|
/**
|
|
487
489
|
* Measure a synchronous task
|
|
@@ -491,6 +493,8 @@ class PerformanceEvent {
|
|
|
491
493
|
* @param markers - See {@link IPerformanceEventMarkers}
|
|
492
494
|
* @param sampleThreshold - events with the same name and category will be sent to the logger
|
|
493
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.
|
|
494
498
|
* @returns The results of the executed task
|
|
495
499
|
*
|
|
496
500
|
* @remarks Note that if the "same" event (category + eventName) would be emitted by different
|
|
@@ -498,8 +502,8 @@ class PerformanceEvent {
|
|
|
498
502
|
* so executing either of the tasks will increase the internal counter and they
|
|
499
503
|
* effectively "share" the sampling rate for the event.
|
|
500
504
|
*/
|
|
501
|
-
static timedExec(logger, event, callback, markers, sampleThreshold = 1) {
|
|
502
|
-
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);
|
|
503
507
|
try {
|
|
504
508
|
const ret = callback(perfEvent);
|
|
505
509
|
perfEvent.autoEnd();
|
|
@@ -519,6 +523,8 @@ class PerformanceEvent {
|
|
|
519
523
|
* @param recordHeapSize - whether or not to also record memory performance
|
|
520
524
|
* @param sampleThreshold - events with the same name and category will be sent to the logger
|
|
521
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.
|
|
522
528
|
* @returns The results of the executed task
|
|
523
529
|
*
|
|
524
530
|
* @remarks Note that if the "same" event (category + eventName) would be emitted by different
|
|
@@ -526,8 +532,8 @@ class PerformanceEvent {
|
|
|
526
532
|
* so executing either of the tasks will increase the internal counter and they
|
|
527
533
|
* effectively "share" the sampling rate for the event.
|
|
528
534
|
*/
|
|
529
|
-
static async timedExecAsync(logger, event, callback, markers, sampleThreshold = 1) {
|
|
530
|
-
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);
|
|
531
537
|
try {
|
|
532
538
|
const ret = await callback(perfEvent);
|
|
533
539
|
perfEvent.autoEnd();
|
|
@@ -541,10 +547,11 @@ class PerformanceEvent {
|
|
|
541
547
|
get duration() {
|
|
542
548
|
return (0, client_utils_1.performanceNow)() - this.startTime;
|
|
543
549
|
}
|
|
544
|
-
constructor(logger, event, markers = { end: true, cancel: "generic" }, emitLogs = true) {
|
|
550
|
+
constructor(logger, event, markers = { end: true, cancel: "generic" }, emitLogs = true, logLevel) {
|
|
545
551
|
this.logger = logger;
|
|
546
552
|
this.markers = markers;
|
|
547
553
|
this.emitLogs = emitLogs;
|
|
554
|
+
this.logLevel = logLevel;
|
|
548
555
|
this.startTime = (0, client_utils_1.performanceNow)();
|
|
549
556
|
this.event = { ...event };
|
|
550
557
|
if (this.markers.start) {
|
|
@@ -607,7 +614,7 @@ class PerformanceEvent {
|
|
|
607
614
|
if (eventNameSuffix !== "start") {
|
|
608
615
|
event.duration = this.duration;
|
|
609
616
|
}
|
|
610
|
-
this.logger.sendPerformanceEvent(event, error);
|
|
617
|
+
this.logger.sendPerformanceEvent(event, error, this.logLevel);
|
|
611
618
|
}
|
|
612
619
|
static shouldReport(event, sampleThreshold) {
|
|
613
620
|
const eventKey = `.${event.category}.${event.eventName}`;
|