Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@astro-my/apm-js
Advanced tools
This library is a wrapper around **elastic-apm-js-base** to make sure in future if we need to replace the monitoring or extend the existing one, it will be done without breaking the existing code. For full documentation you can refer to : https://www.elas
This library is a wrapper around elastic-apm-js-base to make sure in future if we need to replace the monitoring or extend the existing one, it will be done without breaking the existing code. For full documentation you can refer to : https://www.elastic.co/guide/en/apm/agent/js-base/current/index.html
Disclaimer: Few of the function name and logic has been modified, hence please read below.
Install the Astro APM agent for JavaScript as a dependency to your application:
npm install @astro-my/apm-js --save
Configuring the agent
import { configure } from '@astro-my/apm-js'
configure({
// Set custom APM Service Name (default: identity-frontend-application)
serviceName: '',
// Set custom APM Server URL (default: http://localhost:8200)
serverUrl: '',
// Set service version (required for sourcemap feature, default: 0.0.1)
serviceVersion: ''
// Whether the client is enabled or not (default value is true)
active: boolean
})
import { setUser } from '@astro-my/apm-js'
setUser(userId) // where userId is unique user identifier
Call this method to enrich collected performance data and errors with information about the user. The provided user context is stored under context.user in Elasticsearch on both errors and transactions.
import { setContext } from '@astro-my/apm-js'
setContext(context)
Call this to enrich collected errors and transactions with any information that you think will help you debug performance issues or errors. The provided custom context is stored under context.custom in Elasticsearch on both errors and transactions. The given context argument must be an object and can contain any property that can be JSON encoded.
import { setTags } from '@astro-my/apm-js'
setTags(tags)
Set tags on transactions and errors. Tags are key/value pairs that are indexed by Elasticsearch and therefore searchable (as opposed to data set via setCustomContext()). You can set multiple tags. Arguments: tags - Any key/value object with the following specifications:
A filter can be used to modify the APM payload before it is sent to the apm-server. This can be useful in for example redacting sensitive information from the payload:
import { addFilter } from '@astro-my/apm-js'
addFilter(function (payload) {
if (payload.errors) {
payload.errors.forEach(function (error) {
error.exception.message = error.exception.message.replace('secret', '[REDACTED]')
})
}
if (payload.transactions) {
payload.transactions.forEach(function (tr) {
tr.spans.forEach(function (span) {
if (span.context && span.context.http && span.context.http.url) {
var url = new URL(span.context.http.url)
if (url.searchParams.get('token')) {
url.searchParams.set('token', 'REDACTED')
}
span.context.http.url = url.toString()
}
})
})
}
// Make sure to return the payload
return payload
})
Starts and returns a new transaction.
import { startTransaction } from '@astro-my/apm-js'
startTransaction(name, type)
Arguments:
Starts and returns a new span on the current transaction.
import { startSpan } from '@astro-my/apm-js'
startSpan(name, type)
Arguments:
import { setInitialPageLoadName } from '@astro-my/apm-js'
setInitialPageLoadName(name)
Arguments:
Use this method to set the name of the page-load transaction that is sent automatically on page load event.
import { captureError } from '@astro-my/apm-js'
captureError(error)
Use this method to manually send an error to APM Server
P.S: If you need to get the raw apm object, you can import it as root, but use this if really necessary.
FAQs
This library is a wrapper around **elastic-apm-js-base** to make sure in future if we need to replace the monitoring or extend the existing one, it will be done without breaking the existing code. For full documentation you can refer to : https://www.elas
The npm package @astro-my/apm-js receives a total of 4 weekly downloads. As such, @astro-my/apm-js popularity was classified as not popular.
We found that @astro-my/apm-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.