diff --git a/README.md b/README.md index 1067753f..e650f2b9 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ available on Linux. To register metrics to another registry, pass it in as `register`: ```js -const client = require('@prometheus/client'); +const client = require('@prometheus-io/client'); const collectDefaultMetrics = client.collectDefaultMetrics; const Registry = client.Registry; const register = new Registry(); @@ -78,7 +78,7 @@ collectDefaultMetrics({ register }); To use custom buckets for GC duration histogram, pass it in as `gcDurationBuckets`: ```js -const client = require('@prometheus/client'); +const client = require('@prometheus-io/client'); const collectDefaultMetrics = client.collectDefaultMetrics; collectDefaultMetrics({ gcDurationBuckets: [0.1, 0.2, 0.3] }); ``` @@ -86,7 +86,7 @@ collectDefaultMetrics({ gcDurationBuckets: [0.1, 0.2, 0.3] }); To prefix metric names with your own arbitrary string, pass in a `prefix`: ```js -const client = require('@prometheus/client'); +const client = require('@prometheus-io/client'); const collectDefaultMetrics = client.collectDefaultMetrics; const prefix = 'my_application_'; collectDefaultMetrics({ prefix }); @@ -95,7 +95,7 @@ collectDefaultMetrics({ prefix }); To apply generic labels to all default metrics, pass an object to the `labels` property (useful if you're working in a clustered environment): ```js -const client = require('@prometheus/client'); +const client = require('@prometheus-io/client'); const collectDefaultMetrics = client.collectDefaultMetrics; collectDefaultMetrics({ labels: { NODE_APP_INSTANCE: process.env.NODE_APP_INSTANCE }, @@ -109,7 +109,7 @@ Default metrics are collected on scrape of metrics endpoint, not on an interval. ```js -const client = require('@prometheus/client'); +const client = require('@prometheus-io/client'); const collectDefaultMetrics = client.collectDefaultMetrics; @@ -137,7 +137,7 @@ metric types. Counters go up, and reset when the process restarts. ```js -const client = require('@prometheus/client'); +const client = require('@prometheus-io/client'); const counter = new client.Counter({ name: 'metric_name', help: 'metric_help', @@ -151,7 +151,7 @@ counter.inc(10); // Increment by 10 Gauges are similar to Counters but a Gauge's value can be decreased. ```js -const client = require('@prometheus/client'); +const client = require('@prometheus-io/client'); const gauge = new client.Gauge({ name: 'metric_name', help: 'metric_help' }); gauge.set(10); // Set to 10 gauge.inc(); // Increment 1 @@ -166,7 +166,7 @@ If the gauge is used for a point-in-time observation, you should provide a `collect` function: ```js -const client = require('@prometheus/client'); +const client = require('@prometheus-io/client'); new client.Gauge({ name: 'metric_name', help: 'metric_help', @@ -180,7 +180,7 @@ new client.Gauge({ ```js // Async version: -const client = require('@prometheus/client'); +const client = require('@prometheus-io/client'); new client.Gauge({ name: 'metric_name', help: 'metric_help', @@ -218,7 +218,7 @@ The defaults buckets are intended to cover usual web/RPC requests, but they can be overridden. (See also [**Bucket Generators**](#bucket-generators).) ```js -const client = require('@prometheus/client'); +const client = require('@prometheus-io/client'); new client.Histogram({ name: 'metric_name', help: 'metric_help', @@ -229,7 +229,7 @@ new client.Histogram({ ##### Examples ```js -const client = require('@prometheus/client'); +const client = require('@prometheus-io/client'); const histogram = new client.Histogram({ name: 'metric_name', help: 'metric_help', @@ -257,7 +257,7 @@ can be overridden by specifying a `percentiles` array. (See also [**Bucket Generators**](#bucket-generators).) ```js -const client = require('@prometheus/client'); +const client = require('@prometheus-io/client'); new client.Summary({ name: 'metric_name', help: 'metric_help', @@ -269,7 +269,7 @@ To enable the sliding window functionality for summaries you need to add `maxAgeSeconds` and `ageBuckets` to the config like this: ```js -const client = require('@prometheus/client'); +const client = require('@prometheus-io/client'); new client.Summary({ name: 'metric_name', help: 'metric_help', @@ -288,7 +288,7 @@ always be present, even when empty (its percentile values will be `0`). Set ##### Examples ```js -const client = require('@prometheus/client'); +const client = require('@prometheus-io/client'); const summary = new client.Summary({ name: 'metric_name', help: 'metric_help', @@ -312,7 +312,7 @@ label names that the metric support needs to be declared here. There are two ways to add values to the labels: ```js -const client = require('@prometheus/client'); +const client = require('@prometheus-io/client'); const gauge = new client.Gauge({ name: 'metric_name', help: 'metric_help', @@ -364,7 +364,7 @@ histogram.zero({ method: 'POST' }); Typescript can also enforce label names using `as const` ```typescript -import * as client from '@prometheus/client'; +import * as client from '@prometheus-io/client'; const counter = new client.Counter({ name: 'metric_name', @@ -386,7 +386,7 @@ counter.inc({ methods: 1 }); Static labels may be applied to every metric emitted by a registry: ```js -const client = require('@prometheus/client'); +const client = require('@prometheus-io/client'); const defaultLabels = { serviceName: 'api-v1' }; client.register.setDefaultLabels(defaultLabels); ``` @@ -423,7 +423,7 @@ The library supports both the old Prometheus format and the OpenMetrics format. The format can be set per registry. For default metrics: ```js -const Prometheus = require('@prometheus/client'); +const Prometheus = require('@prometheus-io/client'); Prometheus.register.setContentType( Prometheus.Registry.OPENMETRICS_CONTENT_TYPE, ); @@ -447,7 +447,7 @@ type when creating a new registry, currently defaults to Prometheus type. ### Multiple registries By default, metrics are automatically registered to the global registry (located -at `require('@prometheus/client').register`). You can prevent this by specifying +at `require('@prometheus-io/client').register`). You can prevent this by specifying `registers: []` in the metric constructor configuration. Using non-global registries requires creating a Registry instance and passing it @@ -462,7 +462,7 @@ Merging registries of different types is undefined. The user needs to make sure all used registries have the same type (Prometheus or OpenMetrics versions). ```js -const client = require('@prometheus/client'); +const client = require('@prometheus-io/client'); const registry = new client.Registry(); const counter = new client.Counter({ name: 'metric_name', @@ -544,7 +544,7 @@ It is possible to push metrics via a [Pushgateway](https://github.com/prometheus/pushgateway). ```js -const client = require('@prometheus/client'); +const client = require('@prometheus-io/client'); let gateway = new client.Pushgateway('http://127.0.0.1:9091'); gateway.pushAdd({ jobName: 'test' }) @@ -607,7 +607,7 @@ For convenience, there are two bucket generator functions - linear and exponential. ```js -const client = require('@prometheus/client'); +const client = require('@prometheus-io/client'); new client.Histogram({ name: 'metric_name', help: 'metric_help', diff --git a/benchmarks/index.js b/benchmarks/index.js index 90c4211c..d96b5f66 100644 --- a/benchmarks/index.js +++ b/benchmarks/index.js @@ -28,10 +28,10 @@ const Benchmark = require('faceoff').default; */ const benchmarks = new Benchmark({ - // TODO: Update this once the module is published to as @prometheus/client. - '@prometheus/client@latest': 'prom-client@latest', - '@prometheus/client@trunk': 'git@github.com:prometheus/client_js', - '@prometheus/client@current': { location: process.cwd() }, + // TODO: Update this once the module is published to as @prometheus-io/client. + latest: 'prom-client@latest', + trunk: 'git@github.com:prometheus/client_js', + current: { location: process.cwd() }, }); benchmarks.suite('counter', require('./counter')); diff --git a/benchmarks/util.js b/benchmarks/util.js index a4009e14..45e31659 100644 --- a/benchmarks/util.js +++ b/benchmarks/util.js @@ -19,7 +19,7 @@ const Path = require('path'); module.exports = setupUtilSuite; function setupUtilSuite(suite) { - const skip = ['@prometheus/client@latest']; + const skip = ['latest']; suite.add( 'hashObject', @@ -91,7 +91,7 @@ function setupUtilSuite(suite) { return new Util.LabelGrouper(); }, - skip: ['@prometheus/client@latest', '@prometheus/client@trunk'], + skip: ['latest', 'trunk'], }, ); } diff --git a/example/worker.js b/example/worker.js index 2af9ea83..ba24662d 100644 --- a/example/worker.js +++ b/example/worker.js @@ -19,7 +19,7 @@ const { Worker, isMainThread, workerData } = require('node:worker_threads'); const express = require('express'); const WorkerRegistry = require('../').WorkerRegistry; -const collector = workerData?.['@prometheus/client']?.collector === true; +const collector = workerData?.['@prometheus-io/client']?.collector === true; const metricsServer = express(); const workerRegistry = new WorkerRegistry( WorkerRegistry.PROMETHEUS_CONTENT_TYPE, @@ -31,7 +31,7 @@ if (isMainThread) { new Worker(Path.join(__filename), { env: { ...process.env, PORT: 3333 }, workerData: { - '@prometheus/client': { collector: true }, + '@prometheus-io/client': { collector: true }, }, }); diff --git a/index.d.ts b/index.d.ts index 5b1a81d4..898c15ae 100644 --- a/index.d.ts +++ b/index.d.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Type definitions for @prometheus/client +// Type definitions for @prometheus-io/client // Definitions by: Simon Nyberg http://twitter.com/siimon_nyberg export type Charset = 'utf-8'; diff --git a/lib/cluster.js b/lib/cluster.js index 4e6f08b8..237c9a81 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -31,8 +31,8 @@ let cluster = () => { return data; }; -const GET_METRICS_REQ = '@prometheus/client:getMetricsReq'; -const GET_METRICS_RES = '@prometheus/client:getMetricsRes'; +const GET_METRICS_REQ = '@prometheus-io/client:getMetricsReq'; +const GET_METRICS_RES = '@prometheus-io/client:getMetricsRes'; let registries = [Registry.globalRegistry]; let requestCtr = 0; // Concurrency control diff --git a/lib/worker.js b/lib/worker.js index 8f4e3b3a..03ad2c93 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -26,11 +26,11 @@ const Registry = require('./registry'); const worker = require('node:worker_threads'); const { isMainThread, threadId, BroadcastChannel } = worker; -const ANNOUNCEMENT = '@prometheus/client:announcement'; -const GET_METRICS_REQ = '@prometheus/client:getMetricsReq'; -const GET_METRICS_RES = '@prometheus/client:getMetricsRes'; +const ANNOUNCEMENT = '@prometheus-io/client:announcement'; +const GET_METRICS_REQ = '@prometheus-io/client:getMetricsReq'; +const GET_METRICS_RES = '@prometheus-io/client:getMetricsRes'; const ANNOUNCEMENT_CHANNEL = new BroadcastChannel( - '@prometheus/client:announce', + '@prometheus-io/client:announce', ); ANNOUNCEMENT_CHANNEL.unref(); @@ -229,7 +229,7 @@ function addListeners(registry) { listenersAdded = true; - const name = `@prometheus/client:worker:${threadId}`; + const name = `@prometheus-io/client:worker:${threadId}`; const channel = new BroadcastChannel(name); channel.unref(); diff --git a/package.json b/package.json index 0a6816c9..679e75c2 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@prometheus/client", + "name": "@prometheus-io/client", "version": "15.1.3", "description": "Client for prometheus", "main": "index.js", @@ -41,7 +41,7 @@ "eslint-plugin-n": "^17.20.0", "eslint-plugin-prettier": "^5.0.1", "express": "^5.1.0", - "faceoff": "^1.1.0", + "faceoff": "^1.3.0", "globals": "^16.2.0", "husky": "^9.0.0", "jest": "^30.0.2", diff --git a/test/clusterTest.js b/test/clusterTest.js index 70dcd081..64e1db60 100644 --- a/test/clusterTest.js +++ b/test/clusterTest.js @@ -18,7 +18,7 @@ const cluster = require('cluster'); const process = require('process'); const Registry = require('../lib/cluster'); -const GET_METRICS_RES = '@prometheus/client:getMetricsRes'; +const GET_METRICS_RES = '@prometheus-io/client:getMetricsRes'; function metric(value) { return { @@ -120,7 +120,7 @@ describe.each([ //Emulate a response that has been deleted from requests const unexpected = { - type: '@prometheus/client:getMetricsRes', + type: '@prometheus-io/client:getMetricsRes', metrics: ['{}'], requestId: -3, }; diff --git a/test/workerTest.js b/test/workerTest.js index 76c3ad45..f61c85a4 100644 --- a/test/workerTest.js +++ b/test/workerTest.js @@ -19,8 +19,8 @@ const { setTimeout: delay } = require('timers/promises'); const { BroadcastChannel } = require('worker_threads'); const Registry = require('../lib/worker'); -const GET_METRICS_REQ = '@prometheus/client:getMetricsReq'; -const GET_METRICS_RES = '@prometheus/client:getMetricsRes'; +const GET_METRICS_REQ = '@prometheus-io/client:getMetricsReq'; +const GET_METRICS_RES = '@prometheus-io/client:getMetricsRes'; function metric(value) { return { @@ -52,10 +52,10 @@ describe.each([ it('aggregates worker responses in thread id order', async () => { const registry = new Registry(regType); const announcementChannel = new BroadcastChannel( - '@prometheus/client:announce', + '@prometheus-io/client:announce', ); const responders = [1, 2, 3].map(threadId => { - const name = `@prometheus/client:test-worker:${threadId}`; + const name = `@prometheus-io/client:test-worker:${threadId}`; registry.addWorker(name); return { threadId, @@ -111,7 +111,7 @@ describe.each([ //Emulate a response that has been deleted from requests const unexpected = { - type: '@prometheus/client:getMetricsRes', + type: '@prometheus-io/client:getMetricsRes', metrics: ['{}'], requestId: -3, };