@fluidframework/telemetry-utils 2.0.0-rc.2.0.1 → 2.0.0-rc.3.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 +23 -0
- package/api-report/telemetry-utils.api.md +6 -6
- package/dist/config.d.ts +2 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +6 -2
- package/dist/config.js.map +1 -1
- package/dist/error.d.ts +4 -2
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +5 -5
- package/dist/error.js.map +1 -1
- package/dist/errorLogging.d.ts +3 -2
- package/dist/errorLogging.d.ts.map +1 -1
- package/dist/errorLogging.js.map +1 -1
- package/dist/eventEmitterWithErrorHandling.d.ts +1 -1
- package/dist/eventEmitterWithErrorHandling.d.ts.map +1 -1
- package/dist/eventEmitterWithErrorHandling.js +2 -2
- package/dist/eventEmitterWithErrorHandling.js.map +1 -1
- package/dist/events.d.ts +1 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/fluidErrorBase.d.ts.map +1 -1
- package/dist/fluidErrorBase.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +28 -0
- package/dist/logger.d.ts +2 -2
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/mockLogger.d.ts +1 -1
- package/dist/mockLogger.d.ts.map +1 -1
- package/dist/mockLogger.js +3 -3
- package/dist/mockLogger.js.map +1 -1
- package/dist/public.d.ts +20 -0
- package/dist/sampledTelemetryHelper.d.ts +2 -2
- package/dist/sampledTelemetryHelper.d.ts.map +1 -1
- package/dist/sampledTelemetryHelper.js.map +1 -1
- package/dist/utils.d.ts +4 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +4 -0
- package/dist/utils.js.map +1 -1
- package/internal.d.ts +11 -0
- package/legacy.d.ts +11 -0
- package/lib/config.d.ts +2 -2
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +5 -1
- package/lib/config.js.map +1 -1
- package/lib/error.d.ts +4 -2
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js +1 -1
- package/lib/error.js.map +1 -1
- package/lib/errorLogging.d.ts +3 -2
- package/lib/errorLogging.d.ts.map +1 -1
- package/lib/errorLogging.js.map +1 -1
- package/lib/eventEmitterWithErrorHandling.d.ts +1 -1
- package/lib/eventEmitterWithErrorHandling.d.ts.map +1 -1
- package/lib/eventEmitterWithErrorHandling.js.map +1 -1
- package/lib/events.d.ts +1 -1
- package/lib/events.d.ts.map +1 -1
- package/lib/events.js.map +1 -1
- package/lib/fluidErrorBase.d.ts.map +1 -1
- package/lib/fluidErrorBase.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +28 -0
- package/lib/logger.d.ts +2 -2
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +2 -2
- package/lib/logger.js.map +1 -1
- package/lib/mockLogger.d.ts +1 -1
- package/lib/mockLogger.d.ts.map +1 -1
- package/lib/mockLogger.js +2 -2
- package/lib/mockLogger.js.map +1 -1
- package/lib/public.d.ts +20 -0
- package/lib/sampledTelemetryHelper.d.ts +2 -2
- package/lib/sampledTelemetryHelper.d.ts.map +1 -1
- package/lib/sampledTelemetryHelper.js.map +1 -1
- package/lib/utils.d.ts +4 -0
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +4 -0
- package/lib/utils.js.map +1 -1
- package/package.json +27 -48
- package/src/config.ts +5 -3
- package/src/error.ts +4 -4
- package/src/errorLogging.ts +6 -8
- package/src/eventEmitterWithErrorHandling.ts +2 -1
- package/src/events.ts +2 -1
- package/src/fluidErrorBase.ts +1 -0
- package/src/index.ts +1 -0
- package/src/logger.ts +7 -6
- package/src/mockLogger.ts +4 -3
- package/src/sampledTelemetryHelper.ts +3 -2
- package/src/utils.ts +2 -0
- package/api-extractor-cjs.json +0 -8
- package/dist/telemetry-utils-alpha.d.ts +0 -282
- package/dist/telemetry-utils-beta.d.ts +0 -239
- package/dist/telemetry-utils-public.d.ts +0 -239
- package/dist/telemetry-utils-untrimmed.d.ts +0 -1077
- package/lib/telemetry-utils-alpha.d.ts +0 -282
- package/lib/telemetry-utils-beta.d.ts +0 -239
- package/lib/telemetry-utils-public.d.ts +0 -239
- package/lib/telemetry-utils-untrimmed.d.ts +0 -1077
- package/lib/test/EventEmitterWithErrorHandling.spec.js +0 -86
- package/lib/test/EventEmitterWithErrorHandling.spec.js.map +0 -1
- package/lib/test/childLogger.spec.js +0 -233
- package/lib/test/childLogger.spec.js.map +0 -1
- package/lib/test/config.spec.js +0 -229
- package/lib/test/config.spec.js.map +0 -1
- package/lib/test/error.spec.js +0 -161
- package/lib/test/error.spec.js.map +0 -1
- package/lib/test/errorLogging.spec.js +0 -801
- package/lib/test/errorLogging.spec.js.map +0 -1
- package/lib/test/errorTypeLoggingTest.spec.js +0 -107
- package/lib/test/errorTypeLoggingTest.spec.js.map +0 -1
- package/lib/test/mockLogger.spec.js +0 -164
- package/lib/test/mockLogger.spec.js.map +0 -1
- package/lib/test/multiSinkLogger.spec.js +0 -84
- package/lib/test/multiSinkLogger.spec.js.map +0 -1
- package/lib/test/performanceEvent.spec.js +0 -86
- package/lib/test/performanceEvent.spec.js.map +0 -1
- package/lib/test/sampledTelemetryHelper.spec.js +0 -169
- package/lib/test/sampledTelemetryHelper.spec.js.map +0 -1
- package/lib/test/telemetryLogger.spec.js +0 -357
- package/lib/test/telemetryLogger.spec.js.map +0 -1
- package/lib/test/thresholdCounter.spec.js +0 -51
- package/lib/test/thresholdCounter.spec.js.map +0 -1
- package/lib/test/types/validateTelemetryUtilsPrevious.generated.js +0 -132
- package/lib/test/types/validateTelemetryUtilsPrevious.generated.js.map +0 -1
- package/lib/test/utils.spec.js +0 -284
- package/lib/test/utils.spec.js.map +0 -1
- /package/{dist → lib}/tsdoc-metadata.json +0 -0
|
@@ -1,1077 +0,0 @@
|
|
|
1
|
-
import { ConfigTypes } from '@fluidframework/core-interfaces';
|
|
2
|
-
import type { EventEmitter } from '@fluid-internal/client-utils';
|
|
3
|
-
import { EventEmitterEventType } from '@fluid-internal/client-utils';
|
|
4
|
-
import { IConfigProviderBase } from '@fluidframework/core-interfaces';
|
|
5
|
-
import type { IDisposable } from '@fluidframework/core-interfaces';
|
|
6
|
-
import { IErrorBase } from '@fluidframework/core-interfaces';
|
|
7
|
-
import { IEvent } from '@fluidframework/core-interfaces';
|
|
8
|
-
import { IGenericError } from '@fluidframework/core-interfaces';
|
|
9
|
-
import type { ILoggingError } from '@fluidframework/core-interfaces';
|
|
10
|
-
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
|
|
11
|
-
import { ITelemetryBaseEvent } from '@fluidframework/core-interfaces';
|
|
12
|
-
import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
13
|
-
import { ITelemetryBaseProperties } from '@fluidframework/core-interfaces';
|
|
14
|
-
import { IUsageError } from '@fluidframework/core-interfaces';
|
|
15
|
-
import { Lazy } from '@fluidframework/core-utils';
|
|
16
|
-
import { LogLevel } from '@fluidframework/core-interfaces';
|
|
17
|
-
import { Tagged } from '@fluidframework/core-interfaces';
|
|
18
|
-
import { TelemetryBaseEventPropertyType } from '@fluidframework/core-interfaces';
|
|
19
|
-
import { TypedEventEmitter } from '@fluid-internal/client-utils';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
export declare const connectedEventName = "connected";
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Create a child logger based on the provided props object.
|
|
28
|
-
*
|
|
29
|
-
* @remarks
|
|
30
|
-
* Passing in no props object (i.e. undefined) will return a logger that is effectively a no-op.
|
|
31
|
-
*
|
|
32
|
-
* @param props - logger is the base logger the child will log to after it's processing, namespace will be prefixed to all event names, properties are default properties that will be applied events.
|
|
33
|
-
*
|
|
34
|
-
* @alpha
|
|
35
|
-
*/
|
|
36
|
-
export declare function createChildLogger(props?: {
|
|
37
|
-
logger?: ITelemetryBaseLogger;
|
|
38
|
-
namespace?: string;
|
|
39
|
-
properties?: ITelemetryLoggerPropertyBags;
|
|
40
|
-
}): ITelemetryLoggerExt;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Creates a child logger with a {@link MonitoringContext}.
|
|
44
|
-
*
|
|
45
|
-
* @see {@link loggerToMonitoringContext}
|
|
46
|
-
* @internal
|
|
47
|
-
*/
|
|
48
|
-
export declare function createChildMonitoringContext(props: Parameters<typeof createChildLogger>[0]): MonitoringContext;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Create a logger which logs to multiple other loggers based on the provided props object.
|
|
52
|
-
*
|
|
53
|
-
* @internal
|
|
54
|
-
*/
|
|
55
|
-
export declare function createMultiSinkLogger(props: MultiSinkLoggerProperties): ITelemetryLoggerExt;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Wraps around an existing logger matching the {@link ITelemetryLoggerExt} interface and provides the ability to only log a subset of events using a sampling strategy provided by an ${@link IEventSampler}.
|
|
59
|
-
* You can chose to not provide an event sampler which is effectively a no-op, meaning that it will be treated as if the sampler always returns true.
|
|
60
|
-
*
|
|
61
|
-
* @remarks
|
|
62
|
-
* The sampling functionality uses the Fluid telemetry logging configuration along with the optionally provided event sampling callback to determine whether an event should
|
|
63
|
-
* be logged or not.
|
|
64
|
-
*
|
|
65
|
-
* Configuration object parameters:
|
|
66
|
-
* 'Fluid.Telemetry.DisableSampling': if this config value is set to true, all events will be unsampled and therefore logged.
|
|
67
|
-
* Otherwise only a sample will be logged according to the provided event sampler callback.
|
|
68
|
-
*
|
|
69
|
-
* Note that the same sampler is used for all APIs of the returned logger. If you want separate events flowing through the returned logger to be sampled separately, the {@link IEventSampler} you provide should track them separately.
|
|
70
|
-
*
|
|
71
|
-
* @internal
|
|
72
|
-
*/
|
|
73
|
-
export declare function createSampledLogger(logger: ITelemetryLoggerExt, eventSampler?: IEventSampler): ISampledTelemetryLogger;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* DataCorruptionError indicates that we encountered definitive evidence that the data at rest
|
|
77
|
-
* backing this container is corrupted, and this container would never be expected to load properly again
|
|
78
|
-
*
|
|
79
|
-
* @internal
|
|
80
|
-
*/
|
|
81
|
-
export declare class DataCorruptionError extends LoggingError implements IErrorBase, IFluidErrorBase {
|
|
82
|
-
readonly errorType: "dataCorruptionError";
|
|
83
|
-
readonly canRetry = false;
|
|
84
|
-
constructor(message: string, props: ITelemetryBaseProperties);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Indicates we hit a fatal error while processing incoming data from the Fluid Service.
|
|
89
|
-
*
|
|
90
|
-
* @remarks
|
|
91
|
-
*
|
|
92
|
-
* The error will often originate in the dataStore or DDS implementation that is responding to incoming changes.
|
|
93
|
-
* This differs from {@link DataCorruptionError} in that this may be a transient error that will not repro in another
|
|
94
|
-
* client or session.
|
|
95
|
-
*
|
|
96
|
-
* @internal
|
|
97
|
-
*/
|
|
98
|
-
export declare class DataProcessingError extends LoggingError implements IErrorBase, IFluidErrorBase {
|
|
99
|
-
/**
|
|
100
|
-
* {@inheritDoc IFluidErrorBase.errorType}
|
|
101
|
-
*/
|
|
102
|
-
readonly errorType: "dataProcessingError";
|
|
103
|
-
readonly canRetry = false;
|
|
104
|
-
private constructor();
|
|
105
|
-
/**
|
|
106
|
-
* Create a new `DataProcessingError` detected and raised within the Fluid Framework.
|
|
107
|
-
*/
|
|
108
|
-
static create(errorMessage: string, dataProcessingCodepath: string, sequencedMessage?: ISequencedDocumentMessage, props?: ITelemetryBaseProperties): IFluidErrorBase;
|
|
109
|
-
/**
|
|
110
|
-
* Wrap the given error in a `DataProcessingError`, unless the error is already of a known type
|
|
111
|
-
* with the exception of a normalized {@link LoggingError}, which will still be wrapped.
|
|
112
|
-
*
|
|
113
|
-
* In either case, the error will have some relevant properties added for telemetry.
|
|
114
|
-
*
|
|
115
|
-
* @remarks
|
|
116
|
-
*
|
|
117
|
-
* We wrap conditionally since known error types represent well-understood failure modes, and ideally
|
|
118
|
-
* one day we will move away from throwing these errors but rather we'll return them.
|
|
119
|
-
* But an unrecognized error needs to be classified as `DataProcessingError`.
|
|
120
|
-
*
|
|
121
|
-
* @param originalError - The error to be converted.
|
|
122
|
-
* @param dataProcessingCodepath - Which code-path failed while processing data.
|
|
123
|
-
* @param messageLike - Message to include info about via telemetry props.
|
|
124
|
-
*
|
|
125
|
-
* @returns Either a new `DataProcessingError`, or (if wrapping is deemed unnecessary) the given error.
|
|
126
|
-
*/
|
|
127
|
-
static wrapIfUnrecognized(originalError: unknown, dataProcessingCodepath: string, messageLike?: Partial<Pick<ISequencedDocumentMessage, "clientId" | "sequenceNumber" | "clientSequenceNumber" | "referenceSequenceNumber" | "minimumSequenceNumber" | "timestamp">>): IFluidErrorBase;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* @internal
|
|
132
|
-
*/
|
|
133
|
-
export declare const disconnectedEventName = "disconnected";
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Event Emitter helper class
|
|
137
|
-
*
|
|
138
|
-
* @remarks
|
|
139
|
-
* Any exceptions thrown by listeners will be caught and raised through "error" event.
|
|
140
|
-
* Any exception thrown by "error" listeners will propagate to the caller.
|
|
141
|
-
* @privateRemarks
|
|
142
|
-
* This probably doesn't belong in this package, as it is not telemetry-specific, and is really only intended for internal fluid-framework use.
|
|
143
|
-
* We should consider moving it to the `core-utils` package.
|
|
144
|
-
* @alpha
|
|
145
|
-
*/
|
|
146
|
-
export declare class EventEmitterWithErrorHandling<TEvent extends IEvent = IEvent> extends TypedEventEmitter<TEvent> {
|
|
147
|
-
private readonly errorHandler;
|
|
148
|
-
constructor(errorHandler: (eventName: EventEmitterEventType, error: any) => void);
|
|
149
|
-
emit(event: EventEmitterEventType, ...args: unknown[]): boolean;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* String used to concatenate the namespace of parent loggers and their child loggers.
|
|
154
|
-
* @internal
|
|
155
|
-
*/
|
|
156
|
-
export declare const eventNamespaceSeparator: ":";
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Inspect the given error for common "safe" props and return them.
|
|
160
|
-
*
|
|
161
|
-
* @internal
|
|
162
|
-
*/
|
|
163
|
-
export declare function extractLogSafeErrorProperties(error: unknown, sanitizeStack: boolean): {
|
|
164
|
-
message: string;
|
|
165
|
-
errorType?: string | undefined;
|
|
166
|
-
stack?: string | undefined;
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Extracts specific properties from the provided message that we know are safe to log.
|
|
171
|
-
*
|
|
172
|
-
* @param messageLike - Message to include info about via telemetry props.
|
|
173
|
-
*
|
|
174
|
-
* @internal
|
|
175
|
-
*/
|
|
176
|
-
export declare const extractSafePropertiesFromMessage: (messageLike: Partial<Pick<ISequencedDocumentMessage, "clientId" | "sequenceNumber" | "clientSequenceNumber" | "referenceSequenceNumber" | "minimumSequenceNumber" | "timestamp">>) => {
|
|
177
|
-
messageClientId: string | undefined;
|
|
178
|
-
messageSequenceNumber: number | undefined;
|
|
179
|
-
messageClientSequenceNumber: number | undefined;
|
|
180
|
-
messageReferenceSequenceNumber: number | undefined;
|
|
181
|
-
messageMinimumSequenceNumber: number | undefined;
|
|
182
|
-
messageTimestamp: number | undefined;
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* @internal
|
|
187
|
-
*/
|
|
188
|
-
export declare function formatTick(tick: number): number;
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* The purpose of this function is to provide ability to capture stack context quickly.
|
|
192
|
-
* Accessing new Error().stack is slow, and the slowest part is accessing stack property itself.
|
|
193
|
-
* There are scenarios where we generate error with stack, but error is handled in most cases and
|
|
194
|
-
* stack property is not accessed.
|
|
195
|
-
* For such cases it's better to not read stack property right away, but rather delay it until / if it's needed
|
|
196
|
-
* Some browsers will populate stack right away, others require throwing Error, so we do auto-detection on the fly.
|
|
197
|
-
* @returns Error object that has stack populated.
|
|
198
|
-
*
|
|
199
|
-
* @internal
|
|
200
|
-
*/
|
|
201
|
-
export declare function generateErrorWithStack(): Error;
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Generate a stack at this callsite as if an error were thrown from here.
|
|
205
|
-
* @returns the callstack (does not throw)
|
|
206
|
-
*
|
|
207
|
-
* @internal
|
|
208
|
-
*/
|
|
209
|
-
export declare function generateStack(): string | undefined;
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Generic wrapper for an unrecognized/uncategorized error object
|
|
213
|
-
*
|
|
214
|
-
* @internal
|
|
215
|
-
*/
|
|
216
|
-
export declare class GenericError extends LoggingError implements IGenericError, IFluidErrorBase {
|
|
217
|
-
readonly error?: any;
|
|
218
|
-
readonly errorType: "genericError";
|
|
219
|
-
/**
|
|
220
|
-
* Create a new GenericError
|
|
221
|
-
* @param message - Error message
|
|
222
|
-
* @param error - inner error object
|
|
223
|
-
* @param props - Telemetry props to include when the error is logged
|
|
224
|
-
*/
|
|
225
|
-
constructor(message: string, error?: any, props?: ITelemetryBaseProperties);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Borrowed from
|
|
230
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value#examples}
|
|
231
|
-
* Avoids runtime errors with circular references.
|
|
232
|
-
* Not ideal, as will cut values that are not necessarily circular references.
|
|
233
|
-
* Could be improved by implementing Node's util.inspect() for browser (minus all the coloring code)
|
|
234
|
-
*
|
|
235
|
-
* @internal
|
|
236
|
-
*/
|
|
237
|
-
export declare const getCircularReplacer: () => (key: string, value: unknown) => any;
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Type guard for error data containing the {@link IFluidErrorBase.errorInstanceId} property.
|
|
241
|
-
*
|
|
242
|
-
* @internal
|
|
243
|
-
*/
|
|
244
|
-
export declare const hasErrorInstanceId: (x: unknown) => x is {
|
|
245
|
-
errorInstanceId: string;
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Explicitly typed interface for reading configurations.
|
|
250
|
-
*
|
|
251
|
-
* @internal
|
|
252
|
-
*/
|
|
253
|
-
export declare interface IConfigProvider extends IConfigProviderBase {
|
|
254
|
-
getBoolean(name: string): boolean | undefined;
|
|
255
|
-
getNumber(name: string): number | undefined;
|
|
256
|
-
getString(name: string): string | undefined;
|
|
257
|
-
getBooleanArray(name: string): boolean[] | undefined;
|
|
258
|
-
getNumberArray(name: string): number[] | undefined;
|
|
259
|
-
getStringArray(name: string): string[] | undefined;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* An object that contains a callback used in conjunction with the {@link createSampledLogger} utility function to provide custom logic for sampling events.
|
|
264
|
-
*
|
|
265
|
-
* @internal
|
|
266
|
-
*/
|
|
267
|
-
export declare interface IEventSampler {
|
|
268
|
-
/**
|
|
269
|
-
* @returns true if the event should be sampled or false if not
|
|
270
|
-
*/
|
|
271
|
-
sample: () => boolean | undefined;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Metadata to annotate an error object when annotating or normalizing it
|
|
276
|
-
*
|
|
277
|
-
* @internal
|
|
278
|
-
*/
|
|
279
|
-
export declare interface IFluidErrorAnnotations {
|
|
280
|
-
/**
|
|
281
|
-
* Telemetry props to log with the error
|
|
282
|
-
*/
|
|
283
|
-
props?: ITelemetryBaseProperties;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* An error emitted by the Fluid Framework.
|
|
288
|
-
*
|
|
289
|
-
* @remarks
|
|
290
|
-
*
|
|
291
|
-
* All normalized errors flowing through the Fluid Framework adhere to this readonly interface.
|
|
292
|
-
*
|
|
293
|
-
* It features the members of {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | Error}
|
|
294
|
-
* made readonly, as well as {@link IFluidErrorBase.errorType} and {@link IFluidErrorBase.errorInstanceId}.
|
|
295
|
-
* It also features getters and setters for telemetry props to be included when the error is logged.
|
|
296
|
-
*
|
|
297
|
-
* @internal
|
|
298
|
-
*/
|
|
299
|
-
export declare interface IFluidErrorBase extends Error {
|
|
300
|
-
/**
|
|
301
|
-
* Classification of what type of error this is.
|
|
302
|
-
*
|
|
303
|
-
* @remarks Used programmatically by consumers to interpret the error.
|
|
304
|
-
*/
|
|
305
|
-
readonly errorType: string;
|
|
306
|
-
/**
|
|
307
|
-
* Error's message property, made readonly.
|
|
308
|
-
*
|
|
309
|
-
* @remarks
|
|
310
|
-
*
|
|
311
|
-
* Recommendations:
|
|
312
|
-
*
|
|
313
|
-
* Be specific, but also take care when including variable data to consider suitability for aggregation in telemetry.
|
|
314
|
-
* Also avoid including any data that jeopardizes the user's privacy. Add a tagged telemetry property instead.
|
|
315
|
-
*/
|
|
316
|
-
readonly message: string;
|
|
317
|
-
/**
|
|
318
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack}.
|
|
319
|
-
*/
|
|
320
|
-
readonly stack?: string;
|
|
321
|
-
/**
|
|
322
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name}.
|
|
323
|
-
*/
|
|
324
|
-
readonly name: string;
|
|
325
|
-
/**
|
|
326
|
-
* A Guid identifying this error instance.
|
|
327
|
-
*
|
|
328
|
-
* @remarks
|
|
329
|
-
*
|
|
330
|
-
* Useful in telemetry for deduplicating multiple logging events arising from the same error,
|
|
331
|
-
* or correlating an error with an inner error that caused it, in case of error wrapping.
|
|
332
|
-
*/
|
|
333
|
-
readonly errorInstanceId: string;
|
|
334
|
-
/**
|
|
335
|
-
* Get the telemetry properties stashed on this error for logging.
|
|
336
|
-
*/
|
|
337
|
-
getTelemetryProperties(): ITelemetryBaseProperties;
|
|
338
|
-
/**
|
|
339
|
-
* Add telemetry properties to this error which will be logged with the error
|
|
340
|
-
*/
|
|
341
|
-
addTelemetryProperties: (props: ITelemetryPropertiesExt) => void;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Describes what events {@link PerformanceEvent} should log.
|
|
346
|
-
*
|
|
347
|
-
* @remarks
|
|
348
|
-
* By default, all events are logged, but the client can override this behavior.
|
|
349
|
-
*
|
|
350
|
-
* For example, there is rarely a need to record a start event, as we're really after
|
|
351
|
-
* success / failure tracking, including duration (on success).
|
|
352
|
-
*
|
|
353
|
-
* @internal
|
|
354
|
-
*/
|
|
355
|
-
export declare interface IPerformanceEventMarkers {
|
|
356
|
-
start?: true;
|
|
357
|
-
end?: true;
|
|
358
|
-
cancel?: "generic" | "error";
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* A telemetry logger that has sampling capabilities
|
|
363
|
-
*
|
|
364
|
-
* @internal
|
|
365
|
-
*/
|
|
366
|
-
export declare interface ISampledTelemetryLogger extends ITelemetryLoggerExt {
|
|
367
|
-
/**
|
|
368
|
-
* Indicates if the feature flag to disable sampling is set.
|
|
369
|
-
*
|
|
370
|
-
* @remarks Exposed to enable some advanced scenarios where the code using the sampled logger
|
|
371
|
-
* could take advantage of skipping the execution of some logic when it can determine
|
|
372
|
-
* it won't be necessary because the telemetry event that needs it wouldn't be
|
|
373
|
-
* emitted anyway.
|
|
374
|
-
*/
|
|
375
|
-
isSamplingDisabled: boolean;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* True for any error object that is an (optionally normalized) external error
|
|
380
|
-
* False for any error we created and raised within the FF codebase via LoggingError base class,
|
|
381
|
-
* or wrapped in a well-known error type
|
|
382
|
-
*
|
|
383
|
-
* @internal
|
|
384
|
-
*/
|
|
385
|
-
export declare function isExternalError(error: unknown): boolean;
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Type guard for {@link IFluidErrorBase}.
|
|
389
|
-
*
|
|
390
|
-
* @internal
|
|
391
|
-
*/
|
|
392
|
-
export declare function isFluidError(error: unknown): error is IFluidErrorBase;
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* Type-guard for {@link @fluidframework/core-interfaces#ILoggingError}.
|
|
396
|
-
*
|
|
397
|
-
* @internal
|
|
398
|
-
*/
|
|
399
|
-
export declare const isILoggingError: (x: unknown) => x is ILoggingError;
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* Type guard to identify if a particular telemetry property appears to be a
|
|
403
|
-
* {@link @fluidframework/core-interfaces#Tagged} telemetry property.
|
|
404
|
-
*
|
|
405
|
-
* @internal
|
|
406
|
-
*/
|
|
407
|
-
export declare function isTaggedTelemetryPropertyValue(x: Tagged<TelemetryEventPropertyTypeExt> | TelemetryEventPropertyTypeExt): x is Tagged<TelemetryEventPropertyTypeExt>;
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
* Type guard for old standard of valid/known errors.
|
|
411
|
-
*
|
|
412
|
-
* @internal
|
|
413
|
-
*/
|
|
414
|
-
export declare function isValidLegacyError(error: unknown): error is Omit<IFluidErrorBase, "errorInstanceId">;
|
|
415
|
-
|
|
416
|
-
/**
|
|
417
|
-
* A property to be logged to telemetry containing both the value and a tag. Tags are generic strings that can be used
|
|
418
|
-
* to mark pieces of information that should be organized or handled differently by loggers in various first or third
|
|
419
|
-
* party scenarios. For example, tags are used to mark personal information that should not be stored in logs.
|
|
420
|
-
*
|
|
421
|
-
* @deprecated Use {@link @fluidframework/core-interfaces#Tagged}\<{@link TelemetryEventPropertyTypeExt}\>
|
|
422
|
-
* @internal
|
|
423
|
-
*/
|
|
424
|
-
export declare interface ITaggedTelemetryPropertyTypeExt {
|
|
425
|
-
value: TelemetryEventPropertyTypeExt;
|
|
426
|
-
tag: string;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Error telemetry event.
|
|
431
|
-
* @remarks Maps to category = "error"
|
|
432
|
-
* @public
|
|
433
|
-
*/
|
|
434
|
-
export declare interface ITelemetryErrorEventExt extends ITelemetryPropertiesExt {
|
|
435
|
-
eventName: string;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
/**
|
|
439
|
-
* Interface for logging telemetry statements.
|
|
440
|
-
* @remarks May contain any number of properties that get serialized as json payload.
|
|
441
|
-
* @param category - category of the event, like "error", "performance", "generic", etc.
|
|
442
|
-
* @param eventName - name of the event.
|
|
443
|
-
*
|
|
444
|
-
* @internal
|
|
445
|
-
*/
|
|
446
|
-
export declare interface ITelemetryEventExt extends ITelemetryPropertiesExt {
|
|
447
|
-
category: string;
|
|
448
|
-
eventName: string;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* Informational (non-error) telemetry event
|
|
453
|
-
* @remarks Maps to category = "generic"
|
|
454
|
-
* @public
|
|
455
|
-
*/
|
|
456
|
-
export declare interface ITelemetryGenericEventExt extends ITelemetryPropertiesExt {
|
|
457
|
-
eventName: string;
|
|
458
|
-
category?: TelemetryEventCategory;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* An extended {@link @fluidframework/core-interfaces#ITelemetryBaseLogger} which allows for more lenient event types.
|
|
463
|
-
*
|
|
464
|
-
* @remarks
|
|
465
|
-
* This interface is meant to be used internally within the Fluid Framework,
|
|
466
|
-
* and `ITelemetryBaseLogger` should be used when loggers are passed between layers.
|
|
467
|
-
* @public
|
|
468
|
-
*/
|
|
469
|
-
export declare interface ITelemetryLoggerExt extends ITelemetryBaseLogger {
|
|
470
|
-
/**
|
|
471
|
-
* Send information telemetry event
|
|
472
|
-
* @param event - Event to send
|
|
473
|
-
* @param error - optional error object to log
|
|
474
|
-
* @param logLevel - optional level of the log.
|
|
475
|
-
*/
|
|
476
|
-
sendTelemetryEvent(event: ITelemetryGenericEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
|
|
477
|
-
/**
|
|
478
|
-
* Send error telemetry event
|
|
479
|
-
* @param event - Event to send
|
|
480
|
-
* @param error - optional error object to log
|
|
481
|
-
*/
|
|
482
|
-
sendErrorEvent(event: ITelemetryErrorEventExt, error?: unknown): void;
|
|
483
|
-
/**
|
|
484
|
-
* Send performance telemetry event
|
|
485
|
-
* @param event - Event to send
|
|
486
|
-
* @param error - optional error object to log
|
|
487
|
-
* @param logLevel - optional level of the log.
|
|
488
|
-
*/
|
|
489
|
-
sendPerformanceEvent(event: ITelemetryPerformanceEventExt, error?: unknown, logLevel?: typeof LogLevel.verbose | typeof LogLevel.default): void;
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
/**
|
|
493
|
-
* @alpha
|
|
494
|
-
*/
|
|
495
|
-
export declare interface ITelemetryLoggerPropertyBag {
|
|
496
|
-
[index: string]: TelemetryEventPropertyTypes | (() => TelemetryEventPropertyTypes);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* @alpha
|
|
501
|
-
*/
|
|
502
|
-
export declare interface ITelemetryLoggerPropertyBags {
|
|
503
|
-
all?: ITelemetryLoggerPropertyBag;
|
|
504
|
-
error?: ITelemetryLoggerPropertyBag;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
/**
|
|
508
|
-
* Performance telemetry event.
|
|
509
|
-
* @remarks Maps to category = "performance"
|
|
510
|
-
* @public
|
|
511
|
-
*/
|
|
512
|
-
export declare interface ITelemetryPerformanceEventExt extends ITelemetryGenericEventExt {
|
|
513
|
-
duration?: number;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* JSON-serializable properties, which will be logged with telemetry.
|
|
518
|
-
* @public
|
|
519
|
-
*/
|
|
520
|
-
export declare interface ITelemetryPropertiesExt {
|
|
521
|
-
[index: string]: TelemetryEventPropertyTypeExt | Tagged<TelemetryEventPropertyTypeExt>;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
/**
|
|
525
|
-
* Creates a {@link MonitoringContext} from the provided logger, if it isn't already one.
|
|
526
|
-
*
|
|
527
|
-
* @internal
|
|
528
|
-
*/
|
|
529
|
-
export declare function loggerToMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(logger: L): MonitoringContext<L>;
|
|
530
|
-
|
|
531
|
-
/**
|
|
532
|
-
* Base class for "trusted" errors we create, whose properties can generally be logged to telemetry safely.
|
|
533
|
-
* All properties set on the object, or passed in (via the constructor or addTelemetryProperties),
|
|
534
|
-
* will be logged in accordance with their tag, if present.
|
|
535
|
-
*
|
|
536
|
-
* PLEASE take care to avoid setting sensitive data on this object without proper tagging!
|
|
537
|
-
*
|
|
538
|
-
* @internal
|
|
539
|
-
*/
|
|
540
|
-
export declare class LoggingError extends Error implements ILoggingError, Omit<IFluidErrorBase, "errorType"> {
|
|
541
|
-
private readonly omitPropsFromLogging;
|
|
542
|
-
private _errorInstanceId;
|
|
543
|
-
get errorInstanceId(): string;
|
|
544
|
-
overwriteErrorInstanceId(id: string): void;
|
|
545
|
-
/**
|
|
546
|
-
* Backwards compatibility to appease {@link isFluidError} in old code that may handle this error.
|
|
547
|
-
*/
|
|
548
|
-
private readonly fluidErrorCode;
|
|
549
|
-
/**
|
|
550
|
-
* Create a new LoggingError
|
|
551
|
-
* @param message - Error message to use for Error base class
|
|
552
|
-
* @param props - telemetry props to include on the error for when it's logged
|
|
553
|
-
* @param omitPropsFromLogging - properties by name to omit from telemetry props
|
|
554
|
-
*/
|
|
555
|
-
constructor(message: string, props?: ITelemetryBaseProperties, omitPropsFromLogging?: Set<string>);
|
|
556
|
-
/**
|
|
557
|
-
* Determines if a given object is an instance of a LoggingError
|
|
558
|
-
* @param object - any object
|
|
559
|
-
* @returns true if the object is an instance of a LoggingError, false if not.
|
|
560
|
-
*/
|
|
561
|
-
static typeCheck(object: unknown): object is LoggingError;
|
|
562
|
-
/**
|
|
563
|
-
* Add additional properties to be logged
|
|
564
|
-
*/
|
|
565
|
-
addTelemetryProperties(props: ITelemetryPropertiesExt): void;
|
|
566
|
-
/**
|
|
567
|
-
* Get all properties fit to be logged to telemetry for this error
|
|
568
|
-
*/
|
|
569
|
-
getTelemetryProperties(): ITelemetryBaseProperties;
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
/**
|
|
573
|
-
* Creates a {@link MonitoringContext} from the provided logger.
|
|
574
|
-
*
|
|
575
|
-
* @remarks
|
|
576
|
-
* Assumes that the provided logger is not itself already a {@link MonitoringContext}, and will throw an error if it is.
|
|
577
|
-
* If you are unsure, use {@link loggerToMonitoringContext} instead.
|
|
578
|
-
*
|
|
579
|
-
* @throws If the provided logger is already a {@link MonitoringContext}.
|
|
580
|
-
*
|
|
581
|
-
* @internal
|
|
582
|
-
*/
|
|
583
|
-
export declare function mixinMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(logger: L, ...configs: (IConfigProviderBase | undefined)[]): MonitoringContext<L>;
|
|
584
|
-
|
|
585
|
-
/**
|
|
586
|
-
* The MockLogger records events sent to it, and then can walk back over those events
|
|
587
|
-
* searching for a set of expected events to match against the logged events.
|
|
588
|
-
*
|
|
589
|
-
* @internal
|
|
590
|
-
*/
|
|
591
|
-
export declare class MockLogger implements ITelemetryBaseLogger {
|
|
592
|
-
readonly minLogLevel?: LogLevel | undefined;
|
|
593
|
-
events: ITelemetryBaseEvent[];
|
|
594
|
-
constructor(minLogLevel?: LogLevel | undefined);
|
|
595
|
-
clear(): void;
|
|
596
|
-
toTelemetryLogger(): ITelemetryLoggerExt;
|
|
597
|
-
send(event: ITelemetryBaseEvent): void;
|
|
598
|
-
/**
|
|
599
|
-
* Search events logged since the last time matchEvents was called, looking for the given expected
|
|
600
|
-
* events in order.
|
|
601
|
-
* @param expectedEvents - events in order that are expected to appear in the recorded log.
|
|
602
|
-
* @param inlineDetailsProp - true if the "details" property in the actual event should be extracted and inlined.
|
|
603
|
-
* These event objects may be subsets of the logged events.
|
|
604
|
-
* Note: category is omitted from the type because it's usually uninteresting and tedious to type.
|
|
605
|
-
*/
|
|
606
|
-
matchEvents(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], inlineDetailsProp?: boolean): boolean;
|
|
607
|
-
/**
|
|
608
|
-
* Asserts that matchEvents is true, and prints the actual/expected output if not.
|
|
609
|
-
*/
|
|
610
|
-
assertMatch(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string, inlineDetailsProp?: boolean): void;
|
|
611
|
-
/**
|
|
612
|
-
* Search events logged since the last time matchEvents was called, looking for any of the given
|
|
613
|
-
* expected events.
|
|
614
|
-
* @param expectedEvents - events that are expected to appear in the recorded log.
|
|
615
|
-
* @param inlineDetailsProp - true if the "details" property in the actual event should be extracted and inlined.
|
|
616
|
-
* These event objects may be subsets of the logged events.
|
|
617
|
-
* Note: category is omitted from the type because it's usually uninteresting and tedious to type.
|
|
618
|
-
* @returns if any of the expected events is found.
|
|
619
|
-
*/
|
|
620
|
-
matchAnyEvent(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], inlineDetailsProp?: boolean): boolean;
|
|
621
|
-
/**
|
|
622
|
-
* Asserts that matchAnyEvent is true, and prints the actual/expected output if not.
|
|
623
|
-
*/
|
|
624
|
-
assertMatchAny(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string, inlineDetailsProp?: boolean): void;
|
|
625
|
-
/**
|
|
626
|
-
* Search events logged since the last time matchEvents was called, looking only for the given expected
|
|
627
|
-
* events in order.
|
|
628
|
-
* @param expectedEvents - events in order that are expected to be the only events in the recorded log.
|
|
629
|
-
* @param inlineDetailsProp - true if the "details" property in the actual event should be extracted and inlined.
|
|
630
|
-
* These event objects may be subsets of the logged events.
|
|
631
|
-
* Note: category is omitted from the type because it's usually uninteresting and tedious to type.
|
|
632
|
-
*/
|
|
633
|
-
matchEventStrict(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], inlineDetailsProp?: boolean): boolean;
|
|
634
|
-
/**
|
|
635
|
-
* Asserts that matchEvents is true, and prints the actual/expected output if not
|
|
636
|
-
*/
|
|
637
|
-
assertMatchStrict(expectedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string, inlineDetailsProp?: boolean): void;
|
|
638
|
-
/**
|
|
639
|
-
* Asserts that matchAnyEvent is false for the given events, and prints the actual/expected output if not
|
|
640
|
-
*/
|
|
641
|
-
assertMatchNone(disallowedEvents: Omit<ITelemetryBaseEvent, "category">[], message?: string, inlineDetailsProp?: boolean): void;
|
|
642
|
-
private getMatchedEventsCount;
|
|
643
|
-
/**
|
|
644
|
-
* Ensure the expected event is a strict subset of the actual event
|
|
645
|
-
*/
|
|
646
|
-
private static eventsMatch;
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
/**
|
|
650
|
-
* A type containing both a telemetry logger and a configuration provider.
|
|
651
|
-
*
|
|
652
|
-
* @internal
|
|
653
|
-
*/
|
|
654
|
-
export declare interface MonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt> {
|
|
655
|
-
config: IConfigProvider;
|
|
656
|
-
logger: L;
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
/**
|
|
660
|
-
* Input properties for {@link createMultiSinkLogger}.
|
|
661
|
-
*
|
|
662
|
-
* @internal
|
|
663
|
-
*/
|
|
664
|
-
export declare interface MultiSinkLoggerProperties {
|
|
665
|
-
/**
|
|
666
|
-
* Will be prefixed to all event names.
|
|
667
|
-
*/
|
|
668
|
-
namespace?: string;
|
|
669
|
-
/**
|
|
670
|
-
* Default properties that will be applied to all events flowing through this logger.
|
|
671
|
-
*/
|
|
672
|
-
properties?: ITelemetryLoggerPropertyBags;
|
|
673
|
-
/**
|
|
674
|
-
* The base loggers that this logger will forward the logs to, after it processes them.
|
|
675
|
-
*/
|
|
676
|
-
loggers?: (ITelemetryBaseLogger | undefined)[];
|
|
677
|
-
/**
|
|
678
|
-
* If true, the logger will attempt to copy the custom properties (if they are of a known type, i.e. one from this package) of all the base loggers passed to it, to apply them itself to logs that flow through.
|
|
679
|
-
*/
|
|
680
|
-
tryInheritProperties?: true;
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
/**
|
|
684
|
-
* The Error class used when normalizing an external error
|
|
685
|
-
*
|
|
686
|
-
* @internal
|
|
687
|
-
*/
|
|
688
|
-
export declare const NORMALIZED_ERROR_TYPE = "genericError";
|
|
689
|
-
|
|
690
|
-
/**
|
|
691
|
-
* Normalize the given error yielding a valid Fluid Error
|
|
692
|
-
* @returns A valid Fluid Error with any provided annotations applied
|
|
693
|
-
* @param error - The error to normalize
|
|
694
|
-
* @param annotations - Annotations to apply to the normalized error
|
|
695
|
-
*
|
|
696
|
-
* @internal
|
|
697
|
-
*/
|
|
698
|
-
export declare function normalizeError(error: unknown, annotations?: IFluidErrorAnnotations): IFluidErrorBase;
|
|
699
|
-
|
|
700
|
-
/**
|
|
701
|
-
* Attempts to parse number from string.
|
|
702
|
-
* If it fails, it will return the original string.
|
|
703
|
-
*
|
|
704
|
-
* @remarks
|
|
705
|
-
* Used to make telemetry data typed (and support math operations, like comparison),
|
|
706
|
-
* in places where we do expect numbers (like contentsize/duration property in http header).
|
|
707
|
-
*
|
|
708
|
-
* @internal
|
|
709
|
-
*/
|
|
710
|
-
export declare function numberFromString(str: string | null | undefined): string | number | undefined;
|
|
711
|
-
|
|
712
|
-
/**
|
|
713
|
-
* Attempts to overwrite the error's stack
|
|
714
|
-
*
|
|
715
|
-
* There have been reports of certain JS environments where overwriting stack will throw.
|
|
716
|
-
* If that happens, this adds the given stack as the telemetry property "stack2"
|
|
717
|
-
*
|
|
718
|
-
* @internal
|
|
719
|
-
*/
|
|
720
|
-
export declare function overwriteStack(error: IFluidErrorBase | LoggingError, stack: string): void;
|
|
721
|
-
|
|
722
|
-
/**
|
|
723
|
-
* Helper class to log performance events.
|
|
724
|
-
*
|
|
725
|
-
* @internal
|
|
726
|
-
*/
|
|
727
|
-
export declare class PerformanceEvent {
|
|
728
|
-
private readonly logger;
|
|
729
|
-
private readonly markers;
|
|
730
|
-
private readonly recordHeapSize;
|
|
731
|
-
private readonly emitLogs;
|
|
732
|
-
/**
|
|
733
|
-
* Creates an instance of {@link PerformanceEvent} and starts measurements
|
|
734
|
-
* @param logger - the logger to be used for publishing events
|
|
735
|
-
* @param event - the logging event details which will be published with the performance measurements
|
|
736
|
-
* @param markers - See {@link IPerformanceEventMarkers}
|
|
737
|
-
* @param recordHeapSize - whether or not to also record memory performance
|
|
738
|
-
* @param emitLogs - should this instance emit logs. If set to false, logs will not be emitted to the logger,
|
|
739
|
-
* but measurements will still be performed and any specified markers will be generated.
|
|
740
|
-
* @returns An instance of {@link PerformanceEvent}
|
|
741
|
-
*/
|
|
742
|
-
static start(logger: ITelemetryLoggerExt, event: ITelemetryGenericEventExt, markers?: IPerformanceEventMarkers, recordHeapSize?: boolean, emitLogs?: boolean): PerformanceEvent;
|
|
743
|
-
/**
|
|
744
|
-
* Measure a synchronous task
|
|
745
|
-
* @param logger - the logger to be used for publishing events
|
|
746
|
-
* @param event - the logging event details which will be published with the performance measurements
|
|
747
|
-
* @param callback - the task to be executed and measured
|
|
748
|
-
* @param markers - See {@link IPerformanceEventMarkers}
|
|
749
|
-
* @param sampleThreshold - events with the same name and category will be sent to the logger
|
|
750
|
-
* only when we hit this many executions of the task. If unspecified, all events will be sent.
|
|
751
|
-
* @returns The results of the executed task
|
|
752
|
-
*
|
|
753
|
-
* @remarks Note that if the "same" event (category + eventName) would be emitted by different
|
|
754
|
-
* tasks (`callback`), `sampleThreshold` is still applied only based on the event's category + eventName,
|
|
755
|
-
* so executing either of the tasks will increase the internal counter and they
|
|
756
|
-
* effectively "share" the sampling rate for the event.
|
|
757
|
-
*/
|
|
758
|
-
static timedExec<T>(logger: ITelemetryLoggerExt, event: ITelemetryGenericEventExt, callback: (event: PerformanceEvent) => T, markers?: IPerformanceEventMarkers, sampleThreshold?: number): T;
|
|
759
|
-
/**
|
|
760
|
-
* Measure an asynchronous task
|
|
761
|
-
* @param logger - the logger to be used for publishing events
|
|
762
|
-
* @param event - the logging event details which will be published with the performance measurements
|
|
763
|
-
* @param callback - the task to be executed and measured
|
|
764
|
-
* @param markers - See {@link IPerformanceEventMarkers}
|
|
765
|
-
* @param recordHeapSize - whether or not to also record memory performance
|
|
766
|
-
* @param sampleThreshold - events with the same name and category will be sent to the logger
|
|
767
|
-
* only when we hit this many executions of the task. If unspecified, all events will be sent.
|
|
768
|
-
* @returns The results of the executed task
|
|
769
|
-
*
|
|
770
|
-
* @remarks Note that if the "same" event (category + eventName) would be emitted by different
|
|
771
|
-
* tasks (`callback`), `sampleThreshold` is still applied only based on the event's category + eventName,
|
|
772
|
-
* so executing either of the tasks will increase the internal counter and they
|
|
773
|
-
* effectively "share" the sampling rate for the event.
|
|
774
|
-
*/
|
|
775
|
-
static timedExecAsync<T>(logger: ITelemetryLoggerExt, event: ITelemetryGenericEventExt, callback: (event: PerformanceEvent) => Promise<T>, markers?: IPerformanceEventMarkers, recordHeapSize?: boolean, sampleThreshold?: number): Promise<T>;
|
|
776
|
-
get duration(): number;
|
|
777
|
-
private event?;
|
|
778
|
-
private readonly startTime;
|
|
779
|
-
private startMark?;
|
|
780
|
-
private startMemoryCollection;
|
|
781
|
-
protected constructor(logger: ITelemetryLoggerExt, event: ITelemetryGenericEventExt, markers?: IPerformanceEventMarkers, recordHeapSize?: boolean, emitLogs?: boolean);
|
|
782
|
-
reportProgress(props?: ITelemetryPropertiesExt, eventNameSuffix?: string): void;
|
|
783
|
-
private autoEnd;
|
|
784
|
-
end(props?: ITelemetryPropertiesExt): void;
|
|
785
|
-
private performanceEndMark;
|
|
786
|
-
cancel(props?: ITelemetryPropertiesExt, error?: unknown): void;
|
|
787
|
-
/**
|
|
788
|
-
* Report the event, if it hasn't already been reported.
|
|
789
|
-
*/
|
|
790
|
-
reportEvent(eventNameSuffix: string, props?: ITelemetryPropertiesExt, error?: unknown): void;
|
|
791
|
-
private static readonly eventHits;
|
|
792
|
-
private static shouldReport;
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
/**
|
|
796
|
-
* Raises events pertaining to the connection
|
|
797
|
-
* @param logger - The logger to log telemetry
|
|
798
|
-
* @param emitter - The event emitter instance
|
|
799
|
-
* @param connected - A boolean tracking whether the connection was in a connected state or not
|
|
800
|
-
* @param clientId - The connected/disconnected clientId
|
|
801
|
-
* @param disconnectedReason - The reason for the connection to be disconnected (Used for telemetry purposes only)
|
|
802
|
-
*
|
|
803
|
-
* @internal
|
|
804
|
-
*/
|
|
805
|
-
export declare function raiseConnectedEvent(logger: ITelemetryLoggerExt, emitter: EventEmitter, connected: boolean, clientId?: string, disconnectedReason?: string): void;
|
|
806
|
-
|
|
807
|
-
/**
|
|
808
|
-
* @internal
|
|
809
|
-
*/
|
|
810
|
-
export declare function safeRaiseEvent(emitter: EventEmitter, logger: ITelemetryLoggerExt, event: string, ...args: unknown[]): void;
|
|
811
|
-
|
|
812
|
-
/**
|
|
813
|
-
* Helper class that executes a specified code block and writes an
|
|
814
|
-
* {@link @fluidframework/core-interfaces#ITelemetryPerformanceEvent} to a specified logger every time a specified
|
|
815
|
-
* number of executions is reached (or when the class is disposed).
|
|
816
|
-
*
|
|
817
|
-
* The `duration` field in the telemetry event is the duration of the latest execution (sample) of the specified
|
|
818
|
-
* function. See the documentation of the `includeAggregateMetrics` parameter for additional details that can be
|
|
819
|
-
* included.
|
|
820
|
-
*
|
|
821
|
-
* @internal
|
|
822
|
-
*/
|
|
823
|
-
export declare class SampledTelemetryHelper implements IDisposable {
|
|
824
|
-
private readonly eventBase;
|
|
825
|
-
private readonly logger;
|
|
826
|
-
private readonly sampleThreshold;
|
|
827
|
-
private readonly includeAggregateMetrics;
|
|
828
|
-
private readonly perBucketProperties;
|
|
829
|
-
disposed: boolean;
|
|
830
|
-
private readonly measurementsMap;
|
|
831
|
-
/**
|
|
832
|
-
* @param eventBase -
|
|
833
|
-
* Custom properties to include in the telemetry performance event when it is written.
|
|
834
|
-
* @param logger -
|
|
835
|
-
* The logger to use to write the telemetry performance event.
|
|
836
|
-
* @param sampleThreshold -
|
|
837
|
-
* Telemetry performance events will be generated every time we hit this many executions of the code block.
|
|
838
|
-
* @param includeAggregateMetrics -
|
|
839
|
-
* If set to `true`, the telemetry performance event will include aggregated metrics (total duration, min duration,
|
|
840
|
-
* max duration) for all the executions in between generated events.
|
|
841
|
-
* @param perBucketProperties -
|
|
842
|
-
* Map of strings that represent different buckets (which can be specified when calling the 'measure' method), to
|
|
843
|
-
* properties which should be added to the telemetry event for that bucket. If a bucket being measured does not
|
|
844
|
-
* have an entry in this map, no additional properties will be added to its telemetry events. The following keys are
|
|
845
|
-
* reserved for use by this class: "duration", "count", "totalDuration", "minDuration", "maxDuration". If any of
|
|
846
|
-
* them is specified as a key in one of the ITelemetryBaseProperties objects in this map, that key-value pair will be
|
|
847
|
-
* ignored.
|
|
848
|
-
*/
|
|
849
|
-
constructor(eventBase: ITelemetryGenericEventExt, logger: ITelemetryLoggerExt, sampleThreshold: number, includeAggregateMetrics?: boolean, perBucketProperties?: Map<string, ITelemetryBaseProperties>);
|
|
850
|
-
/**
|
|
851
|
-
* Executes the specified code and keeps track of execution time statistics.
|
|
852
|
-
* If it's been called enough times (the sampleThreshold for the class) then it generates a log message with the necessary information.
|
|
853
|
-
*
|
|
854
|
-
* @param codeToMeasure - The code to be executed and measured.
|
|
855
|
-
* @param bucket - A key to track executions of the code block separately.
|
|
856
|
-
* Each different value of this parameter has a separate set of executions and metrics tracked by the class.
|
|
857
|
-
* If no such distinction needs to be made, do not provide a value.
|
|
858
|
-
* @returns Whatever the passed-in code block returns.
|
|
859
|
-
*/
|
|
860
|
-
measure<T>(codeToMeasure: () => T, bucket?: string): T;
|
|
861
|
-
private flushBucket;
|
|
862
|
-
dispose(error?: Error | undefined): void;
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
/**
|
|
866
|
-
* Creates a base configuration provider based on `sessionStorage`
|
|
867
|
-
*
|
|
868
|
-
* @returns A lazy initialized base configuration provider with `sessionStorage` as the underlying config store
|
|
869
|
-
*
|
|
870
|
-
* @internal
|
|
871
|
-
*/
|
|
872
|
-
export declare const sessionStorageConfigProvider: Lazy<IConfigProviderBase>;
|
|
873
|
-
|
|
874
|
-
/**
|
|
875
|
-
* Tags all provided `values` as {@link TelemetryDataTag.CodeArtifact}.
|
|
876
|
-
*
|
|
877
|
-
* @param values - The values to be tagged.
|
|
878
|
-
*
|
|
879
|
-
* @remarks
|
|
880
|
-
* It supports properties of type {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType},
|
|
881
|
-
* as well as callbacks that return that type.
|
|
882
|
-
*
|
|
883
|
-
* @example Sample usage
|
|
884
|
-
* ```typescript
|
|
885
|
-
* {
|
|
886
|
-
* // ...Other properties being added to a telemetry event
|
|
887
|
-
* ...tagCodeArtifacts("someTag", {foo: 1, bar: 2}),
|
|
888
|
-
* // ...
|
|
889
|
-
* }
|
|
890
|
-
* ```
|
|
891
|
-
* This will result in `foo` and `bar` added to the event with their values tagged as {@link TelemetryDataTag.CodeArtifact}.
|
|
892
|
-
*
|
|
893
|
-
* @see {@link tagData}
|
|
894
|
-
*
|
|
895
|
-
* @internal
|
|
896
|
-
*/
|
|
897
|
-
export declare const tagCodeArtifacts: <T extends Record<string, TelemetryBaseEventPropertyType | (() => TelemetryBaseEventPropertyType)>>(values: T) => { [P in keyof T]: (T[P] extends () => TelemetryBaseEventPropertyType ? () => {
|
|
898
|
-
value: ReturnType<T[P]>;
|
|
899
|
-
tag: TelemetryDataTag.CodeArtifact;
|
|
900
|
-
} : {
|
|
901
|
-
value: Exclude<T[P], undefined>;
|
|
902
|
-
tag: TelemetryDataTag.CodeArtifact;
|
|
903
|
-
}) | (T[P] extends undefined ? undefined : never); };
|
|
904
|
-
|
|
905
|
-
/**
|
|
906
|
-
* Tags all given `values` with the same `tag`.
|
|
907
|
-
*
|
|
908
|
-
* @param tag - The tag with which all `values` will be annotated.
|
|
909
|
-
* @param values - The values to be tagged.
|
|
910
|
-
*
|
|
911
|
-
* @remarks
|
|
912
|
-
* It supports properties of type {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType},
|
|
913
|
-
* as well as callbacks that return that type.
|
|
914
|
-
*
|
|
915
|
-
* @example Sample usage
|
|
916
|
-
* ```typescript
|
|
917
|
-
* {
|
|
918
|
-
* // ...Other properties being added to a telemetry event
|
|
919
|
-
* ...tagData("someTag", {foo: 1, bar: 2}),
|
|
920
|
-
* // ...
|
|
921
|
-
* }
|
|
922
|
-
* ```
|
|
923
|
-
* This will result in `foo` and `bar` added to the event with their values tagged.
|
|
924
|
-
*
|
|
925
|
-
* @internal
|
|
926
|
-
*/
|
|
927
|
-
export declare const tagData: <T extends TelemetryDataTag, V extends Record<string, TelemetryBaseEventPropertyType | (() => TelemetryBaseEventPropertyType)>>(tag: T, values: V) => { [P in keyof V]: (V[P] extends () => TelemetryBaseEventPropertyType ? () => {
|
|
928
|
-
value: ReturnType<V[P]>;
|
|
929
|
-
tag: T;
|
|
930
|
-
} : {
|
|
931
|
-
value: Exclude<V[P], undefined>;
|
|
932
|
-
tag: T;
|
|
933
|
-
}) | (V[P] extends undefined ? undefined : never); };
|
|
934
|
-
|
|
935
|
-
/**
|
|
936
|
-
* @deprecated 0.56, remove TaggedLoggerAdapter once its usage is removed from
|
|
937
|
-
* container-runtime. Issue: #8191
|
|
938
|
-
* TaggedLoggerAdapter class can add tag handling to your logger.
|
|
939
|
-
*
|
|
940
|
-
* @internal
|
|
941
|
-
*/
|
|
942
|
-
export declare class TaggedLoggerAdapter implements ITelemetryBaseLogger {
|
|
943
|
-
private readonly logger;
|
|
944
|
-
constructor(logger: ITelemetryBaseLogger);
|
|
945
|
-
/**
|
|
946
|
-
* {@inheritDoc @fluidframework/core-interfaces#ITelemetryBaseLogger.send}
|
|
947
|
-
*/
|
|
948
|
-
send(eventWithTagsMaybe: ITelemetryBaseEvent): void;
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
/**
|
|
952
|
-
* Broad classifications to be applied to individual properties as they're prepared to be logged to telemetry.
|
|
953
|
-
*
|
|
954
|
-
* @privateRemarks Please do not modify existing entries, to maintain backwards compatibility.
|
|
955
|
-
*
|
|
956
|
-
* @internal
|
|
957
|
-
*/
|
|
958
|
-
export declare enum TelemetryDataTag {
|
|
959
|
-
/**
|
|
960
|
-
* Data containing terms or IDs from code packages that may have been dynamically loaded
|
|
961
|
-
*/
|
|
962
|
-
CodeArtifact = "CodeArtifact",
|
|
963
|
-
/**
|
|
964
|
-
* Personal data of a variety of classifications that pertains to the user
|
|
965
|
-
*/
|
|
966
|
-
UserData = "UserData"
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
/**
|
|
970
|
-
* The categories FF uses when instrumenting the code.
|
|
971
|
-
*
|
|
972
|
-
* generic - Informational log event
|
|
973
|
-
*
|
|
974
|
-
* error - Error log event, ideally 0 of these are logged during a session
|
|
975
|
-
*
|
|
976
|
-
* performance - Includes duration, and often has _start, _end, or _cancel suffixes for activity tracking
|
|
977
|
-
* @public
|
|
978
|
-
*/
|
|
979
|
-
export declare type TelemetryEventCategory = "generic" | "error" | "performance";
|
|
980
|
-
|
|
981
|
-
/**
|
|
982
|
-
* Property types that can be logged.
|
|
983
|
-
*
|
|
984
|
-
* @remarks
|
|
985
|
-
* Includes extra types beyond {@link @fluidframework/core-interfaces#TelemetryBaseEventPropertyType}, which must be
|
|
986
|
-
* converted before sending to a base logger.
|
|
987
|
-
* @public
|
|
988
|
-
*/
|
|
989
|
-
export declare type TelemetryEventPropertyTypeExt = string | number | boolean | undefined | (string | number | boolean)[] | {
|
|
990
|
-
[key: string]: // Flat objects can have the same properties as the event itself
|
|
991
|
-
string | number | boolean | undefined | (string | number | boolean)[];
|
|
992
|
-
};
|
|
993
|
-
|
|
994
|
-
/**
|
|
995
|
-
* @alpha
|
|
996
|
-
*/
|
|
997
|
-
export declare type TelemetryEventPropertyTypes = ITelemetryBaseProperties[string];
|
|
998
|
-
|
|
999
|
-
/**
|
|
1000
|
-
* Utility counter which will send event only if the provided value is above a configured threshold.
|
|
1001
|
-
*
|
|
1002
|
-
* @internal
|
|
1003
|
-
*/
|
|
1004
|
-
export declare class ThresholdCounter {
|
|
1005
|
-
private readonly threshold;
|
|
1006
|
-
private readonly logger;
|
|
1007
|
-
private thresholdMultiple;
|
|
1008
|
-
constructor(threshold: number, logger: ITelemetryLoggerExt, thresholdMultiple?: number);
|
|
1009
|
-
/**
|
|
1010
|
-
* Sends the value if it's above the treshold.
|
|
1011
|
-
*/
|
|
1012
|
-
send(eventName: string, value: number): void;
|
|
1013
|
-
/**
|
|
1014
|
-
* Sends the value if it's above the threshold
|
|
1015
|
-
* and a multiple of the threshold.
|
|
1016
|
-
*
|
|
1017
|
-
* To be used in scenarios where we'd like to record a
|
|
1018
|
-
* threshold violation while reducing telemetry noise.
|
|
1019
|
-
*/
|
|
1020
|
-
sendIfMultiple(eventName: string, value: number): void;
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
/**
|
|
1024
|
-
* Error indicating an API is being used improperly resulting in an invalid operation.
|
|
1025
|
-
*
|
|
1026
|
-
* @internal
|
|
1027
|
-
*/
|
|
1028
|
-
export declare class UsageError extends LoggingError implements IUsageError, IFluidErrorBase {
|
|
1029
|
-
readonly errorType: "usageError";
|
|
1030
|
-
constructor(message: string, props?: ITelemetryBaseProperties);
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
/**
|
|
1034
|
-
* Throws a UsageError with the given message if the condition is not met.
|
|
1035
|
-
* Use this API when `false` indicates a precondition is not met on a public API (for any FF layer).
|
|
1036
|
-
*
|
|
1037
|
-
* @param condition - The condition that should be true, if the condition is false a UsageError will be thrown.
|
|
1038
|
-
* @param message - The message to include in the error when the condition does not hold.
|
|
1039
|
-
* @param props - Telemetry props to include on the error when the condition does not hold.
|
|
1040
|
-
* @internal
|
|
1041
|
-
*/
|
|
1042
|
-
export declare function validatePrecondition(condition: boolean, message: string, props?: ITelemetryBaseProperties): asserts condition;
|
|
1043
|
-
|
|
1044
|
-
/**
|
|
1045
|
-
* Creates a wrapper on top of an existing config provider which allows for
|
|
1046
|
-
* specifying feature gates if not present in the original provider.
|
|
1047
|
-
*
|
|
1048
|
-
* @param original - the original config provider
|
|
1049
|
-
* @param defaults - default feature gate configs to be used if not specified by the original provider
|
|
1050
|
-
* @returns A config provider that looks for any requested feature gates in the original provider and falls
|
|
1051
|
-
* back to the values specified in the `defaults` feature gates if they're not present in the original.
|
|
1052
|
-
*
|
|
1053
|
-
* @internal
|
|
1054
|
-
*/
|
|
1055
|
-
export declare const wrapConfigProviderWithDefaults: (original: IConfigProviderBase | undefined, defaults: Record<string, ConfigTypes>) => IConfigProviderBase;
|
|
1056
|
-
|
|
1057
|
-
/**
|
|
1058
|
-
* Create a new error using newErrorFn, wrapping and caused by the given unknown error.
|
|
1059
|
-
* Copies the inner error's stack, errorInstanceId and telemetry props over to the new error if present
|
|
1060
|
-
* @param innerError - An error from untrusted/unknown origins
|
|
1061
|
-
* @param newErrorFn - callback that will create a new error given the original error's message
|
|
1062
|
-
* @returns A new error object "wrapping" the given error
|
|
1063
|
-
*
|
|
1064
|
-
* @internal
|
|
1065
|
-
*/
|
|
1066
|
-
export declare function wrapError<T extends LoggingError>(innerError: unknown, newErrorFn: (message: string) => T): T;
|
|
1067
|
-
|
|
1068
|
-
/**
|
|
1069
|
-
* The same as wrapError, but also logs the innerError, including the wrapping error's instance ID.
|
|
1070
|
-
*
|
|
1071
|
-
* @typeParam T - The kind of wrapper error to create.
|
|
1072
|
-
*
|
|
1073
|
-
* @internal
|
|
1074
|
-
*/
|
|
1075
|
-
export declare function wrapErrorAndLog<T extends LoggingError>(innerError: unknown, newErrorFn: (message: string) => T, logger: ITelemetryLoggerExt): T;
|
|
1076
|
-
|
|
1077
|
-
export { }
|