Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@workpop/graphql-metrics
Advanced tools
GraphQL-metrics instruments GraphQL resolvers, logging response times and statuses (if there was an error or not) to the console as well as to InfluxDB.
To install:
yarn add @workpop/graphql-metrics
import { WPGraphQLMetrics } from '@workpop/graphql-metrics';
const hostname = process.env.HOSTNAME;
const site = process.env.SITE;
const service = 'MyAwesomeGraphQLService';
const influxConfig = {
host: process.env.INFLUX_HOST,
port: parseInt(process.env.INFLUX_PORT, 10),
protocol: process.env.INFLUX_PROTOCOL,
username: process.env.INFLUX_USERNAME,
password: process.env.INFLUX_PASSWORD,
database: process.env.INFLUX_DATABASE,
requestTimeout: parseInt(process.env.INFLUX_REQUEST_TIMEOUT, 10),
};
export const Metrics = new WPGraphQLMetrics({
site,
hostname,
service,
logFunc: console.log, // eslint-disable-line no-console
metricIntervalMs: 60000,
influxSettings: influxConfig,
});
import { instrumentResolvers } from '@workpop/graphql-metrics';
import { beersOnTap, pourBeer } from './resolvers';
import { Logger } from './log';
const logger = new Logger('WPGRAPHQL');
const logLevels = {
INFO: 'info',
ERROR: 'error',
WARNING: 'warning',
TRACE: 'trace',
};
function _logFunction(logLevel, ...args) {
logger.log(logLevel, ...args);
}
const instrumentedResolvers = instrumentResolvers({
resolvers: {
Query: {
beersOnTap,
},
Mutation: {
pourBeer,
},
},
logFunc: _logFunction, // eslint-disable-line no-console
logLevels,
metrics: Metrics,
});
Each resolver invocation will produce 2 logs - one for start and one for completion. A callId property is logged to allow correlation between the start and completion log for a single resolver invocation. elapsedTime
is measured in milliseconds.
Here are some sample logs:
Start log:
2017-07-21T18:09:51+00:00 INFO [WPGRAPHQL]
{
"callId": "ca9f0dfc93455b7c8939fcb2e9f31404",
"resolverName": "beersOnTap",
"resolverArgs": {
"search": "guiness"
},
"context": {
"userId": "abc123"
}
}
Completion log on success:
2017-07-21T18:09:51+00:00 INFO [WPGRAPHQL]
{
"callId": "ca9f0dfc93455b7c8939fcb2e9f31404",
"resolverName": "beersOnTap",
"resolverArgs": {
"search": "guiness"
},
"context": {
"userId": "abc123"
}
"elapsedTime": 2,
"status": 200
}
Completion log on error:
2017-07-21T18:09:51+00:00 INFO [WPGRAPHQL]
{
"callId": "ca9f0dfc93455b7c8939fcb2e9f31404",
"resolverName": "beersOnTap",
"resolverArgs": {
"search": "guiness"
},
"context": {
"userId": "abc123"
}
"elapsedTime": 2,
"status": 404,
"err": "Beer named guiness not found"
}
Metrics for each resolver are aggregated on a one minute interval and flushed to InfluxDB once per minute. The following metrics are sent to InfluxDB for each resolver
${resolver}_count
${resolver}_4XX_count
${resolver}_5XX_count
${resolver}_total_response_time
${resolver}_ave_response_time
FAQs
Collection of GraphQL Metric Utils
The npm package @workpop/graphql-metrics receives a total of 0 weekly downloads. As such, @workpop/graphql-metrics popularity was classified as not popular.
We found that @workpop/graphql-metrics demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 open source maintainers 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.