New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

prometheus-tracking

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prometheus-tracking - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

lib/tracker.counter.1.d.ts

26

lib/tracker.d.ts

@@ -0,1 +1,4 @@

import { Counter } from './tracker.counter';
import { Gauge } from './tracker.gauge';
import { Histogram } from './tracker.historgram';
export declare class Tracker {

@@ -14,4 +17,25 @@ private name;

private constructor();
trackResponseTime(uri: string, method: string, status: number, seconds: number): void;
trackRequest(uri: string, method: string, status: number, seconds: number): void;
/**
* creates a new counter metric
* @param name name of the counter (used as metric key)
* @param description helpful description for the metric
* @param labels define a list of labels for this metric
*/
createCounter(name: string, description: string, labels: string[]): Counter;
/**
* creates a new gauge metric
* @param name name of the gauge (used as metric key)
* @param description helpful description for the metric
* @param labels define a list of labels for this metric
*/
createGauge(name: string, description: string, labels: string[]): Gauge;
/**
* creates a new histogram metric
* @param name name of the histogram (used as metric key)
* @param description helpful description for the metric
* @param labels define a list of labels for this metric
*/
createHistogram(name: string, description: string, labels: string[]): Histogram;
getMetrics(): any;
}

44

lib/tracker.js

@@ -5,2 +5,5 @@ "use strict";

const client = require("prom-client");
const tracker_counter_1 = require("./tracker.counter");
const tracker_gauge_1 = require("./tracker.gauge");
const tracker_historgram_1 = require("./tracker.historgram");
const NS_PER_SEC = 1000000000;

@@ -10,12 +13,4 @@ class Tracker {

this.name = name;
this.responseTime = new client.Histogram({
name: 'response_time_histogram',
help: 'Response time histogram',
labelNames: ['name', 'uri', 'method', 'status'],
});
this.requestCounter = new client.Counter({
name: 'request_counter',
help: 'Counter of all requests',
labelNames: ['name', 'uri', 'method', 'status'],
});
this.responseTime = this.createHistogram('response_time_histogram', 'Response time histogram', ['name', 'uri', 'method', 'status']);
this.requestCounter = this.createCounter('request_counter', 'Counter of all requests', ['name', 'uri', 'method', 'status']);
if (collectDefaultMetrics) {

@@ -50,6 +45,33 @@ // Probe every 5th second.

}
trackResponseTime(uri, method, status, seconds) {
trackRequest(uri, method, status, seconds) {
this.responseTime.labels(this.name, uri, method, status.toString()).observe(seconds);
this.requestCounter.labels(this.name, uri, method, status.toString()).inc();
}
/**
* creates a new counter metric
* @param name name of the counter (used as metric key)
* @param description helpful description for the metric
* @param labels define a list of labels for this metric
*/
createCounter(name, description, labels) {
return new tracker_counter_1.Counter(name, description, labels);
}
/**
* creates a new gauge metric
* @param name name of the gauge (used as metric key)
* @param description helpful description for the metric
* @param labels define a list of labels for this metric
*/
createGauge(name, description, labels) {
return new tracker_gauge_1.Gauge(name, description, labels);
}
/**
* creates a new histogram metric
* @param name name of the histogram (used as metric key)
* @param description helpful description for the metric
* @param labels define a list of labels for this metric
*/
createHistogram(name, description, labels) {
return new tracker_historgram_1.Histogram(name, description, labels);
}
getMetrics() {

@@ -56,0 +78,0 @@ return client.register.metrics();

{
"name": "prometheus-tracking",
"version": "0.1.0",
"version": "0.2.0",
"description": "prometheus-tracking",

@@ -5,0 +5,0 @@ "author": "",

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