
Security News
GitHub Actions Pricing Whiplash: Self-Hosted Actions Billing Change Postponed
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.
@gasket/plugin-elastic-apm
Advanced tools
Adds Elastic APM instrumentation to your application
npm i @gasket/plugin-elastic-apm
Update your gasket file plugin configuration:
// gasket.js
+ import pluginElasticApm from '@gasket/plugin-elastic-apm';
export default makeGasket({
plugins: [
+ pluginElasticApm
]
});
Add NODE_OPTIONS=--import=./setup.js to the package.json start script:
"scripts": {
"build": "next build",
- "start": "next start",
+ "start": "NODE_OPTIONS=--import=./setup.js next start",
"local": "next dev"
}
Add a setup.js script to the root of your app
// setup.js
import apm from 'elastic-apm-node';
// Elastic APM setup
apm.start({
serviceName: 'my-service-name',
captureHeaders: false,
secretToken: process.env.ELASTIC_APM_SECRET_TOKEN,
serverUrl: process.env.ELASTIC_APM_SERVER_URL
// additional configuration options
});
The start recommendations for the APM agent are to require it as early as
possible in your app. For Gasket apps, using NODE_OPTIONS=--import=./setup.js
will accomplish this. To configure the APM agent, set the environment variables
described in the configuration options documentation.
In particular, the APM server URL (ELASTIC_APM_SERVER_URL) and secret token
(ELASTIC_APM_SECRET_TOKEN) are both required configuration. If either of these
are not present, the APM agent will be disabled.
If you wish to use dotenv, be sure it is installed and imported in setup.js:
npm i dotenv
// setup.js
+ import 'dotenv/config';
import apm from 'elastic-apm-node';
// Elastic APM setup
apm.start({
...
The Gasket plugin provides some additional setup helpers. These can be
configured under elasticAPM in the gasket.js.
sensitiveCookies - (string[]) A list of sensitive cookies to filterIf your application’s users send session credentials or any other sensitive
information in their cookies, you may wish to filter them out before they are
stored in Elasticsearch. Specify a list of cookie names to redact in
gasket.js:
export default makeGasket({
elasticAPM: {
sensitiveCookies: ['my_jwt', 'userFullName']
}
});
If your application’s users send session credentials or any other sensitive
information in their cookies, you may wish to filter them out before they are
stored in Elasticsearch. Specify a list of cookie names to redact in
setup.js using the sanitizeFieldNames configuration option:
// setup.js
import apm from 'elastic-apm-node';
// Elastic APM setup
apm.start({
+ sanitizeFieldNames: ['foo', 'bar', '*token*']
...
The sanitizeFieldNames config option can be used for:
application/x-www-form-urlencoded data requestTo filter out other data, use the APM Add Filter API.
According to the Elastic APM docs, the Elastic APM agent for Node.js is a singleton. This means that you can import and configure the singleton in various hooks of your Gasket app, such as with the init or middleware lifecycles.
Use the getApmTransaction action to access and decorate the current APM
transaction. This action is available in any lifecycle hook or server-side code.
// example-plugin.js
export default {
name: 'example-plugin',
hooks: {
express(gasket, app) {
app.use(async (req, res, next) => {
const transaction = await gasket.actions.getApmTransaction(req);
const locale = await gasket.actions.getIntlLocale(req);
transaction.setLabel('locale', locale);
next();
});
}
}
}
In the above example, we are hooking the express lifecycle to add middleware
to decorate the transaction.
Calling getApmTransaction will also allow other plugins to decorate the
transaction by hooking the apmTransaction lifecycle discussed next.
At a minimum, the getApmTransaction action must be invoked to execute
the apmTransaction lifecycle described below.
This can be adjusted to only run for specific requests.
export default {
name: 'example-plugin',
hooks: {
express(gasket, app) {
app.use(async (req, res, next) => {
// Only decorate APM transaction for non-API requests
if(!req.path.startsWith('/api')) {
await gasket.actions.getApmTransaction(req);
}
next();
});
}
}
}
Enables customizing an APM transaction. Hooks receive the current APM Transaction and details about the request. Hooks may be asynchronous. The request details are as follows:
| Property | Description |
|---|---|
req | The HTTP request or framework-specific wrapper around it |
res | The HTTP response or framework-specific wrapper around it |
// example-plugin.js
export default {
name: 'example-plugin',
hooks: {
apmTransaction(gasket, transaction, { req, res }) => {
transaction.setLabel('language', req.headers['accept-language']);
}
}
}
This plugin hooks the Gasket [configure] lifecycle to set additional filtering, such as for sensitive cookies.
FAQs
Adds Elastic APM instrumentation to your application
We found that @gasket/plugin-elastic-apm demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.

Security News
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.