Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -78,15 +78,15 @@ 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] });
```

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 });
Expand All @@ -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 },
Expand All @@ -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;

Expand Down Expand Up @@ -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',
Expand All @@ -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
Expand All @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -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);
```
Expand Down Expand Up @@ -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,
);
Expand All @@ -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
Expand All @@ -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',
Expand Down Expand Up @@ -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' })
Expand Down Expand Up @@ -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',
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -91,7 +91,7 @@ function setupUtilSuite(suite) {

return new Util.LabelGrouper();
},
skip: ['@prometheus/client@latest', '@prometheus/client@trunk'],
skip: ['latest', 'trunk'],
},
);
}
Expand Down
4 changes: 2 additions & 2 deletions example/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 },
},
});

Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions lib/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions lib/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@prometheus/client",
"name": "@prometheus-io/client",
"version": "15.1.3",
"description": "Client for prometheus",
"main": "index.js",
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions test/clusterTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
};
Expand Down
10 changes: 5 additions & 5 deletions test/workerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
};
Expand Down
Loading