Socket
Socket
Sign inDemoInstall

nice-grpc-prometheus

Package Overview
Dependencies
6
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nice-grpc-prometheus

Prometheus monitoring for nice-grpc


Version published
Weekly downloads
1.1K
decreased by-21.59%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

nice-grpc-prometheus npm version

Prometheus monitoring for nice-grpc. Uses prom-client. Metrics mostly mimic go-grpc-prometheus.

Installation

npm install nice-grpc-prometheus

Usage

Import nice-grpc-prometheus metrics registry and merge it with the global registry:

import {register as globalRegistry, Registry} from 'prom-client';
import {registry as niceGrpcRegistry} from 'nice-grpc-prometheus';

// use `await mergedRegistry.metrics()` to export all metrics
const mergedRegistry = Registry.merge([globalRegistry, niceGrpcRegistry]);

Attach middleware as the first one on the server:

import {createServer} from 'nice-grpc';
import {prometheusServerMiddleware} from 'nice-grpc-prometheus';

const server = createServer()
  .use(prometheusServerMiddleware())
  .use(/* ... other middleware */);

Attach middleware as the first one on the client:

import {createClientFactory} from 'nice-grpc';
import {prometheusClientMiddleware} from 'nice-grpc-prometheus';

const clientFactory = createClientFactory()
  .use(prometheusClientMiddleware())
  .use(/* ... other middleware */);

const client = clientFactory.create(/* ... */);

Metrics

Following metrics are provided:

Server

NameTypeDescriptionLabels
grpc_server_started_totalCounterTotal number of RPCs started on the server.Common (see below)
grpc_server_handled_totalCounterTotal number of RPCs completed on the server, regardless of success or failure.Common + grpc_code
grpc_server_msg_received_totalCounterTotal number of RPC stream messages received by the server.Common
grpc_server_msg_sent_totalCounterTotal number of gRPC stream messages sent by the server.Common
grpc_server_handling_secondsHistogramHistogram of response latency (seconds) of gRPC that had been application-level handled by the server.Common + grpc_code

Client

NameTypeDescriptionLabels
grpc_client_started_totalCounterTotal number of RPCs started on the client.Common
grpc_client_handled_totalCounterTotal number of RPCs completed on the client, regardless of success or failure.Common + grpc_code
grpc_client_msg_received_totalCounterTotal number of RPC stream messages received by the client.Common
grpc_client_msg_sent_totalCounterTotal number of gRPC stream messages sent by the client.Common
grpc_client_handling_secondsHistogramHistogram of response latency (seconds) of the gRPC until it is finished by the application.Common + grpc_code

Labels

Common labels:

NameDescriptionExamples
grpc_typeCall typeunary, server_stream, client_stream, bidi_stream
grpc_pathFull path of a method/my.package.MyService/MyMethod
grpc_serviceFull service name with packagemy.package.MyService
grpc_methodMethod nameMyMethod

Metrics that correspond to finished calls have extra label:

NameDescriptionExamples
grpc_codeStatus code nameOK, CANCELLED, NOT_FOUND

Keywords

FAQs

Last updated on 11 Mar 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc