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

grpc-prometheus

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grpc-prometheus - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

27

package.json
{
"name": "grpc-prometheus",
"version": "1.0.0",
"version": "2.0.0",
"description": "Interceptor for the server to collect statistics of calls through Prometheus",
"engines": {
"node": ">=10.10.0"
},
"main": "./src/index.js",

@@ -18,3 +21,4 @@ "types": "./src/index.d.ts",

"build": "npm run build:server && npm run build:client",
"test": "jest --verbose"
"test": "jest --verbose",
"coverageCalculation": "jest --coverage"
},

@@ -36,18 +40,17 @@ "repository": {

"peerDependencies": {
"grpc": "^1.24.2",
"@grpc/grpc-js": "^1.2.0",
"prom-client": "^11.5.3"
},
"devDependencies": {
"@types/jest": "^25.1.3",
"coveralls": "^3.0.9",
"grpc": "^1.24.2",
"grpc-host-builder": "^4.3.2",
"grpc-instrumentum": "^2.0.6",
"grpc-pbf-loader": "^1.0.2",
"jest": "^25.1.0",
"@grpc/grpc-js": "^1.2.12",
"@types/jest": "^26.0.22",
"grpc-host-builder": "^5.3.3",
"grpc-instrumentum": "^3.0.7",
"grpc-pbf-loader": "^1.0.4",
"jest": "^26.6.3",
"jest-extended": "^0.11.5",
"make-dir-cli": "^2.0.0",
"processing-context": "^1.0.0",
"prom-client": "^11.5.3",
"protobufjs": "^6.8.8"
"prom-client": "^13.1.0",
"protobufjs": "^6.10.2"
},

@@ -54,0 +57,0 @@ "jest": {

@@ -7,3 +7,3 @@ # grpc-prometheus

[![dev dependencies](https://img.shields.io/david/dev/litichevskiydv/grpc-prometheus.svg)](https://www.npmjs.com/package/grpc-prometheus)
[![Build Status](https://travis-ci.org/litichevskiydv/grpc-prometheus.svg?branch=master)](https://travis-ci.org/litichevskiydv/grpc-prometheus)
[![Build Status](https://github.com/litichevskiydv/grpc-prometheus/actions/workflows/ci.yaml/badge.svg?branch=master)](https://github.com/litichevskiydv/grpc-prometheus/actions/workflows/ci.yaml)
[![Coverage Status](https://coveralls.io/repos/github/litichevskiydv/grpc-prometheus/badge.svg?branch=master)](https://coveralls.io/github/litichevskiydv/grpc-prometheus?branch=master)

@@ -15,3 +15,3 @@

`npm i grpc-opentracing`
`npm i grpc-prometheus`

@@ -25,7 +25,7 @@ # Usage

const server = new GrpcHostBuilder()
const server = await new GrpcHostBuilder()
/*...*/
.addInterceptor(
serverInterceptorsFactory({
timeBuckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 10]
timeBuckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 10],
})

@@ -35,3 +35,3 @@ )

.bind(grpcBind)
.build();
.buildAsync();
```

@@ -38,0 +38,0 @@

@@ -7,4 +7,4 @@ import {

ServerReadableStream,
ServerDuplexStream
} from "grpc";
ServerDuplexStream,
} from "@grpc/grpc-js";

@@ -11,0 +11,0 @@ interface InterceptorsFactoryOptions {

@@ -1,2 +0,2 @@

const { status } = require("grpc");
const { status } = require("@grpc/grpc-js");
const { Counter, Histogram } = require("prom-client");

@@ -21,3 +21,3 @@

[status.DATA_LOSS, "DataLoss"],
[status.UNAUTHENTICATED, "Unauthenticated"]
[status.UNAUTHENTICATED, "Unauthenticated"],
]);

@@ -29,7 +29,7 @@ const defaultTimeBuckets = [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 10];

*/
const configureMetrics = timeBuckets => ({
const configureMetrics = (timeBuckets) => ({
grpcServerHandledTotal: new Counter({
name: "grpc_server_handled_total",
labelNames: ["grpc_code", "grpc_method", "grpc_service", "grpc_type"],
help: "Total number of RPCs completed on the server, regardless of success or failure."
help: "Total number of RPCs completed on the server, regardless of success or failure.",
}),

@@ -40,4 +40,4 @@ grpcServerHandlingSeconds: new Histogram({

labelNames: ["grpc_code", "grpc_method", "grpc_service", "grpc_type"],
help: "Histogram of response latency (seconds) of gRPC that had been application-level handled by the server."
})
help: "Histogram of response latency (seconds) of gRPC that had been application-level handled by the server.",
}),
});

@@ -49,3 +49,3 @@

*/
const parseMethodPath = path => {
const parseMethodPath = (path) => {
const [, serviceName, methodName] = path.split("/");

@@ -56,8 +56,8 @@ return { serviceName, methodName };

/**
* @param {import("grpc").MethodDefinition} methodDefinition
* @returns {string}
* @param {import("@grpc/grpc-js").MethodDefinition} methodDefinition
* @returns {"bidi" | "clientStream" | "serverStream" | "unary"}
*/
const getMethodType = methodDefinition => {
if (methodDefinition.requestStream) return methodDefinition.responseStream ? "bidi" : "client_stream";
return methodDefinition.responseStream ? "server_stream" : "unary";
const getMethodType = (methodDefinition) => {
if (methodDefinition.requestStream) return methodDefinition.responseStream ? "bidi" : "clientStream";
return methodDefinition.responseStream ? "serverStream" : "unary";
};

@@ -68,3 +68,3 @@

*/
const getElapsedMilliseconds = startTime => {
const getElapsedMilliseconds = (startTime) => {
const diff = process.hrtime(startTime);

@@ -77,3 +77,3 @@ return diff[0] * 1e3 + diff[1] * 1e-6;

*/
module.exports = function(options) {
module.exports = function (options) {
const opts = options || {};

@@ -80,0 +80,0 @@ const { grpcServerHandledTotal, grpcServerHandlingSeconds } = configureMetrics(

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