@fluidframework/telemetry-utils 2.0.0-internal.5.4.0 → 2.0.0-internal.6.0.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 +21 -0
- package/dist/config.js +25 -31
- package/dist/config.js.map +1 -1
- package/dist/errorLogging.js +16 -10
- package/dist/errorLogging.js.map +1 -1
- package/dist/fluidErrorBase.js +7 -7
- package/dist/fluidErrorBase.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -9
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +1 -56
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +42 -129
- package/dist/logger.js.map +1 -1
- package/dist/mockLogger.d.ts +3 -5
- package/dist/mockLogger.d.ts.map +1 -1
- package/dist/mockLogger.js +6 -15
- package/dist/mockLogger.js.map +1 -1
- package/dist/sampledTelemetryHelper.js +8 -5
- package/dist/sampledTelemetryHelper.js.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/lib/config.js +25 -31
- package/lib/config.js.map +1 -1
- package/lib/errorLogging.js +16 -10
- package/lib/errorLogging.js.map +1 -1
- package/lib/fluidErrorBase.js +7 -7
- package/lib/fluidErrorBase.js.map +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/lib/logger.d.ts +1 -56
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +41 -125
- package/lib/logger.js.map +1 -1
- package/lib/mockLogger.d.ts +3 -5
- package/lib/mockLogger.d.ts.map +1 -1
- package/lib/mockLogger.js +7 -16
- package/lib/mockLogger.js.map +1 -1
- package/lib/sampledTelemetryHelper.js +8 -5
- package/lib/sampledTelemetryHelper.js.map +1 -1
- package/lib/utils.js +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +39 -6
- package/src/index.ts +0 -7
- package/src/logger.ts +11 -98
- package/src/mockLogger.ts +8 -8
- package/dist/debugLogger.d.ts +0 -39
- package/dist/debugLogger.d.ts.map +0 -1
- package/dist/debugLogger.js +0 -105
- package/dist/debugLogger.js.map +0 -1
- package/lib/debugLogger.d.ts +0 -39
- package/lib/debugLogger.d.ts.map +0 -1
- package/lib/debugLogger.js +0 -101
- package/lib/debugLogger.js.map +0 -1
- package/src/debugLogger.ts +0 -138
package/lib/errorLogging.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorLogging.js","sourceRoot":"","sources":["../src/errorLogging.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EACN,kBAAkB,EAElB,YAAY,EACZ,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;AAO1B,wEAAwE;AACxE,MAAM,eAAe,GAAG,CAAC,KAAU,EAAW,EAAE;IAC/C,OAAO,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AAC7E,CAAC,CAAC;AAEF,sEAAsE;AACtE,MAAM,UAAU,6BAA6B,CAAC,KAAU,EAAE,aAAsB;IAC/E,MAAM,sBAAsB,GAAG,CAAC,KAAa,EAAE,SAAkB,EAAE,EAAE;QACpE,IAAI,CAAC,aAAa,EAAE;YACnB,OAAO,KAAK,CAAC;SACb;QACD,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACtC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,uCAAuC;QAC5D,IAAI,SAAS,KAAK,SAAS,EAAE;YAC5B,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,oBAAoB;SACpD;QACD,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,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BAAgB,IACrC;IACH,CAAC;CACD;AAED,8DAA8D;AAC9D,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CAAC;AACpD,MAAM,sBAAuB,SAAQ,YAAY;IAKhD,YAAY,UAAsD;QACjE,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAL3B,2EAA2E;QAC3E,2EAA2E;QAC3E,cAAS,GAAG,qBAAqB,CAAC;QAKjC,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE;YACnC,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;SACvC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tILoggingError,\n\tITaggedTelemetryPropertyType,\n\tITelemetryProperties,\n\tTelemetryEventPropertyType,\n} from \"@fluidframework/core-interfaces\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n\thasErrorInstanceId,\n\tIFluidErrorBase,\n\tisFluidError,\n\tisValidLegacyError,\n} from \"./fluidErrorBase\";\nimport {\n\tITaggedTelemetryPropertyTypeExt,\n\tITelemetryLoggerExt,\n\tTelemetryEventPropertyTypeExt,\n} from \"./telemetryTypes\";\n\n/** @returns true if value is an object but neither null nor an array */\nconst isRegularObject = (value: any): boolean => {\n\treturn value !== null && !Array.isArray(value) && typeof value === \"object\";\n};\n\n/** Inspect the given error for common \"safe\" props and return them */\nexport function extractLogSafeErrorProperties(error: any, sanitizeStack: boolean) {\n\tconst removeMessageFromStack = (stack: string, errorName?: string) => {\n\t\tif (!sanitizeStack) {\n\t\t\treturn stack;\n\t\t}\n\t\tconst stackFrames = stack.split(\"\\n\");\n\t\tstackFrames.shift(); // Remove \"[ErrorName]: [ErrorMessage]\"\n\t\tif (errorName !== undefined) {\n\t\t\tstackFrames.unshift(errorName); // Add \"[ErrorName]\"\n\t\t}\n\t\treturn stackFrames.join(\"\\n\");\n\t};\n\n\tconst message = typeof error?.message === \"string\" ? (error.message as string) : String(error);\n\n\tconst safeProps: { message: string; errorType?: string; stack?: string } = {\n\t\tmessage,\n\t};\n\n\tif (isRegularObject(error)) {\n\t\tconst { errorType, stack, name } = error;\n\n\t\tif (typeof errorType === \"string\") {\n\t\t\tsafeProps.errorType = errorType;\n\t\t}\n\n\t\tif (typeof stack === \"string\") {\n\t\t\tconst errorName = typeof name === \"string\" ? name : undefined;\n\t\t\tsafeProps.stack = removeMessageFromStack(stack, errorName);\n\t\t}\n\t}\n\n\treturn safeProps;\n}\n\n/** type guard for ILoggingError interface */\nexport const isILoggingError = (x: any): x is ILoggingError =>\n\ttypeof x?.getTelemetryProperties === \"function\";\n\n/** Copy props from source onto target, but do not overwrite an existing prop that matches */\nfunction copyProps(target: ITelemetryProperties | LoggingError, source: ITelemetryProperties) {\n\tfor (const key of Object.keys(source)) {\n\t\tif (target[key] === undefined) {\n\t\t\ttarget[key] = source[key];\n\t\t}\n\t}\n}\n\n/** Metadata to annotate an error object when annotating or normalizing it */\nexport interface IFluidErrorAnnotations {\n\t/** Telemetry props to log with the error */\n\tprops?: ITelemetryProperties;\n}\n\n/** For backwards compatibility with pre-errorInstanceId valid errors */\nfunction patchLegacyError(\n\tlegacyError: Omit<IFluidErrorBase, \"errorInstanceId\">,\n): asserts legacyError is IFluidErrorBase {\n\tconst patchMe: { -readonly [P in \"errorInstanceId\"]?: IFluidErrorBase[P] } = legacyError as any;\n\tif (patchMe.errorInstanceId === undefined) {\n\t\tpatchMe.errorInstanceId = uuid();\n\t}\n}\n\n/**\n * Normalize the given error yielding a valid Fluid Error\n * @returns A valid Fluid Error with any provided annotations applied\n * @param error - The error to normalize\n * @param annotations - Annotations to apply to the normalized error\n */\nexport function normalizeError(\n\terror: unknown,\n\tannotations: IFluidErrorAnnotations = {},\n): IFluidErrorBase {\n\t// Back-compat, while IFluidErrorBase is rolled out\n\tif (isValidLegacyError(error)) {\n\t\tpatchLegacyError(error);\n\t}\n\n\tif (isFluidError(error)) {\n\t\t// We can simply add the telemetry props to the error and return it\n\t\terror.addTelemetryProperties(annotations.props ?? {});\n\t\treturn error;\n\t}\n\n\t// We have to construct a new Fluid Error, copying safe properties over\n\tconst { message, stack } = extractLogSafeErrorProperties(error, false /* sanitizeStack */);\n\tconst fluidError: IFluidErrorBase = new NormalizedLoggingError({\n\t\tmessage,\n\t\tstack,\n\t});\n\n\t// We need to preserve these properties which are used in a non-typesafe way throughout driver code (see #8743)\n\t// Anywhere they are set should be on a valid Fluid Error that would have been returned above,\n\t// but we can't prove it with the types, so adding this defensive measure.\n\tif (typeof error === \"object\" && error !== null) {\n\t\tconst maybeHasRetry: Partial<Record<\"canRetry\" | \"retryAfterSeconds\", unknown>> = error;\n\t\tlet retryProps: Partial<Record<\"canRetry\" | \"retryAfterSeconds\", unknown>> | undefined;\n\t\tif (\"canRetry\" in error) {\n\t\t\tretryProps ??= {};\n\t\t\tretryProps.canRetry = maybeHasRetry.canRetry;\n\t\t}\n\t\tif (\"retryAfterSeconds\" in error) {\n\t\t\tretryProps ??= {};\n\t\t\tretryProps.retryAfterSeconds = maybeHasRetry.retryAfterSeconds;\n\t\t}\n\t\tif (retryProps !== undefined) {\n\t\t\tObject.assign(fluidError, retryProps);\n\t\t}\n\t}\n\n\tif (typeof error !== \"object\") {\n\t\t// This is only interesting for non-objects\n\t\tfluidError.addTelemetryProperties({ typeofError: typeof error });\n\t}\n\n\tconst errorTelemetryProps = LoggingError.typeCheck(error)\n\t\t? error.getTelemetryProperties()\n\t\t: { untrustedOrigin: 1 }; // This will let us filter errors that did not originate from our own codebase\n\n\tfluidError.addTelemetryProperties({\n\t\t...errorTelemetryProps,\n\t\t...annotations.props,\n\t});\n\n\treturn fluidError;\n}\n\nlet stackPopulatedOnCreation: boolean | undefined;\n\n/**\n * The purpose of this function is to provide ability to capture stack context quickly.\n * Accessing new Error().stack is slow, and the slowest part is accessing stack property itself.\n * There are scenarios where we generate error with stack, but error is handled in most cases and\n * stack property is not accessed.\n * For such cases it's better to not read stack property right away, but rather delay it until / if it's needed\n * Some browsers will populate stack right away, others require throwing Error, so we do auto-detection on the fly.\n * @returns Error object that has stack populated.\n */\nexport function generateErrorWithStack(): Error {\n\tconst err = new Error(\"<<generated stack>>\");\n\n\tif (stackPopulatedOnCreation === undefined) {\n\t\tstackPopulatedOnCreation = err.stack !== undefined;\n\t}\n\n\tif (stackPopulatedOnCreation) {\n\t\treturn err;\n\t}\n\n\ttry {\n\t\tthrow err;\n\t} catch (e) {\n\t\treturn e as Error;\n\t}\n}\n\nexport function generateStack(): string | undefined {\n\treturn generateErrorWithStack().stack;\n}\n\n/**\n * Create a new error using newErrorFn, wrapping and caused by the given unknown error.\n * Copies the inner error's stack, errorInstanceId and telemetry props over to the new error if present\n * @param innerError - An error from untrusted/unknown origins\n * @param newErrorFn - callback that will create a new error given the original error's message\n * @returns A new error object \"wrapping\" the given error\n */\nexport function wrapError<T extends LoggingError>(\n\tinnerError: unknown,\n\tnewErrorFn: (message: string) => T,\n): T {\n\tconst { message, stack } = extractLogSafeErrorProperties(innerError, false /* sanitizeStack */);\n\n\tconst newError = newErrorFn(message);\n\n\tif (stack !== undefined) {\n\t\toverwriteStack(newError, stack);\n\t}\n\n\t// Mark external errors with untrustedOrigin flag\n\tif (isExternalError(innerError)) {\n\t\tnewError.addTelemetryProperties({ untrustedOrigin: 1 });\n\t}\n\n\t// Reuse errorInstanceId\n\tif (hasErrorInstanceId(innerError)) {\n\t\tnewError.overwriteErrorInstanceId(innerError.errorInstanceId);\n\n\t\t// For \"back-compat\" in the logs\n\t\tnewError.addTelemetryProperties({ innerErrorInstanceId: innerError.errorInstanceId });\n\t}\n\n\t// Lastly, copy over all other telemetry properties. Note these will not overwrite existing properties\n\t// This will include the untrustedOrigin property if the inner error itself was created from an external error\n\tif (isILoggingError(innerError)) {\n\t\tnewError.addTelemetryProperties(innerError.getTelemetryProperties());\n\t}\n\n\treturn newError;\n}\n\n/** The same as wrapError, but also logs the innerError, including the wrapping error's instance id */\nexport function wrapErrorAndLog<T extends LoggingError>(\n\tinnerError: unknown,\n\tnewErrorFn: (message: string) => T,\n\tlogger: ITelemetryLoggerExt,\n) {\n\tconst newError = wrapError(innerError, newErrorFn);\n\n\t// This will match innerError.errorInstanceId if present (see wrapError)\n\tconst errorInstanceId = newError.errorInstanceId;\n\n\t// For \"back-compat\" in the logs\n\tconst wrappedByErrorInstanceId = errorInstanceId;\n\n\tlogger.sendTelemetryEvent(\n\t\t{\n\t\t\teventName: \"WrapError\",\n\t\t\terrorInstanceId,\n\t\t\twrappedByErrorInstanceId,\n\t\t},\n\t\tinnerError,\n\t);\n\n\treturn newError;\n}\n\nfunction overwriteStack(error: IFluidErrorBase | LoggingError, stack: string) {\n\t// supposedly setting stack on an Error can throw.\n\ttry {\n\t\tObject.assign(error, { stack });\n\t} catch (errorSettingStack) {\n\t\terror.addTelemetryProperties({ stack2: stack });\n\t}\n}\n\n/**\n * True for any error object that is an (optionally normalized) external error\n * False for any error we created and raised within the FF codebase via LoggingError base class,\n * or wrapped in a well-known error type\n */\nexport function isExternalError(e: any): boolean {\n\t// LoggingErrors are an internal FF error type. However, an external error can be converted\n\t// into a LoggingError if it is normalized. In this case we must use the untrustedOrigin flag to\n\t// determine whether the original error was infact external.\n\tif (LoggingError.typeCheck(e)) {\n\t\tif ((e as NormalizedLoggingError).errorType === NORMALIZED_ERROR_TYPE) {\n\t\t\treturn e.getTelemetryProperties().untrustedOrigin === 1;\n\t\t}\n\t\treturn false;\n\t}\n\treturn !isValidLegacyError(e);\n}\n\n/**\n * Type guard to identify if a particular telemetry property appears to be a tagged telemetry property\n */\nexport function isTaggedTelemetryPropertyValue(\n\tx: ITaggedTelemetryPropertyTypeExt | TelemetryEventPropertyTypeExt,\n): x is ITaggedTelemetryPropertyType | ITaggedTelemetryPropertyTypeExt {\n\treturn typeof (x as any)?.tag === \"string\";\n}\n\n/**\n * Filter serializable telemetry properties\n * @param x - any telemetry prop\n * @returns - as-is if x is primitive. returns stringified if x is an array of primitive.\n * otherwise returns null since this is what we support at the moment.\n */\nfunction filterValidTelemetryProps(x: any, key: string): TelemetryEventPropertyType {\n\tif (Array.isArray(x) && x.every((val) => isTelemetryEventPropertyValue(val))) {\n\t\treturn JSON.stringify(x);\n\t}\n\tif (isTelemetryEventPropertyValue(x)) {\n\t\treturn x;\n\t}\n\t// We don't support logging arbitrary objects\n\tconsole.error(`UnSupported Format of Logging Error Property for key ${key}:`, x);\n\treturn \"REDACTED (arbitrary object)\";\n}\n\n// checking type of x, returns false if x is null\nfunction isTelemetryEventPropertyValue(x: any): x is TelemetryEventPropertyType {\n\tswitch (typeof x) {\n\t\tcase \"string\":\n\t\tcase \"number\":\n\t\tcase \"boolean\":\n\t\tcase \"undefined\":\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n/**\n * Walk an object's enumerable properties to find those fit for telemetry.\n */\nfunction getValidTelemetryProps(obj: any, keysToOmit: Set<string>): ITelemetryProperties {\n\tconst props: ITelemetryProperties = {};\n\tfor (const key of Object.keys(obj)) {\n\t\tif (keysToOmit.has(key)) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst val = obj[key];\n\n\t\t// ensure only valid props get logged, since props of logging error could be in any shape\n\t\tif (isTaggedTelemetryPropertyValue(val)) {\n\t\t\tprops[key] = {\n\t\t\t\tvalue: filterValidTelemetryProps(val.value, key),\n\t\t\t\ttag: val.tag,\n\t\t\t};\n\t\t} else {\n\t\t\tprops[key] = filterValidTelemetryProps(val, key);\n\t\t}\n\t}\n\treturn props;\n}\n\n/**\n * Borrowed from\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value#examples}\n * Avoids runtime errors with circular references.\n * Not ideal, as will cut values that are not necessarily circular references.\n * Could be improved by implementing Node's util.inspect() for browser (minus all the coloring code)\n */\nexport const getCircularReplacer = () => {\n\tconst seen = new WeakSet();\n\treturn (key: string, value: any): any => {\n\t\tif (typeof value === \"object\" && value !== null) {\n\t\t\tif (seen.has(value)) {\n\t\t\t\treturn \"<removed/circular>\";\n\t\t\t}\n\t\t\tseen.add(value);\n\t\t}\n\t\treturn value;\n\t};\n};\n\n/**\n * Base class for \"trusted\" errors we create, whose properties can generally be logged to telemetry safely.\n * All properties set on the object, or passed in (via the constructor or addTelemetryProperties),\n * will be logged in accordance with their tag, if present.\n *\n * PLEASE take care to avoid setting sensitive data on this object without proper tagging!\n */\nexport class LoggingError\n\textends Error\n\timplements ILoggingError, Omit<IFluidErrorBase, \"errorType\">\n{\n\tprivate _errorInstanceId = uuid();\n\tget errorInstanceId() {\n\t\treturn this._errorInstanceId;\n\t}\n\toverwriteErrorInstanceId(id: string) {\n\t\tthis._errorInstanceId = id;\n\t}\n\n\t/** Back-compat to appease isFluidError typeguard in old code that may handle this error */\n\t// @ts-expect-error - This field shouldn't be referenced in the current version, but needs to exist at runtime.\n\tprivate readonly fluidErrorCode: \"-\" = \"-\";\n\n\t/**\n\t * Create a new LoggingError\n\t * @param message - Error message to use for Error base class\n\t * @param props - telemetry props to include on the error for when it's logged\n\t * @param omitPropsFromLogging - properties by name to omit from telemetry props\n\t */\n\tconstructor(\n\t\tmessage: string,\n\t\tprops?: ITelemetryProperties,\n\t\tprivate readonly omitPropsFromLogging: Set<string> = new Set(),\n\t) {\n\t\tsuper(message);\n\n\t\t// Don't log this list itself, or the private _errorInstanceId\n\t\tomitPropsFromLogging.add(\"omitPropsFromLogging\");\n\t\tomitPropsFromLogging.add(\"_errorInstanceId\");\n\n\t\tif (props) {\n\t\t\tthis.addTelemetryProperties(props);\n\t\t}\n\t}\n\n\t/**\n\t * Determines if a given object is an instance of a LoggingError\n\t * @param object - any object\n\t * @returns - true if the object is an instance of a LoggingError, false if not.\n\t */\n\tpublic static typeCheck(object: unknown): object is LoggingError {\n\t\tif (typeof object === \"object\" && object !== null) {\n\t\t\treturn (\n\t\t\t\ttypeof (object as LoggingError).addTelemetryProperties === \"function\" &&\n\t\t\t\ttypeof (object as LoggingError).getTelemetryProperties === \"function\" &&\n\t\t\t\ttypeof (object as LoggingError).errorInstanceId === \"string\"\n\t\t\t);\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Add additional properties to be logged\n\t */\n\tpublic addTelemetryProperties(props: ITelemetryProperties) {\n\t\tcopyProps(this, props);\n\t}\n\n\t/**\n\t * Get all properties fit to be logged to telemetry for this error\n\t */\n\tpublic getTelemetryProperties(): ITelemetryProperties {\n\t\tconst taggableProps = getValidTelemetryProps(this, this.omitPropsFromLogging);\n\t\t// Include non-enumerable props that are not returned by getValidTelemetryProps\n\t\treturn {\n\t\t\t...taggableProps,\n\t\t\tstack: this.stack,\n\t\t\tmessage: this.message,\n\t\t\terrorInstanceId: this._errorInstanceId,\n\t\t};\n\t}\n}\n\n/** The Error class used when normalizing an external error */\nexport const NORMALIZED_ERROR_TYPE = \"genericError\";\nclass NormalizedLoggingError extends LoggingError {\n\t// errorType \"genericError\" is used as a default value throughout the code.\n\t// Note that this matches ContainerErrorType/DriverErrorType's genericError\n\terrorType = NORMALIZED_ERROR_TYPE;\n\n\tconstructor(errorProps: Pick<IFluidErrorBase, \"message\" | \"stack\">) {\n\t\tsuper(errorProps.message);\n\n\t\tif (errorProps.stack !== undefined) {\n\t\t\toverwriteStack(this, errorProps.stack);\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"errorLogging.js","sourceRoot":"","sources":["../src/errorLogging.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EACN,kBAAkB,EAElB,YAAY,EACZ,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;AAO1B,wEAAwE;AACxE,MAAM,eAAe,GAAG,CAAC,KAAU,EAAW,EAAE;IAC/C,OAAO,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AAC7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,CAAC;IACd,CAAC;IAED;;OAEG;IACI,sBAAsB,CAAC,KAA2B;QACxD,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACxB,CAAC;IAED;;OAEG;IACI,sBAAsB;QAC5B,MAAM,aAAa,GAAG,sBAAsB,CAAC,IAAI,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC9E,+EAA+E;QAC/E,OAAO;YACN,GAAG,aAAa;YAChB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,eAAe,EAAE,IAAI,CAAC,gBAAgB;SACtC,CAAC;IACH,CAAC;CACD;AAED,8DAA8D;AAC9D,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CAAC;AACpD,MAAM,sBAAuB,SAAQ,YAAY;IAKhD,YAAY,UAAsD;QACjE,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAL3B,2EAA2E;QAC3E,2EAA2E;QAC3E,cAAS,GAAG,qBAAqB,CAAC;QAKjC,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE;YACnC,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;SACvC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tILoggingError,\n\tITaggedTelemetryPropertyType,\n\tITelemetryProperties,\n\tTelemetryEventPropertyType,\n} from \"@fluidframework/core-interfaces\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n\thasErrorInstanceId,\n\tIFluidErrorBase,\n\tisFluidError,\n\tisValidLegacyError,\n} from \"./fluidErrorBase\";\nimport {\n\tITaggedTelemetryPropertyTypeExt,\n\tITelemetryLoggerExt,\n\tTelemetryEventPropertyTypeExt,\n} from \"./telemetryTypes\";\n\n/** @returns true if value is an object but neither null nor an array */\nconst isRegularObject = (value: any): boolean => {\n\treturn value !== null && !Array.isArray(value) && typeof value === \"object\";\n};\n\n/** Inspect the given error for common \"safe\" props and return them */\nexport function extractLogSafeErrorProperties(error: any, sanitizeStack: boolean) {\n\tconst removeMessageFromStack = (stack: string, errorName?: string) => {\n\t\tif (!sanitizeStack) {\n\t\t\treturn stack;\n\t\t}\n\t\tconst stackFrames = stack.split(\"\\n\");\n\t\tstackFrames.shift(); // Remove \"[ErrorName]: [ErrorMessage]\"\n\t\tif (errorName !== undefined) {\n\t\t\tstackFrames.unshift(errorName); // Add \"[ErrorName]\"\n\t\t}\n\t\treturn stackFrames.join(\"\\n\");\n\t};\n\n\tconst message = typeof error?.message === \"string\" ? (error.message as string) : String(error);\n\n\tconst safeProps: { message: string; errorType?: string; stack?: string } = {\n\t\tmessage,\n\t};\n\n\tif (isRegularObject(error)) {\n\t\tconst { errorType, stack, name } = error;\n\n\t\tif (typeof errorType === \"string\") {\n\t\t\tsafeProps.errorType = errorType;\n\t\t}\n\n\t\tif (typeof stack === \"string\") {\n\t\t\tconst errorName = typeof name === \"string\" ? name : undefined;\n\t\t\tsafeProps.stack = removeMessageFromStack(stack, errorName);\n\t\t}\n\t}\n\n\treturn safeProps;\n}\n\n/** type guard for ILoggingError interface */\nexport const isILoggingError = (x: any): x is ILoggingError =>\n\ttypeof x?.getTelemetryProperties === \"function\";\n\n/** Copy props from source onto target, but do not overwrite an existing prop that matches */\nfunction copyProps(target: ITelemetryProperties | LoggingError, source: ITelemetryProperties) {\n\tfor (const key of Object.keys(source)) {\n\t\tif (target[key] === undefined) {\n\t\t\ttarget[key] = source[key];\n\t\t}\n\t}\n}\n\n/** Metadata to annotate an error object when annotating or normalizing it */\nexport interface IFluidErrorAnnotations {\n\t/** Telemetry props to log with the error */\n\tprops?: ITelemetryProperties;\n}\n\n/** For backwards compatibility with pre-errorInstanceId valid errors */\nfunction patchLegacyError(\n\tlegacyError: Omit<IFluidErrorBase, \"errorInstanceId\">,\n): asserts legacyError is IFluidErrorBase {\n\tconst patchMe: { -readonly [P in \"errorInstanceId\"]?: IFluidErrorBase[P] } = legacyError as any;\n\tif (patchMe.errorInstanceId === undefined) {\n\t\tpatchMe.errorInstanceId = uuid();\n\t}\n}\n\n/**\n * Normalize the given error yielding a valid Fluid Error\n * @returns A valid Fluid Error with any provided annotations applied\n * @param error - The error to normalize\n * @param annotations - Annotations to apply to the normalized error\n */\nexport function normalizeError(\n\terror: unknown,\n\tannotations: IFluidErrorAnnotations = {},\n): IFluidErrorBase {\n\t// Back-compat, while IFluidErrorBase is rolled out\n\tif (isValidLegacyError(error)) {\n\t\tpatchLegacyError(error);\n\t}\n\n\tif (isFluidError(error)) {\n\t\t// We can simply add the telemetry props to the error and return it\n\t\terror.addTelemetryProperties(annotations.props ?? {});\n\t\treturn error;\n\t}\n\n\t// We have to construct a new Fluid Error, copying safe properties over\n\tconst { message, stack } = extractLogSafeErrorProperties(error, false /* sanitizeStack */);\n\tconst fluidError: IFluidErrorBase = new NormalizedLoggingError({\n\t\tmessage,\n\t\tstack,\n\t});\n\n\t// We need to preserve these properties which are used in a non-typesafe way throughout driver code (see #8743)\n\t// Anywhere they are set should be on a valid Fluid Error that would have been returned above,\n\t// but we can't prove it with the types, so adding this defensive measure.\n\tif (typeof error === \"object\" && error !== null) {\n\t\tconst maybeHasRetry: Partial<Record<\"canRetry\" | \"retryAfterSeconds\", unknown>> = error;\n\t\tlet retryProps: Partial<Record<\"canRetry\" | \"retryAfterSeconds\", unknown>> | undefined;\n\t\tif (\"canRetry\" in error) {\n\t\t\tretryProps ??= {};\n\t\t\tretryProps.canRetry = maybeHasRetry.canRetry;\n\t\t}\n\t\tif (\"retryAfterSeconds\" in error) {\n\t\t\tretryProps ??= {};\n\t\t\tretryProps.retryAfterSeconds = maybeHasRetry.retryAfterSeconds;\n\t\t}\n\t\tif (retryProps !== undefined) {\n\t\t\tObject.assign(fluidError, retryProps);\n\t\t}\n\t}\n\n\tif (typeof error !== \"object\") {\n\t\t// This is only interesting for non-objects\n\t\tfluidError.addTelemetryProperties({ typeofError: typeof error });\n\t}\n\n\tconst errorTelemetryProps = LoggingError.typeCheck(error)\n\t\t? error.getTelemetryProperties()\n\t\t: { untrustedOrigin: 1 }; // This will let us filter errors that did not originate from our own codebase\n\n\tfluidError.addTelemetryProperties({\n\t\t...errorTelemetryProps,\n\t\t...annotations.props,\n\t});\n\n\treturn fluidError;\n}\n\nlet stackPopulatedOnCreation: boolean | undefined;\n\n/**\n * The purpose of this function is to provide ability to capture stack context quickly.\n * Accessing new Error().stack is slow, and the slowest part is accessing stack property itself.\n * There are scenarios where we generate error with stack, but error is handled in most cases and\n * stack property is not accessed.\n * For such cases it's better to not read stack property right away, but rather delay it until / if it's needed\n * Some browsers will populate stack right away, others require throwing Error, so we do auto-detection on the fly.\n * @returns Error object that has stack populated.\n */\nexport function generateErrorWithStack(): Error {\n\tconst err = new Error(\"<<generated stack>>\");\n\n\tif (stackPopulatedOnCreation === undefined) {\n\t\tstackPopulatedOnCreation = err.stack !== undefined;\n\t}\n\n\tif (stackPopulatedOnCreation) {\n\t\treturn err;\n\t}\n\n\ttry {\n\t\tthrow err;\n\t} catch (e) {\n\t\treturn e as Error;\n\t}\n}\n\nexport function generateStack(): string | undefined {\n\treturn generateErrorWithStack().stack;\n}\n\n/**\n * Create a new error using newErrorFn, wrapping and caused by the given unknown error.\n * Copies the inner error's stack, errorInstanceId and telemetry props over to the new error if present\n * @param innerError - An error from untrusted/unknown origins\n * @param newErrorFn - callback that will create a new error given the original error's message\n * @returns A new error object \"wrapping\" the given error\n */\nexport function wrapError<T extends LoggingError>(\n\tinnerError: unknown,\n\tnewErrorFn: (message: string) => T,\n): T {\n\tconst { message, stack } = extractLogSafeErrorProperties(innerError, false /* sanitizeStack */);\n\n\tconst newError = newErrorFn(message);\n\n\tif (stack !== undefined) {\n\t\toverwriteStack(newError, stack);\n\t}\n\n\t// Mark external errors with untrustedOrigin flag\n\tif (isExternalError(innerError)) {\n\t\tnewError.addTelemetryProperties({ untrustedOrigin: 1 });\n\t}\n\n\t// Reuse errorInstanceId\n\tif (hasErrorInstanceId(innerError)) {\n\t\tnewError.overwriteErrorInstanceId(innerError.errorInstanceId);\n\n\t\t// For \"back-compat\" in the logs\n\t\tnewError.addTelemetryProperties({ innerErrorInstanceId: innerError.errorInstanceId });\n\t}\n\n\t// Lastly, copy over all other telemetry properties. Note these will not overwrite existing properties\n\t// This will include the untrustedOrigin property if the inner error itself was created from an external error\n\tif (isILoggingError(innerError)) {\n\t\tnewError.addTelemetryProperties(innerError.getTelemetryProperties());\n\t}\n\n\treturn newError;\n}\n\n/** The same as wrapError, but also logs the innerError, including the wrapping error's instance id */\nexport function wrapErrorAndLog<T extends LoggingError>(\n\tinnerError: unknown,\n\tnewErrorFn: (message: string) => T,\n\tlogger: ITelemetryLoggerExt,\n) {\n\tconst newError = wrapError(innerError, newErrorFn);\n\n\t// This will match innerError.errorInstanceId if present (see wrapError)\n\tconst errorInstanceId = newError.errorInstanceId;\n\n\t// For \"back-compat\" in the logs\n\tconst wrappedByErrorInstanceId = errorInstanceId;\n\n\tlogger.sendTelemetryEvent(\n\t\t{\n\t\t\teventName: \"WrapError\",\n\t\t\terrorInstanceId,\n\t\t\twrappedByErrorInstanceId,\n\t\t},\n\t\tinnerError,\n\t);\n\n\treturn newError;\n}\n\nfunction overwriteStack(error: IFluidErrorBase | LoggingError, stack: string) {\n\t// supposedly setting stack on an Error can throw.\n\ttry {\n\t\tObject.assign(error, { stack });\n\t} catch (errorSettingStack) {\n\t\terror.addTelemetryProperties({ stack2: stack });\n\t}\n}\n\n/**\n * True for any error object that is an (optionally normalized) external error\n * False for any error we created and raised within the FF codebase via LoggingError base class,\n * or wrapped in a well-known error type\n */\nexport function isExternalError(e: any): boolean {\n\t// LoggingErrors are an internal FF error type. However, an external error can be converted\n\t// into a LoggingError if it is normalized. In this case we must use the untrustedOrigin flag to\n\t// determine whether the original error was infact external.\n\tif (LoggingError.typeCheck(e)) {\n\t\tif ((e as NormalizedLoggingError).errorType === NORMALIZED_ERROR_TYPE) {\n\t\t\treturn e.getTelemetryProperties().untrustedOrigin === 1;\n\t\t}\n\t\treturn false;\n\t}\n\treturn !isValidLegacyError(e);\n}\n\n/**\n * Type guard to identify if a particular telemetry property appears to be a tagged telemetry property\n */\nexport function isTaggedTelemetryPropertyValue(\n\tx: ITaggedTelemetryPropertyTypeExt | TelemetryEventPropertyTypeExt,\n): x is ITaggedTelemetryPropertyType | ITaggedTelemetryPropertyTypeExt {\n\treturn typeof (x as any)?.tag === \"string\";\n}\n\n/**\n * Filter serializable telemetry properties\n * @param x - any telemetry prop\n * @returns - as-is if x is primitive. returns stringified if x is an array of primitive.\n * otherwise returns null since this is what we support at the moment.\n */\nfunction filterValidTelemetryProps(x: any, key: string): TelemetryEventPropertyType {\n\tif (Array.isArray(x) && x.every((val) => isTelemetryEventPropertyValue(val))) {\n\t\treturn JSON.stringify(x);\n\t}\n\tif (isTelemetryEventPropertyValue(x)) {\n\t\treturn x;\n\t}\n\t// We don't support logging arbitrary objects\n\tconsole.error(`UnSupported Format of Logging Error Property for key ${key}:`, x);\n\treturn \"REDACTED (arbitrary object)\";\n}\n\n// checking type of x, returns false if x is null\nfunction isTelemetryEventPropertyValue(x: any): x is TelemetryEventPropertyType {\n\tswitch (typeof x) {\n\t\tcase \"string\":\n\t\tcase \"number\":\n\t\tcase \"boolean\":\n\t\tcase \"undefined\":\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n/**\n * Walk an object's enumerable properties to find those fit for telemetry.\n */\nfunction getValidTelemetryProps(obj: any, keysToOmit: Set<string>): ITelemetryProperties {\n\tconst props: ITelemetryProperties = {};\n\tfor (const key of Object.keys(obj)) {\n\t\tif (keysToOmit.has(key)) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst val = obj[key];\n\n\t\t// ensure only valid props get logged, since props of logging error could be in any shape\n\t\tif (isTaggedTelemetryPropertyValue(val)) {\n\t\t\tprops[key] = {\n\t\t\t\tvalue: filterValidTelemetryProps(val.value, key),\n\t\t\t\ttag: val.tag,\n\t\t\t};\n\t\t} else {\n\t\t\tprops[key] = filterValidTelemetryProps(val, key);\n\t\t}\n\t}\n\treturn props;\n}\n\n/**\n * Borrowed from\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value#examples}\n * Avoids runtime errors with circular references.\n * Not ideal, as will cut values that are not necessarily circular references.\n * Could be improved by implementing Node's util.inspect() for browser (minus all the coloring code)\n */\nexport const getCircularReplacer = () => {\n\tconst seen = new WeakSet();\n\treturn (key: string, value: any): any => {\n\t\tif (typeof value === \"object\" && value !== null) {\n\t\t\tif (seen.has(value)) {\n\t\t\t\treturn \"<removed/circular>\";\n\t\t\t}\n\t\t\tseen.add(value);\n\t\t}\n\t\treturn value;\n\t};\n};\n\n/**\n * Base class for \"trusted\" errors we create, whose properties can generally be logged to telemetry safely.\n * All properties set on the object, or passed in (via the constructor or addTelemetryProperties),\n * will be logged in accordance with their tag, if present.\n *\n * PLEASE take care to avoid setting sensitive data on this object without proper tagging!\n */\nexport class LoggingError\n\textends Error\n\timplements ILoggingError, Omit<IFluidErrorBase, \"errorType\">\n{\n\tprivate _errorInstanceId = uuid();\n\tget errorInstanceId() {\n\t\treturn this._errorInstanceId;\n\t}\n\toverwriteErrorInstanceId(id: string) {\n\t\tthis._errorInstanceId = id;\n\t}\n\n\t/** Back-compat to appease isFluidError typeguard in old code that may handle this error */\n\t// @ts-expect-error - This field shouldn't be referenced in the current version, but needs to exist at runtime.\n\tprivate readonly fluidErrorCode: \"-\" = \"-\";\n\n\t/**\n\t * Create a new LoggingError\n\t * @param message - Error message to use for Error base class\n\t * @param props - telemetry props to include on the error for when it's logged\n\t * @param omitPropsFromLogging - properties by name to omit from telemetry props\n\t */\n\tconstructor(\n\t\tmessage: string,\n\t\tprops?: ITelemetryProperties,\n\t\tprivate readonly omitPropsFromLogging: Set<string> = new Set(),\n\t) {\n\t\tsuper(message);\n\n\t\t// Don't log this list itself, or the private _errorInstanceId\n\t\tomitPropsFromLogging.add(\"omitPropsFromLogging\");\n\t\tomitPropsFromLogging.add(\"_errorInstanceId\");\n\n\t\tif (props) {\n\t\t\tthis.addTelemetryProperties(props);\n\t\t}\n\t}\n\n\t/**\n\t * Determines if a given object is an instance of a LoggingError\n\t * @param object - any object\n\t * @returns - true if the object is an instance of a LoggingError, false if not.\n\t */\n\tpublic static typeCheck(object: unknown): object is LoggingError {\n\t\tif (typeof object === \"object\" && object !== null) {\n\t\t\treturn (\n\t\t\t\ttypeof (object as LoggingError).addTelemetryProperties === \"function\" &&\n\t\t\t\ttypeof (object as LoggingError).getTelemetryProperties === \"function\" &&\n\t\t\t\ttypeof (object as LoggingError).errorInstanceId === \"string\"\n\t\t\t);\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Add additional properties to be logged\n\t */\n\tpublic addTelemetryProperties(props: ITelemetryProperties) {\n\t\tcopyProps(this, props);\n\t}\n\n\t/**\n\t * Get all properties fit to be logged to telemetry for this error\n\t */\n\tpublic getTelemetryProperties(): ITelemetryProperties {\n\t\tconst taggableProps = getValidTelemetryProps(this, this.omitPropsFromLogging);\n\t\t// Include non-enumerable props that are not returned by getValidTelemetryProps\n\t\treturn {\n\t\t\t...taggableProps,\n\t\t\tstack: this.stack,\n\t\t\tmessage: this.message,\n\t\t\terrorInstanceId: this._errorInstanceId,\n\t\t};\n\t}\n}\n\n/** The Error class used when normalizing an external error */\nexport const NORMALIZED_ERROR_TYPE = \"genericError\";\nclass NormalizedLoggingError extends LoggingError {\n\t// errorType \"genericError\" is used as a default value throughout the code.\n\t// Note that this matches ContainerErrorType/DriverErrorType's genericError\n\terrorType = NORMALIZED_ERROR_TYPE;\n\n\tconstructor(errorProps: Pick<IFluidErrorBase, \"message\" | \"stack\">) {\n\t\tsuper(errorProps.message);\n\n\t\tif (errorProps.stack !== undefined) {\n\t\t\toverwriteStack(this, errorProps.stack);\n\t\t}\n\t}\n}\n"]}
|
package/lib/fluidErrorBase.js
CHANGED
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
const hasTelemetryPropFunctions = (x) => typeof
|
|
6
|
-
typeof
|
|
7
|
-
export const hasErrorInstanceId = (x) => typeof
|
|
5
|
+
const hasTelemetryPropFunctions = (x) => typeof x?.getTelemetryProperties === "function" &&
|
|
6
|
+
typeof x?.addTelemetryProperties === "function";
|
|
7
|
+
export const hasErrorInstanceId = (x) => typeof x?.errorInstanceId === "string";
|
|
8
8
|
/** type guard for IFluidErrorBase interface */
|
|
9
9
|
export function isFluidError(e) {
|
|
10
|
-
return (typeof
|
|
11
|
-
typeof
|
|
10
|
+
return (typeof e?.errorType === "string" &&
|
|
11
|
+
typeof e?.message === "string" &&
|
|
12
12
|
hasErrorInstanceId(e) &&
|
|
13
13
|
hasTelemetryPropFunctions(e));
|
|
14
14
|
}
|
|
15
15
|
/** type guard for old standard of valid/known errors */
|
|
16
16
|
export function isValidLegacyError(e) {
|
|
17
|
-
return (typeof
|
|
18
|
-
typeof
|
|
17
|
+
return (typeof e?.errorType === "string" &&
|
|
18
|
+
typeof e?.message === "string" &&
|
|
19
19
|
hasTelemetryPropFunctions(e));
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=fluidErrorBase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluidErrorBase.js","sourceRoot":"","sources":["../src/fluidErrorBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAuCH,MAAM,yBAAyB,GAAG,CAAC,CAAM,EAAW,EAAE,CACrD,OAAO,
|
|
1
|
+
{"version":3,"file":"fluidErrorBase.js","sourceRoot":"","sources":["../src/fluidErrorBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAuCH,MAAM,yBAAyB,GAAG,CAAC,CAAM,EAAW,EAAE,CACrD,OAAO,CAAC,EAAE,sBAAsB,KAAK,UAAU;IAC/C,OAAO,CAAC,EAAE,sBAAsB,KAAK,UAAU,CAAC;AAEjD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAM,EAAoC,EAAE,CAC9E,OAAO,CAAC,EAAE,eAAe,KAAK,QAAQ,CAAC;AAExC,+CAA+C;AAC/C,MAAM,UAAU,YAAY,CAAC,CAAM;IAClC,OAAO,CACN,OAAO,CAAC,EAAE,SAAS,KAAK,QAAQ;QAChC,OAAO,CAAC,EAAE,OAAO,KAAK,QAAQ;QAC9B,kBAAkB,CAAC,CAAC,CAAC;QACrB,yBAAyB,CAAC,CAAC,CAAC,CAC5B,CAAC;AACH,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,kBAAkB,CAAC,CAAM;IACxC,OAAO,CACN,OAAO,CAAC,EAAE,SAAS,KAAK,QAAQ;QAChC,OAAO,CAAC,EAAE,OAAO,KAAK,QAAQ;QAC9B,yBAAyB,CAAC,CAAC,CAAC,CAC5B,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryProperties } from \"@fluidframework/core-interfaces\";\n\n/**\n * All normalized errors flowing through the Fluid Framework adhere to this readonly interface.\n * It features errorType and errorInstanceId on top of Error's members as readonly,\n * and a getter/setter for telemetry props to be included when the error is logged.\n */\nexport interface IFluidErrorBase extends Error {\n\t/** Classification of what type of error this is, used programmatically by consumers to interpret the error */\n\treadonly errorType: string;\n\n\t/**\n\t * Error's message property, made readonly.\n\t * Be specific, but also take care when including variable data to consider suitability for aggregation in telemetry\n\t * Also avoid including any data that jeopardizes the user's privacy. Add a tagged telemetry property instead.\n\t */\n\treadonly message: string;\n\n\t/** Error's stack property, made readonly */\n\treadonly stack?: string;\n\n\t/** Error's name property, made readonly */\n\treadonly name: string;\n\n\t/**\n\t * A Guid identifying this error instance.\n\t * Useful in telemetry for deduping multiple logging events arising from the same error,\n\t * or correlating an error with an inner error that caused it, in case of error wrapping.\n\t */\n\treadonly errorInstanceId: string;\n\n\t/** Get the telemetry properties stashed on this error for logging */\n\tgetTelemetryProperties(): ITelemetryProperties;\n\t/** Add telemetry properties to this error which will be logged with the error */\n\taddTelemetryProperties: (props: ITelemetryProperties) => void;\n}\n\nconst hasTelemetryPropFunctions = (x: any): boolean =>\n\ttypeof x?.getTelemetryProperties === \"function\" &&\n\ttypeof x?.addTelemetryProperties === \"function\";\n\nexport const hasErrorInstanceId = (x: any): x is { errorInstanceId: string } =>\n\ttypeof x?.errorInstanceId === \"string\";\n\n/** type guard for IFluidErrorBase interface */\nexport function isFluidError(e: any): e is IFluidErrorBase {\n\treturn (\n\t\ttypeof e?.errorType === \"string\" &&\n\t\ttypeof e?.message === \"string\" &&\n\t\thasErrorInstanceId(e) &&\n\t\thasTelemetryPropFunctions(e)\n\t);\n}\n\n/** type guard for old standard of valid/known errors */\nexport function isValidLegacyError(e: any): e is Omit<IFluidErrorBase, \"errorInstanceId\"> {\n\treturn (\n\t\ttypeof e?.errorType === \"string\" &&\n\t\ttypeof e?.message === \"string\" &&\n\t\thasTelemetryPropFunctions(e)\n\t);\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
export { createChildMonitoringContext, MonitoringContext, IConfigProviderBase, sessionStorageConfigProvider, mixinMonitoringContext, IConfigProvider, ConfigTypes, loggerToMonitoringContext, } from "./config";
|
|
6
|
-
export { DebugLogger } from "./debugLogger";
|
|
7
6
|
export { extractLogSafeErrorProperties, generateErrorWithStack, generateStack, getCircularReplacer, IFluidErrorAnnotations, isExternalError, isILoggingError, isTaggedTelemetryPropertyValue, LoggingError, NORMALIZED_ERROR_TYPE, normalizeError, wrapError, wrapErrorAndLog, } from "./errorLogging";
|
|
8
7
|
export { EventEmitterWithErrorHandling } from "./eventEmitterWithErrorHandling";
|
|
9
8
|
export { connectedEventName, disconnectedEventName, raiseConnectedEvent, safeRaiseEvent, } from "./events";
|
|
10
9
|
export { hasErrorInstanceId, IFluidErrorBase, isFluidError, isValidLegacyError, } from "./fluidErrorBase";
|
|
11
|
-
export { eventNamespaceSeparator,
|
|
10
|
+
export { eventNamespaceSeparator, createChildLogger, createMultiSinkLogger, formatTick, IPerformanceEventMarkers, ITelemetryLoggerPropertyBag, ITelemetryLoggerPropertyBags, numberFromString, PerformanceEvent, TaggedLoggerAdapter, tagData, tagCodeArtifacts, TelemetryDataTag, TelemetryEventPropertyTypes, } from "./logger";
|
|
12
11
|
export { MockLogger } from "./mockLogger";
|
|
13
12
|
export { ThresholdCounter } from "./thresholdCounter";
|
|
14
13
|
export { SampledTelemetryHelper } from "./sampledTelemetryHelper";
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,4BAA4B,EAC5B,iBAAiB,EACjB,mBAAmB,EACnB,4BAA4B,EAC5B,sBAAsB,EACtB,eAAe,EACf,WAAW,EACX,yBAAyB,GACzB,MAAM,UAAU,CAAC;AAClB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,4BAA4B,EAC5B,iBAAiB,EACjB,mBAAmB,EACnB,4BAA4B,EAC5B,sBAAsB,EACtB,eAAe,EACf,WAAW,EACX,yBAAyB,GACzB,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,6BAA6B,EAC7B,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,8BAA8B,EAC9B,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,SAAS,EACT,eAAe,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EACN,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,GACd,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,EACV,wBAAwB,EACxB,2BAA2B,EAC3B,4BAA4B,EAC5B,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,OAAO,EACP,gBAAgB,EAChB,gBAAgB,EAChB,2BAA2B,GAC3B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EACN,6BAA6B,EAC7B,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,EACvB,6BAA6B,EAC7B,mBAAmB,EACnB,+BAA+B,EAC/B,uBAAuB,GACvB,MAAM,kBAAkB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
export { createChildMonitoringContext, sessionStorageConfigProvider, mixinMonitoringContext, loggerToMonitoringContext, } from "./config";
|
|
6
|
-
export { DebugLogger } from "./debugLogger";
|
|
7
6
|
export { extractLogSafeErrorProperties, generateErrorWithStack, generateStack, getCircularReplacer, isExternalError, isILoggingError, isTaggedTelemetryPropertyValue, LoggingError, NORMALIZED_ERROR_TYPE, normalizeError, wrapError, wrapErrorAndLog, } from "./errorLogging";
|
|
8
7
|
export { EventEmitterWithErrorHandling } from "./eventEmitterWithErrorHandling";
|
|
9
8
|
export { connectedEventName, disconnectedEventName, raiseConnectedEvent, safeRaiseEvent, } from "./events";
|
|
10
9
|
export { hasErrorInstanceId, isFluidError, isValidLegacyError, } from "./fluidErrorBase";
|
|
11
|
-
export { eventNamespaceSeparator,
|
|
10
|
+
export { eventNamespaceSeparator, createChildLogger, createMultiSinkLogger, formatTick, numberFromString, PerformanceEvent, TaggedLoggerAdapter, tagData, tagCodeArtifacts, TelemetryDataTag, } from "./logger";
|
|
12
11
|
export { MockLogger } from "./mockLogger";
|
|
13
12
|
export { ThresholdCounter } from "./thresholdCounter";
|
|
14
13
|
export { SampledTelemetryHelper } from "./sampledTelemetryHelper";
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,4BAA4B,EAG5B,4BAA4B,EAC5B,sBAAsB,EAGtB,yBAAyB,GACzB,MAAM,UAAU,CAAC;AAClB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,4BAA4B,EAG5B,4BAA4B,EAC5B,sBAAsB,EAGtB,yBAAyB,GACzB,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,6BAA6B,EAC7B,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EAEnB,eAAe,EACf,eAAe,EACf,8BAA8B,EAC9B,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,SAAS,EACT,eAAe,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EACN,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,GACd,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,kBAAkB,EAElB,YAAY,EACZ,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,EAIV,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,OAAO,EACP,gBAAgB,EAChB,gBAAgB,GAEhB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nexport {\n\tcreateChildMonitoringContext,\n\tMonitoringContext,\n\tIConfigProviderBase,\n\tsessionStorageConfigProvider,\n\tmixinMonitoringContext,\n\tIConfigProvider,\n\tConfigTypes,\n\tloggerToMonitoringContext,\n} from \"./config\";\nexport {\n\textractLogSafeErrorProperties,\n\tgenerateErrorWithStack,\n\tgenerateStack,\n\tgetCircularReplacer,\n\tIFluidErrorAnnotations,\n\tisExternalError,\n\tisILoggingError,\n\tisTaggedTelemetryPropertyValue,\n\tLoggingError,\n\tNORMALIZED_ERROR_TYPE,\n\tnormalizeError,\n\twrapError,\n\twrapErrorAndLog,\n} from \"./errorLogging\";\nexport { EventEmitterWithErrorHandling } from \"./eventEmitterWithErrorHandling\";\nexport {\n\tconnectedEventName,\n\tdisconnectedEventName,\n\traiseConnectedEvent,\n\tsafeRaiseEvent,\n} from \"./events\";\nexport {\n\thasErrorInstanceId,\n\tIFluidErrorBase,\n\tisFluidError,\n\tisValidLegacyError,\n} from \"./fluidErrorBase\";\nexport {\n\teventNamespaceSeparator,\n\tcreateChildLogger,\n\tcreateMultiSinkLogger,\n\tformatTick,\n\tIPerformanceEventMarkers,\n\tITelemetryLoggerPropertyBag,\n\tITelemetryLoggerPropertyBags,\n\tnumberFromString,\n\tPerformanceEvent,\n\tTaggedLoggerAdapter,\n\ttagData,\n\ttagCodeArtifacts,\n\tTelemetryDataTag,\n\tTelemetryEventPropertyTypes,\n} from \"./logger\";\nexport { MockLogger } from \"./mockLogger\";\nexport { ThresholdCounter } from \"./thresholdCounter\";\nexport { SampledTelemetryHelper } from \"./sampledTelemetryHelper\";\nexport { logIfFalse } from \"./utils\";\nexport {\n\tTelemetryEventPropertyTypeExt,\n\tITelemetryEventExt,\n\tITelemetryGenericEventExt,\n\tITelemetryErrorEventExt,\n\tITelemetryPerformanceEventExt,\n\tITelemetryLoggerExt,\n\tITaggedTelemetryPropertyTypeExt,\n\tITelemetryPropertiesExt,\n} from \"./telemetryTypes\";\n"]}
|
package/lib/logger.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ITelemetryBaseEvent, ITelemetryBaseLogger, ITelemetryErrorEvent, ITelemetryGenericEvent,
|
|
5
|
+
import { ITelemetryBaseEvent, ITelemetryBaseLogger, ITelemetryErrorEvent, ITelemetryGenericEvent, ITelemetryProperties, TelemetryEventPropertyType, ITaggedTelemetryPropertyType, TelemetryEventCategory } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { IsomorphicPerformance } from "@fluidframework/common-utils";
|
|
7
7
|
import { ITaggedTelemetryPropertyTypeExt, ITelemetryGenericEventExt, ITelemetryLoggerExt, ITelemetryPerformanceEventExt, TelemetryEventPropertyTypeExt } from "./telemetryTypes";
|
|
8
8
|
export interface Memory {
|
|
@@ -43,24 +43,11 @@ export declare const eventNamespaceSeparator: ":";
|
|
|
43
43
|
* encoding in one place schemas for various types of Fluid telemetry events.
|
|
44
44
|
* Creates sub-logger that appends properties to all events
|
|
45
45
|
*
|
|
46
|
-
* @deprecated - In a subsequent release this type will no longer be exported, use ITelemetryLogger instead
|
|
47
46
|
*/
|
|
48
47
|
export declare abstract class TelemetryLogger implements ITelemetryLoggerExt {
|
|
49
48
|
protected readonly namespace?: string | undefined;
|
|
50
49
|
protected readonly properties?: ITelemetryLoggerPropertyBags | undefined;
|
|
51
50
|
static readonly eventNamespaceSeparator: ":";
|
|
52
|
-
/**
|
|
53
|
-
* @deprecated - use formatTick
|
|
54
|
-
*/
|
|
55
|
-
static formatTick(tick: number): number;
|
|
56
|
-
/**
|
|
57
|
-
* Attempts to parse number from string.
|
|
58
|
-
* If fails,returns original string.
|
|
59
|
-
* Used to make telemetry data typed (and support math operations, like comparison),
|
|
60
|
-
* in places where we do expect numbers (like contentsize/duration property in http header)
|
|
61
|
-
* @deprecated - use numberFromString
|
|
62
|
-
*/
|
|
63
|
-
static numberFromString(str: string | null | undefined): string | number | undefined;
|
|
64
51
|
static sanitizePkgName(name: string): string;
|
|
65
52
|
/**
|
|
66
53
|
* Take an unknown error object and add the appropriate info from it to the event. Message and stack will be copied
|
|
@@ -136,7 +123,6 @@ export declare function createChildLogger(props?: {
|
|
|
136
123
|
* ChildLogger class contains various helper telemetry methods,
|
|
137
124
|
* encoding in one place schemas for various types of Fluid telemetry events.
|
|
138
125
|
* Creates sub-logger that appends properties to all events
|
|
139
|
-
* @deprecated - Use createChildLogger instead
|
|
140
126
|
*/
|
|
141
127
|
export declare class ChildLogger extends TelemetryLogger {
|
|
142
128
|
protected readonly baseLogger: ITelemetryBaseLogger;
|
|
@@ -170,7 +156,6 @@ export declare function createMultiSinkLogger(props: {
|
|
|
170
156
|
/**
|
|
171
157
|
* Multi-sink logger
|
|
172
158
|
* Takes multiple ITelemetryBaseLogger objects (sinks) and logs all events into each sink
|
|
173
|
-
* @deprecated - use createMultiSinkLogger instead
|
|
174
159
|
*/
|
|
175
160
|
export declare class MultiSinkLogger extends TelemetryLogger {
|
|
176
161
|
protected loggers: ITelemetryBaseLogger[];
|
|
@@ -231,46 +216,6 @@ export declare class PerformanceEvent {
|
|
|
231
216
|
*/
|
|
232
217
|
reportEvent(eventNameSuffix: string, props?: ITelemetryProperties, error?: any): void;
|
|
233
218
|
}
|
|
234
|
-
/**
|
|
235
|
-
* Logger that is useful for UT
|
|
236
|
-
* It can be used in places where logger instance is required, but events should be not send over.
|
|
237
|
-
* @deprecated - Use createChildLogger instead
|
|
238
|
-
*/
|
|
239
|
-
export declare class TelemetryUTLogger implements ITelemetryLoggerExt {
|
|
240
|
-
send(event: ITelemetryBaseEvent): void;
|
|
241
|
-
sendTelemetryEvent(event: ITelemetryGenericEvent, error?: any): void;
|
|
242
|
-
sendErrorEvent(event: ITelemetryErrorEvent, error?: any): void;
|
|
243
|
-
sendPerformanceEvent(event: ITelemetryPerformanceEvent, error?: any): void;
|
|
244
|
-
logGenericError(eventName: string, error: any): void;
|
|
245
|
-
logException(event: ITelemetryErrorEvent, exception: any): void;
|
|
246
|
-
debugAssert(condition: boolean, event?: ITelemetryErrorEvent): void;
|
|
247
|
-
shipAssert(condition: boolean, event?: ITelemetryErrorEvent): void;
|
|
248
|
-
private reportError;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Null logger
|
|
252
|
-
* It can be used in places where logger instance is required, but events should be not send over.
|
|
253
|
-
* @deprecated - for internal use only
|
|
254
|
-
*/
|
|
255
|
-
export declare class BaseTelemetryNullLogger implements ITelemetryBaseLogger {
|
|
256
|
-
/**
|
|
257
|
-
* Send an event with the logger
|
|
258
|
-
*
|
|
259
|
-
* @param event - the event to send
|
|
260
|
-
*/
|
|
261
|
-
send(event: ITelemetryBaseEvent): void;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Null logger
|
|
265
|
-
* It can be used in places where logger instance is required, but events should be not send over.
|
|
266
|
-
* @deprecated - for internal use only
|
|
267
|
-
*/
|
|
268
|
-
export declare class TelemetryNullLogger implements ITelemetryLoggerExt {
|
|
269
|
-
send(event: ITelemetryBaseEvent): void;
|
|
270
|
-
sendTelemetryEvent(event: ITelemetryGenericEvent, error?: any): void;
|
|
271
|
-
sendErrorEvent(event: ITelemetryErrorEvent, error?: any): void;
|
|
272
|
-
sendPerformanceEvent(event: ITelemetryPerformanceEvent, error?: any): void;
|
|
273
|
-
}
|
|
274
219
|
/**
|
|
275
220
|
* Takes in value, and does one of 4 things.
|
|
276
221
|
* if value is of primitive type - returns the original value.
|
package/lib/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EAEtB,oBAAoB,EACpB,0BAA0B,EAC1B,4BAA4B,EAC5B,sBAAsB,EACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAe,MAAM,8BAA8B,CAAC;AAQlF,OAAO,EACN,+BAA+B,EAE/B,yBAAyB,EACzB,mBAAmB,EACnB,6BAA6B,EAC7B,6BAA6B,EAC7B,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,MAAM;IACtB,cAAc,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IACnE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AACD;;;GAGG;AACH,oBAAY,gBAAgB;IAC3B,4FAA4F;IAC5F,YAAY,iBAAiB;IAC7B,8EAA8E;IAC9E,QAAQ,aAAa;CACrB;AAED,oBAAY,2BAA2B,GAAG,0BAA0B,GAAG,4BAA4B,CAAC;AAEpG,MAAM,WAAW,2BAA2B;IAC3C,CAAC,KAAK,EAAE,MAAM,GAAG,2BAA2B,GAAG,CAAC,MAAM,2BAA2B,CAAC,CAAC;CACnF;AACD,MAAM,WAAW,4BAA4B;IAC5C,GA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