Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@microsoft/metrics-ts

Package Overview
Dependencies
Maintainers
4
Versions
743
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/metrics-ts - npm Package Compare versions

Comparing version 0.0.2-alpha.961514c22.0 to 0.0.2-alpha.9831da6ed.0

2

build/capability/index.d.ts

@@ -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.961514c22.0",
"version": "0.0.2-alpha.9831da6ed.0",
"description": "Add metrics without intruding source code",

@@ -62,3 +62,3 @@ "keywords": [

},
"gitHead": "1ab573d5671f1972e31177b8736114df9c61f4f4"
"gitHead": "9ebad9813c30a759cec96ca5a91162678fc6f1d4"
}
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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc