@microsoft/metrics-ts
Advanced tools
Comparing version 0.0.2-alpha.0c8479eb2.0 to 0.0.2-alpha.140cc095c.0
@@ -1,2 +0,2 @@ | ||
export { timer } from "./timer"; | ||
export { MSTimer } from "./timer"; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.timer = void 0; | ||
exports.MSTimer = void 0; | ||
var timer_1 = require("./timer"); | ||
Object.defineProperty(exports, "timer", { enumerable: true, get: function () { return timer_1.timer; } }); | ||
Object.defineProperty(exports, "MSTimer", { enumerable: true, get: function () { return timer_1.MSTimer; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
export declare const timer: (fn: string) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; | ||
export declare const MSTimer: (fn: string) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; | ||
//# sourceMappingURL=timer.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.timer = void 0; | ||
exports.MSTimer = void 0; | ||
/** | ||
@@ -8,5 +8,12 @@ * Timer - measures call-rate of a function and the distribution of the duration of all calls | ||
const perf_hooks_1 = require("perf_hooks"); | ||
const rawData_1 = require("../rawData"); | ||
const tracing_1 = require("../tracing"); | ||
const writer_1 = require("../writer"); | ||
const timer = (fn) => { | ||
/** | ||
* TODO: allow cutomization | ||
* all in millsecond | ||
*/ | ||
const fast = 1; | ||
const normal = 20; | ||
const MSTimer = (fn) => { | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
@@ -32,4 +39,16 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
const end = perf_hooks_1.performance.now(); | ||
const duration = end - start; | ||
let severity; | ||
if (duration > normal) { | ||
severity = rawData_1.TimerSeverity.Slow; | ||
} | ||
else if (duration > fast) { | ||
severity = rawData_1.TimerSeverity.Normal; | ||
} | ||
else { | ||
severity = rawData_1.TimerSeverity.Fast; | ||
} | ||
const timerData = { | ||
duraion: end - start, | ||
duration: duration, | ||
severity: severity, | ||
}; | ||
@@ -47,4 +66,16 @@ data.timer = timerData; | ||
const end = perf_hooks_1.performance.now(); | ||
const duration = end - start; | ||
let severity; | ||
if (duration > normal) { | ||
severity = rawData_1.TimerSeverity.Slow; | ||
} | ||
else if (duration > fast) { | ||
severity = rawData_1.TimerSeverity.Normal; | ||
} | ||
else { | ||
severity = rawData_1.TimerSeverity.Fast; | ||
} | ||
const timerData = { | ||
duraion: end - start, | ||
duration: duration, | ||
severity: severity, | ||
}; | ||
@@ -59,3 +90,3 @@ data.timer = timerData; | ||
}; | ||
exports.timer = timer; | ||
exports.MSTimer = MSTimer; | ||
//# sourceMappingURL=timer.js.map |
@@ -10,5 +10,11 @@ export interface tracePoint { | ||
} | ||
export declare enum TimerSeverity { | ||
Fast = "fast", | ||
Normal = "normal", | ||
Slow = "slow" | ||
} | ||
export interface timerData { | ||
duraion: number; | ||
duration: number; | ||
severity: TimerSeverity; | ||
} | ||
//# sourceMappingURL=rawData.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TimerSeverity = void 0; | ||
var TimerSeverity; | ||
(function (TimerSeverity) { | ||
TimerSeverity["Fast"] = "fast"; | ||
TimerSeverity["Normal"] = "normal"; | ||
TimerSeverity["Slow"] = "slow"; | ||
})(TimerSeverity = exports.TimerSeverity || (exports.TimerSeverity = {})); | ||
//# sourceMappingURL=rawData.js.map |
{ | ||
"name": "@microsoft/metrics-ts", | ||
"version": "0.0.2-alpha.0c8479eb2.0", | ||
"version": "0.0.2-alpha.140cc095c.0", | ||
"description": "Add metrics without intruding source code", | ||
@@ -62,3 +62,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "20d795492c2079210d5c18537997f193f2e1a982" | ||
"gitHead": "85e7149b455024eef887abaef3d19e7f55fdeb54" | ||
} |
import * as path123 from "path"; | ||
import { timer } from "@microsoft/metrics-ts"; | ||
import { MSTimer } from "@microsoft/metrics-ts"; | ||
@@ -9,3 +9,3 @@ function delay(ms: number) { | ||
class Foo { | ||
@timer() | ||
@MSTimer(__filename) | ||
bar() { | ||
@@ -17,3 +17,3 @@ const r = this.baz(); | ||
@timer() | ||
@MSTimer(__filename) | ||
baz(): number[] { | ||
@@ -24,3 +24,3 @@ path123.join("a", "b"); | ||
@timer() | ||
@MSTimer(__filename) | ||
async buz(arg: string, arg2: any) { | ||
@@ -27,0 +27,0 @@ await delay(1000); |
@@ -1,1 +0,1 @@ | ||
export { timer } from "./timer"; | ||
export { MSTimer } from "./timer"; |
@@ -5,7 +5,14 @@ /** | ||
import { performance } from "perf_hooks"; | ||
import { timerData, tracePoint } from "../rawData"; | ||
import { timerData, TimerSeverity, tracePoint } from "../rawData"; | ||
import { traceId } from "../tracing"; | ||
import { appendOutput, appendOutputSync } from "../writer"; | ||
export const timer = (fn: string) => { | ||
/** | ||
* TODO: allow cutomization | ||
* all in millsecond | ||
*/ | ||
const fast = 1; | ||
const normal = 20; | ||
export const MSTimer = (fn: string) => { | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
@@ -34,5 +41,16 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
const end = performance.now(); | ||
const duration = end - start; | ||
let severity: TimerSeverity; | ||
if (duration > normal) { | ||
severity = TimerSeverity.Slow; | ||
} else if (duration > fast) { | ||
severity = TimerSeverity.Normal; | ||
} else { | ||
severity = TimerSeverity.Fast; | ||
} | ||
const timerData: timerData = { | ||
duraion: end - start, | ||
duration: duration, | ||
severity: severity, | ||
}; | ||
data.timer = timerData; | ||
@@ -50,5 +68,16 @@ | ||
const end = performance.now(); | ||
const duration = end - start; | ||
let severity: TimerSeverity; | ||
if (duration > normal) { | ||
severity = TimerSeverity.Slow; | ||
} else if (duration > fast) { | ||
severity = TimerSeverity.Normal; | ||
} else { | ||
severity = TimerSeverity.Fast; | ||
} | ||
const timerData: timerData = { | ||
duraion: end - start, | ||
duration: duration, | ||
severity: severity, | ||
}; | ||
data.timer = timerData; | ||
@@ -55,0 +84,0 @@ |
@@ -14,4 +14,11 @@ export interface tracePoint { | ||
export enum TimerSeverity { | ||
Fast = "fast", | ||
Normal = "normal", | ||
Slow = "slow", | ||
} | ||
export interface timerData { | ||
duraion: number; | ||
duration: number; | ||
severity: TimerSeverity; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32463
592