@fluidframework/telemetry-utils 0.59.4001 → 1.1.0-75972
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +1 -1
- package/dist/errorLogging.d.ts +4 -10
- package/dist/errorLogging.d.ts.map +1 -1
- package/dist/errorLogging.js +20 -25
- package/dist/errorLogging.js.map +1 -1
- package/dist/logger.d.ts +6 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +6 -1
- package/dist/logger.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/errorLogging.d.ts +4 -10
- package/lib/errorLogging.d.ts.map +1 -1
- package/lib/errorLogging.js +19 -23
- package/lib/errorLogging.js.map +1 -1
- package/lib/logger.d.ts +6 -1
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +6 -1
- package/lib/logger.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +12 -20
- package/src/errorLogging.ts +29 -32
- package/src/logger.ts +7 -2
- package/src/packageVersion.ts +1 -1
package/src/errorLogging.ts
CHANGED
|
@@ -88,10 +88,6 @@ function patchLegacyError(
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
// errorType "genericError" is used as a default value throughout the code.
|
|
92
|
-
// Note that this matches ContainerErrorType/DriverErrorType's genericError
|
|
93
|
-
const defaultErrorTypeForNormalize = "genericError";
|
|
94
|
-
|
|
95
91
|
/**
|
|
96
92
|
* Normalize the given error yielding a valid Fluid Error
|
|
97
93
|
* @returns A valid Fluid Error with any provided annotations applied
|
|
@@ -115,17 +111,11 @@ export function normalizeError(
|
|
|
115
111
|
|
|
116
112
|
// We have to construct a new Fluid Error, copying safe properties over
|
|
117
113
|
const { message, stack } = extractLogSafeErrorProperties(error, false /* sanitizeStack */);
|
|
118
|
-
const fluidError: IFluidErrorBase = new
|
|
119
|
-
errorType: defaultErrorTypeForNormalize,
|
|
114
|
+
const fluidError: IFluidErrorBase = new NormalizedExternalError({
|
|
120
115
|
message,
|
|
121
116
|
stack,
|
|
122
117
|
});
|
|
123
118
|
|
|
124
|
-
fluidError.addTelemetryProperties({
|
|
125
|
-
...annotations.props,
|
|
126
|
-
untrustedOrigin: 1, // This will let us filter to errors not originated by our own code
|
|
127
|
-
});
|
|
128
|
-
|
|
129
119
|
// We need to preserve these properties which are used in a non-typesafe way throughout driver code (see #8743)
|
|
130
120
|
// Anywhere they are set should be on a valid Fluid Error that would have been returned above,
|
|
131
121
|
// but we can't prove it with the types, so adding this defensive measure.
|
|
@@ -138,6 +128,14 @@ export function normalizeError(
|
|
|
138
128
|
// This is only interesting for non-objects
|
|
139
129
|
fluidError.addTelemetryProperties({ typeofError: typeof (error) });
|
|
140
130
|
}
|
|
131
|
+
|
|
132
|
+
const originalErrorTelemetryProps = isILoggingError(error) ? error.getTelemetryProperties() : {};
|
|
133
|
+
fluidError.addTelemetryProperties({
|
|
134
|
+
...originalErrorTelemetryProps,
|
|
135
|
+
...annotations.props,
|
|
136
|
+
untrustedOrigin: 1, // This will let us filter to errors not originated by our own code
|
|
137
|
+
});
|
|
138
|
+
|
|
141
139
|
return fluidError;
|
|
142
140
|
}
|
|
143
141
|
|
|
@@ -175,9 +173,8 @@ export function generateStack(): string | undefined {
|
|
|
175
173
|
}
|
|
176
174
|
|
|
177
175
|
/**
|
|
178
|
-
* Create a new error, wrapping and caused by the given unknown error.
|
|
179
|
-
* Copies the inner error's
|
|
180
|
-
* The inner error's instance id will also be logged for telemetry analysis.
|
|
176
|
+
* Create a new error using newErrorFn, wrapping and caused by the given unknown error.
|
|
177
|
+
* Copies the inner error's stack, errorInstanceId and telemetry props over to the new error if present
|
|
181
178
|
* @param innerError - An error from untrusted/unknown origins
|
|
182
179
|
* @param newErrorFn - callback that will create a new error given the original error's message
|
|
183
180
|
* @returns A new error object "wrapping" the given error
|
|
@@ -198,7 +195,7 @@ export function wrapError<T extends LoggingError>(
|
|
|
198
195
|
}
|
|
199
196
|
|
|
200
197
|
// Mark external errors with untrustedOrigin flag
|
|
201
|
-
if (
|
|
198
|
+
if (isExternalError(innerError)) {
|
|
202
199
|
newError.addTelemetryProperties({ untrustedOrigin: 1 });
|
|
203
200
|
}
|
|
204
201
|
|
|
@@ -210,6 +207,12 @@ export function wrapError<T extends LoggingError>(
|
|
|
210
207
|
newError.addTelemetryProperties({ innerErrorInstanceId: innerError.errorInstanceId });
|
|
211
208
|
}
|
|
212
209
|
|
|
210
|
+
// Lastly, copy over all other telemetry properties. Note these will not overwrite existing properties
|
|
211
|
+
// This will include the untrustedOrigin property if the inner error itself was created from an external error
|
|
212
|
+
if (isILoggingError(innerError)) {
|
|
213
|
+
newError.addTelemetryProperties(innerError.getTelemetryProperties());
|
|
214
|
+
}
|
|
215
|
+
|
|
213
216
|
return newError;
|
|
214
217
|
}
|
|
215
218
|
|
|
@@ -245,14 +248,6 @@ function overwriteStack(error: IFluidErrorBase | LoggingError, stack: string) {
|
|
|
245
248
|
}
|
|
246
249
|
}
|
|
247
250
|
|
|
248
|
-
/**
|
|
249
|
-
* True for any error object that is either external itself or is a wrapped/normalized external error
|
|
250
|
-
* False for any error we created and raised within the FF codebase.
|
|
251
|
-
*/
|
|
252
|
-
export function originatedAsExternalError(e: any): boolean {
|
|
253
|
-
return !isValidLegacyError(e) || (e.getTelemetryProperties().untrustedOrigin === 1);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
251
|
/**
|
|
257
252
|
* True for any error object that is an (optionally normalized) external error
|
|
258
253
|
* False for any error we created and raised within the FF codebase, or wrapped in a well-known error type
|
|
@@ -260,7 +255,7 @@ export function originatedAsExternalError(e: any): boolean {
|
|
|
260
255
|
export function isExternalError(e: any): boolean {
|
|
261
256
|
return !isValidLegacyError(e) ||
|
|
262
257
|
(e.getTelemetryProperties().untrustedOrigin === 1 &&
|
|
263
|
-
e.errorType ===
|
|
258
|
+
e.errorType === NormalizedExternalError.normalizedErrorType);
|
|
264
259
|
}
|
|
265
260
|
|
|
266
261
|
/**
|
|
@@ -316,19 +311,18 @@ export const getCircularReplacer = () => {
|
|
|
316
311
|
}
|
|
317
312
|
seen.add(value);
|
|
318
313
|
}
|
|
319
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
320
314
|
return value;
|
|
321
315
|
};
|
|
322
316
|
};
|
|
323
317
|
|
|
324
318
|
/**
|
|
325
319
|
* Base class for "trusted" errors we create, whose properties can generally be logged to telemetry safely.
|
|
326
|
-
* All properties set on the object, or passed in (via the constructor or
|
|
320
|
+
* All properties set on the object, or passed in (via the constructor or addTelemetryProperties),
|
|
327
321
|
* will be logged in accordance with their tag, if present.
|
|
328
322
|
*
|
|
329
323
|
* PLEASE take care to avoid setting sensitive data on this object without proper tagging!
|
|
330
324
|
*/
|
|
331
|
-
export class LoggingError extends Error implements ILoggingError,
|
|
325
|
+
export class LoggingError extends Error implements ILoggingError, Omit<IFluidErrorBase, "errorType"> {
|
|
332
326
|
private _errorInstanceId = uuid();
|
|
333
327
|
get errorInstanceId() { return this._errorInstanceId; }
|
|
334
328
|
overwriteErrorInstanceId(id: string) { this._errorInstanceId = id; }
|
|
@@ -381,19 +375,22 @@ export class LoggingError extends Error implements ILoggingError, Pick<IFluidErr
|
|
|
381
375
|
}
|
|
382
376
|
}
|
|
383
377
|
|
|
384
|
-
/**
|
|
385
|
-
class
|
|
386
|
-
|
|
378
|
+
/** The Error class used when normalizing an external error */
|
|
379
|
+
class NormalizedExternalError extends LoggingError {
|
|
380
|
+
// errorType "genericError" is used as a default value throughout the code.
|
|
381
|
+
// Note that this matches ContainerErrorType/DriverErrorType's genericError
|
|
382
|
+
static readonly normalizedErrorType = "genericError";
|
|
383
|
+
|
|
384
|
+
errorType = NormalizedExternalError.normalizedErrorType;
|
|
387
385
|
|
|
388
386
|
constructor(
|
|
389
387
|
errorProps: Pick<IFluidErrorBase,
|
|
390
388
|
| "message"
|
|
391
389
|
| "stack"
|
|
392
|
-
| "errorType"
|
|
393
390
|
>,
|
|
394
391
|
) {
|
|
395
392
|
super(errorProps.message);
|
|
396
|
-
|
|
393
|
+
|
|
397
394
|
if (errorProps.stack !== undefined) {
|
|
398
395
|
overwriteStack(this, errorProps.stack);
|
|
399
396
|
}
|
package/src/logger.ts
CHANGED
|
@@ -31,9 +31,14 @@ import {
|
|
|
31
31
|
* Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.
|
|
32
32
|
* Please do not modify existing entries for backwards compatibility.
|
|
33
33
|
*/
|
|
34
|
-
|
|
35
|
-
/**
|
|
34
|
+
export enum TelemetryDataTag {
|
|
35
|
+
/**
|
|
36
|
+
* Data containing terms from code packages that may have been dynamically loaded
|
|
37
|
+
* @deprecated 1.0, will be removed in next release (see issue #6603). Use `TelemetryDataTag.CodeArtifact` instead.
|
|
38
|
+
*/
|
|
36
39
|
PackageData = "PackageData",
|
|
40
|
+
/** Data containing terms or IDs from code packages that may have been dynamically loaded */
|
|
41
|
+
CodeArtifact = "CodeArtifact",
|
|
37
42
|
/** Personal data of a variety of classifications that pertains to the user */
|
|
38
43
|
UserData = "UserData",
|
|
39
44
|
}
|
package/src/packageVersion.ts
CHANGED