Socket
Socket
Sign inDemoInstall

@lidofinance/api-metrics

Package Overview
Dependencies
3
Maintainers
2
Versions
48
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @lidofinance/api-metrics

Utils to work with common API metrics


Version published
Weekly downloads
118
increased by84.38%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

@lidofinance/api-metrics

Utils to work with common API metrics

Installation

yarn add @lidofinance/api-metrics

Getting started

collectStartupMetrics

Just call it in the same place where you call collectDefaultMetrics.

import { Registry, collectDefaultMetrics } from 'prom-client';
import getConfig from 'next/config';
import { METRICS_PREFIX } from 'config';
import buildInfoJson from 'build-info.json';
import { collectStartupMetrics } from '@lidofinance/api-metrics';

const { publicRuntimeConfig } = getConfig();
const { defaultChain, supportedChains } = publicRuntimeConfig;

export const registry = new Registry();

collectStartupMetrics({
  prefix: METRICS_PREFIX,
  registry,
  defaultChain,
  supportedChains: supportedChains.split(','),
  version: process.env.npm_package_version ?? 'unversioned',
  commit: buildInfoJson.commit,
  branch: buildInfoJson.branch,
});

collectDefaultMetrics({ prefix: METRICS_PREFIX, register: registry });

rpcMetricsFactory

It's mostly internal util for @lidofinance/api-rpc and @lidofinance/eth-api-providers, but you should use it if you use RPC requests in some other way.

Take a look into the file itself to view exported metrics, it's quite simple.

rpcMetricsUtils

There is a list of utils, which helps to reduce cardinality, e.g. you should collect '2xx' instead of '200', '201', ... and other HTTP response statuses, because in most cases it doesn't matter.

FAQs

Last updated on 26 Apr 2024

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