
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
cf-service-metrics-logger
Advanced tools
You want to log service metrics from your application on Cloud Foundry? - Yes? - Here you are 🙌 !!
Service | Version |
---|---|
MongoDB | >=3.6.6 |
Redis | >=2.3.9 |
Install library by using npm
npm install cf-service-metrics-logger
or by using yarn
yarn add cf-service-metrics-logger
Using CommonJS
module loader:
const CfServiceMetricsLogger = require('cf-service-metrics-logger');
Using ES6
module loader:
import { CfServiceMetricsLogger } from 'cf-service-metrics-logger';
Create new instance of CfServiceMetricsLogger
and provide options:
const options = {
mongoDB: {
serverStatusInterval: 10000,
dbStatsInterval: 20000,
},
redis: {
infoInterval: 100000
}
};
const cfServiceMetricsLogger = new CfServiceMetricsLogger(options);
Subscribe metrics
to receive service metrics data:
cfServiceMetricsLogger.subscribe('metrics', data => {
// do some fancy stuff with your metrics
});
Subscribe logs
to receive general application logs:
cfServiceMetricsLogger.subscribe('logs', {message, level} => {
console[level](message));
});
Start service metrics logging:
cfServiceMetricsLogger.start();
Stop service metrics logging:
cfServiceMetricsLogger.stop();
Option | Description | Default Value |
---|---|---|
mongoDb.serverStatusInterval (optional) | MongoDb database status polling interval in ms | 10000 |
mongoDb.dbStatsInterval (optional) | MongoDB storage statistics polling interval in ms | 10000 |
redis.infoInterval (optional) | Redis statistics polling interval | 10000 |
vcap (optional) | Provide local VCAP_SERVICES and/or VCAP_APPLICATION values | {} |
vcapFile (optional) | Provide local VCAP_SERVICES and/or VCAP_APPLICATION file | '' |
Method | Description |
---|---|
start() | Start service metrics |
stop() | Stop service metrics |
subscribe(eventId, callback) | Subscribe an event |
unsubscribe(eventId, callback) | Unsubscribe an event |
unsubscribeAll() | Unsubscribe all events |
Id | Description |
---|---|
metrics | Service metrics |
logs | General application logs for levels debug , info , warn and error |
You need to set up your development environment before you can do anything.
Install Node.js and NPM
brew install node
choco install nodejs
Install yarn globally
yarn install yarn -g
Copy the vcap.example.json
file and rename it to vcap.json
. This file provides VCAP_SERVICES
and/or VCAP_APPLICATION
for local development.
More information is provided here.
Install all dependencies with yarn.
yarn install
yarn install
yarn run lint
. This runs tslint.yarn run test
.yarn run build
to generate commonJS and ES6 modules as well as declaration from the TypeScript source.dist
folder.Just set a breakpoint in source or unit test and hit F5 in your Visual Studio Code to execute and debug all unit tests.
Name | Description |
---|---|
.vscode/ | VSCode tasks, launch configuration and some other settings |
dist/ | Compiled and bundled source files will be placed here |
src/ | Source files |
src/types/ *.d.ts | Custom type definitions and files that aren't on DefinitelyTyped |
test/ | Tests |
test/unit/ *.test.ts | Unit tests |
vcap.example.json | Provides VCAP_SERVICES and/or VCAP_APPLICATION for local development |
vcap.test.json | Provides VCAP_SERVICES and/or VCAP_APPLICATION for unit tests |
rollup.config.js | Config for Rollup module bundler |
[0.2.1] - 2019-02-04
FAQs
Log Cloud Foundry service metrics
The npm package cf-service-metrics-logger receives a total of 1 weekly downloads. As such, cf-service-metrics-logger popularity was classified as not popular.
We found that cf-service-metrics-logger demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.