@across-protocol/sdk 3.2.14-beta.1 → 3.2.15

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.
@@ -52,6 +52,7 @@ var RateLimitedProvider = (function (_super) {
52
52
  method: method,
53
53
  params: params,
54
54
  chainId: this.network.chainId,
55
+ datadog: true,
55
56
  };
56
57
  startTime = performance.now();
57
58
  _a.label = 2;
@@ -1 +1 @@
1
- {"version":3,"file":"rateLimitedProvider.js","sourceRoot":"","sources":["../../../src/providers/rateLimitedProvider.ts"],"names":[],"mappings":";;;;AAIA,+BAA2C;AAC3C,iCAAgC;AAEhC,sDAAyD;AACzD,4DAA0C;AAI1C;IAAyC,+CAAsC;IAM7E,6BACE,cAAsB,EACb,iBAAyB,EACzB,MAEP;QAFO,uBAAA,EAAA,SAAiB,iBAAO,CAAC,YAAY,CAAC;YAC7C,UAAU,EAAE,CAAC,IAAI,iBAAO,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;SAC/C,CAAC;QACF,gCAA+F;aAA/F,UAA+F,EAA/F,qBAA+F,EAA/F,IAA+F;YAA/F,+CAA+F;;QANjG,+BAQW,sBAAsB,UAahC;QAnBU,uBAAiB,GAAjB,iBAAiB,CAAQ;QACzB,YAAM,GAAN,MAAM,CAEb;QAQF,KAAI,CAAC,KAAK,GAAG,IAAA,aAAK,EAAC,UAAO,EAA4C,EAAE,QAAoB;gBAAhE,QAAQ,cAAA,EAAE,OAAO,aAAA,EAAE,MAAM,YAAA;;;;gCACnD,WAAM,IAAI,CAAC,eAAe,OAApB,IAAI,EAAoB,QAAQ,EACnC,IAAI,CAAC,OAAO,CAAC;iCACb,KAAK,CAAC,MAAM,CAAC,EAAA;;4BAFhB,SAEgB,CAAC;4BAGjB,QAAQ,EAAE,CAAC;;;;;SACZ,EAAE,cAAc,CAAC,CAAC;;IACrB,CAAC;IAEK,6CAAe,GAArB,UAAsB,MAAc,EAAE,MAAsB;;;;;;6BACtD,CAAA,IA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gBACP,MAAM,QAAA;aACP,CAAC;YAGF,KAAK,KAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;IACH,0BAAC;AAAD,CAAC,AAnFD,CAAyC,eAAM,CAAC,SAAS,CAAC,qBAAqB,GAmF9E;AAnFY,kDAAmB"}
@@ -0,0 +1,40 @@
1
+ import { Logger } from "winston";
2
+ import { DefaultLogLevels } from "./LogUtils";
3
+ type Detail = {
4
+ message?: string;
5
+ [key: string]: unknown;
6
+ };
7
+ export type PerformanceData = {
8
+ task: string;
9
+ duration: number;
10
+ message: string;
11
+ at: string;
12
+ data?: Record<string, unknown>;
13
+ };
14
+ type ProfilerOptions = {
15
+ logger: Logger;
16
+ at: string;
17
+ logLevel?: DefaultLogLevels;
18
+ } & Record<string, unknown>;
19
+ export declare class Profiler {
20
+ private marks;
21
+ private at;
22
+ private detail;
23
+ private logger;
24
+ private logLevel;
25
+ constructor({ logger, at, logLevel, ...detail }: ProfilerOptions);
26
+ log(logLevel: DefaultLogLevels, data: Parameters<Logger["log"]>[1]): void;
27
+ logMeasure(data: Omit<PerformanceData, "at">, logLevel?: DefaultLogLevels): void;
28
+ start(task: string, detail?: Detail): {
29
+ startTime: number;
30
+ stop: (_detail?: Detail) => number | undefined;
31
+ };
32
+ mark(label: string, detail?: Detail): number;
33
+ measure(task: string, params: {
34
+ from: string;
35
+ to?: string;
36
+ } & Detail): number | undefined;
37
+ measureAsync<T>(pr: Promise<T>, task: string, detail?: Detail): Promise<T>;
38
+ measureSync<T>(fn: () => T, task: string, detail?: Detail): T;
39
+ }
40
+ export {};
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Profiler = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var node_perf_hooks_1 = require("node:perf_hooks");
6
+ var crypto_1 = tslib_1.__importDefault(require("crypto"));
7
+ var defaultMeta = { datadog: true };
8
+ var Profiler = (function () {
9
+ function Profiler(_a) {
10
+ var logger = _a.logger, at = _a.at, logLevel = _a.logLevel, detail = tslib_1.__rest(_a, ["logger", "at", "logLevel"]);
11
+ this.marks = new Map();
12
+ this.logger = logger;
13
+ this.at = at;
14
+ this.logLevel = logLevel !== null && logLevel !== void 0 ? logLevel : "debug";
15
+ this.detail = detail;
16
+ }
17
+ Profiler.prototype.log = function (logLevel, data) {
18
+ this.logger.log(logLevel, tslib_1.__assign(tslib_1.__assign({ at: this.at }, defaultMeta), data));
19
+ };
20
+ Profiler.prototype.logMeasure = function (data, logLevel) {
21
+ if (logLevel === void 0) { logLevel = this.logLevel; }
22
+ this.log(logLevel, tslib_1.__assign({}, data));
23
+ };
24
+ Profiler.prototype.start = function (task, detail) {
25
+ var _this = this;
26
+ var start = crypto_1.default.randomUUID();
27
+ var startTime = this.mark(start, detail);
28
+ return {
29
+ startTime: startTime,
30
+ stop: function (_detail) { return _this.measure(task, tslib_1.__assign(tslib_1.__assign({ from: start }, (detail !== null && detail !== void 0 ? detail : {})), (_detail !== null && _detail !== void 0 ? _detail : {}))); },
31
+ };
32
+ };
33
+ Profiler.prototype.mark = function (label, detail) {
34
+ var _a;
35
+ var currentTime = node_perf_hooks_1.performance.now();
36
+ this.detail = tslib_1.__assign(tslib_1.__assign({}, ((_a = this.detail) !== null && _a !== void 0 ? _a : {})), (detail !== null && detail !== void 0 ? detail : {}));
37
+ this.marks.set(label, { time: currentTime, detail: detail });
38
+ return currentTime;
39
+ };
40
+ Profiler.prototype.measure = function (task, params) {
41
+ var _a, _b;
42
+ var from = params.from, to = params.to, detail = tslib_1.__rest(params, ["from", "to"]);
43
+ var startMark = this.marks.get(from);
44
+ var endMark = to ? this.marks.get(to) : undefined;
45
+ if (!startMark) {
46
+ this.log("warn", tslib_1.__assign({ message: "Cannot find start mark for label \"".concat(from, "\".") }, this.detail));
47
+ return;
48
+ }
49
+ var endTime = (_a = endMark === null || endMark === void 0 ? void 0 : endMark.time) !== null && _a !== void 0 ? _a : node_perf_hooks_1.performance.now();
50
+ var duration = endTime - startMark.time;
51
+ var _c = tslib_1.__assign(tslib_1.__assign({}, ((_b = this.detail) !== null && _b !== void 0 ? _b : {})), (detail !== null && detail !== void 0 ? detail : {})), message = _c.message, combinedDetail = tslib_1.__rest(_c, ["message"]);
52
+ var defaultMessage = "Profiler Log: ".concat(task);
53
+ this.logMeasure({
54
+ task: task,
55
+ duration: duration,
56
+ message: message !== null && message !== void 0 ? message : defaultMessage,
57
+ data: combinedDetail,
58
+ });
59
+ return duration;
60
+ };
61
+ Profiler.prototype.measureAsync = function (pr, task, detail) {
62
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
63
+ var startTime, result, endTime, duration, _a, message, combinedDetail, defaultMessage;
64
+ return tslib_1.__generator(this, function (_b) {
65
+ switch (_b.label) {
66
+ case 0:
67
+ startTime = node_perf_hooks_1.performance.now();
68
+ _b.label = 1;
69
+ case 1:
70
+ _b.trys.push([1, , 3, 4]);
71
+ return [4, pr];
72
+ case 2:
73
+ result = _b.sent();
74
+ return [2, result];
75
+ case 3:
76
+ endTime = node_perf_hooks_1.performance.now();
77
+ duration = endTime - startTime;
78
+ _a = tslib_1.__assign({}, detail), message = _a.message, combinedDetail = tslib_1.__rest(_a, ["message"]);
79
+ defaultMessage = "Profiler Log: ".concat(task);
80
+ this.logMeasure({
81
+ task: task,
82
+ duration: duration,
83
+ message: message !== null && message !== void 0 ? message : defaultMessage,
84
+ data: combinedDetail,
85
+ });
86
+ return [7];
87
+ case 4: return [2];
88
+ }
89
+ });
90
+ });
91
+ };
92
+ Profiler.prototype.measureSync = function (fn, task, detail) {
93
+ var startTime = node_perf_hooks_1.performance.now();
94
+ try {
95
+ var result = fn();
96
+ return result;
97
+ }
98
+ finally {
99
+ var endTime = node_perf_hooks_1.performance.now();
100
+ var duration = endTime - startTime;
101
+ var _a = tslib_1.__assign({}, detail), message = _a.message, combinedDetail = tslib_1.__rest(_a, ["message"]);
102
+ var defaultMessage = "Profiler Log: ".concat(task);
103
+ this.logMeasure({
104
+ task: task,
105
+ duration: duration,
106
+ message: message !== null && message !== void 0 ? message : defaultMessage,
107
+ data: combinedDetail,
108
+ });
109
+ }
110
+ };
111
+ return Profiler;
112
+ }());
113
+ exports.Profiler = Profiler;
114
+ //# sourceMappingURL=Profiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Profiler.js","sourceRoot":"","sources":["../../../src/utils/Profiler.ts"],"names":[],"mappings":";;;;AAAA,mDAA8C;AAE9C,0DAA4B;AAQ5B,IAAM,WAAW,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAgBtC;IAaE,kBAAY,EAAoD;QAAlD,IAAA,MAAM,YAAA,EAAE,EAAE,QAAA,EAAE,QAAQ,cAAA,EAAK,MAAM,sBAAjC,4BAAmC,CAAF;QAC3C,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,QAAQ,GAAG,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,OAAO,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,sBAAG,GAAH,UAAI,QAA0B,EAAE,IAAkC;QAChE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,sCACtB,EAAE,EAAE,IAAI,CAAC,EAAE,IACR,WAAW,GACX,IAAI,EACP,CAAC;IACL,CAAC;IAED,6BAAU,GAAV,UAAW,IAAiC,EAAE,QAA0C;QAA1C,yBAAA,EAAA,WAA6B,IAAI,CAAC,QAAQ;QACtF,IAAI,CAAC,GAAG,CAAC,QAAQ,uBACZ,IAAI,EACP,CAAC;IACL,CAAC;IAQD,wBAAK,GAAL,UAAM,IAAY,EAAE,MAAe;QAAnC,iBAOC;QANC,IAAM,KAAK,GAAG,gBAAM,CAAC,UAAU,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AAO,aAAP,OAAO,cAAP,OAAO,GAAI,cAAc;4BAClC,IAAI,EAAE,cAAc;yBACrB,CAAC,CAAC;;;;;;KAEN;IASD,8BAAW,GAAX,UAAe,EAAW,EAAE,IAAY,EAAE,MAAe;QACvD,IAAM,SAAS,GAAG,6BAAW,CAAC,GAAG,EAAE,CAAC;QAEpC,IAAI;YACF,IAAM,MAAM,GAAG,EAAE,EAAE,CAAC;YACpB,OAAO,MAAM,CAAC;SACf;gBAAS;YACR,IAAM,OAAO,GAAG,6BAAW,CAAC,GAAG,EAAE,CAAC;YAClC,IAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;YACrC,IAAM,0BAAsC,MAAM,CAAE,EAA5C,OAAO,aAAA,EAAK,cAAc,sBAA5B,WAA8B,CAAgB,CAAC;YACrD,IAAM,cAAc,GAAG,wBAAiB,IAAI,CAAE,CAAC;YAE/C,IAAI,CAAC,UAAU,CAAC;gBACd,IAAI,MAAA;gBACJ,QAAQ,UAAA;gBACR,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,cAAc;gBAClC,IAAI,EAAE,cAAc;aACrB,CAAC,CAAC;SACJ;IACH,CAAC;IACH,eAAC;AAAD,CAAC,AAvKD,IAuKC;AAvKY,4BAAQ"}
@@ -62,6 +62,7 @@ var RateLimitedProvider = /** @class */ (function (_super) {
62
62
  method: method,
63
63
  params: params,
64
64
  chainId: this.network.chainId,
65
+ datadog: true,
65
66
  };
66
67
  startTime = performance.now();
67
68
  _a.label = 2;
@@ -1 +1 @@
1
- {"version":3,"file":"rateLimitedProvider.js","sourceRoot":"","sources":["../../../src/providers/rateLimitedProvider.ts"],"names":[],"mappings":"AAAA,iHAAiH;AACjH,uFAAuF;AACvF,sFAAsF;;AAEtF,OAAO,EAAe,KAAK,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB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,EAAE,MAAM;YAC1C,IAAM,IAAI,GAAkB;gBAC1B,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;gBAC1B,OAAO,SAAA;gBACP,MAAM,QAAA;aACP,CAAC;YACF,4DAA4D;YAC5D,6CAA6C;YAC7C,KAAK,KAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;IACH,0BAAC;AAAD,CAAC,AAnFD,CAAyC,MAAM,CAAC,SAAS,CAAC,qBAAqB,GAmF9E"}
@@ -0,0 +1,81 @@
1
+ import { Logger } from "winston";
2
+ import { DefaultLogLevels } from "./LogUtils";
3
+ type Detail = {
4
+ message?: string;
5
+ [key: string]: unknown;
6
+ };
7
+ export type PerformanceData = {
8
+ task: string;
9
+ duration: number;
10
+ message: string;
11
+ at: string;
12
+ data?: Record<string, unknown>;
13
+ };
14
+ type ProfilerOptions = {
15
+ logger: Logger;
16
+ at: string;
17
+ logLevel?: DefaultLogLevels;
18
+ } & Record<string, unknown>;
19
+ export declare class Profiler {
20
+ private marks;
21
+ private at;
22
+ private detail;
23
+ private logger;
24
+ private logLevel;
25
+ /**
26
+ * Initializes a new instance of the Profiler class.
27
+ * @param logger The logger instance for logging performance data.
28
+ * @param at A string identifier for where the profiler is used.
29
+ * @param detail Optional additional detail data.
30
+ */
31
+ constructor({ logger, at, logLevel, ...detail }: ProfilerOptions);
32
+ log(logLevel: DefaultLogLevels, data: Parameters<Logger["log"]>[1]): void;
33
+ logMeasure(data: Omit<PerformanceData, "at">, logLevel?: DefaultLogLevels): void;
34
+ /**
35
+ * Starts a profiling session for a task.
36
+ * @param task The name of the task being measured.
37
+ * @param detail Optional detail data to merge.
38
+ * @returns An object containing the start time and a stop function.
39
+ */
40
+ start(task: string, detail?: Detail): {
41
+ startTime: number;
42
+ stop: (_detail?: Detail) => number | undefined;
43
+ };
44
+ /**
45
+ * Records a mark with a label and optional detail.
46
+ * @param label The label for the mark.
47
+ * @param detail Optional detail data to merge.
48
+ * @returns The current timestamp in milliseconds.
49
+ */
50
+ mark(label: string, detail?: Detail): number;
51
+ /**
52
+ * Measures the duration between two marks and logs the performance data.
53
+ * @param task The name of the task for this measurement.
54
+ * @param params An object containing:
55
+ * - `from`: The label of the starting mark.
56
+ * - `to` (optional): The label of the ending mark.
57
+ * - Additional detail data to merge.
58
+ * @returns The duration in milliseconds, or undefined if the start mark is not found.
59
+ */
60
+ measure(task: string, params: {
61
+ from: string;
62
+ to?: string;
63
+ } & Detail): number | undefined;
64
+ /**
65
+ * Measures the performance of an asynchronous operation represented by a promise.
66
+ * @param pr The promise representing the asynchronous operation to measure.
67
+ * @param task The name of the task for this measurement.
68
+ * @param detail Optional detail data to merge.
69
+ * @returns A promise that resolves with the result of the asynchronous operation.
70
+ */
71
+ measureAsync<T>(pr: Promise<T>, task: string, detail?: Detail): Promise<T>;
72
+ /**
73
+ * Measures the performance of a synchronous function by wrapping it.
74
+ * @param fn The synchronous function to measure.
75
+ * @param task The name of the task for this measurement.
76
+ * @param detail Optional detail data to merge.
77
+ * @returns The result of the synchronous function.
78
+ */
79
+ measureSync<T>(fn: () => T, task: string, detail?: Detail): T;
80
+ }
81
+ export {};
@@ -0,0 +1,155 @@
1
+ import { __assign, __awaiter, __generator, __rest } from "tslib";
2
+ import { performance } from "node:perf_hooks";
3
+ import crypto from "crypto";
4
+ var defaultMeta = { datadog: true };
5
+ var Profiler = /** @class */ (function () {
6
+ /**
7
+ * Initializes a new instance of the Profiler class.
8
+ * @param logger The logger instance for logging performance data.
9
+ * @param at A string identifier for where the profiler is used.
10
+ * @param detail Optional additional detail data.
11
+ */
12
+ function Profiler(_a) {
13
+ var logger = _a.logger, at = _a.at, logLevel = _a.logLevel, detail = __rest(_a, ["logger", "at", "logLevel"]);
14
+ this.marks = new Map();
15
+ this.logger = logger;
16
+ this.at = at;
17
+ this.logLevel = logLevel !== null && logLevel !== void 0 ? logLevel : "debug";
18
+ this.detail = detail;
19
+ }
20
+ Profiler.prototype.log = function (logLevel, data) {
21
+ this.logger.log(logLevel, __assign(__assign({ at: this.at }, defaultMeta), data));
22
+ };
23
+ Profiler.prototype.logMeasure = function (data, logLevel) {
24
+ if (logLevel === void 0) { logLevel = this.logLevel; }
25
+ this.log(logLevel, __assign({}, data));
26
+ };
27
+ /**
28
+ * Starts a profiling session for a task.
29
+ * @param task The name of the task being measured.
30
+ * @param detail Optional detail data to merge.
31
+ * @returns An object containing the start time and a stop function.
32
+ */
33
+ Profiler.prototype.start = function (task, detail) {
34
+ var _this = this;
35
+ var start = crypto.randomUUID();
36
+ var startTime = this.mark(start, detail);
37
+ return {
38
+ startTime: startTime,
39
+ stop: function (_detail) { return _this.measure(task, __assign(__assign({ from: start }, (detail !== null && detail !== void 0 ? detail : {})), (_detail !== null && _detail !== void 0 ? _detail : {}))); },
40
+ };
41
+ };
42
+ /**
43
+ * Records a mark with a label and optional detail.
44
+ * @param label The label for the mark.
45
+ * @param detail Optional detail data to merge.
46
+ * @returns The current timestamp in milliseconds.
47
+ */
48
+ Profiler.prototype.mark = function (label, detail) {
49
+ var _a;
50
+ var currentTime = performance.now();
51
+ // Merge additional data
52
+ this.detail = __assign(__assign({}, ((_a = this.detail) !== null && _a !== void 0 ? _a : {})), (detail !== null && detail !== void 0 ? detail : {}));
53
+ // Store the mark
54
+ this.marks.set(label, { time: currentTime, detail: detail });
55
+ return currentTime;
56
+ };
57
+ /**
58
+ * Measures the duration between two marks and logs the performance data.
59
+ * @param task The name of the task for this measurement.
60
+ * @param params An object containing:
61
+ * - `from`: The label of the starting mark.
62
+ * - `to` (optional): The label of the ending mark.
63
+ * - Additional detail data to merge.
64
+ * @returns The duration in milliseconds, or undefined if the start mark is not found.
65
+ */
66
+ Profiler.prototype.measure = function (task, params) {
67
+ var _a, _b;
68
+ var from = params.from, to = params.to, detail = __rest(params, ["from", "to"]);
69
+ var startMark = this.marks.get(from);
70
+ var endMark = to ? this.marks.get(to) : undefined;
71
+ if (!startMark) {
72
+ this.log("warn", __assign({ message: "Cannot find start mark for label \"".concat(from, "\".") }, this.detail));
73
+ return;
74
+ }
75
+ var endTime = (_a = endMark === null || endMark === void 0 ? void 0 : endMark.time) !== null && _a !== void 0 ? _a : performance.now();
76
+ var duration = endTime - startMark.time;
77
+ // Merge detail
78
+ var _c = __assign(__assign({}, ((_b = this.detail) !== null && _b !== void 0 ? _b : {})), (detail !== null && detail !== void 0 ? detail : {})), message = _c.message, combinedDetail = __rest(_c, ["message"]);
79
+ var defaultMessage = "Profiler Log: ".concat(task);
80
+ this.logMeasure({
81
+ task: task,
82
+ duration: duration,
83
+ message: message !== null && message !== void 0 ? message : defaultMessage,
84
+ data: combinedDetail,
85
+ });
86
+ return duration;
87
+ };
88
+ /**
89
+ * Measures the performance of an asynchronous operation represented by a promise.
90
+ * @param pr The promise representing the asynchronous operation to measure.
91
+ * @param task The name of the task for this measurement.
92
+ * @param detail Optional detail data to merge.
93
+ * @returns A promise that resolves with the result of the asynchronous operation.
94
+ */
95
+ Profiler.prototype.measureAsync = function (pr, task, detail) {
96
+ return __awaiter(this, void 0, void 0, function () {
97
+ var startTime, result, endTime, duration, _a, message, combinedDetail, defaultMessage;
98
+ return __generator(this, function (_b) {
99
+ switch (_b.label) {
100
+ case 0:
101
+ startTime = performance.now();
102
+ _b.label = 1;
103
+ case 1:
104
+ _b.trys.push([1, , 3, 4]);
105
+ return [4 /*yield*/, pr];
106
+ case 2:
107
+ result = _b.sent();
108
+ return [2 /*return*/, result];
109
+ case 3:
110
+ endTime = performance.now();
111
+ duration = endTime - startTime;
112
+ _a = __assign({}, detail), message = _a.message, combinedDetail = __rest(_a, ["message"]);
113
+ defaultMessage = "Profiler Log: ".concat(task);
114
+ this.logMeasure({
115
+ task: task,
116
+ duration: duration,
117
+ message: message !== null && message !== void 0 ? message : defaultMessage,
118
+ data: combinedDetail,
119
+ });
120
+ return [7 /*endfinally*/];
121
+ case 4: return [2 /*return*/];
122
+ }
123
+ });
124
+ });
125
+ };
126
+ /**
127
+ * Measures the performance of a synchronous function by wrapping it.
128
+ * @param fn The synchronous function to measure.
129
+ * @param task The name of the task for this measurement.
130
+ * @param detail Optional detail data to merge.
131
+ * @returns The result of the synchronous function.
132
+ */
133
+ Profiler.prototype.measureSync = function (fn, task, detail) {
134
+ var startTime = performance.now();
135
+ try {
136
+ var result = fn();
137
+ return result;
138
+ }
139
+ finally {
140
+ var endTime = performance.now();
141
+ var duration = endTime - startTime;
142
+ var _a = __assign({}, detail), message = _a.message, combinedDetail = __rest(_a, ["message"]);
143
+ var defaultMessage = "Profiler Log: ".concat(task);
144
+ this.logMeasure({
145
+ task: task,
146
+ duration: duration,
147
+ message: message !== null && message !== void 0 ? message : defaultMessage,
148
+ data: combinedDetail,
149
+ });
150
+ }
151
+ };
152
+ return Profiler;
153
+ }());
154
+ export { Profiler };
155
+ //# sourceMappingURL=Profiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Profiler.js","sourceRoot":"","sources":["../../../src/utils/Profiler.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAQ5B,IAAM,WAAW,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAgBtC;IAOE;;;;;OAKG;IACH,kBAAY,EAAoD;QAAlD,IAAA,MAAM,YAAA,EAAE,EAAE,QAAA,EAAE,QAAQ,cAAA,EAAK,MAAM,cAAjC,4BAAmC,CAAF;QAC3C,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,QAAQ,GAAG,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,OAAO,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,sBAAG,GAAH,UA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AC,CAAC;SACJ;IACH,CAAC;IACH,eAAC;AAAD,CAAC,AAvKD,IAuKC"}
@@ -1 +1 @@
1
- {"version":3,"file":"rateLimitedProvider.d.ts","sourceRoot":"","sources":["../../../src/providers/rateLimitedProvider.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAgB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAI1C,qBAAa,mBAAoB,SAAQ,MAAM,CAAC,SAAS,CAAC,qBAAqB;IAQ3E,QAAQ,CAAC,iBAAiB,EAAE,MAAM;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM;IAPzB,OAAO,CAAC,KAAK,CAA6B;gBAKxC,cAAc,EAAE,MAAM,EACb,iBAAiB,EAAE,MAAM,EACzB,MAAM,GAAE,MAEf,EACF,GAAG,sBAAsB,EAAE,qBAAqB,CAAC,OAAO,MAAM,CAAC,SAAS,CAAC,qBAAqB,CAAC;IAiB3F,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC;IAwCnD,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;CAaxE"}
1
+ {"version":3,"file":"rateLimitedProvider.d.ts","sourceRoot":"","sources":["../../../src/providers/rateLimitedProvider.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAgB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAI1C,qBAAa,mBAAoB,SAAQ,MAAM,CAAC,SAAS,CAAC,qBAAqB;IAQ3E,QAAQ,CAAC,iBAAiB,EAAE,MAAM;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM;IAPzB,OAAO,CAAC,KAAK,CAA6B;gBAKxC,cAAc,EAAE,MAAM,EACb,iBAAiB,EAAE,MAAM,EACzB,MAAM,GAAE,MAEf,EACF,GAAG,sBAAsB,EAAE,qBAAqB,CAAC,OAAO,MAAM,CAAC,SAAS,CAAC,qBAAqB,CAAC;IAiB3F,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC;IAyCnD,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;CAaxE"}
@@ -0,0 +1,82 @@
1
+ import { Logger } from "winston";
2
+ import { DefaultLogLevels } from "./LogUtils";
3
+ type Detail = {
4
+ message?: string;
5
+ [key: string]: unknown;
6
+ };
7
+ export type PerformanceData = {
8
+ task: string;
9
+ duration: number;
10
+ message: string;
11
+ at: string;
12
+ data?: Record<string, unknown>;
13
+ };
14
+ type ProfilerOptions = {
15
+ logger: Logger;
16
+ at: string;
17
+ logLevel?: DefaultLogLevels;
18
+ } & Record<string, unknown>;
19
+ export declare class Profiler {
20
+ private marks;
21
+ private at;
22
+ private detail;
23
+ private logger;
24
+ private logLevel;
25
+ /**
26
+ * Initializes a new instance of the Profiler class.
27
+ * @param logger The logger instance for logging performance data.
28
+ * @param at A string identifier for where the profiler is used.
29
+ * @param detail Optional additional detail data.
30
+ */
31
+ constructor({ logger, at, logLevel, ...detail }: ProfilerOptions);
32
+ log(logLevel: DefaultLogLevels, data: Parameters<Logger["log"]>[1]): void;
33
+ logMeasure(data: Omit<PerformanceData, "at">, logLevel?: DefaultLogLevels): void;
34
+ /**
35
+ * Starts a profiling session for a task.
36
+ * @param task The name of the task being measured.
37
+ * @param detail Optional detail data to merge.
38
+ * @returns An object containing the start time and a stop function.
39
+ */
40
+ start(task: string, detail?: Detail): {
41
+ startTime: number;
42
+ stop: (_detail?: Detail) => number | undefined;
43
+ };
44
+ /**
45
+ * Records a mark with a label and optional detail.
46
+ * @param label The label for the mark.
47
+ * @param detail Optional detail data to merge.
48
+ * @returns The current timestamp in milliseconds.
49
+ */
50
+ mark(label: string, detail?: Detail): number;
51
+ /**
52
+ * Measures the duration between two marks and logs the performance data.
53
+ * @param task The name of the task for this measurement.
54
+ * @param params An object containing:
55
+ * - `from`: The label of the starting mark.
56
+ * - `to` (optional): The label of the ending mark.
57
+ * - Additional detail data to merge.
58
+ * @returns The duration in milliseconds, or undefined if the start mark is not found.
59
+ */
60
+ measure(task: string, params: {
61
+ from: string;
62
+ to?: string;
63
+ } & Detail): number | undefined;
64
+ /**
65
+ * Measures the performance of an asynchronous operation represented by a promise.
66
+ * @param pr The promise representing the asynchronous operation to measure.
67
+ * @param task The name of the task for this measurement.
68
+ * @param detail Optional detail data to merge.
69
+ * @returns A promise that resolves with the result of the asynchronous operation.
70
+ */
71
+ measureAsync<T>(pr: Promise<T>, task: string, detail?: Detail): Promise<T>;
72
+ /**
73
+ * Measures the performance of a synchronous function by wrapping it.
74
+ * @param fn The synchronous function to measure.
75
+ * @param task The name of the task for this measurement.
76
+ * @param detail Optional detail data to merge.
77
+ * @returns The result of the synchronous function.
78
+ */
79
+ measureSync<T>(fn: () => T, task: string, detail?: Detail): T;
80
+ }
81
+ export {};
82
+ //# sourceMappingURL=Profiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Profiler.d.ts","sourceRoot":"","sources":["../../../src/utils/Profiler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,KAAK,MAAM,GAAG;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAIF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,C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IACG,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAqBhF;;;;;;OAMG;IACH,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,CAAC;CAoB9D"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@across-protocol/sdk",
3
3
  "author": "UMA Team",
4
- "version": "3.2.14-beta.1",
4
+ "version": "3.2.15",
5
5
  "license": "AGPL-3.0",
6
6
  "homepage": "https://docs.across.to/reference/sdk",
7
7
  "files": [
@@ -51,6 +51,7 @@ export class RateLimitedProvider extends ethers.providers.StaticJsonRpcProvider
51
51
  method,
52
52
  params,
53
53
  chainId: this.network.chainId,
54
+ datadog: true,
54
55
  };
55
56
 
56
57
  // In this path we log an rpc response sample.
@@ -0,0 +1,194 @@
1
+ import { performance } from "node:perf_hooks";
2
+ import { Logger } from "winston";
3
+ import crypto from "crypto";
4
+ import { DefaultLogLevels } from "./LogUtils";
5
+
6
+ type Detail = {
7
+ message?: string;
8
+ [key: string]: unknown;
9
+ };
10
+
11
+ const defaultMeta = { datadog: true };
12
+
13
+ export type PerformanceData = {
14
+ task: string; // The name of the task being measured.
15
+ duration: number; // Duration in milliseconds.
16
+ message: string; // A descriptive message about the task.
17
+ at: string; // Identifier indicating where the profiling is happening.
18
+ data?: Record<string, unknown>; // Additional detail data.
19
+ };
20
+
21
+ type ProfilerOptions = {
22
+ logger: Logger;
23
+ at: string;
24
+ logLevel?: DefaultLogLevels;
25
+ } & Record<string, unknown>;
26
+
27
+ export class Profiler {
28
+ private marks: Map<string, { time: number; detail?: Record<string, unknown> }>;
29
+ private at: string;
30
+ private detail: Detail;
31
+ private logger: Logger;
32
+ private logLevel: DefaultLogLevels;
33
+
34
+ /**
35
+ * Initializes a new instance of the Profiler class.
36
+ * @param logger The logger instance for logging performance data.
37
+ * @param at A string identifier for where the profiler is used.
38
+ * @param detail Optional additional detail data.
39
+ */
40
+ constructor({ logger, at, logLevel, ...detail }: ProfilerOptions) {
41
+ this.marks = new Map();
42
+ this.logger = logger;
43
+ this.at = at;
44
+ this.logLevel = logLevel ?? "debug";
45
+ this.detail = detail;
46
+ }
47
+
48
+ log(logLevel: DefaultLogLevels, data: Parameters<Logger["log"]>[1]): void {
49
+ this.logger.log(logLevel, {
50
+ at: this.at,
51
+ ...defaultMeta,
52
+ ...data,
53
+ });
54
+ }
55
+
56
+ logMeasure(data: Omit<PerformanceData, "at">, logLevel: DefaultLogLevels = this.logLevel): void {
57
+ this.log(logLevel, {
58
+ ...data,
59
+ });
60
+ }
61
+
62
+ /**
63
+ * Starts a profiling session for a task.
64
+ * @param task The name of the task being measured.
65
+ * @param detail Optional detail data to merge.
66
+ * @returns An object containing the start time and a stop function.
67
+ */
68
+ start(task: string, detail?: Detail): { startTime: number; stop: (_detail?: Detail) => number | undefined } {
69
+ const start = crypto.randomUUID();
70
+ const startTime = this.mark(start, detail);
71
+ return {
72
+ startTime,
73
+ stop: (_detail?: Detail) => this.measure(task, { from: start, ...(detail ?? {}), ...(_detail ?? {}) }),
74
+ };
75
+ }
76
+
77
+ /**
78
+ * Records a mark with a label and optional detail.
79
+ * @param label The label for the mark.
80
+ * @param detail Optional detail data to merge.
81
+ * @returns The current timestamp in milliseconds.
82
+ */
83
+ mark(label: string, detail?: Detail): number {
84
+ const currentTime = performance.now();
85
+
86
+ // Merge additional data
87
+ this.detail = { ...(this.detail ?? {}), ...(detail ?? {}) };
88
+
89
+ // Store the mark
90
+ this.marks.set(label, { time: currentTime, detail });
91
+ return currentTime;
92
+ }
93
+
94
+ /**
95
+ * Measures the duration between two marks and logs the performance data.
96
+ * @param task The name of the task for this measurement.
97
+ * @param params An object containing:
98
+ * - `from`: The label of the starting mark.
99
+ * - `to` (optional): The label of the ending mark.
100
+ * - Additional detail data to merge.
101
+ * @returns The duration in milliseconds, or undefined if the start mark is not found.
102
+ */
103
+ measure(
104
+ task: string,
105
+ params: {
106
+ from: string;
107
+ to?: string;
108
+ } & Detail
109
+ ): number | undefined {
110
+ const { from, to, ...detail } = params;
111
+ const startMark = this.marks.get(from);
112
+ const endMark = to ? this.marks.get(to) : undefined;
113
+
114
+ if (!startMark) {
115
+ this.log("warn", {
116
+ message: `Cannot find start mark for label "${from}".`,
117
+ ...this.detail,
118
+ });
119
+ return;
120
+ }
121
+ const endTime = endMark?.time ?? performance.now();
122
+
123
+ const duration = endTime - startMark.time;
124
+
125
+ // Merge detail
126
+ const { message, ...combinedDetail } = { ...(this.detail ?? {}), ...(detail ?? {}) };
127
+ const defaultMessage = `Profiler Log: ${task}`;
128
+
129
+ this.logMeasure({
130
+ task,
131
+ duration,
132
+ message: message ?? defaultMessage,
133
+ data: combinedDetail,
134
+ });
135
+
136
+ return duration;
137
+ }
138
+
139
+ /**
140
+ * Measures the performance of an asynchronous operation represented by a promise.
141
+ * @param pr The promise representing the asynchronous operation to measure.
142
+ * @param task The name of the task for this measurement.
143
+ * @param detail Optional detail data to merge.
144
+ * @returns A promise that resolves with the result of the asynchronous operation.
145
+ */
146
+ async measureAsync<T>(pr: Promise<T>, task: string, detail?: Detail): Promise<T> {
147
+ const startTime = performance.now();
148
+
149
+ try {
150
+ const result = await pr;
151
+ return result;
152
+ } finally {
153
+ const endTime = performance.now();
154
+ const duration = endTime - startTime;
155
+ const { message, ...combinedDetail } = { ...detail };
156
+ const defaultMessage = `Profiler Log: ${task}`;
157
+
158
+ this.logMeasure({
159
+ task,
160
+ duration,
161
+ message: message ?? defaultMessage,
162
+ data: combinedDetail,
163
+ });
164
+ }
165
+ }
166
+
167
+ /**
168
+ * Measures the performance of a synchronous function by wrapping it.
169
+ * @param fn The synchronous function to measure.
170
+ * @param task The name of the task for this measurement.
171
+ * @param detail Optional detail data to merge.
172
+ * @returns The result of the synchronous function.
173
+ */
174
+ measureSync<T>(fn: () => T, task: string, detail?: Detail): T {
175
+ const startTime = performance.now();
176
+
177
+ try {
178
+ const result = fn();
179
+ return result;
180
+ } finally {
181
+ const endTime = performance.now();
182
+ const duration = endTime - startTime;
183
+ const { message, ...combinedDetail } = { ...detail };
184
+ const defaultMessage = `Profiler Log: ${task}`;
185
+
186
+ this.logMeasure({
187
+ task,
188
+ duration,
189
+ message: message ?? defaultMessage,
190
+ data: combinedDetail,
191
+ });
192
+ }
193
+ }
194
+ }