@fluidframework/telemetry-utils 2.0.0-internal.5.3.2 → 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.
Files changed (63) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/config.d.ts +2 -0
  3. package/dist/config.d.ts.map +1 -1
  4. package/dist/config.js +27 -34
  5. package/dist/config.js.map +1 -1
  6. package/dist/errorLogging.js +16 -10
  7. package/dist/errorLogging.js.map +1 -1
  8. package/dist/fluidErrorBase.js +7 -7
  9. package/dist/fluidErrorBase.js.map +1 -1
  10. package/dist/index.d.ts +2 -3
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +9 -9
  13. package/dist/index.js.map +1 -1
  14. package/dist/logger.d.ts +47 -48
  15. package/dist/logger.d.ts.map +1 -1
  16. package/dist/logger.js +111 -117
  17. package/dist/logger.js.map +1 -1
  18. package/dist/mockLogger.d.ts +3 -5
  19. package/dist/mockLogger.d.ts.map +1 -1
  20. package/dist/mockLogger.js +27 -19
  21. package/dist/mockLogger.js.map +1 -1
  22. package/dist/sampledTelemetryHelper.js +8 -5
  23. package/dist/sampledTelemetryHelper.js.map +1 -1
  24. package/dist/utils.js +1 -1
  25. package/dist/utils.js.map +1 -1
  26. package/lib/config.d.ts +2 -0
  27. package/lib/config.d.ts.map +1 -1
  28. package/lib/config.js +26 -34
  29. package/lib/config.js.map +1 -1
  30. package/lib/errorLogging.js +16 -10
  31. package/lib/errorLogging.js.map +1 -1
  32. package/lib/fluidErrorBase.js +7 -7
  33. package/lib/fluidErrorBase.js.map +1 -1
  34. package/lib/index.d.ts +2 -3
  35. package/lib/index.d.ts.map +1 -1
  36. package/lib/index.js +2 -3
  37. package/lib/index.js.map +1 -1
  38. package/lib/logger.d.ts +47 -48
  39. package/lib/logger.d.ts.map +1 -1
  40. package/lib/logger.js +104 -113
  41. package/lib/logger.js.map +1 -1
  42. package/lib/mockLogger.d.ts +3 -5
  43. package/lib/mockLogger.d.ts.map +1 -1
  44. package/lib/mockLogger.js +28 -20
  45. package/lib/mockLogger.js.map +1 -1
  46. package/lib/sampledTelemetryHelper.js +8 -5
  47. package/lib/sampledTelemetryHelper.js.map +1 -1
  48. package/lib/utils.js +1 -1
  49. package/lib/utils.js.map +1 -1
  50. package/package.json +41 -8
  51. package/src/config.ts +11 -6
  52. package/src/index.ts +8 -7
  53. package/src/logger.ts +125 -94
  54. package/src/mockLogger.ts +37 -13
  55. package/dist/debugLogger.d.ts +0 -39
  56. package/dist/debugLogger.d.ts.map +0 -1
  57. package/dist/debugLogger.js +0 -112
  58. package/dist/debugLogger.js.map +0 -1
  59. package/lib/debugLogger.d.ts +0 -39
  60. package/lib/debugLogger.d.ts.map +0 -1
  61. package/lib/debugLogger.js +0 -108
  62. package/lib/debugLogger.js.map +0 -1
  63. package/src/debugLogger.ts +0 -143
@@ -1,108 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { performance } from "@fluidframework/common-utils";
6
- import { debug as registerDebug } from "debug";
7
- import { TelemetryLogger, MultiSinkLogger, ChildLogger, } from "./logger";
8
- /**
9
- * Implementation of debug logger
10
- */
11
- export class DebugLogger extends TelemetryLogger {
12
- constructor(debug, debugErr, properties) {
13
- super(undefined, properties);
14
- this.debug = debug;
15
- this.debugErr = debugErr;
16
- }
17
- /**
18
- * Create debug logger - all events are output to debug npm library
19
- * @param namespace - Telemetry event name prefix to add to all events
20
- * @param properties - Base properties to add to all events
21
- * @param propertyGetters - Getters to add additional properties to all events
22
- */
23
- static create(namespace, properties) {
24
- // Setup base logger upfront, such that host can disable it (if needed)
25
- const debug = registerDebug(namespace);
26
- // Create one for errors that is always enabled
27
- // It can be silenced by replacing console.error if the debug namespace is not enabled.
28
- const debugErr = registerDebug(namespace);
29
- debugErr.log = function () {
30
- if (debug.enabled) {
31
- // if the namespace is enabled, just use the default logger
32
- registerDebug.log(...arguments);
33
- }
34
- else {
35
- // other wise, use the console logger (which could be replaced and silenced)
36
- console.error(...arguments);
37
- }
38
- };
39
- debugErr.enabled = true;
40
- return new DebugLogger(debug, debugErr, properties);
41
- }
42
- /**
43
- * Mix in debug logger with another logger.
44
- * Returned logger will output events to both newly created debug logger, as well as base logger
45
- * @param namespace - Telemetry event name prefix to add to all events
46
- * @param properties - Base properties to add to all events
47
- * @param propertyGetters - Getters to add additional properties to all events
48
- * @param baseLogger - Base logger to output events (in addition to debug logger being created). Can be undefined.
49
- */
50
- static mixinDebugLogger(namespace, baseLogger, properties) {
51
- if (!baseLogger) {
52
- return DebugLogger.create(namespace, properties);
53
- }
54
- const multiSinkLogger = new MultiSinkLogger(undefined, properties);
55
- multiSinkLogger.addLogger(DebugLogger.create(namespace, this.tryGetBaseLoggerProps(baseLogger)));
56
- multiSinkLogger.addLogger(ChildLogger.create(baseLogger, namespace));
57
- return multiSinkLogger;
58
- }
59
- static tryGetBaseLoggerProps(baseLogger) {
60
- if (baseLogger instanceof TelemetryLogger) {
61
- return baseLogger.properties;
62
- }
63
- return undefined;
64
- }
65
- /**
66
- * Send an event to debug loggers
67
- *
68
- * @param event - the event to send
69
- */
70
- send(event) {
71
- const newEvent = this.prepareEvent(event);
72
- const isError = newEvent.category === "error";
73
- let logger = isError ? this.debugErr : this.debug;
74
- // Use debug's coloring schema for base of the event
75
- const index = event.eventName.lastIndexOf(TelemetryLogger.eventNamespaceSeparator);
76
- const name = event.eventName.substring(index + 1);
77
- if (index > 0) {
78
- logger = logger.extend(event.eventName.substring(0, index));
79
- }
80
- newEvent.eventName = undefined;
81
- let tick = "";
82
- tick = `tick=${TelemetryLogger.formatTick(performance.now())}`;
83
- // Extract stack to put it last, but also to avoid escaping '\n' in it by JSON.stringify below
84
- const stack = newEvent.stack ? newEvent.stack : "";
85
- newEvent.stack = undefined;
86
- // Watch out for circular references - they can come from two sources
87
- // 1) error object - we do not control it and should remove it and retry
88
- // 2) properties supplied by telemetry caller - that's a bug that should be addressed!
89
- let payload;
90
- try {
91
- payload = JSON.stringify(newEvent);
92
- }
93
- catch (error) {
94
- newEvent.error = undefined;
95
- payload = JSON.stringify(newEvent);
96
- }
97
- if (payload === "{}") {
98
- payload = "";
99
- }
100
- // Force errors out, to help with diagnostics
101
- if (isError) {
102
- logger.enabled = true;
103
- }
104
- // Print multi-line.
105
- logger(`${name} ${payload} ${tick} ${stack}`);
106
- }
107
- }
108
- //# sourceMappingURL=debugLogger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"debugLogger.js","sourceRoot":"","sources":["../src/debugLogger.ts"],"names":[],"mappings":"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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tITelemetryBaseEvent,\n\tITelemetryBaseLogger,\n\tITelemetryProperties,\n} from \"@fluidframework/core-interfaces\";\nimport { performance } from \"@fluidframework/common-utils\";\nimport { debug as registerDebug, IDebugger } from \"debug\";\nimport {\n\tTelemetryLogger,\n\tMultiSinkLogger,\n\tChildLogger,\n\tITelemetryLoggerPropertyBags,\n} from \"./logger\";\n\n/**\n * Implementation of debug logger\n */\nexport class DebugLogger extends TelemetryLogger {\n\t/**\n\t * Create debug logger - all events are output to debug npm library\n\t * @param namespace - Telemetry event name prefix to add to all events\n\t * @param properties - Base properties to add to all events\n\t * @param propertyGetters - Getters to add additional properties to all events\n\t */\n\tpublic static create(\n\t\tnamespace: string,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t): TelemetryLogger {\n\t\t// Setup base logger upfront, such that host can disable it (if needed)\n\t\tconst debug = registerDebug(namespace);\n\n\t\t// Create one for errors that is always enabled\n\t\t// It can be silenced by replacing console.error if the debug namespace is not enabled.\n\t\tconst debugErr = registerDebug(namespace);\n\t\tdebugErr.log = function () {\n\t\t\tif (debug.enabled) {\n\t\t\t\t// if the namespace is enabled, just use the default logger\n\t\t\t\tregisterDebug.log(...arguments);\n\t\t\t} else {\n\t\t\t\t// other wise, use the console logger (which could be replaced and silenced)\n\t\t\t\tconsole.error(...arguments);\n\t\t\t}\n\t\t};\n\t\tdebugErr.enabled = true;\n\n\t\treturn new DebugLogger(debug, debugErr, properties);\n\t}\n\n\t/**\n\t * Mix in debug logger with another logger.\n\t * Returned logger will output events to both newly created debug logger, as well as base logger\n\t * @param namespace - Telemetry event name prefix to add to all events\n\t * @param properties - Base properties to add to all events\n\t * @param propertyGetters - Getters to add additional properties to all events\n\t * @param baseLogger - Base logger to output events (in addition to debug logger being created). Can be undefined.\n\t */\n\tpublic static mixinDebugLogger(\n\t\tnamespace: string,\n\t\tbaseLogger?: ITelemetryBaseLogger,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t): TelemetryLogger {\n\t\tif (!baseLogger) {\n\t\t\treturn DebugLogger.create(namespace, properties);\n\t\t}\n\n\t\tconst multiSinkLogger = new MultiSinkLogger(undefined, properties);\n\t\tmultiSinkLogger.addLogger(\n\t\t\tDebugLogger.create(namespace, this.tryGetBaseLoggerProps(baseLogger)),\n\t\t);\n\t\tmultiSinkLogger.addLogger(ChildLogger.create(baseLogger, namespace));\n\n\t\treturn multiSinkLogger;\n\t}\n\n\tprivate static tryGetBaseLoggerProps(baseLogger?: ITelemetryBaseLogger) {\n\t\tif (baseLogger instanceof TelemetryLogger) {\n\t\t\treturn (baseLogger as any as { properties: ITelemetryLoggerPropertyBags }).properties;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconstructor(\n\t\tprivate readonly debug: IDebugger,\n\t\tprivate readonly debugErr: IDebugger,\n\t\tproperties?: ITelemetryLoggerPropertyBags,\n\t) {\n\t\tsuper(undefined, properties);\n\t}\n\n\t/**\n\t * Send an event to debug loggers\n\t *\n\t * @param event - the event to send\n\t */\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\tconst newEvent: ITelemetryProperties = this.prepareEvent(event);\n\t\tconst isError = newEvent.category === \"error\";\n\t\tlet logger = isError ? this.debugErr : this.debug;\n\n\t\t// Use debug's coloring schema for base of the event\n\t\tconst index = event.eventName.lastIndexOf(TelemetryLogger.eventNamespaceSeparator);\n\t\tconst name = event.eventName.substring(index + 1);\n\t\tif (index > 0) {\n\t\t\tlogger = logger.extend(event.eventName.substring(0, index));\n\t\t}\n\t\tnewEvent.eventName = undefined;\n\n\t\tlet tick = \"\";\n\t\ttick = `tick=${TelemetryLogger.formatTick(performance.now())}`;\n\n\t\t// Extract stack to put it last, but also to avoid escaping '\\n' in it by JSON.stringify below\n\t\tconst stack = newEvent.stack ? newEvent.stack : \"\";\n\t\tnewEvent.stack = undefined;\n\n\t\t// Watch out for circular references - they can come from two sources\n\t\t// 1) error object - we do not control it and should remove it and retry\n\t\t// 2) properties supplied by telemetry caller - that's a bug that should be addressed!\n\t\tlet payload: string;\n\t\ttry {\n\t\t\tpayload = JSON.stringify(newEvent);\n\t\t} catch (error) {\n\t\t\tnewEvent.error = undefined;\n\t\t\tpayload = JSON.stringify(newEvent);\n\t\t}\n\n\t\tif (payload === \"{}\") {\n\t\t\tpayload = \"\";\n\t\t}\n\n\t\t// Force errors out, to help with diagnostics\n\t\tif (isError) {\n\t\t\tlogger.enabled = true;\n\t\t}\n\n\t\t// Print multi-line.\n\t\tlogger(`${name} ${payload} ${tick} ${stack}`);\n\t}\n}\n"]}
@@ -1,143 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- import {
7
- ITelemetryBaseEvent,
8
- ITelemetryBaseLogger,
9
- ITelemetryProperties,
10
- } from "@fluidframework/core-interfaces";
11
- import { performance } from "@fluidframework/common-utils";
12
- import { debug as registerDebug, IDebugger } from "debug";
13
- import {
14
- TelemetryLogger,
15
- MultiSinkLogger,
16
- ChildLogger,
17
- ITelemetryLoggerPropertyBags,
18
- } from "./logger";
19
-
20
- /**
21
- * Implementation of debug logger
22
- */
23
- export class DebugLogger extends TelemetryLogger {
24
- /**
25
- * Create debug logger - all events are output to debug npm library
26
- * @param namespace - Telemetry event name prefix to add to all events
27
- * @param properties - Base properties to add to all events
28
- * @param propertyGetters - Getters to add additional properties to all events
29
- */
30
- public static create(
31
- namespace: string,
32
- properties?: ITelemetryLoggerPropertyBags,
33
- ): TelemetryLogger {
34
- // Setup base logger upfront, such that host can disable it (if needed)
35
- const debug = registerDebug(namespace);
36
-
37
- // Create one for errors that is always enabled
38
- // It can be silenced by replacing console.error if the debug namespace is not enabled.
39
- const debugErr = registerDebug(namespace);
40
- debugErr.log = function () {
41
- if (debug.enabled) {
42
- // if the namespace is enabled, just use the default logger
43
- registerDebug.log(...arguments);
44
- } else {
45
- // other wise, use the console logger (which could be replaced and silenced)
46
- console.error(...arguments);
47
- }
48
- };
49
- debugErr.enabled = true;
50
-
51
- return new DebugLogger(debug, debugErr, properties);
52
- }
53
-
54
- /**
55
- * Mix in debug logger with another logger.
56
- * Returned logger will output events to both newly created debug logger, as well as base logger
57
- * @param namespace - Telemetry event name prefix to add to all events
58
- * @param properties - Base properties to add to all events
59
- * @param propertyGetters - Getters to add additional properties to all events
60
- * @param baseLogger - Base logger to output events (in addition to debug logger being created). Can be undefined.
61
- */
62
- public static mixinDebugLogger(
63
- namespace: string,
64
- baseLogger?: ITelemetryBaseLogger,
65
- properties?: ITelemetryLoggerPropertyBags,
66
- ): TelemetryLogger {
67
- if (!baseLogger) {
68
- return DebugLogger.create(namespace, properties);
69
- }
70
-
71
- const multiSinkLogger = new MultiSinkLogger(undefined, properties);
72
- multiSinkLogger.addLogger(
73
- DebugLogger.create(namespace, this.tryGetBaseLoggerProps(baseLogger)),
74
- );
75
- multiSinkLogger.addLogger(ChildLogger.create(baseLogger, namespace));
76
-
77
- return multiSinkLogger;
78
- }
79
-
80
- private static tryGetBaseLoggerProps(baseLogger?: ITelemetryBaseLogger) {
81
- if (baseLogger instanceof TelemetryLogger) {
82
- return (baseLogger as any as { properties: ITelemetryLoggerPropertyBags }).properties;
83
- }
84
- return undefined;
85
- }
86
-
87
- constructor(
88
- private readonly debug: IDebugger,
89
- private readonly debugErr: IDebugger,
90
- properties?: ITelemetryLoggerPropertyBags,
91
- ) {
92
- super(undefined, properties);
93
- }
94
-
95
- /**
96
- * Send an event to debug loggers
97
- *
98
- * @param event - the event to send
99
- */
100
- public send(event: ITelemetryBaseEvent): void {
101
- const newEvent: ITelemetryProperties = this.prepareEvent(event);
102
- const isError = newEvent.category === "error";
103
- let logger = isError ? this.debugErr : this.debug;
104
-
105
- // Use debug's coloring schema for base of the event
106
- const index = event.eventName.lastIndexOf(TelemetryLogger.eventNamespaceSeparator);
107
- const name = event.eventName.substring(index + 1);
108
- if (index > 0) {
109
- logger = logger.extend(event.eventName.substring(0, index));
110
- }
111
- newEvent.eventName = undefined;
112
-
113
- let tick = "";
114
- tick = `tick=${TelemetryLogger.formatTick(performance.now())}`;
115
-
116
- // Extract stack to put it last, but also to avoid escaping '\n' in it by JSON.stringify below
117
- const stack = newEvent.stack ? newEvent.stack : "";
118
- newEvent.stack = undefined;
119
-
120
- // Watch out for circular references - they can come from two sources
121
- // 1) error object - we do not control it and should remove it and retry
122
- // 2) properties supplied by telemetry caller - that's a bug that should be addressed!
123
- let payload: string;
124
- try {
125
- payload = JSON.stringify(newEvent);
126
- } catch (error) {
127
- newEvent.error = undefined;
128
- payload = JSON.stringify(newEvent);
129
- }
130
-
131
- if (payload === "{}") {
132
- payload = "";
133
- }
134
-
135
- // Force errors out, to help with diagnostics
136
- if (isError) {
137
- logger.enabled = true;
138
- }
139
-
140
- // Print multi-line.
141
- logger(`${name} ${payload} ${tick} ${stack}`);
142
- }
143
- }