@sentry/profiling-node
Advanced tools
Comparing version
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
const nodeCpuProfiler = require('@sentry-internal/node-cpu-profiler'); | ||
const core = require('@sentry/core'); | ||
const node_module = require('node:module'); | ||
const node_os = require('node:os'); | ||
const node_path = require('node:path'); | ||
const node_process = require('node:process'); | ||
const node_url = require('node:url'); | ||
const node_worker_threads = require('node:worker_threads'); | ||
const detectLibc = require('detect-libc'); | ||
const nodeAbi = require('node-abi'); | ||
const os = require('os'); | ||
@@ -16,3 +9,2 @@ const process$1 = require('process'); | ||
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; | ||
/** | ||
@@ -25,200 +17,2 @@ * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code. | ||
const stdlib = detectLibc.familySync(); | ||
const platform = process.env['BUILD_PLATFORM'] || node_os.platform(); | ||
const arch = process.env['BUILD_ARCH'] || node_os.arch(); | ||
const abi = nodeAbi.getAbi(node_process.versions.node, 'node'); | ||
const identifier = [platform, arch, stdlib, abi].filter(c => c !== undefined && c !== null).join('-'); | ||
/** | ||
* Imports cpp bindings based on the current platform and architecture. | ||
*/ | ||
// eslint-disable-next-line complexity | ||
function importCppBindingsModule() { | ||
// We need to work around using import.meta.url directly with import.meta.url because jest complains about it. | ||
const importMetaUrl = | ||
typeof (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)) !== 'undefined' | ||
? // This case is always hit when the SDK is built | ||
(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)) | ||
: // This case is hit when the tests are run | ||
node_url.pathToFileURL(__filename).href; | ||
const createdRequire = node_module.createRequire(importMetaUrl); | ||
const esmCompatibleDirname = node_path.dirname(node_url.fileURLToPath(importMetaUrl)); | ||
// If a binary path is specified, use that. | ||
if (node_process.env['SENTRY_PROFILER_BINARY_PATH']) { | ||
const envPath = node_process.env['SENTRY_PROFILER_BINARY_PATH']; | ||
return createdRequire(envPath); | ||
} | ||
// If a user specifies a different binary dir, they are in control of the binaries being moved there | ||
if (node_process.env['SENTRY_PROFILER_BINARY_DIR']) { | ||
const binaryPath = node_path.join(node_path.resolve(node_process.env['SENTRY_PROFILER_BINARY_DIR']), `sentry_cpu_profiler-${identifier}`); | ||
return createdRequire(`${binaryPath}.node`); | ||
} | ||
// We need the fallthrough so that in the end, we can fallback to the dynamic require. | ||
// This is for cases where precompiled binaries were not provided, but may have been compiled from source. | ||
if (platform === 'darwin') { | ||
if (arch === 'x64') { | ||
if (abi === '93') { | ||
return createdRequire('../sentry_cpu_profiler-darwin-x64-93.node'); | ||
} | ||
if (abi === '108') { | ||
return createdRequire('../sentry_cpu_profiler-darwin-x64-108.node'); | ||
} | ||
if (abi === '115') { | ||
return createdRequire('../sentry_cpu_profiler-darwin-x64-115.node'); | ||
} | ||
if (abi === '127') { | ||
return createdRequire('../sentry_cpu_profiler-darwin-x64-127.node'); | ||
} | ||
} | ||
if (arch === 'arm64') { | ||
if (abi === '93') { | ||
return createdRequire('../sentry_cpu_profiler-darwin-arm64-93.node'); | ||
} | ||
if (abi === '108') { | ||
return createdRequire('../sentry_cpu_profiler-darwin-arm64-108.node'); | ||
} | ||
if (abi === '115') { | ||
return createdRequire('../sentry_cpu_profiler-darwin-arm64-115.node'); | ||
} | ||
if (abi === '127') { | ||
return createdRequire('../sentry_cpu_profiler-darwin-arm64-127.node'); | ||
} | ||
} | ||
} | ||
if (platform === 'win32') { | ||
if (arch === 'x64') { | ||
if (abi === '93') { | ||
return createdRequire('../sentry_cpu_profiler-win32-x64-93.node'); | ||
} | ||
if (abi === '108') { | ||
return createdRequire('../sentry_cpu_profiler-win32-x64-108.node'); | ||
} | ||
if (abi === '115') { | ||
return createdRequire('../sentry_cpu_profiler-win32-x64-115.node'); | ||
} | ||
if (abi === '127') { | ||
return createdRequire('../sentry_cpu_profiler-win32-x64-127.node'); | ||
} | ||
} | ||
} | ||
if (platform === 'linux') { | ||
if (arch === 'x64') { | ||
if (stdlib === 'musl') { | ||
if (abi === '93') { | ||
return createdRequire('../sentry_cpu_profiler-linux-x64-musl-93.node'); | ||
} | ||
if (abi === '108') { | ||
return createdRequire('../sentry_cpu_profiler-linux-x64-musl-108.node'); | ||
} | ||
if (abi === '115') { | ||
return createdRequire('../sentry_cpu_profiler-linux-x64-musl-115.node'); | ||
} | ||
if (abi === '127') { | ||
return createdRequire('../sentry_cpu_profiler-linux-x64-musl-127.node'); | ||
} | ||
} | ||
if (stdlib === 'glibc') { | ||
if (abi === '93') { | ||
return createdRequire('../sentry_cpu_profiler-linux-x64-glibc-93.node'); | ||
} | ||
if (abi === '108') { | ||
return createdRequire('../sentry_cpu_profiler-linux-x64-glibc-108.node'); | ||
} | ||
if (abi === '115') { | ||
return createdRequire('../sentry_cpu_profiler-linux-x64-glibc-115.node'); | ||
} | ||
if (abi === '127') { | ||
return createdRequire('../sentry_cpu_profiler-linux-x64-glibc-127.node'); | ||
} | ||
} | ||
} | ||
if (arch === 'arm64') { | ||
if (stdlib === 'musl') { | ||
if (abi === '93') { | ||
return createdRequire('../sentry_cpu_profiler-linux-arm64-musl-93.node'); | ||
} | ||
if (abi === '108') { | ||
return createdRequire('../sentry_cpu_profiler-linux-arm64-musl-108.node'); | ||
} | ||
if (abi === '115') { | ||
return createdRequire('../sentry_cpu_profiler-linux-arm64-musl-115.node'); | ||
} | ||
if (abi === '127') { | ||
return createdRequire('../sentry_cpu_profiler-linux-arm64-musl-127.node'); | ||
} | ||
} | ||
if (stdlib === 'glibc') { | ||
if (abi === '93') { | ||
return createdRequire('../sentry_cpu_profiler-linux-arm64-glibc-93.node'); | ||
} | ||
if (abi === '108') { | ||
return createdRequire('../sentry_cpu_profiler-linux-arm64-glibc-108.node'); | ||
} | ||
if (abi === '115') { | ||
return createdRequire('../sentry_cpu_profiler-linux-arm64-glibc-115.node'); | ||
} | ||
if (abi === '127') { | ||
return createdRequire('../sentry_cpu_profiler-linux-arm64-glibc-127.node'); | ||
} | ||
} | ||
} | ||
} | ||
const built_from_source_path = node_path.resolve(esmCompatibleDirname, '..', `sentry_cpu_profiler-${identifier}`); | ||
return createdRequire(`${built_from_source_path}.node`); | ||
} | ||
const PrivateCpuProfilerBindings = importCppBindingsModule(); | ||
class Bindings { | ||
startProfiling(name) { | ||
if (!PrivateCpuProfilerBindings) { | ||
DEBUG_BUILD && core.logger.log('[Profiling] Bindings not loaded, ignoring call to startProfiling.'); | ||
return; | ||
} | ||
if (typeof PrivateCpuProfilerBindings.startProfiling !== 'function') { | ||
DEBUG_BUILD && | ||
core.logger.log('[Profiling] Native startProfiling function is not available, ignoring call to startProfiling.'); | ||
return; | ||
} | ||
return PrivateCpuProfilerBindings.startProfiling(name); | ||
} | ||
stopProfiling( | ||
name, | ||
format, | ||
) { | ||
if (!PrivateCpuProfilerBindings) { | ||
DEBUG_BUILD && | ||
core.logger.log('[Profiling] Bindings not loaded or profile was never started, ignoring call to stopProfiling.'); | ||
return null; | ||
} | ||
if (typeof PrivateCpuProfilerBindings.stopProfiling !== 'function') { | ||
DEBUG_BUILD && | ||
core.logger.log('[Profiling] Native stopProfiling function is not available, ignoring call to stopProfiling.'); | ||
return null; | ||
} | ||
return PrivateCpuProfilerBindings.stopProfiling( | ||
name, | ||
format , | ||
node_worker_threads.threadId, | ||
!!core.GLOBAL_OBJ._sentryDebugIds, | ||
); | ||
} | ||
} | ||
const CpuProfilerBindings = new Bindings(); | ||
const NODE_VERSION = core.parseSemver(process.versions.node) ; | ||
@@ -296,3 +90,3 @@ const NODE_MAJOR = NODE_VERSION.major; | ||
start_timestamp: event.start_timestamp ? event.start_timestamp * 1000 : Date.now(), | ||
trace_id: event.contexts?.['trace']?.['trace_id'] ?? '', | ||
trace_id: event.contexts?.trace?.trace_id ?? '', | ||
profile_id: profile.profile_id, | ||
@@ -548,3 +342,3 @@ }); | ||
for (let j = 1; j < item.length; j++) { | ||
const event = item[j]; | ||
const event = item[j] ; | ||
@@ -556,7 +350,6 @@ if (!event) { | ||
// @ts-expect-error profile_id is not part of the metadata type | ||
const profile_id = (event.contexts )?.['profile']?.['profile_id']; | ||
const profile_id = event.contexts?.profile?.profile_id; | ||
if (event && profile_id) { | ||
events.push(item[j] ); | ||
events.push(event); | ||
} | ||
@@ -701,3 +494,3 @@ } | ||
const profile_id = core.uuid4(); | ||
CpuProfilerBindings.startProfiling(profile_id); | ||
nodeCpuProfiler.CpuProfilerBindings.startProfiling(profile_id); | ||
DEBUG_BUILD && core.logger.log(`[Profiling] started profiling transaction: ${core.spanToJSON(span).description}`); | ||
@@ -722,3 +515,3 @@ | ||
const profile = CpuProfilerBindings.stopProfiling(profile_id, 0); | ||
const profile = nodeCpuProfiler.CpuProfilerBindings.stopProfiling(profile_id, 0); | ||
DEBUG_BUILD && core.logger.log(`[Profiling] stopped profiling of transaction: ${core.spanToJSON(span).description}`); | ||
@@ -746,2 +539,5 @@ | ||
/* eslint-disable max-lines */ | ||
const CHUNK_INTERVAL_MS = 5000; | ||
@@ -837,4 +633,4 @@ const PROFILE_MAP = new core.LRUMap(50); | ||
for (const profiledTransaction of profiledTransactionEvents) { | ||
const profileContext = profiledTransaction.contexts?.['profile']; | ||
const profile_id = profileContext?.['profile_id']; | ||
const profileContext = profiledTransaction.contexts?.profile; | ||
const profile_id = profileContext?.profile_id; | ||
@@ -847,3 +643,3 @@ if (!profile_id) { | ||
if (profileContext) { | ||
delete profiledTransaction.contexts?.['profile']; | ||
delete profiledTransaction.contexts?.profile; | ||
} | ||
@@ -969,3 +765,3 @@ | ||
const profile = CpuProfilerBindings.stopProfiling(this._chunkData.id, ProfileFormat.CHUNK); | ||
const profile = nodeCpuProfiler.CpuProfilerBindings.stopProfiling(this._chunkData.id, ProfileFormat.CHUNK); | ||
@@ -1048,3 +844,3 @@ if (!profile) { | ||
CpuProfilerBindings.startProfiling(chunk.id); | ||
nodeCpuProfiler.CpuProfilerBindings.startProfiling(chunk.id); | ||
DEBUG_BUILD && core.logger.log(`[Profiling] starting profiling chunk: ${chunk.id}`); | ||
@@ -1115,3 +911,3 @@ | ||
_assignThreadIdContext(event) { | ||
if (!event?.['contexts']?.['profile']) { | ||
if (!event?.contexts?.profile) { | ||
return; | ||
@@ -1126,6 +922,6 @@ } | ||
// and in case it does, we dont want to override whatever was passed initially. | ||
event.contexts['trace'] = { | ||
...(event.contexts?.['trace'] ?? {}), | ||
event.contexts.trace = { | ||
...(event.contexts?.trace ?? {}), | ||
data: { | ||
...(event.contexts?.['trace']?.['data'] ?? {}), | ||
...(event.contexts?.trace?.data ?? {}), | ||
['thread.id']: PROFILER_THREAD_ID_STRING, | ||
@@ -1132,0 +928,0 @@ ['thread.name']: PROFILER_THREAD_NAME, |
@@ -1,13 +0,6 @@ | ||
import { logger, GLOBAL_OBJ, parseSemver, forEachEnvelopeItem, createEnvelope, getDebugImagesForResources, uuid4, dsnToString, spanIsSampled, spanToJSON, LRUMap, defineIntegration, consoleSandbox, getRootSpan, getIsolationScope, getCurrentScope, getGlobalScope } from '@sentry/core'; | ||
import { createRequire } from 'node:module'; | ||
import { platform as platform$1, arch as arch$1 } from 'node:os'; | ||
import { dirname, join, resolve } from 'node:path'; | ||
import { versions, env } from 'node:process'; | ||
import { pathToFileURL, fileURLToPath } from 'node:url'; | ||
import { threadId } from 'node:worker_threads'; | ||
import { familySync } from 'detect-libc'; | ||
import { getAbi } from 'node-abi'; | ||
import { CpuProfilerBindings } from '@sentry-internal/node-cpu-profiler'; | ||
import { parseSemver, logger, forEachEnvelopeItem, createEnvelope, getDebugImagesForResources, uuid4, dsnToString, spanIsSampled, spanToJSON, LRUMap, defineIntegration, consoleSandbox, getRootSpan, getIsolationScope, getCurrentScope, getGlobalScope } from '@sentry/core'; | ||
import * as os from 'os'; | ||
import { versions as versions$1, env as env$1 } from 'process'; | ||
import { threadId as threadId$1, isMainThread } from 'worker_threads'; | ||
import { versions, env } from 'process'; | ||
import { threadId, isMainThread } from 'worker_threads'; | ||
@@ -21,200 +14,2 @@ /** | ||
const stdlib = familySync(); | ||
const platform = process.env['BUILD_PLATFORM'] || platform$1(); | ||
const arch = process.env['BUILD_ARCH'] || arch$1(); | ||
const abi = getAbi(versions.node, 'node'); | ||
const identifier = [platform, arch, stdlib, abi].filter(c => c !== undefined && c !== null).join('-'); | ||
/** | ||
* Imports cpp bindings based on the current platform and architecture. | ||
*/ | ||
// eslint-disable-next-line complexity | ||
function importCppBindingsModule() { | ||
// We need to work around using import.meta.url directly with import.meta.url because jest complains about it. | ||
const importMetaUrl = | ||
typeof import.meta.url !== 'undefined' | ||
? // This case is always hit when the SDK is built | ||
import.meta.url | ||
: // This case is hit when the tests are run | ||
pathToFileURL(__filename).href; | ||
const createdRequire = createRequire(importMetaUrl); | ||
const esmCompatibleDirname = dirname(fileURLToPath(importMetaUrl)); | ||
// If a binary path is specified, use that. | ||
if (env['SENTRY_PROFILER_BINARY_PATH']) { | ||
const envPath = env['SENTRY_PROFILER_BINARY_PATH']; | ||
return createdRequire(envPath); | ||
} | ||
// If a user specifies a different binary dir, they are in control of the binaries being moved there | ||
if (env['SENTRY_PROFILER_BINARY_DIR']) { | ||
const binaryPath = join(resolve(env['SENTRY_PROFILER_BINARY_DIR']), `sentry_cpu_profiler-${identifier}`); | ||
return createdRequire(`${binaryPath}.node`); | ||
} | ||
// We need the fallthrough so that in the end, we can fallback to the dynamic require. | ||
// This is for cases where precompiled binaries were not provided, but may have been compiled from source. | ||
if (platform === 'darwin') { | ||
if (arch === 'x64') { | ||
if (abi === '93') { | ||
return createdRequire('../sentry_cpu_profiler-darwin-x64-93.node'); | ||
} | ||
if (abi === '108') { | ||
return createdRequire('../sentry_cpu_profiler-darwin-x64-108.node'); | ||
} | ||
if (abi === '115') { | ||
return createdRequire('../sentry_cpu_profiler-darwin-x64-115.node'); | ||
} | ||
if (abi === '127') { | ||
return createdRequire('../sentry_cpu_profiler-darwin-x64-127.node'); | ||
} | ||
} | ||
if (arch === 'arm64') { | ||
if (abi === '93') { | ||
return createdRequire('../sentry_cpu_profiler-darwin-arm64-93.node'); | ||
} | ||
if (abi === '108') { | ||
return createdRequire('../sentry_cpu_profiler-darwin-arm64-108.node'); | ||
} | ||
if (abi === '115') { | ||
return createdRequire('../sentry_cpu_profiler-darwin-arm64-115.node'); | ||
} | ||
if (abi === '127') { | ||
return createdRequire('../sentry_cpu_profiler-darwin-arm64-127.node'); | ||
} | ||
} | ||
} | ||
if (platform === 'win32') { | ||
if (arch === 'x64') { | ||
if (abi === '93') { | ||
return createdRequire('../sentry_cpu_profiler-win32-x64-93.node'); | ||
} | ||
if (abi === '108') { | ||
return createdRequire('../sentry_cpu_profiler-win32-x64-108.node'); | ||
} | ||
if (abi === '115') { | ||
return createdRequire('../sentry_cpu_profiler-win32-x64-115.node'); | ||
} | ||
if (abi === '127') { | ||
return createdRequire('../sentry_cpu_profiler-win32-x64-127.node'); | ||
} | ||
} | ||
} | ||
if (platform === 'linux') { | ||
if (arch === 'x64') { | ||
if (stdlib === 'musl') { | ||
if (abi === '93') { | ||
return createdRequire('../sentry_cpu_profiler-linux-x64-musl-93.node'); | ||
} | ||
if (abi === '108') { | ||
return createdRequire('../sentry_cpu_profiler-linux-x64-musl-108.node'); | ||
} | ||
if (abi === '115') { | ||
return createdRequire('../sentry_cpu_profiler-linux-x64-musl-115.node'); | ||
} | ||
if (abi === '127') { | ||
return createdRequire('../sentry_cpu_profiler-linux-x64-musl-127.node'); | ||
} | ||
} | ||
if (stdlib === 'glibc') { | ||
if (abi === '93') { | ||
return createdRequire('../sentry_cpu_profiler-linux-x64-glibc-93.node'); | ||
} | ||
if (abi === '108') { | ||
return createdRequire('../sentry_cpu_profiler-linux-x64-glibc-108.node'); | ||
} | ||
if (abi === '115') { | ||
return createdRequire('../sentry_cpu_profiler-linux-x64-glibc-115.node'); | ||
} | ||
if (abi === '127') { | ||
return createdRequire('../sentry_cpu_profiler-linux-x64-glibc-127.node'); | ||
} | ||
} | ||
} | ||
if (arch === 'arm64') { | ||
if (stdlib === 'musl') { | ||
if (abi === '93') { | ||
return createdRequire('../sentry_cpu_profiler-linux-arm64-musl-93.node'); | ||
} | ||
if (abi === '108') { | ||
return createdRequire('../sentry_cpu_profiler-linux-arm64-musl-108.node'); | ||
} | ||
if (abi === '115') { | ||
return createdRequire('../sentry_cpu_profiler-linux-arm64-musl-115.node'); | ||
} | ||
if (abi === '127') { | ||
return createdRequire('../sentry_cpu_profiler-linux-arm64-musl-127.node'); | ||
} | ||
} | ||
if (stdlib === 'glibc') { | ||
if (abi === '93') { | ||
return createdRequire('../sentry_cpu_profiler-linux-arm64-glibc-93.node'); | ||
} | ||
if (abi === '108') { | ||
return createdRequire('../sentry_cpu_profiler-linux-arm64-glibc-108.node'); | ||
} | ||
if (abi === '115') { | ||
return createdRequire('../sentry_cpu_profiler-linux-arm64-glibc-115.node'); | ||
} | ||
if (abi === '127') { | ||
return createdRequire('../sentry_cpu_profiler-linux-arm64-glibc-127.node'); | ||
} | ||
} | ||
} | ||
} | ||
const built_from_source_path = resolve(esmCompatibleDirname, '..', `sentry_cpu_profiler-${identifier}`); | ||
return createdRequire(`${built_from_source_path}.node`); | ||
} | ||
const PrivateCpuProfilerBindings = importCppBindingsModule(); | ||
class Bindings { | ||
startProfiling(name) { | ||
if (!PrivateCpuProfilerBindings) { | ||
DEBUG_BUILD && logger.log('[Profiling] Bindings not loaded, ignoring call to startProfiling.'); | ||
return; | ||
} | ||
if (typeof PrivateCpuProfilerBindings.startProfiling !== 'function') { | ||
DEBUG_BUILD && | ||
logger.log('[Profiling] Native startProfiling function is not available, ignoring call to startProfiling.'); | ||
return; | ||
} | ||
return PrivateCpuProfilerBindings.startProfiling(name); | ||
} | ||
stopProfiling( | ||
name, | ||
format, | ||
) { | ||
if (!PrivateCpuProfilerBindings) { | ||
DEBUG_BUILD && | ||
logger.log('[Profiling] Bindings not loaded or profile was never started, ignoring call to stopProfiling.'); | ||
return null; | ||
} | ||
if (typeof PrivateCpuProfilerBindings.stopProfiling !== 'function') { | ||
DEBUG_BUILD && | ||
logger.log('[Profiling] Native stopProfiling function is not available, ignoring call to stopProfiling.'); | ||
return null; | ||
} | ||
return PrivateCpuProfilerBindings.stopProfiling( | ||
name, | ||
format , | ||
threadId, | ||
!!GLOBAL_OBJ._sentryDebugIds, | ||
); | ||
} | ||
} | ||
const CpuProfilerBindings = new Bindings(); | ||
const NODE_VERSION = parseSemver(process.versions.node) ; | ||
@@ -225,3 +20,3 @@ const NODE_MAJOR = NODE_VERSION.major; | ||
// I guess tsc does not check file contents when it's imported. | ||
const PROFILER_THREAD_ID_STRING = String(threadId$1); | ||
const PROFILER_THREAD_ID_STRING = String(threadId); | ||
const PROFILER_THREAD_NAME = isMainThread ? 'main' : 'worker'; | ||
@@ -293,3 +88,3 @@ const FORMAT_VERSION = '1'; | ||
start_timestamp: event.start_timestamp ? event.start_timestamp * 1000 : Date.now(), | ||
trace_id: event.contexts?.['trace']?.['trace_id'] ?? '', | ||
trace_id: event.contexts?.trace?.trace_id ?? '', | ||
profile_id: profile.profile_id, | ||
@@ -339,3 +134,3 @@ }); | ||
name: 'node', | ||
version: versions$1.node || '', | ||
version: versions.node || '', | ||
}, | ||
@@ -348,3 +143,3 @@ os: { | ||
device: { | ||
locale: env$1['LC_ALL'] || env$1['LC_MESSAGES'] || env$1['LANG'] || env$1['LANGUAGE'] || '', | ||
locale: env['LC_ALL'] || env['LC_MESSAGES'] || env['LANG'] || env['LANGUAGE'] || '', | ||
model: MODEL, | ||
@@ -547,3 +342,3 @@ manufacturer: TYPE, | ||
for (let j = 1; j < item.length; j++) { | ||
const event = item[j]; | ||
const event = item[j] ; | ||
@@ -555,7 +350,6 @@ if (!event) { | ||
// @ts-expect-error profile_id is not part of the metadata type | ||
const profile_id = (event.contexts )?.['profile']?.['profile_id']; | ||
const profile_id = event.contexts?.profile?.profile_id; | ||
if (event && profile_id) { | ||
events.push(item[j] ); | ||
events.push(event); | ||
} | ||
@@ -743,2 +537,5 @@ } | ||
/* eslint-disable max-lines */ | ||
const CHUNK_INTERVAL_MS = 5000; | ||
@@ -834,4 +631,4 @@ const PROFILE_MAP = new LRUMap(50); | ||
for (const profiledTransaction of profiledTransactionEvents) { | ||
const profileContext = profiledTransaction.contexts?.['profile']; | ||
const profile_id = profileContext?.['profile_id']; | ||
const profileContext = profiledTransaction.contexts?.profile; | ||
const profile_id = profileContext?.profile_id; | ||
@@ -844,3 +641,3 @@ if (!profile_id) { | ||
if (profileContext) { | ||
delete profiledTransaction.contexts?.['profile']; | ||
delete profiledTransaction.contexts?.profile; | ||
} | ||
@@ -1110,3 +907,3 @@ | ||
_assignThreadIdContext(event) { | ||
if (!event?.['contexts']?.['profile']) { | ||
if (!event?.contexts?.profile) { | ||
return; | ||
@@ -1121,6 +918,6 @@ } | ||
// and in case it does, we dont want to override whatever was passed initially. | ||
event.contexts['trace'] = { | ||
...(event.contexts?.['trace'] ?? {}), | ||
event.contexts.trace = { | ||
...(event.contexts?.trace ?? {}), | ||
data: { | ||
...(event.contexts?.['trace']?.['data'] ?? {}), | ||
...(event.contexts?.trace?.data ?? {}), | ||
['thread.id']: PROFILER_THREAD_ID_STRING, | ||
@@ -1127,0 +924,0 @@ ['thread.name']: PROFILER_THREAD_NAME, |
@@ -1,1 +0,1 @@ | ||
{"type":"module","version":"9.0.0-alpha.0","sideEffects":false} | ||
{"type":"module","version":"9.0.0-alpha.1","sideEffects":false} |
{ | ||
"name": "@sentry/profiling-node", | ||
"version": "9.0.0-alpha.0", | ||
"version": "9.0.0-alpha.1", | ||
"description": "Official Sentry SDK for Node.js Profiling", | ||
@@ -43,49 +43,30 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
"/lib", | ||
"/bindings", | ||
"/binding.gyp", | ||
"package.json", | ||
"/scripts/binaries.js", | ||
"/scripts/check-build.js", | ||
"/scripts/copy-target.js", | ||
"/scripts/prune-profiler-binaries.js" | ||
], | ||
"scripts": { | ||
"install": "node scripts/check-build.js", | ||
"clean": "rm -rf build && rm -rf lib", | ||
"lint": "yarn lint:eslint && yarn lint:clang", | ||
"lint:eslint": "eslint . --format stylish", | ||
"lint:clang": "node clang-format.js", | ||
"lint": "eslint . --format stylish", | ||
"fix": "eslint . --format stylish --fix", | ||
"lint:fix": "yarn fix:eslint && yarn fix:clang", | ||
"lint:fix:clang": "node clang-format.js --fix", | ||
"build": "yarn build:lib && yarn build:bindings:configure && yarn build:bindings", | ||
"build": "yarn build:lib", | ||
"build:lib": "yarn build:types && rollup -c rollup.npm.config.mjs", | ||
"build:transpile": "yarn build:bindings:configure && yarn build:bindings && yarn build:lib", | ||
"build:transpile": "yarn build:lib", | ||
"build:types:downlevel": "yarn downlevel-dts lib/types lib/types-ts3.8 --to ts3.8", | ||
"build:types": "tsc -p tsconfig.types.json && yarn build:types:downlevel", | ||
"build:types:watch": "tsc -p tsconfig.types.json --watch", | ||
"build:bindings:configure": "node-gyp configure", | ||
"build:bindings:configure:arm64": "node-gyp configure --arch=arm64 --target_arch=arm64", | ||
"build:bindings": "node-gyp build && node scripts/copy-target.js", | ||
"build:bindings:arm64": "node-gyp build --arch=arm64 && node scripts/copy-target.js", | ||
"build:dev": "yarn clean && yarn build:bindings:configure && yarn build", | ||
"build:dev": "yarn clean && yarn build", | ||
"build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", | ||
"build:watch": "run-p build:transpile:watch build:types:watch", | ||
"build:tarball": "npm pack", | ||
"test:watch": "cross-env SENTRY_PROFILER_BINARY_DIR=build jest --watch", | ||
"test:watch": "jest --watch", | ||
"test:bundle": "node test-binaries.esbuild.js", | ||
"test": "cross-env SENTRY_PROFILER_BINARY_DIR=lib jest --config jest.config.js" | ||
"test": "jest --config jest.config.js" | ||
}, | ||
"dependencies": { | ||
"@sentry/core": "9.0.0-alpha.0", | ||
"@sentry/node": "9.0.0-alpha.0", | ||
"detect-libc": "^2.0.2", | ||
"node-abi": "^3.61.0" | ||
"@sentry-internal/node-cpu-profiler": "^2.0.0", | ||
"@sentry/core": "9.0.0-alpha.1", | ||
"@sentry/node": "9.0.0-alpha.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18.19.1", | ||
"@types/node-abi": "^3.0.3", | ||
"clang-format": "^1.8.0", | ||
"cross-env": "^7.0.3", | ||
"node-gyp": "^9.4.1" | ||
"@types/node": "^18.19.1" | ||
}, | ||
@@ -92,0 +73,0 @@ "volta": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
3
-25%1
-80%0
-100%3
-81.25%0
-100%218316
-91.35%30
-49.15%2233
-18.27%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated