update tsconfig
This commit is contained in:
parent
fc4bc118d6
commit
e514209fb8
@ -5,17 +5,33 @@
|
|||||||
"githost": "code.foss.global",
|
"githost": "code.foss.global",
|
||||||
"gitscope": "push.rocks",
|
"gitscope": "push.rocks",
|
||||||
"gitrepo": "smartmetrics",
|
"gitrepo": "smartmetrics",
|
||||||
"description": "easy system metrics",
|
"description": "A package for easy collection and reporting of system and process metrics.",
|
||||||
"npmPackagename": "@push.rocks/smartmetrics",
|
"npmPackagename": "@push.rocks/smartmetrics",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"projectDomain": "push.rocks"
|
"projectDomain": "push.rocks",
|
||||||
|
"keywords": [
|
||||||
|
"system metrics",
|
||||||
|
"performance monitoring",
|
||||||
|
"resource usage",
|
||||||
|
"memory management",
|
||||||
|
"CPU usage",
|
||||||
|
"prometheus",
|
||||||
|
"typescript",
|
||||||
|
"nodejs",
|
||||||
|
"process management",
|
||||||
|
"development tools",
|
||||||
|
"performance analysis",
|
||||||
|
"docker environments",
|
||||||
|
"log reporting",
|
||||||
|
"operational insights"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
},
|
},
|
||||||
"tsdocs": {
|
"tsdoc": {
|
||||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
20
package.json
20
package.json
@ -2,7 +2,7 @@
|
|||||||
"name": "@push.rocks/smartmetrics",
|
"name": "@push.rocks/smartmetrics",
|
||||||
"version": "2.0.7",
|
"version": "2.0.7",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "easy system metrics",
|
"description": "A package for easy collection and reporting of system and process metrics.",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
@ -43,5 +43,21 @@
|
|||||||
"pidusage": "^3.0.2",
|
"pidusage": "^3.0.2",
|
||||||
"prom-client": "^14.2.0"
|
"prom-client": "^14.2.0"
|
||||||
},
|
},
|
||||||
"type": "module"
|
"type": "module",
|
||||||
|
"keywords": [
|
||||||
|
"system metrics",
|
||||||
|
"performance monitoring",
|
||||||
|
"resource usage",
|
||||||
|
"memory management",
|
||||||
|
"CPU usage",
|
||||||
|
"prometheus",
|
||||||
|
"typescript",
|
||||||
|
"nodejs",
|
||||||
|
"process management",
|
||||||
|
"development tools",
|
||||||
|
"performance analysis",
|
||||||
|
"docker environments",
|
||||||
|
"log reporting",
|
||||||
|
"operational insights"
|
||||||
|
]
|
||||||
}
|
}
|
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
135
readme.md
135
readme.md
@ -1,37 +1,120 @@
|
|||||||
# @pushrocks/smartmetrics
|
# @push.rocks/smartmetrics
|
||||||
|
|
||||||
easy system metrics
|
easy system metrics
|
||||||
|
|
||||||
## Availabililty and Links
|
## Install
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartmetrics)
|
|
||||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartmetrics)
|
|
||||||
* [github.com (source mirror)](https://github.com/pushrocks/smartmetrics)
|
|
||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartmetrics/)
|
|
||||||
|
|
||||||
## Status for master
|
To include `@push.rocks/smartmetrics` in your project, you need a Node.js environment with support for ES Modules. Make sure that your `package.json` contains `"type": "module"`. You can install `@push.rocks/smartmetrics` using npm:
|
||||||
|
|
||||||
Status Category | Status Badge
|
```bash
|
||||||
-- | --
|
npm install @push.rocks/smartmetrics --save
|
||||||
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartmetrics/badges/master/pipeline.svg)](https://lossless.cloud)
|
```
|
||||||
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartmetrics/badges/master/coverage.svg)](https://lossless.cloud)
|
|
||||||
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartmetrics)](https://lossless.cloud)
|
Or using yarn:
|
||||||
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartmetrics)](https://lossless.cloud)
|
|
||||||
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
|
```bash
|
||||||
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
yarn add @push.rocks/smartmetrics
|
||||||
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
|
```
|
||||||
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartmetrics)](https://lossless.cloud)
|
|
||||||
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartmetrics)](https://lossless.cloud)
|
|
||||||
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartmetrics)](https://lossless.cloud)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Use TypeScript for best in class intellisense
|
The `@push.rocks/smartmetrics` package provides an easy way to collect and monitor system metrics such as CPU and memory usage within your Node.js applications. It's built with TypeScript, offering type safety and IntelliSense in editors that support it.
|
||||||
|
|
||||||
## Contribution
|
### Getting Started
|
||||||
|
|
||||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
Before diving into the code, ensure you have `@push.rocks/smartmetrics` installed in your project and your environment is configured to use ES Modules (ESM) and TypeScript.
|
||||||
|
|
||||||
For further information read the linked docs at the top of this readme.
|
#### Initialization
|
||||||
|
|
||||||
## Legal
|
To begin using `smartmetrics`, you need to import the module and initialize it:
|
||||||
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
```typescript
|
||||||
|
// Import dependencies
|
||||||
|
import { SmartMetrics } from '@push.rocks/smartmetrics';
|
||||||
|
import { Smartlog } from '@push.rocks/smartlog';
|
||||||
|
|
||||||
|
// Setup a logger (or use your existing logger if applicable)
|
||||||
|
const logger = new Smartlog({
|
||||||
|
logContext: 'applicationName',
|
||||||
|
minimumLogLevel: 'info',
|
||||||
|
});
|
||||||
|
|
||||||
|
// Initialize smartmetrics with the prepared logger
|
||||||
|
const smartMetrics = new SmartMetrics(logger, 'sourceName');
|
||||||
|
```
|
||||||
|
|
||||||
|
In this snippet, `Smartlog` is used for logging purposes. Replace `'applicationName'` and `'sourceName'` with appropriate values for your application.
|
||||||
|
|
||||||
|
#### Starting Metrics Monitoring
|
||||||
|
|
||||||
|
With `smartMetrics` initialized, you can start the metrics monitoring process:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
smartMetrics.start();
|
||||||
|
```
|
||||||
|
|
||||||
|
This starts the collection and monitoring of various system metrics. By default, `smartMetrics` sends heartbeat messages including these metrics at a regular interval.
|
||||||
|
|
||||||
|
#### Metrics Collection
|
||||||
|
|
||||||
|
To manually collect metrics at any point, you can call the `getMetrics` method. This could be useful for logging or sending metrics to a monitoring tool:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
async function logMetrics() {
|
||||||
|
const metrics = await smartMetrics.getMetrics();
|
||||||
|
console.log(metrics);
|
||||||
|
}
|
||||||
|
|
||||||
|
logMetrics();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Customizing Monitoring
|
||||||
|
|
||||||
|
The `start` method begins an unattended process of collecting and logging metrics. If you require more control over how and when metrics are collected or reported, you can use the `getMetrics` method in combination with your logic.
|
||||||
|
|
||||||
|
#### Stopping Metrics Monitoring
|
||||||
|
|
||||||
|
To stop the automatic metrics monitoring, simply call:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
smartMetrics.stop();
|
||||||
|
```
|
||||||
|
|
||||||
|
This stops the internal loop that periodically collects and logs metrics. It's useful for clean shutdowns of your application or when metrics monitoring is only needed during specific intervals.
|
||||||
|
|
||||||
|
### Understanding the Metrics
|
||||||
|
|
||||||
|
The `getMetrics` method returns a snapshot of various system metrics, including CPU and memory usage. Here's a brief overview of the information provided:
|
||||||
|
|
||||||
|
- `process_cpu_seconds_total`: Total CPU time spent by the process.
|
||||||
|
- `nodejs_active_handles_total`: Number of active handles.
|
||||||
|
- `nodejs_active_requests_total`: Number of active requests.
|
||||||
|
- `nodejs_heap_size_total_bytes`: Total size of the heap.
|
||||||
|
- `cpuPercentage`: Overall CPU usage percentage.
|
||||||
|
- `cpuUsageText`: Readable string representation of CPU usage.
|
||||||
|
- `memoryPercentage`: Percentage of memory used.
|
||||||
|
- `memoryUsageBytes`: Total memory used in bytes.
|
||||||
|
- `memoryUsageText`: Readable string representation of memory usage.
|
||||||
|
|
||||||
|
### Conclusion
|
||||||
|
|
||||||
|
`@push.rocks/smartmetrics` offers a straightforward and efficient way to monitor essential system metrics of your Node.js application. By integrating it, you gain valuable insights into the performance and health of your system, aiding in diagnosis and optimization efforts.
|
||||||
|
|
||||||
|
## License and Legal Information
|
||||||
|
|
||||||
|
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||||
|
|
||||||
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
### Trademarks
|
||||||
|
|
||||||
|
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||||
|
|
||||||
|
### Company Information
|
||||||
|
|
||||||
|
Task Venture Capital GmbH
|
||||||
|
Registered at District court Bremen HRB 35230 HB, Germany
|
||||||
|
|
||||||
|
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||||
|
|
||||||
|
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||||
|
Loading…
Reference in New Issue
Block a user