{"id":18262871,"url":"https://github.com/midwayjs/metrics-common","last_synced_at":"2025-04-04T20:30:57.124Z","repository":{"id":33155193,"uuid":"153083848","full_name":"midwayjs/metrics-common","owner":"midwayjs","description":"A basic metrics implementation package for data aggregation computing in different scenarios.","archived":false,"fork":false,"pushed_at":"2021-12-28T16:03:58.000Z","size":56,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-03-20T18:09:43.053Z","etag":null,"topics":["counter","gauge","histogram","meters","metrics","metrics-common"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/midwayjs.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-15T09:06:19.000Z","updated_at":"2020-04-09T04:00:05.000Z","dependencies_parsed_at":"2022-07-16T07:46:56.271Z","dependency_job_id":null,"html_url":"https://github.com/midwayjs/metrics-common","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midwayjs%2Fmetrics-common","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midwayjs%2Fmetrics-common/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midwayjs%2Fmetrics-common/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midwayjs%2Fmetrics-common/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/midwayjs","download_url":"https://codeload.github.com/midwayjs/metrics-common/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247246191,"owners_count":20907750,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["counter","gauge","histogram","meters","metrics","metrics-common"],"created_at":"2024-11-05T11:09:06.001Z","updated_at":"2025-04-04T20:30:54.372Z","avatar_url":"https://github.com/midwayjs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Metrics Common\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/midwayjs/metrics-common/blob/master/LICENSE)\n[![GitHub tag](https://img.shields.io/github/tag/midwayjs/metrics-common.svg)]()\n[![Build Status](https://travis-ci.org/midwayjs/metrics-common.svg?branch=master)](https://travis-ci.org/midwayjs/metrics-common)\n[![Test Coverage](https://img.shields.io/codecov/c/github/midwayjs/metrics-common/master.svg)](https://codecov.io/gh/midwayjs/metrics-common/branch/master)\n[![Package Quality](http://npm.packagequality.com/shield/metrics-common.svg)](http://packagequality.com/#?package=metrics-common)\n[![Known Vulnerabilities](https://snyk.io/test/npm/metrics-common/badge.svg)](https://snyk.io/test/npm/metrics-common)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/metrics-common/pulls)\n\n## Overview\n\nMetrics 的原意是 **指标**，用于反馈应用的当前状况的数据值，所以 Metrics 最后的结果都是**数字**。\n\n在业界标准的 Metrics 类型中，有几种标准的类型。\n\n- Gauge 瞬时值\n- Counter 计数器\n- Meter 吞吐率度量器\n- Histogram 直方分布度量器\n\n本包扩展出一堆基础 Metrics 指标的实现。\n\n包括常见的 Gauge, Counter, Timer, Histogram, Meter，以及扩展出来的 BucketCounter, FastCompass 等。\n\n## Install\n\n```shell\nnpm i metrics-common --save\n```\n\n## Usage\n\n```js\nimport { MetricsServerManager } from 'metrics-common';\n\nconst manager = new MetricsServerManager();\n\nconst app = koa();\n\napp.use(async (ctx) =\u003e {\n  const counter = manager.getCounter('system', 'test.system.counter');\n  const histogram = manager.getHistogram('system', 'test.system.histogram');\n  const timer = manager.getTimer('system', 'test.system.timer');\n  const meter = manager.getMeter('system', 'test.system.meter');\n  const fastcompass = manager.getFastCompass('system', 'test.system.fastcompass');\n  counter.inc();\n});\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmidwayjs%2Fmetrics-common","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmidwayjs%2Fmetrics-common","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmidwayjs%2Fmetrics-common/lists"}