Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
@adonisjs/profiler
Advanced tools
Profiler to time actions in your code with context.
Small and performant module to time functions in your Node.js code. The profilers comes in many shapes and have different scopes. For example: The v8 profiler provides low level data around the event loop and ticks. However, this module is focused on providing high level insights for your application code such as:
The main focus of this module is to tie all the profiling actions to a parent, so that you can visualize code performance in reference to a high level task. For example: AdonisJS can tie SQL queries, Redis calls to a given HTTP request
The goal of the module is to have negligible impact on the application performance and following decisions have been made for the same.
There are two different types of data nodes.
Rows: A single row can contain one or more actions. Whenever you want to group multiple actions together, you must store them inside a row. Rows can also be nested.
{
id: string,
type: 'row',
label: string,
timestamp: number,
duration: [number, number],
data: any,
parent_id?: string,
}
Actions: As the name suggests, actions are individual profiler actions. An action doesn't have an id
, as they are never referenced by the other nodes.
{
type: 'action',
label: string,
timestamp: number,
duration: [number, number],
data: any,
parent_id?: string,
}
If you look at the data structures carefully, you will notice that each action
and row
has it's own single object and are not nested inside each other. We avoid nesting for performance reasons. Instead, we recommend data processing layer to build the nested tree using the parent_id
attribute.
row
or action
without parent_id
is a top level row/action.row
or action
whose parent data packet is missing is considered orphan. Orphan row/actions should eventually get a parent, unless there are bugs in the code.label
is super important and used for grouping actions of similar nature. So do not add dynamic data to the labels and instead use data
object for that.Install the package from the npm registry as follows:
npm i @adonisjs/profiler
# yarn
yarn add @adonisjs/profiler
and then use it as follows
import { Profiler } from '@adonisjs/profiler/build/standalone'
const profiler = new Profiler({
enabled: true,
whitelist: [],
blacklist: [],
})
Profile an action
const action = profiler.profile('find:route', { url: '/users/1' })
findRouteFunction()
action.end()
Once an action is finished, the profiler will notify the processor worker or function about the action and the time it took to complete the action.
The profiling data is delivered to a processor function and then processor can decide the storage or representation of data.
profiler.process((packet) => {
// write somewhere
})
or define path to a seperate file. In this case, a worker node will be created.
profiler.process('./profiler-processor-node')
You can only have one processor listening for profiler packets at a given time. This is done for the simplicitiy and performance, since we want the profiler to have minimum overhead to your applications.
The scope of profiling should always trim down as your application get mature, in that scanerio, instead of removing profiler calls, you can blacklist or whitelist actions and they will result in noop. For example:
const profiler = new Profiler({
enabled: true,
whitelist: [],
blacklist: ['find:route'],
})
const row = profile.create('http:request', { url: '/' })
row.profile('find:route', {}, () => {
// Code to find route
})
Without changing anything in your code, the find:route
action will have no impact. If you will blacklist a row label, then all of it's actions will be disabled as well.
Following are the autogenerated files via Typedoc
FAQs
Profiler to time function calls in AdonisJs with context
The npm package @adonisjs/profiler receives a total of 10,615 weekly downloads. As such, @adonisjs/profiler popularity was classified as popular.
We found that @adonisjs/profiler demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.