@sentry/profiling-node 9.1.0 → 9.2.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -524,15 +524,9 @@ function stopSpanProfile(span, profile_id) {
524
524
  return profile;
525
525
  }
526
526
 
527
- var ProfileFormat; (function (ProfileFormat) {
528
- const THREAD = 0; ProfileFormat[ProfileFormat["THREAD"] = THREAD] = "THREAD";
529
- const CHUNK = 1; ProfileFormat[ProfileFormat["CHUNK"] = CHUNK] = "CHUNK";
530
- })(ProfileFormat || (ProfileFormat = {}));
531
-
532
527
  /* eslint-disable max-lines */
533
528
 
534
-
535
- const CHUNK_INTERVAL_MS = 5000;
529
+ const CHUNK_INTERVAL_MS = 1000 * 60;
536
530
  const PROFILE_MAP = new core.LRUMap(50);
537
531
  const PROFILE_TIMEOUTS = {};
538
532
 
@@ -752,7 +746,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
752
746
  return;
753
747
  }
754
748
 
755
- const profile = nodeCpuProfiler.CpuProfilerBindings.stopProfiling(this._chunkData.id, ProfileFormat.CHUNK);
749
+ const profile = nodeCpuProfiler.CpuProfilerBindings.stopProfiling(this._chunkData.id, nodeCpuProfiler.ProfileFormat.CHUNK);
756
750
 
757
751
  if (!profile) {
758
752
  DEBUG_BUILD && core.logger.log(`[Profiling] _chunkiledStartTraceID to collect profile for: ${this._chunkData.id}`);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/debug-build.ts","../../src/nodeVersion.ts","../../src/utils.ts","../../src/spanProfileUtils.ts","../../src/types.ts","../../src/integration.ts"],"sourcesContent":["declare const __DEBUG_BUILD__: boolean;\n\n/**\n * 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.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nexport const DEBUG_BUILD = __DEBUG_BUILD__;\n","import { parseSemver } from '@sentry/core';\n\nexport const NODE_VERSION = parseSemver(process.versions.node) as { major: number; minor: number; patch: number };\nexport const NODE_MAJOR = NODE_VERSION.major;\n","import * as os from 'os';\nimport type {\n Client,\n ContinuousThreadCpuProfile,\n DebugImage,\n DsnComponents,\n Envelope,\n Event,\n EventEnvelopeHeaders,\n Profile,\n ProfileChunk,\n ProfileChunkEnvelope,\n ProfileChunkItem,\n SdkInfo,\n ThreadCpuProfile,\n TransactionEvent,\n} from '@sentry/core';\nimport {\n createEnvelope,\n dsnToString,\n forEachEnvelopeItem,\n getDebugImagesForResources,\n logger,\n uuid4,\n} from '@sentry/core';\n\nimport { env, versions } from 'process';\nimport { isMainThread, threadId } from 'worker_threads';\n\nimport { DEBUG_BUILD } from './debug-build';\nimport type { RawChunkCpuProfile, RawThreadCpuProfile } from './types';\n\n// We require the file because if we import it, it will be included in the bundle.\n// I guess tsc does not check file contents when it's imported.\nexport const PROFILER_THREAD_ID_STRING = String(threadId);\nexport const PROFILER_THREAD_NAME = isMainThread ? 'main' : 'worker';\nconst FORMAT_VERSION = '1';\nconst CONTINUOUS_FORMAT_VERSION = '2';\n\n// Machine properties (eval only once)\nconst PLATFORM = os.platform();\nconst RELEASE = os.release();\nconst VERSION = os.version();\nconst TYPE = os.type();\nconst MODEL = os.machine();\nconst ARCH = os.arch();\n\n/**\n * Checks if the profile is a raw profile or a profile enriched with thread information.\n * @param {ThreadCpuProfile | RawThreadCpuProfile} profile\n * @returns {boolean}\n */\nfunction isRawThreadCpuProfile(\n profile: ThreadCpuProfile | RawThreadCpuProfile | ContinuousThreadCpuProfile | RawChunkCpuProfile,\n): profile is RawThreadCpuProfile | RawChunkCpuProfile {\n return !('thread_metadata' in profile);\n}\n\n/**\n * Enriches the profile with threadId of the current thread.\n * This is done in node as we seem to not be able to get the info from C native code.\n *\n * @param {ThreadCpuProfile | RawThreadCpuProfile} profile\n * @returns {ThreadCpuProfile}\n */\nexport function enrichWithThreadInformation(\n profile: ThreadCpuProfile | RawThreadCpuProfile | ContinuousThreadCpuProfile | RawChunkCpuProfile,\n): ThreadCpuProfile | ContinuousThreadCpuProfile {\n if (!isRawThreadCpuProfile(profile)) {\n return profile;\n }\n\n return {\n samples: profile.samples,\n frames: profile.frames,\n stacks: profile.stacks,\n thread_metadata: {\n [PROFILER_THREAD_ID_STRING]: {\n name: PROFILER_THREAD_NAME,\n },\n },\n } as ThreadCpuProfile | ContinuousThreadCpuProfile;\n}\n\n/**\n * Creates a profiling envelope item, if the profile does not pass validation, returns null.\n * @param {RawThreadCpuProfile}\n * @param {Event}\n * @returns {Profile | null}\n */\nexport function createProfilingEvent(client: Client, profile: RawThreadCpuProfile, event: Event): Profile | null {\n if (!isValidProfile(profile)) {\n return null;\n }\n\n return createProfilePayload(client, profile, {\n release: event.release ?? '',\n environment: event.environment ?? '',\n event_id: event.event_id ?? '',\n transaction: event.transaction ?? '',\n start_timestamp: event.start_timestamp ? event.start_timestamp * 1000 : Date.now(),\n trace_id: event.contexts?.trace?.trace_id ?? '',\n profile_id: profile.profile_id,\n });\n}\n\n/**\n * Create a profile\n * @param {RawThreadCpuProfile} cpuProfile\n * @param {options}\n * @returns {Profile}\n */\nfunction createProfilePayload(\n client: Client,\n cpuProfile: RawThreadCpuProfile,\n {\n release,\n environment,\n event_id,\n transaction,\n start_timestamp,\n trace_id,\n profile_id,\n }: {\n release: string;\n environment: string;\n event_id: string;\n transaction: string;\n start_timestamp: number;\n trace_id: string | undefined;\n profile_id: string;\n },\n): Profile {\n // Log a warning if the profile has an invalid traceId (should be uuidv4).\n // All profiles and transactions are rejected if this is the case and we want to\n // warn users that this is happening if they enable debug flag\n if (trace_id?.length !== 32) {\n DEBUG_BUILD && logger.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`);\n }\n\n const enrichedThreadProfile = enrichWithThreadInformation(cpuProfile);\n\n const profile: Profile = {\n event_id: profile_id,\n timestamp: new Date(start_timestamp).toISOString(),\n platform: 'node',\n version: FORMAT_VERSION,\n release: release,\n environment: environment,\n measurements: cpuProfile.measurements,\n runtime: {\n name: 'node',\n version: versions.node || '',\n },\n os: {\n name: PLATFORM,\n version: RELEASE,\n build_number: VERSION,\n },\n device: {\n locale: env['LC_ALL'] || env['LC_MESSAGES'] || env['LANG'] || env['LANGUAGE'] || '',\n model: MODEL,\n manufacturer: TYPE,\n architecture: ARCH,\n is_emulator: false,\n },\n debug_meta: {\n images: applyDebugMetadata(client, cpuProfile.resources),\n },\n profile: enrichedThreadProfile as ThreadCpuProfile,\n transaction: {\n name: transaction,\n id: event_id,\n trace_id: trace_id || '',\n active_thread_id: PROFILER_THREAD_ID_STRING,\n },\n };\n\n return profile;\n}\n\n/**\n * Create a profile chunk from raw thread profile\n * @param {RawThreadCpuProfile} cpuProfile\n * @param {options}\n * @returns {Profile}\n */\nfunction createProfileChunkPayload(\n client: Client,\n cpuProfile: RawChunkCpuProfile,\n {\n release,\n environment,\n trace_id,\n profiler_id,\n chunk_id,\n sdk,\n }: {\n release: string;\n environment: string;\n trace_id: string | undefined;\n chunk_id: string;\n profiler_id: string;\n sdk: SdkInfo | undefined;\n },\n): ProfileChunk {\n // Log a warning if the profile has an invalid traceId (should be uuidv4).\n // All profiles and transactions are rejected if this is the case and we want to\n // warn users that this is happening if they enable debug flag\n if (trace_id?.length !== 32) {\n DEBUG_BUILD && logger.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`);\n }\n\n const enrichedThreadProfile = enrichWithThreadInformation(cpuProfile);\n\n const profile: ProfileChunk = {\n chunk_id: chunk_id,\n client_sdk: {\n name: sdk?.name ?? 'sentry.javascript.node',\n version: sdk?.version ?? '0.0.0',\n },\n profiler_id: profiler_id,\n platform: 'node',\n version: CONTINUOUS_FORMAT_VERSION,\n release: release,\n environment: environment,\n measurements: cpuProfile.measurements,\n debug_meta: {\n images: applyDebugMetadata(client, cpuProfile.resources),\n },\n profile: enrichedThreadProfile as ContinuousThreadCpuProfile,\n };\n\n return profile;\n}\n\n/**\n * Creates a profiling chunk envelope item, if the profile does not pass validation, returns null.\n */\nexport function createProfilingChunkEvent(\n client: Client,\n options: { release?: string; environment?: string },\n profile: RawChunkCpuProfile,\n sdk: SdkInfo | undefined,\n identifiers: { trace_id: string | undefined; chunk_id: string; profiler_id: string },\n): ProfileChunk | null {\n if (!isValidProfileChunk(profile)) {\n return null;\n }\n\n return createProfileChunkPayload(client, profile, {\n release: options.release ?? '',\n environment: options.environment ?? '',\n trace_id: identifiers.trace_id ?? '',\n chunk_id: identifiers.chunk_id,\n profiler_id: identifiers.profiler_id,\n sdk,\n });\n}\n\n/**\n * Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1).\n * @param {unknown} rate\n * @returns {boolean}\n */\nexport function isValidSampleRate(rate: unknown): boolean {\n // we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck\n if ((typeof rate !== 'number' && typeof rate !== 'boolean') || (typeof rate === 'number' && isNaN(rate))) {\n DEBUG_BUILD &&\n logger.warn(\n `[Profiling] Invalid sample rate. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(\n rate,\n )} of type ${JSON.stringify(typeof rate)}.`,\n );\n return false;\n }\n\n // Boolean sample rates are always valid\n if (rate === true || rate === false) {\n return true;\n }\n\n // in case sampleRate is a boolean, it will get automatically cast to 1 if it's true and 0 if it's false\n if (rate < 0 || rate > 1) {\n DEBUG_BUILD && logger.warn(`[Profiling] Invalid sample rate. Sample rate must be between 0 and 1. Got ${rate}.`);\n return false;\n }\n return true;\n}\n\n/**\n * Checks if the profile is valid and can be sent to Sentry.\n * @param {RawThreadCpuProfile} profile\n * @returns {boolean}\n */\nexport function isValidProfile(profile: RawThreadCpuProfile): profile is RawThreadCpuProfile & { profile_id: string } {\n if (profile.samples.length <= 1) {\n DEBUG_BUILD &&\n // Log a warning if the profile has less than 2 samples so users can know why\n // they are not seeing any profiling data and we cant avoid the back and forth\n // of asking them to provide us with a dump of the profile data.\n logger.log('[Profiling] Discarding profile because it contains less than 2 samples');\n return false;\n }\n\n if (!profile.profile_id) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Checks if the profile chunk is valid and can be sent to Sentry.\n * @param profile\n * @returns\n */\nexport function isValidProfileChunk(profile: RawChunkCpuProfile): profile is RawChunkCpuProfile {\n if (profile.samples.length <= 1) {\n DEBUG_BUILD &&\n // Log a warning if the profile has less than 2 samples so users can know why\n // they are not seeing any profiling data and we cant avoid the back and forth\n // of asking them to provide us with a dump of the profile data.\n logger.log('[Profiling] Discarding profile chunk because it contains less than 2 samples');\n return false;\n }\n\n return true;\n}\n\n/**\n * Adds items to envelope if they are not already present - mutates the envelope.\n * @param {Envelope} envelope\n * @param {Profile[]} profiles\n * @returns {Envelope}\n */\nexport function addProfilesToEnvelope(envelope: Envelope, profiles: Profile[]): Envelope {\n if (!profiles.length) {\n return envelope;\n }\n\n for (const profile of profiles) {\n // @ts-expect-error untyped envelope\n envelope[1].push([{ type: 'profile' }, profile]);\n }\n return envelope;\n}\n\n/**\n * Finds transactions with profile_id context in the envelope\n * @param {Envelope} envelope\n * @returns {Event[]}\n */\nexport function findProfiledTransactionsFromEnvelope(envelope: Envelope): Event[] {\n const events: TransactionEvent[] = [];\n\n forEachEnvelopeItem(envelope, (item, type) => {\n if (type !== 'transaction') {\n return;\n }\n\n // First item is the type, so we can skip it, everything else is an event\n for (let j = 1; j < item.length; j++) {\n const event = item[j] as TransactionEvent;\n\n if (!event) {\n // Shouldn't happen, but lets be safe\n continue;\n }\n\n const profile_id = event.contexts?.profile?.profile_id;\n\n if (event && profile_id) {\n events.push(event);\n }\n }\n });\n\n return events;\n}\n\n/**\n * Creates event envelope headers for a profile chunk. This is separate from createEventEnvelopeHeaders util\n * as the profile chunk does not conform to the sentry event type\n */\nexport function createEventEnvelopeHeaders(\n sdkInfo: SdkInfo | undefined,\n tunnel: string | undefined,\n dsn?: DsnComponents,\n): EventEnvelopeHeaders {\n return {\n event_id: uuid4(),\n sent_at: new Date().toISOString(),\n ...(sdkInfo && { sdk: sdkInfo }),\n ...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),\n };\n}\n\n/**\n * Creates a standalone profile_chunk envelope.\n */\nexport function makeProfileChunkEnvelope(\n chunk: ProfileChunk,\n sdkInfo: SdkInfo | undefined,\n tunnel: string | undefined,\n dsn?: DsnComponents,\n): ProfileChunkEnvelope {\n const profileChunkHeader: ProfileChunkItem[0] = {\n type: 'profile_chunk',\n };\n\n return createEnvelope<ProfileChunkEnvelope>(createEventEnvelopeHeaders(sdkInfo, tunnel, dsn), [\n [profileChunkHeader, chunk],\n ]);\n}\n\n/**\n * Cross reference profile collected resources with debug_ids and return a list of debug images.\n * @param {string[]} resource_paths\n * @returns {DebugImage[]}\n */\nexport function applyDebugMetadata(client: Client, resource_paths: ReadonlyArray<string>): DebugImage[] {\n const options = client.getOptions();\n\n if (!options?.stackParser) {\n return [];\n }\n\n return getDebugImagesForResources(options.stackParser, resource_paths);\n}\n","import { CpuProfilerBindings } from '@sentry-internal/node-cpu-profiler';\nimport type { CustomSamplingContext, Span } from '@sentry/core';\nimport { logger, spanIsSampled, spanToJSON, uuid4 } from '@sentry/core';\nimport type { NodeClient } from '@sentry/node';\nimport { DEBUG_BUILD } from './debug-build';\nimport type { RawThreadCpuProfile } from './types';\nimport { isValidSampleRate } from './utils';\n\nexport const MAX_PROFILE_DURATION_MS = 30 * 1000;\n\n/**\n * Takes a transaction and determines if it should be profiled or not. If it should be profiled, it returns the\n * profile_id, otherwise returns undefined. Takes care of setting profile context on transaction as well\n */\nexport function maybeProfileSpan(\n client: NodeClient | undefined,\n span: Span,\n customSamplingContext?: CustomSamplingContext,\n): string | undefined {\n // profilesSampleRate is multiplied with tracesSampleRate to get the final sampling rate. We dont perform\n // the actual multiplication to get the final rate, but we discard the profile if the span was sampled,\n // so anything after this block from here is based on the span sampling.\n if (!spanIsSampled(span)) {\n return;\n }\n\n // Client and options are required for profiling\n if (!client) {\n DEBUG_BUILD && logger.log('[Profiling] Profiling disabled, no client found.');\n return;\n }\n\n const options = client.getOptions();\n if (!options) {\n DEBUG_BUILD && logger.log('[Profiling] Profiling disabled, no options found.');\n return;\n }\n\n const profilesSampler = options.profilesSampler;\n let profilesSampleRate: number | boolean | undefined = options.profilesSampleRate;\n\n // Prefer sampler to sample rate if both are provided.\n if (typeof profilesSampler === 'function') {\n const { description: spanName = '<unknown>', data } = spanToJSON(span);\n // We bail out early if that is not the case\n const parentSampled = true;\n\n profilesSampleRate = profilesSampler({\n name: spanName,\n attributes: data,\n parentSampled,\n ...customSamplingContext,\n });\n }\n\n // Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The\n // only valid values are booleans or numbers between 0 and 1.)\n if (!isValidSampleRate(profilesSampleRate)) {\n DEBUG_BUILD && logger.warn('[Profiling] Discarding profile because of invalid sample rate.');\n return;\n }\n\n // if the function returned 0 (or false), or if `profileSampleRate` is 0, it's a sign the profile should be dropped\n if (!profilesSampleRate) {\n DEBUG_BUILD &&\n logger.log(\n `[Profiling] Discarding profile because ${\n typeof profilesSampler === 'function'\n ? 'profileSampler returned 0 or false'\n : 'a negative sampling decision was inherited or profileSampleRate is set to 0'\n }`,\n );\n return;\n }\n\n // Now we roll the dice. Math.random is inclusive of 0, but not of 1, so strict < is safe here. In case sampleRate is\n // a boolean, the < comparison will cause it to be automatically cast to 1 if it's true and 0 if it's false.\n const sampled = profilesSampleRate === true ? true : Math.random() < profilesSampleRate;\n // Check if we should sample this profile\n if (!sampled) {\n DEBUG_BUILD &&\n logger.log(\n `[Profiling] Discarding profile because it's not included in the random sample (sampling rate = ${Number(\n profilesSampleRate,\n )})`,\n );\n return;\n }\n\n const profile_id = uuid4();\n CpuProfilerBindings.startProfiling(profile_id);\n DEBUG_BUILD && logger.log(`[Profiling] started profiling transaction: ${spanToJSON(span).description}`);\n\n // set transaction context - do this regardless if profiling fails down the line\n // so that we can still see the profile_id in the transaction context\n return profile_id;\n}\n\n/**\n * Stops the profiler for profile_id and returns the profile\n * @param transaction\n * @param profile_id\n * @returns\n */\nexport function stopSpanProfile(span: Span, profile_id: string | undefined): RawThreadCpuProfile | null {\n // Should not happen, but satisfy the type checker and be safe regardless.\n if (!profile_id) {\n return null;\n }\n\n const profile = CpuProfilerBindings.stopProfiling(profile_id, 0);\n DEBUG_BUILD && logger.log(`[Profiling] stopped profiling of transaction: ${spanToJSON(span).description}`);\n\n // In case of an overlapping span, stopProfiling may return null and silently ignore the overlapping profile.\n if (!profile) {\n DEBUG_BUILD &&\n logger.log(\n `[Profiling] profiler returned null profile for: ${spanToJSON(span).description}`,\n 'this may indicate an overlapping span or a call to stopProfiling with a profile title that was never started',\n );\n return null;\n }\n\n // Assign profile_id to the profile\n profile.profile_id = profile_id;\n return profile;\n}\n","import type { Event } from '@sentry/core';\n\ninterface Sample {\n stack_id: number;\n thread_id: string;\n elapsed_since_start_ns: string;\n}\n\ninterface ChunkSample {\n stack_id: number;\n thread_id: string;\n timestamp: number;\n}\n\ntype Frame = {\n function: string;\n file: string;\n lineno: number;\n colno: number;\n};\n\ninterface Measurement {\n unit: string;\n values: {\n elapsed_since_start_ns: number;\n value: number;\n }[];\n}\n\n// Profile is marked as optional because it is deleted from the metadata\n// by the integration before the event is processed by other integrations.\nexport interface ProfiledEvent extends Event {\n sdkProcessingMetadata: {\n profile?: RawThreadCpuProfile;\n };\n}\n\ninterface BaseProfile {\n profile_id?: string;\n stacks: number[][];\n frames: Frame[];\n resources: string[];\n profiler_logging_mode: 'eager' | 'lazy';\n measurements: Record<string, Measurement>;\n}\nexport interface RawThreadCpuProfile extends BaseProfile {\n samples: Sample[];\n}\n\nexport interface RawChunkCpuProfile extends BaseProfile {\n samples: ChunkSample[];\n}\n\nexport interface PrivateV8CpuProfilerBindings {\n startProfiling?: (name: string) => void;\n\n stopProfiling?(\n name: string,\n format: ProfileFormat.THREAD,\n threadId: number,\n collectResources: boolean,\n ): RawThreadCpuProfile | null;\n stopProfiling?(\n name: string,\n format: ProfileFormat.CHUNK,\n threadId: number,\n collectResources: boolean,\n ): RawChunkCpuProfile | null;\n\n // Helper methods exposed for testing\n getFrameModule(abs_path: string): string;\n}\n\nexport enum ProfileFormat {\n THREAD = 0,\n CHUNK = 1,\n}\n\nexport interface V8CpuProfilerBindings {\n startProfiling(name: string): void;\n\n stopProfiling(name: string, format: ProfileFormat.THREAD): RawThreadCpuProfile | null;\n stopProfiling(name: string, format: ProfileFormat.CHUNK): RawChunkCpuProfile | null;\n}\n","/* eslint-disable max-lines */\n\nimport { CpuProfilerBindings } from '@sentry-internal/node-cpu-profiler';\nimport type { Event, IntegrationFn, Profile, ProfileChunk, ProfilingIntegration, Span } from '@sentry/core';\nimport {\n LRUMap,\n consoleSandbox,\n defineIntegration,\n getCurrentScope,\n getGlobalScope,\n getIsolationScope,\n getRootSpan,\n logger,\n spanToJSON,\n uuid4,\n} from '@sentry/core';\nimport type { NodeClient } from '@sentry/node';\nimport { DEBUG_BUILD } from './debug-build';\nimport { NODE_MAJOR, NODE_VERSION } from './nodeVersion';\nimport { MAX_PROFILE_DURATION_MS, maybeProfileSpan, stopSpanProfile } from './spanProfileUtils';\nimport type { RawThreadCpuProfile } from './types';\nimport { ProfileFormat } from './types';\nimport {\n PROFILER_THREAD_ID_STRING,\n PROFILER_THREAD_NAME,\n addProfilesToEnvelope,\n createProfilingChunkEvent,\n createProfilingEvent,\n findProfiledTransactionsFromEnvelope,\n makeProfileChunkEnvelope,\n} from './utils';\n\nconst CHUNK_INTERVAL_MS = 5000;\nconst PROFILE_MAP = new LRUMap<string, RawThreadCpuProfile>(50);\nconst PROFILE_TIMEOUTS: Record<string, NodeJS.Timeout> = {};\n\nfunction addToProfileQueue(profile_id: string, profile: RawThreadCpuProfile): void {\n PROFILE_MAP.set(profile_id, profile);\n}\n\nfunction takeFromProfileQueue(profile_id: string): RawThreadCpuProfile | undefined {\n const profile = PROFILE_MAP.get(profile_id);\n PROFILE_MAP.remove(profile_id);\n return profile;\n}\n\n/**\n * Instruments the client to automatically invoke the profiler on span start and stop events.\n * @param client\n */\nfunction setupAutomatedSpanProfiling(client: NodeClient): void {\n const spanToProfileIdMap = new WeakMap<Span, string>();\n\n client.on('spanStart', span => {\n if (span !== getRootSpan(span)) {\n return;\n }\n\n const profile_id = maybeProfileSpan(client, span);\n\n if (profile_id) {\n const options = client.getOptions();\n // Not intended for external use, hence missing types, but we want to profile a couple of things at Sentry that\n // currently exceed the default timeout set by the SDKs.\n const maxProfileDurationMs = options._experiments?.maxProfileDurationMs || MAX_PROFILE_DURATION_MS;\n\n if (PROFILE_TIMEOUTS[profile_id]) {\n global.clearTimeout(PROFILE_TIMEOUTS[profile_id]);\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete PROFILE_TIMEOUTS[profile_id];\n }\n\n // Enqueue a timeout to prevent profiles from running over max duration.\n const timeout = global.setTimeout(() => {\n DEBUG_BUILD &&\n logger.log('[Profiling] max profile duration elapsed, stopping profiling for:', spanToJSON(span).description);\n\n const profile = stopSpanProfile(span, profile_id);\n if (profile) {\n addToProfileQueue(profile_id, profile);\n }\n }, maxProfileDurationMs);\n\n // Unref timeout so it doesn't keep the process alive.\n timeout.unref();\n\n getIsolationScope().setContext('profile', { profile_id });\n spanToProfileIdMap.set(span, profile_id);\n }\n });\n\n client.on('spanEnd', span => {\n const profile_id = spanToProfileIdMap.get(span);\n\n if (profile_id) {\n if (PROFILE_TIMEOUTS[profile_id]) {\n global.clearTimeout(PROFILE_TIMEOUTS[profile_id]);\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete PROFILE_TIMEOUTS[profile_id];\n }\n const profile = stopSpanProfile(span, profile_id);\n\n if (profile) {\n addToProfileQueue(profile_id, profile);\n }\n }\n });\n\n client.on('beforeEnvelope', (envelope): void => {\n // if not profiles are in queue, there is nothing to add to the envelope.\n if (!PROFILE_MAP.size) {\n return;\n }\n\n const profiledTransactionEvents = findProfiledTransactionsFromEnvelope(envelope);\n if (!profiledTransactionEvents.length) {\n return;\n }\n\n const profilesToAddToEnvelope: Profile[] = [];\n\n for (const profiledTransaction of profiledTransactionEvents) {\n const profileContext = profiledTransaction.contexts?.profile;\n const profile_id = profileContext?.profile_id;\n\n if (!profile_id) {\n throw new TypeError('[Profiling] cannot find profile for a transaction without a profile context');\n }\n\n // Remove the profile from the transaction context before sending, relay will take care of the rest.\n if (profileContext) {\n delete profiledTransaction.contexts?.profile;\n }\n\n const cpuProfile = takeFromProfileQueue(profile_id);\n if (!cpuProfile) {\n DEBUG_BUILD && logger.log(`[Profiling] Could not retrieve profile for transaction: ${profile_id}`);\n continue;\n }\n\n const profile = createProfilingEvent(client, cpuProfile, profiledTransaction);\n if (!profile) return;\n\n profilesToAddToEnvelope.push(profile);\n\n // @ts-expect-error profile does not inherit from Event\n client.emit('preprocessEvent', profile, {\n event_id: profiledTransaction.event_id,\n });\n\n // @ts-expect-error profile does not inherit from Event\n client.emit('postprocessEvent', profile, {\n event_id: profiledTransaction.event_id,\n });\n }\n\n addProfilesToEnvelope(envelope, profilesToAddToEnvelope);\n });\n}\n\ninterface ChunkData {\n id: string;\n timer: NodeJS.Timeout | undefined;\n startTraceID: string;\n}\n\nclass ContinuousProfiler {\n private _profilerId: string | undefined;\n private _client: NodeClient | undefined = undefined;\n private _chunkData: ChunkData | undefined = undefined;\n\n /**\n * Called when the profiler is attached to the client (continuous mode is enabled). If of the profiler\n * methods called before the profiler is initialized will result in a noop action with debug logs.\n * @param client\n */\n public initialize(client: NodeClient): void {\n this._client = client;\n\n // Attaches a listener to beforeSend which will add the threadId data to the event being sent.\n // This adds a constant overhead to all events being sent which could be improved to only attach\n // and detach the listener during a profiler session\n this._client.on('beforeSendEvent', this._onBeforeSendThreadContextAssignment.bind(this));\n }\n\n /**\n * Initializes a new profilerId session and schedules chunk profiling.\n * @returns void\n */\n public start(): void {\n if (!this._client) {\n DEBUG_BUILD && logger.log('[Profiling] Failed to start, sentry client was never attached to the profiler.');\n return;\n }\n\n // Flush any existing chunks before starting a new one.\n this._chunkStop();\n\n // Restart the profiler session\n this._setupSpanChunkInstrumentation();\n this._chunkStart();\n }\n\n /**\n * Stops the current chunk and flushes the profile to Sentry.\n * @returns void\n */\n public stop(): void {\n if (!this._client) {\n DEBUG_BUILD && logger.log('[Profiling] Failed to stop, sentry client was never attached to the profiler.');\n return;\n }\n this._chunkStop();\n this._teardownSpanChunkInstrumentation();\n }\n\n /**\n * Stop profiler and initializes profiling of the next chunk\n */\n private _chunkStart(): void {\n if (!this._client) {\n // The client is not attached to the profiler if the user has not enabled continuous profiling.\n // In this case, calling start() and stop() is a noop action.The reason this exists is because\n // it makes the types easier to work with and avoids users having to do null checks.\n DEBUG_BUILD && logger.log('[Profiling] Profiler was never attached to the client.');\n return;\n }\n if (this._chunkData) {\n DEBUG_BUILD &&\n logger.log(\n `[Profiling] Chunk with chunk_id ${this._chunkData.id} is still running, current chunk will be stopped a new chunk will be started.`,\n );\n this._chunkStop();\n }\n\n this._startChunkProfiling();\n }\n\n /**\n * Stops profiling of the current chunks and flushes the profile to Sentry\n */\n private _chunkStop(): void {\n if (this._chunkData?.timer) {\n global.clearTimeout(this._chunkData.timer);\n this._chunkData.timer = undefined;\n DEBUG_BUILD && logger.log(`[Profiling] Stopping profiling chunk: ${this._chunkData.id}`);\n }\n if (!this._client) {\n DEBUG_BUILD &&\n logger.log('[Profiling] Failed to collect profile, sentry client was never attached to the profiler.');\n return;\n }\n if (!this._chunkData?.id) {\n DEBUG_BUILD &&\n logger.log(`[Profiling] Failed to collect profile for: ${this._chunkData?.id}, the chunk_id is missing.`);\n return;\n }\n\n const profile = CpuProfilerBindings.stopProfiling(this._chunkData.id, ProfileFormat.CHUNK);\n\n if (!profile) {\n DEBUG_BUILD && logger.log(`[Profiling] _chunkiledStartTraceID to collect profile for: ${this._chunkData.id}`);\n return;\n }\n if (!this._profilerId) {\n DEBUG_BUILD &&\n logger.log('[Profiling] Profile chunk does not contain a valid profiler_id, this is a bug in the SDK');\n return;\n }\n if (profile) {\n DEBUG_BUILD && logger.log(`[Profiling] Sending profile chunk ${this._chunkData.id}.`);\n }\n\n DEBUG_BUILD && logger.log(`[Profiling] Profile chunk ${this._chunkData.id} sent to Sentry.`);\n const chunk = createProfilingChunkEvent(\n this._client,\n this._client.getOptions(),\n profile,\n this._client.getSdkMetadata()?.sdk,\n {\n chunk_id: this._chunkData.id,\n trace_id: this._chunkData.startTraceID,\n profiler_id: this._profilerId,\n },\n );\n\n if (!chunk) {\n DEBUG_BUILD && logger.log(`[Profiling] Failed to create profile chunk for: ${this._chunkData.id}`);\n this._resetChunkData();\n return;\n }\n\n this._flush(chunk);\n // Depending on the profile and stack sizes, stopping the profile and converting\n // the format may negatively impact the performance of the application. To avoid\n // blocking for too long, enqueue the next chunk start inside the next macrotask.\n // clear current chunk\n this._resetChunkData();\n }\n\n /**\n * Flushes the profile chunk to Sentry.\n * @param chunk\n */\n private _flush(chunk: ProfileChunk): void {\n if (!this._client) {\n DEBUG_BUILD &&\n logger.log('[Profiling] Failed to collect profile, sentry client was never attached to the profiler.');\n return;\n }\n\n const transport = this._client.getTransport();\n if (!transport) {\n DEBUG_BUILD && logger.log('[Profiling] No transport available to send profile chunk.');\n return;\n }\n\n const dsn = this._client.getDsn();\n const metadata = this._client.getSdkMetadata();\n const tunnel = this._client.getOptions().tunnel;\n\n const envelope = makeProfileChunkEnvelope(chunk, metadata?.sdk, tunnel, dsn);\n transport.send(envelope).then(null, reason => {\n DEBUG_BUILD && logger.error('Error while sending profile chunk envelope:', reason);\n });\n }\n\n /**\n * Starts the profiler and registers the flush timer for a given chunk.\n * @param chunk\n */\n private _startChunkProfiling(): void {\n const traceId =\n getCurrentScope().getPropagationContext().traceId || getIsolationScope().getPropagationContext().traceId;\n const chunk = this._initializeChunk(traceId);\n\n CpuProfilerBindings.startProfiling(chunk.id);\n DEBUG_BUILD && logger.log(`[Profiling] starting profiling chunk: ${chunk.id}`);\n\n chunk.timer = global.setTimeout(() => {\n DEBUG_BUILD && logger.log(`[Profiling] Stopping profiling chunk: ${chunk.id}`);\n this._chunkStop();\n DEBUG_BUILD && logger.log('[Profiling] Starting new profiling chunk.');\n setImmediate(this._chunkStart.bind(this));\n }, CHUNK_INTERVAL_MS);\n\n // Unref timeout so it doesn't keep the process alive.\n chunk.timer.unref();\n }\n\n /**\n * Attaches profiling information to spans that were started\n * during a profiling session.\n */\n private _setupSpanChunkInstrumentation(): void {\n if (!this._client) {\n DEBUG_BUILD &&\n logger.log(\n '[Profiling] Failed to initialize span profiling, sentry client was never attached to the profiler.',\n );\n return;\n }\n\n this._profilerId = uuid4();\n getGlobalScope().setContext('profile', {\n profiler_id: this._profilerId,\n });\n }\n\n /**\n * Assigns thread_id and thread name context to a profiled event if there is an active profiler session\n */\n private _onBeforeSendThreadContextAssignment(event: Event): void {\n if (!this._client || !this._profilerId) return;\n this._assignThreadIdContext(event);\n }\n\n /**\n * Clear profiling information from global context when a profile is not running.\n */\n private _teardownSpanChunkInstrumentation(): void {\n this._profilerId = undefined;\n const globalScope = getGlobalScope();\n globalScope.setContext('profile', {});\n }\n\n /**\n * Initializes new profile chunk metadata\n */\n private _initializeChunk(traceId: string): ChunkData {\n this._chunkData = {\n id: uuid4(),\n startTraceID: traceId,\n timer: undefined,\n };\n return this._chunkData;\n }\n\n /**\n * Assigns thread_id and thread name context to a profiled event.\n */\n private _assignThreadIdContext(event: Event): void {\n if (!event?.contexts?.profile) {\n return;\n }\n\n if (!event.contexts) {\n return;\n }\n\n // @ts-expect-error the trace fallback value is wrong, though it should never happen\n // and in case it does, we dont want to override whatever was passed initially.\n event.contexts.trace = {\n ...(event.contexts?.trace ?? {}),\n data: {\n ...(event.contexts?.trace?.data ?? {}),\n ['thread.id']: PROFILER_THREAD_ID_STRING,\n ['thread.name']: PROFILER_THREAD_NAME,\n },\n };\n }\n\n /**\n * Resets the current chunk state.\n */\n private _resetChunkData(): void {\n this._chunkData = undefined;\n }\n}\n\n/** Exported only for tests. */\nexport const _nodeProfilingIntegration = ((): ProfilingIntegration<NodeClient> => {\n if (![16, 18, 20, 22].includes(NODE_MAJOR)) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry Profiling] You are using a Node.js version that does not have prebuilt binaries (${NODE_VERSION}).`,\n 'The @sentry/profiling-node package only has prebuilt support for the following LTS versions of Node.js: 16, 18, 20, 22.',\n 'To use the @sentry/profiling-node package with this version of Node.js, you will need to compile the native addon from source.',\n 'See: https://github.com/getsentry/sentry-javascript/tree/develop/packages/profiling-node#building-the-package-from-source',\n );\n });\n }\n\n return {\n name: 'ProfilingIntegration',\n _profiler: new ContinuousProfiler(),\n setup(client: NodeClient) {\n DEBUG_BUILD && logger.log('[Profiling] Profiling integration setup.');\n const options = client.getOptions();\n\n const mode =\n (options.profilesSampleRate === undefined ||\n options.profilesSampleRate === null ||\n options.profilesSampleRate === 0) &&\n !options.profilesSampler\n ? 'continuous'\n : 'span';\n switch (mode) {\n case 'continuous': {\n DEBUG_BUILD && logger.log('[Profiling] Continuous profiler mode enabled.');\n this._profiler.initialize(client);\n break;\n }\n // Default to span profiling when no mode profiler mode is set\n case 'span':\n case undefined: {\n DEBUG_BUILD && logger.log('[Profiling] Span profiler mode enabled.');\n setupAutomatedSpanProfiling(client);\n break;\n }\n default: {\n DEBUG_BUILD && logger.warn(`[Profiling] Unknown profiler mode: ${mode}, profiler was not initialized`);\n }\n }\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * We need this integration in order to send data to Sentry. We hook into the event processor\n * and inspect each event to see if it is a transaction event and if that transaction event\n * contains a profile on it's metadata. If that is the case, we create a profiling event envelope\n * and delete the profile from the transaction metadata.\n */\nexport const nodeProfilingIntegration = defineIntegration(_nodeProfilingIntegration);\n"],"names":["parseSemver","threadId","isMainThread","logger","versions","env","forEachEnvelopeItem","uuid4","dsnToString","createEnvelope","getDebugImagesForResources","spanIsSampled","spanToJSON","CpuProfilerBindings","LRUMap","getRootSpan","getIsolationScope","getCurrentScope","getGlobalScope","consoleSandbox","defineIntegration"],"mappings":";;;;;;;;AAEA;AACA;AACA;AAC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,CAAA,CAAA;AACA;AACA;AACA,KAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAA,wBAAA,GAAAiB,sBAAA,CAAA,yBAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/debug-build.ts","../../src/nodeVersion.ts","../../src/utils.ts","../../src/spanProfileUtils.ts","../../src/integration.ts"],"sourcesContent":["declare const __DEBUG_BUILD__: boolean;\n\n/**\n * 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.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nexport const DEBUG_BUILD = __DEBUG_BUILD__;\n","import { parseSemver } from '@sentry/core';\n\nexport const NODE_VERSION = parseSemver(process.versions.node) as { major: number; minor: number; patch: number };\nexport const NODE_MAJOR = NODE_VERSION.major;\n","import * as os from 'os';\nimport type {\n Client,\n ContinuousThreadCpuProfile,\n DebugImage,\n DsnComponents,\n Envelope,\n Event,\n EventEnvelopeHeaders,\n Profile,\n ProfileChunk,\n ProfileChunkEnvelope,\n ProfileChunkItem,\n SdkInfo,\n ThreadCpuProfile,\n TransactionEvent,\n} from '@sentry/core';\nimport {\n createEnvelope,\n dsnToString,\n forEachEnvelopeItem,\n getDebugImagesForResources,\n logger,\n uuid4,\n} from '@sentry/core';\n\nimport { env, versions } from 'process';\nimport { isMainThread, threadId } from 'worker_threads';\n\nimport type { RawChunkCpuProfile, RawThreadCpuProfile } from '@sentry-internal/node-cpu-profiler';\nimport { DEBUG_BUILD } from './debug-build';\n\n// We require the file because if we import it, it will be included in the bundle.\n// I guess tsc does not check file contents when it's imported.\nexport const PROFILER_THREAD_ID_STRING = String(threadId);\nexport const PROFILER_THREAD_NAME = isMainThread ? 'main' : 'worker';\nconst FORMAT_VERSION = '1';\nconst CONTINUOUS_FORMAT_VERSION = '2';\n\n// Machine properties (eval only once)\nconst PLATFORM = os.platform();\nconst RELEASE = os.release();\nconst VERSION = os.version();\nconst TYPE = os.type();\nconst MODEL = os.machine();\nconst ARCH = os.arch();\n\n/**\n * Checks if the profile is a raw profile or a profile enriched with thread information.\n * @param {ThreadCpuProfile | RawThreadCpuProfile} profile\n * @returns {boolean}\n */\nfunction isRawThreadCpuProfile(\n profile: ThreadCpuProfile | RawThreadCpuProfile | ContinuousThreadCpuProfile | RawChunkCpuProfile,\n): profile is RawThreadCpuProfile | RawChunkCpuProfile {\n return !('thread_metadata' in profile);\n}\n\n/**\n * Enriches the profile with threadId of the current thread.\n * This is done in node as we seem to not be able to get the info from C native code.\n *\n * @param {ThreadCpuProfile | RawThreadCpuProfile} profile\n * @returns {ThreadCpuProfile}\n */\nexport function enrichWithThreadInformation(\n profile: ThreadCpuProfile | RawThreadCpuProfile | ContinuousThreadCpuProfile | RawChunkCpuProfile,\n): ThreadCpuProfile | ContinuousThreadCpuProfile {\n if (!isRawThreadCpuProfile(profile)) {\n return profile;\n }\n\n return {\n samples: profile.samples,\n frames: profile.frames,\n stacks: profile.stacks,\n thread_metadata: {\n [PROFILER_THREAD_ID_STRING]: {\n name: PROFILER_THREAD_NAME,\n },\n },\n } as ThreadCpuProfile | ContinuousThreadCpuProfile;\n}\n\n/**\n * Creates a profiling envelope item, if the profile does not pass validation, returns null.\n * @param {RawThreadCpuProfile}\n * @param {Event}\n * @returns {Profile | null}\n */\nexport function createProfilingEvent(client: Client, profile: RawThreadCpuProfile, event: Event): Profile | null {\n if (!isValidProfile(profile)) {\n return null;\n }\n\n return createProfilePayload(client, profile, {\n release: event.release ?? '',\n environment: event.environment ?? '',\n event_id: event.event_id ?? '',\n transaction: event.transaction ?? '',\n start_timestamp: event.start_timestamp ? event.start_timestamp * 1000 : Date.now(),\n trace_id: event.contexts?.trace?.trace_id ?? '',\n profile_id: profile.profile_id,\n });\n}\n\n/**\n * Create a profile\n * @param {RawThreadCpuProfile} cpuProfile\n * @param {options}\n * @returns {Profile}\n */\nfunction createProfilePayload(\n client: Client,\n cpuProfile: RawThreadCpuProfile,\n {\n release,\n environment,\n event_id,\n transaction,\n start_timestamp,\n trace_id,\n profile_id,\n }: {\n release: string;\n environment: string;\n event_id: string;\n transaction: string;\n start_timestamp: number;\n trace_id: string | undefined;\n profile_id: string;\n },\n): Profile {\n // Log a warning if the profile has an invalid traceId (should be uuidv4).\n // All profiles and transactions are rejected if this is the case and we want to\n // warn users that this is happening if they enable debug flag\n if (trace_id?.length !== 32) {\n DEBUG_BUILD && logger.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`);\n }\n\n const enrichedThreadProfile = enrichWithThreadInformation(cpuProfile);\n\n const profile: Profile = {\n event_id: profile_id,\n timestamp: new Date(start_timestamp).toISOString(),\n platform: 'node',\n version: FORMAT_VERSION,\n release: release,\n environment: environment,\n measurements: cpuProfile.measurements,\n runtime: {\n name: 'node',\n version: versions.node || '',\n },\n os: {\n name: PLATFORM,\n version: RELEASE,\n build_number: VERSION,\n },\n device: {\n locale: env['LC_ALL'] || env['LC_MESSAGES'] || env['LANG'] || env['LANGUAGE'] || '',\n model: MODEL,\n manufacturer: TYPE,\n architecture: ARCH,\n is_emulator: false,\n },\n debug_meta: {\n images: applyDebugMetadata(client, cpuProfile.resources),\n },\n profile: enrichedThreadProfile as ThreadCpuProfile,\n transaction: {\n name: transaction,\n id: event_id,\n trace_id: trace_id || '',\n active_thread_id: PROFILER_THREAD_ID_STRING,\n },\n };\n\n return profile;\n}\n\n/**\n * Create a profile chunk from raw thread profile\n * @param {RawThreadCpuProfile} cpuProfile\n * @param {options}\n * @returns {Profile}\n */\nfunction createProfileChunkPayload(\n client: Client,\n cpuProfile: RawChunkCpuProfile,\n {\n release,\n environment,\n trace_id,\n profiler_id,\n chunk_id,\n sdk,\n }: {\n release: string;\n environment: string;\n trace_id: string | undefined;\n chunk_id: string;\n profiler_id: string;\n sdk: SdkInfo | undefined;\n },\n): ProfileChunk {\n // Log a warning if the profile has an invalid traceId (should be uuidv4).\n // All profiles and transactions are rejected if this is the case and we want to\n // warn users that this is happening if they enable debug flag\n if (trace_id?.length !== 32) {\n DEBUG_BUILD && logger.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`);\n }\n\n const enrichedThreadProfile = enrichWithThreadInformation(cpuProfile);\n\n const profile: ProfileChunk = {\n chunk_id: chunk_id,\n client_sdk: {\n name: sdk?.name ?? 'sentry.javascript.node',\n version: sdk?.version ?? '0.0.0',\n },\n profiler_id: profiler_id,\n platform: 'node',\n version: CONTINUOUS_FORMAT_VERSION,\n release: release,\n environment: environment,\n measurements: cpuProfile.measurements,\n debug_meta: {\n images: applyDebugMetadata(client, cpuProfile.resources),\n },\n profile: enrichedThreadProfile as ContinuousThreadCpuProfile,\n };\n\n return profile;\n}\n\n/**\n * Creates a profiling chunk envelope item, if the profile does not pass validation, returns null.\n */\nexport function createProfilingChunkEvent(\n client: Client,\n options: { release?: string; environment?: string },\n profile: RawChunkCpuProfile,\n sdk: SdkInfo | undefined,\n identifiers: { trace_id: string | undefined; chunk_id: string; profiler_id: string },\n): ProfileChunk | null {\n if (!isValidProfileChunk(profile)) {\n return null;\n }\n\n return createProfileChunkPayload(client, profile, {\n release: options.release ?? '',\n environment: options.environment ?? '',\n trace_id: identifiers.trace_id ?? '',\n chunk_id: identifiers.chunk_id,\n profiler_id: identifiers.profiler_id,\n sdk,\n });\n}\n\n/**\n * Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1).\n * @param {unknown} rate\n * @returns {boolean}\n */\nexport function isValidSampleRate(rate: unknown): boolean {\n // we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck\n if ((typeof rate !== 'number' && typeof rate !== 'boolean') || (typeof rate === 'number' && isNaN(rate))) {\n DEBUG_BUILD &&\n logger.warn(\n `[Profiling] Invalid sample rate. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(\n rate,\n )} of type ${JSON.stringify(typeof rate)}.`,\n );\n return false;\n }\n\n // Boolean sample rates are always valid\n if (rate === true || rate === false) {\n return true;\n }\n\n // in case sampleRate is a boolean, it will get automatically cast to 1 if it's true and 0 if it's false\n if (rate < 0 || rate > 1) {\n DEBUG_BUILD && logger.warn(`[Profiling] Invalid sample rate. Sample rate must be between 0 and 1. Got ${rate}.`);\n return false;\n }\n return true;\n}\n\n/**\n * Checks if the profile is valid and can be sent to Sentry.\n * @param {RawThreadCpuProfile} profile\n * @returns {boolean}\n */\nexport function isValidProfile(profile: RawThreadCpuProfile): profile is RawThreadCpuProfile & { profile_id: string } {\n if (profile.samples.length <= 1) {\n DEBUG_BUILD &&\n // Log a warning if the profile has less than 2 samples so users can know why\n // they are not seeing any profiling data and we cant avoid the back and forth\n // of asking them to provide us with a dump of the profile data.\n logger.log('[Profiling] Discarding profile because it contains less than 2 samples');\n return false;\n }\n\n if (!profile.profile_id) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Checks if the profile chunk is valid and can be sent to Sentry.\n * @param profile\n * @returns\n */\nexport function isValidProfileChunk(profile: RawChunkCpuProfile): profile is RawChunkCpuProfile {\n if (profile.samples.length <= 1) {\n DEBUG_BUILD &&\n // Log a warning if the profile has less than 2 samples so users can know why\n // they are not seeing any profiling data and we cant avoid the back and forth\n // of asking them to provide us with a dump of the profile data.\n logger.log('[Profiling] Discarding profile chunk because it contains less than 2 samples');\n return false;\n }\n\n return true;\n}\n\n/**\n * Adds items to envelope if they are not already present - mutates the envelope.\n * @param {Envelope} envelope\n * @param {Profile[]} profiles\n * @returns {Envelope}\n */\nexport function addProfilesToEnvelope(envelope: Envelope, profiles: Profile[]): Envelope {\n if (!profiles.length) {\n return envelope;\n }\n\n for (const profile of profiles) {\n // @ts-expect-error untyped envelope\n envelope[1].push([{ type: 'profile' }, profile]);\n }\n return envelope;\n}\n\n/**\n * Finds transactions with profile_id context in the envelope\n * @param {Envelope} envelope\n * @returns {Event[]}\n */\nexport function findProfiledTransactionsFromEnvelope(envelope: Envelope): Event[] {\n const events: TransactionEvent[] = [];\n\n forEachEnvelopeItem(envelope, (item, type) => {\n if (type !== 'transaction') {\n return;\n }\n\n // First item is the type, so we can skip it, everything else is an event\n for (let j = 1; j < item.length; j++) {\n const event = item[j] as TransactionEvent;\n\n if (!event) {\n // Shouldn't happen, but lets be safe\n continue;\n }\n\n const profile_id = event.contexts?.profile?.profile_id;\n\n if (event && profile_id) {\n events.push(event);\n }\n }\n });\n\n return events;\n}\n\n/**\n * Creates event envelope headers for a profile chunk. This is separate from createEventEnvelopeHeaders util\n * as the profile chunk does not conform to the sentry event type\n */\nexport function createEventEnvelopeHeaders(\n sdkInfo: SdkInfo | undefined,\n tunnel: string | undefined,\n dsn?: DsnComponents,\n): EventEnvelopeHeaders {\n return {\n event_id: uuid4(),\n sent_at: new Date().toISOString(),\n ...(sdkInfo && { sdk: sdkInfo }),\n ...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),\n };\n}\n\n/**\n * Creates a standalone profile_chunk envelope.\n */\nexport function makeProfileChunkEnvelope(\n chunk: ProfileChunk,\n sdkInfo: SdkInfo | undefined,\n tunnel: string | undefined,\n dsn?: DsnComponents,\n): ProfileChunkEnvelope {\n const profileChunkHeader: ProfileChunkItem[0] = {\n type: 'profile_chunk',\n };\n\n return createEnvelope<ProfileChunkEnvelope>(createEventEnvelopeHeaders(sdkInfo, tunnel, dsn), [\n [profileChunkHeader, chunk],\n ]);\n}\n\n/**\n * Cross reference profile collected resources with debug_ids and return a list of debug images.\n * @param {string[]} resource_paths\n * @returns {DebugImage[]}\n */\nexport function applyDebugMetadata(client: Client, resource_paths: ReadonlyArray<string>): DebugImage[] {\n const options = client.getOptions();\n\n if (!options?.stackParser) {\n return [];\n }\n\n return getDebugImagesForResources(options.stackParser, resource_paths);\n}\n","import { CpuProfilerBindings, type RawThreadCpuProfile } from '@sentry-internal/node-cpu-profiler';\nimport type { CustomSamplingContext, Span } from '@sentry/core';\nimport { logger, spanIsSampled, spanToJSON, uuid4 } from '@sentry/core';\nimport type { NodeClient } from '@sentry/node';\nimport { DEBUG_BUILD } from './debug-build';\nimport { isValidSampleRate } from './utils';\n\nexport const MAX_PROFILE_DURATION_MS = 30 * 1000;\n\n/**\n * Takes a transaction and determines if it should be profiled or not. If it should be profiled, it returns the\n * profile_id, otherwise returns undefined. Takes care of setting profile context on transaction as well\n */\nexport function maybeProfileSpan(\n client: NodeClient | undefined,\n span: Span,\n customSamplingContext?: CustomSamplingContext,\n): string | undefined {\n // profilesSampleRate is multiplied with tracesSampleRate to get the final sampling rate. We dont perform\n // the actual multiplication to get the final rate, but we discard the profile if the span was sampled,\n // so anything after this block from here is based on the span sampling.\n if (!spanIsSampled(span)) {\n return;\n }\n\n // Client and options are required for profiling\n if (!client) {\n DEBUG_BUILD && logger.log('[Profiling] Profiling disabled, no client found.');\n return;\n }\n\n const options = client.getOptions();\n if (!options) {\n DEBUG_BUILD && logger.log('[Profiling] Profiling disabled, no options found.');\n return;\n }\n\n const profilesSampler = options.profilesSampler;\n let profilesSampleRate: number | boolean | undefined = options.profilesSampleRate;\n\n // Prefer sampler to sample rate if both are provided.\n if (typeof profilesSampler === 'function') {\n const { description: spanName = '<unknown>', data } = spanToJSON(span);\n // We bail out early if that is not the case\n const parentSampled = true;\n\n profilesSampleRate = profilesSampler({\n name: spanName,\n attributes: data,\n parentSampled,\n ...customSamplingContext,\n });\n }\n\n // Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The\n // only valid values are booleans or numbers between 0 and 1.)\n if (!isValidSampleRate(profilesSampleRate)) {\n DEBUG_BUILD && logger.warn('[Profiling] Discarding profile because of invalid sample rate.');\n return;\n }\n\n // if the function returned 0 (or false), or if `profileSampleRate` is 0, it's a sign the profile should be dropped\n if (!profilesSampleRate) {\n DEBUG_BUILD &&\n logger.log(\n `[Profiling] Discarding profile because ${\n typeof profilesSampler === 'function'\n ? 'profileSampler returned 0 or false'\n : 'a negative sampling decision was inherited or profileSampleRate is set to 0'\n }`,\n );\n return;\n }\n\n // Now we roll the dice. Math.random is inclusive of 0, but not of 1, so strict < is safe here. In case sampleRate is\n // a boolean, the < comparison will cause it to be automatically cast to 1 if it's true and 0 if it's false.\n const sampled = profilesSampleRate === true ? true : Math.random() < profilesSampleRate;\n // Check if we should sample this profile\n if (!sampled) {\n DEBUG_BUILD &&\n logger.log(\n `[Profiling] Discarding profile because it's not included in the random sample (sampling rate = ${Number(\n profilesSampleRate,\n )})`,\n );\n return;\n }\n\n const profile_id = uuid4();\n CpuProfilerBindings.startProfiling(profile_id);\n DEBUG_BUILD && logger.log(`[Profiling] started profiling transaction: ${spanToJSON(span).description}`);\n\n // set transaction context - do this regardless if profiling fails down the line\n // so that we can still see the profile_id in the transaction context\n return profile_id;\n}\n\n/**\n * Stops the profiler for profile_id and returns the profile\n * @param transaction\n * @param profile_id\n * @returns\n */\nexport function stopSpanProfile(span: Span, profile_id: string | undefined): RawThreadCpuProfile | null {\n // Should not happen, but satisfy the type checker and be safe regardless.\n if (!profile_id) {\n return null;\n }\n\n const profile = CpuProfilerBindings.stopProfiling(profile_id, 0);\n DEBUG_BUILD && logger.log(`[Profiling] stopped profiling of transaction: ${spanToJSON(span).description}`);\n\n // In case of an overlapping span, stopProfiling may return null and silently ignore the overlapping profile.\n if (!profile) {\n DEBUG_BUILD &&\n logger.log(\n `[Profiling] profiler returned null profile for: ${spanToJSON(span).description}`,\n 'this may indicate an overlapping span or a call to stopProfiling with a profile title that was never started',\n );\n return null;\n }\n\n // Assign profile_id to the profile\n profile.profile_id = profile_id;\n return profile;\n}\n","/* eslint-disable max-lines */\nimport { CpuProfilerBindings, ProfileFormat, type RawThreadCpuProfile } from '@sentry-internal/node-cpu-profiler';\nimport type { Event, IntegrationFn, Profile, ProfileChunk, ProfilingIntegration, Span } from '@sentry/core';\nimport {\n LRUMap,\n consoleSandbox,\n defineIntegration,\n getCurrentScope,\n getGlobalScope,\n getIsolationScope,\n getRootSpan,\n logger,\n spanToJSON,\n uuid4,\n} from '@sentry/core';\nimport type { NodeClient } from '@sentry/node';\nimport { DEBUG_BUILD } from './debug-build';\nimport { NODE_MAJOR, NODE_VERSION } from './nodeVersion';\nimport { MAX_PROFILE_DURATION_MS, maybeProfileSpan, stopSpanProfile } from './spanProfileUtils';\nimport {\n PROFILER_THREAD_ID_STRING,\n PROFILER_THREAD_NAME,\n addProfilesToEnvelope,\n createProfilingChunkEvent,\n createProfilingEvent,\n findProfiledTransactionsFromEnvelope,\n makeProfileChunkEnvelope,\n} from './utils';\n\nconst CHUNK_INTERVAL_MS = 1000 * 60;\nconst PROFILE_MAP = new LRUMap<string, RawThreadCpuProfile>(50);\nconst PROFILE_TIMEOUTS: Record<string, NodeJS.Timeout> = {};\n\nfunction addToProfileQueue(profile_id: string, profile: RawThreadCpuProfile): void {\n PROFILE_MAP.set(profile_id, profile);\n}\n\nfunction takeFromProfileQueue(profile_id: string): RawThreadCpuProfile | undefined {\n const profile = PROFILE_MAP.get(profile_id);\n PROFILE_MAP.remove(profile_id);\n return profile;\n}\n\n/**\n * Instruments the client to automatically invoke the profiler on span start and stop events.\n * @param client\n */\nfunction setupAutomatedSpanProfiling(client: NodeClient): void {\n const spanToProfileIdMap = new WeakMap<Span, string>();\n\n client.on('spanStart', span => {\n if (span !== getRootSpan(span)) {\n return;\n }\n\n const profile_id = maybeProfileSpan(client, span);\n\n if (profile_id) {\n const options = client.getOptions();\n // Not intended for external use, hence missing types, but we want to profile a couple of things at Sentry that\n // currently exceed the default timeout set by the SDKs.\n const maxProfileDurationMs = options._experiments?.maxProfileDurationMs || MAX_PROFILE_DURATION_MS;\n\n if (PROFILE_TIMEOUTS[profile_id]) {\n global.clearTimeout(PROFILE_TIMEOUTS[profile_id]);\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete PROFILE_TIMEOUTS[profile_id];\n }\n\n // Enqueue a timeout to prevent profiles from running over max duration.\n const timeout = global.setTimeout(() => {\n DEBUG_BUILD &&\n logger.log('[Profiling] max profile duration elapsed, stopping profiling for:', spanToJSON(span).description);\n\n const profile = stopSpanProfile(span, profile_id);\n if (profile) {\n addToProfileQueue(profile_id, profile);\n }\n }, maxProfileDurationMs);\n\n // Unref timeout so it doesn't keep the process alive.\n timeout.unref();\n\n getIsolationScope().setContext('profile', { profile_id });\n spanToProfileIdMap.set(span, profile_id);\n }\n });\n\n client.on('spanEnd', span => {\n const profile_id = spanToProfileIdMap.get(span);\n\n if (profile_id) {\n if (PROFILE_TIMEOUTS[profile_id]) {\n global.clearTimeout(PROFILE_TIMEOUTS[profile_id]);\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete PROFILE_TIMEOUTS[profile_id];\n }\n const profile = stopSpanProfile(span, profile_id);\n\n if (profile) {\n addToProfileQueue(profile_id, profile);\n }\n }\n });\n\n client.on('beforeEnvelope', (envelope): void => {\n // if not profiles are in queue, there is nothing to add to the envelope.\n if (!PROFILE_MAP.size) {\n return;\n }\n\n const profiledTransactionEvents = findProfiledTransactionsFromEnvelope(envelope);\n if (!profiledTransactionEvents.length) {\n return;\n }\n\n const profilesToAddToEnvelope: Profile[] = [];\n\n for (const profiledTransaction of profiledTransactionEvents) {\n const profileContext = profiledTransaction.contexts?.profile;\n const profile_id = profileContext?.profile_id;\n\n if (!profile_id) {\n throw new TypeError('[Profiling] cannot find profile for a transaction without a profile context');\n }\n\n // Remove the profile from the transaction context before sending, relay will take care of the rest.\n if (profileContext) {\n delete profiledTransaction.contexts?.profile;\n }\n\n const cpuProfile = takeFromProfileQueue(profile_id);\n if (!cpuProfile) {\n DEBUG_BUILD && logger.log(`[Profiling] Could not retrieve profile for transaction: ${profile_id}`);\n continue;\n }\n\n const profile = createProfilingEvent(client, cpuProfile, profiledTransaction);\n if (!profile) return;\n\n profilesToAddToEnvelope.push(profile);\n\n // @ts-expect-error profile does not inherit from Event\n client.emit('preprocessEvent', profile, {\n event_id: profiledTransaction.event_id,\n });\n\n // @ts-expect-error profile does not inherit from Event\n client.emit('postprocessEvent', profile, {\n event_id: profiledTransaction.event_id,\n });\n }\n\n addProfilesToEnvelope(envelope, profilesToAddToEnvelope);\n });\n}\n\ninterface ChunkData {\n id: string;\n timer: NodeJS.Timeout | undefined;\n startTraceID: string;\n}\n\nclass ContinuousProfiler {\n private _profilerId: string | undefined;\n private _client: NodeClient | undefined = undefined;\n private _chunkData: ChunkData | undefined = undefined;\n\n /**\n * Called when the profiler is attached to the client (continuous mode is enabled). If of the profiler\n * methods called before the profiler is initialized will result in a noop action with debug logs.\n * @param client\n */\n public initialize(client: NodeClient): void {\n this._client = client;\n\n // Attaches a listener to beforeSend which will add the threadId data to the event being sent.\n // This adds a constant overhead to all events being sent which could be improved to only attach\n // and detach the listener during a profiler session\n this._client.on('beforeSendEvent', this._onBeforeSendThreadContextAssignment.bind(this));\n }\n\n /**\n * Initializes a new profilerId session and schedules chunk profiling.\n * @returns void\n */\n public start(): void {\n if (!this._client) {\n DEBUG_BUILD && logger.log('[Profiling] Failed to start, sentry client was never attached to the profiler.');\n return;\n }\n\n // Flush any existing chunks before starting a new one.\n this._chunkStop();\n\n // Restart the profiler session\n this._setupSpanChunkInstrumentation();\n this._chunkStart();\n }\n\n /**\n * Stops the current chunk and flushes the profile to Sentry.\n * @returns void\n */\n public stop(): void {\n if (!this._client) {\n DEBUG_BUILD && logger.log('[Profiling] Failed to stop, sentry client was never attached to the profiler.');\n return;\n }\n this._chunkStop();\n this._teardownSpanChunkInstrumentation();\n }\n\n /**\n * Stop profiler and initializes profiling of the next chunk\n */\n private _chunkStart(): void {\n if (!this._client) {\n // The client is not attached to the profiler if the user has not enabled continuous profiling.\n // In this case, calling start() and stop() is a noop action.The reason this exists is because\n // it makes the types easier to work with and avoids users having to do null checks.\n DEBUG_BUILD && logger.log('[Profiling] Profiler was never attached to the client.');\n return;\n }\n if (this._chunkData) {\n DEBUG_BUILD &&\n logger.log(\n `[Profiling] Chunk with chunk_id ${this._chunkData.id} is still running, current chunk will be stopped a new chunk will be started.`,\n );\n this._chunkStop();\n }\n\n this._startChunkProfiling();\n }\n\n /**\n * Stops profiling of the current chunks and flushes the profile to Sentry\n */\n private _chunkStop(): void {\n if (this._chunkData?.timer) {\n global.clearTimeout(this._chunkData.timer);\n this._chunkData.timer = undefined;\n DEBUG_BUILD && logger.log(`[Profiling] Stopping profiling chunk: ${this._chunkData.id}`);\n }\n if (!this._client) {\n DEBUG_BUILD &&\n logger.log('[Profiling] Failed to collect profile, sentry client was never attached to the profiler.');\n return;\n }\n if (!this._chunkData?.id) {\n DEBUG_BUILD &&\n logger.log(`[Profiling] Failed to collect profile for: ${this._chunkData?.id}, the chunk_id is missing.`);\n return;\n }\n\n const profile = CpuProfilerBindings.stopProfiling(this._chunkData.id, ProfileFormat.CHUNK);\n\n if (!profile) {\n DEBUG_BUILD && logger.log(`[Profiling] _chunkiledStartTraceID to collect profile for: ${this._chunkData.id}`);\n return;\n }\n if (!this._profilerId) {\n DEBUG_BUILD &&\n logger.log('[Profiling] Profile chunk does not contain a valid profiler_id, this is a bug in the SDK');\n return;\n }\n if (profile) {\n DEBUG_BUILD && logger.log(`[Profiling] Sending profile chunk ${this._chunkData.id}.`);\n }\n\n DEBUG_BUILD && logger.log(`[Profiling] Profile chunk ${this._chunkData.id} sent to Sentry.`);\n const chunk = createProfilingChunkEvent(\n this._client,\n this._client.getOptions(),\n profile,\n this._client.getSdkMetadata()?.sdk,\n {\n chunk_id: this._chunkData.id,\n trace_id: this._chunkData.startTraceID,\n profiler_id: this._profilerId,\n },\n );\n\n if (!chunk) {\n DEBUG_BUILD && logger.log(`[Profiling] Failed to create profile chunk for: ${this._chunkData.id}`);\n this._resetChunkData();\n return;\n }\n\n this._flush(chunk);\n // Depending on the profile and stack sizes, stopping the profile and converting\n // the format may negatively impact the performance of the application. To avoid\n // blocking for too long, enqueue the next chunk start inside the next macrotask.\n // clear current chunk\n this._resetChunkData();\n }\n\n /**\n * Flushes the profile chunk to Sentry.\n * @param chunk\n */\n private _flush(chunk: ProfileChunk): void {\n if (!this._client) {\n DEBUG_BUILD &&\n logger.log('[Profiling] Failed to collect profile, sentry client was never attached to the profiler.');\n return;\n }\n\n const transport = this._client.getTransport();\n if (!transport) {\n DEBUG_BUILD && logger.log('[Profiling] No transport available to send profile chunk.');\n return;\n }\n\n const dsn = this._client.getDsn();\n const metadata = this._client.getSdkMetadata();\n const tunnel = this._client.getOptions().tunnel;\n\n const envelope = makeProfileChunkEnvelope(chunk, metadata?.sdk, tunnel, dsn);\n transport.send(envelope).then(null, reason => {\n DEBUG_BUILD && logger.error('Error while sending profile chunk envelope:', reason);\n });\n }\n\n /**\n * Starts the profiler and registers the flush timer for a given chunk.\n * @param chunk\n */\n private _startChunkProfiling(): void {\n const traceId =\n getCurrentScope().getPropagationContext().traceId || getIsolationScope().getPropagationContext().traceId;\n const chunk = this._initializeChunk(traceId);\n\n CpuProfilerBindings.startProfiling(chunk.id);\n DEBUG_BUILD && logger.log(`[Profiling] starting profiling chunk: ${chunk.id}`);\n\n chunk.timer = global.setTimeout(() => {\n DEBUG_BUILD && logger.log(`[Profiling] Stopping profiling chunk: ${chunk.id}`);\n this._chunkStop();\n DEBUG_BUILD && logger.log('[Profiling] Starting new profiling chunk.');\n setImmediate(this._chunkStart.bind(this));\n }, CHUNK_INTERVAL_MS);\n\n // Unref timeout so it doesn't keep the process alive.\n chunk.timer.unref();\n }\n\n /**\n * Attaches profiling information to spans that were started\n * during a profiling session.\n */\n private _setupSpanChunkInstrumentation(): void {\n if (!this._client) {\n DEBUG_BUILD &&\n logger.log(\n '[Profiling] Failed to initialize span profiling, sentry client was never attached to the profiler.',\n );\n return;\n }\n\n this._profilerId = uuid4();\n getGlobalScope().setContext('profile', {\n profiler_id: this._profilerId,\n });\n }\n\n /**\n * Assigns thread_id and thread name context to a profiled event if there is an active profiler session\n */\n private _onBeforeSendThreadContextAssignment(event: Event): void {\n if (!this._client || !this._profilerId) return;\n this._assignThreadIdContext(event);\n }\n\n /**\n * Clear profiling information from global context when a profile is not running.\n */\n private _teardownSpanChunkInstrumentation(): void {\n this._profilerId = undefined;\n const globalScope = getGlobalScope();\n globalScope.setContext('profile', {});\n }\n\n /**\n * Initializes new profile chunk metadata\n */\n private _initializeChunk(traceId: string): ChunkData {\n this._chunkData = {\n id: uuid4(),\n startTraceID: traceId,\n timer: undefined,\n };\n return this._chunkData;\n }\n\n /**\n * Assigns thread_id and thread name context to a profiled event.\n */\n private _assignThreadIdContext(event: Event): void {\n if (!event?.contexts?.profile) {\n return;\n }\n\n if (!event.contexts) {\n return;\n }\n\n // @ts-expect-error the trace fallback value is wrong, though it should never happen\n // and in case it does, we dont want to override whatever was passed initially.\n event.contexts.trace = {\n ...(event.contexts?.trace ?? {}),\n data: {\n ...(event.contexts?.trace?.data ?? {}),\n ['thread.id']: PROFILER_THREAD_ID_STRING,\n ['thread.name']: PROFILER_THREAD_NAME,\n },\n };\n }\n\n /**\n * Resets the current chunk state.\n */\n private _resetChunkData(): void {\n this._chunkData = undefined;\n }\n}\n\n/** Exported only for tests. */\nexport const _nodeProfilingIntegration = ((): ProfilingIntegration<NodeClient> => {\n if (![16, 18, 20, 22].includes(NODE_MAJOR)) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry Profiling] You are using a Node.js version that does not have prebuilt binaries (${NODE_VERSION}).`,\n 'The @sentry/profiling-node package only has prebuilt support for the following LTS versions of Node.js: 16, 18, 20, 22.',\n 'To use the @sentry/profiling-node package with this version of Node.js, you will need to compile the native addon from source.',\n 'See: https://github.com/getsentry/sentry-javascript/tree/develop/packages/profiling-node#building-the-package-from-source',\n );\n });\n }\n\n return {\n name: 'ProfilingIntegration',\n _profiler: new ContinuousProfiler(),\n setup(client: NodeClient) {\n DEBUG_BUILD && logger.log('[Profiling] Profiling integration setup.');\n const options = client.getOptions();\n\n const mode =\n (options.profilesSampleRate === undefined ||\n options.profilesSampleRate === null ||\n options.profilesSampleRate === 0) &&\n !options.profilesSampler\n ? 'continuous'\n : 'span';\n switch (mode) {\n case 'continuous': {\n DEBUG_BUILD && logger.log('[Profiling] Continuous profiler mode enabled.');\n this._profiler.initialize(client);\n break;\n }\n // Default to span profiling when no mode profiler mode is set\n case 'span':\n case undefined: {\n DEBUG_BUILD && logger.log('[Profiling] Span profiler mode enabled.');\n setupAutomatedSpanProfiling(client);\n break;\n }\n default: {\n DEBUG_BUILD && logger.warn(`[Profiling] Unknown profiler mode: ${mode}, profiler was not initialized`);\n }\n }\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * We need this integration in order to send data to Sentry. We hook into the event processor\n * and inspect each event to see if it is a transaction event and if that transaction event\n * contains a profile on it's metadata. If that is the case, we create a profiling event envelope\n * and delete the profile from the transaction metadata.\n */\nexport const nodeProfilingIntegration = defineIntegration(_nodeProfilingIntegration);\n"],"names":["parseSemver","threadId","isMainThread","logger","versions","env","forEachEnvelopeItem","uuid4","dsnToString","createEnvelope","getDebugImagesForResources","spanIsSampled","spanToJSON","CpuProfilerBindings","LRUMap","getRootSpan","getIsolationScope","ProfileFormat","getCurrentScope","getGlobalScope","consoleSandbox","defineIntegration"],"mappings":";;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACO,MAAM,WAAY,IAAiB,OAAA,gBAAA,KAAA,WAAA,IAAA,gBAAA,CAAA;;ACLnC,MAAM,YAAa,GAAEA,gBAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAE;AACxD,MAAM,UAAA,GAAa,YAAY,CAAC,KAAK;;AC6B5C;AACA;AACO,MAAM,yBAA0B,GAAE,MAAM,CAACC,uBAAQ,CAAC;AAClD,MAAM,oBAAqB,GAAEC,8BAAe,MAAA,GAAS,QAAQ;AACpE,MAAM,cAAA,GAAiB,GAAG;AAC1B,MAAM,yBAAA,GAA4B,GAAG;;AAErC;AACA,MAAM,WAAW,EAAE,CAAC,QAAQ,EAAE;AAC9B,MAAM,UAAU,EAAE,CAAC,OAAO,EAAE;AAC5B,MAAM,UAAU,EAAE,CAAC,OAAO,EAAE;AAC5B,MAAM,OAAO,EAAE,CAAC,IAAI,EAAE;AACtB,MAAM,QAAQ,EAAE,CAAC,OAAO,EAAE;AAC1B,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AACA,UAAA;AACA;AACA;AACA,QAAA,KAAA,MAAA;AACA,QAAA,KAAA,SAAA,EAAA;AACA,UAAA,WAAA,IAAAA,WAAA,CAAA,GAAA,CAAA,yCAAA,CAAA;AACA,UAAA,2BAAA,CAAA,MAAA,CAAA;AACA,UAAA;AACA;AACA,QAAA,SAAA;AACA,UAAA,WAAA,IAAAA,WAAA,CAAA,IAAA,CAAA,CAAA,mCAAA,EAAA,IAAA,CAAA,8BAAA,CAAA,CAAA;AACA;AACA;AACA,KAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAA,wBAAA,GAAAkB,sBAAA,CAAA,yBAAA;;;;"}
package/lib/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CpuProfilerBindings } from '@sentry-internal/node-cpu-profiler';
1
+ import { CpuProfilerBindings, ProfileFormat } from '@sentry-internal/node-cpu-profiler';
2
2
  import { parseSemver, logger, forEachEnvelopeItem, createEnvelope, getDebugImagesForResources, uuid4, dsnToString, spanIsSampled, spanToJSON, LRUMap, defineIntegration, consoleSandbox, getRootSpan, getIsolationScope, getCurrentScope, getGlobalScope } from '@sentry/core';
3
3
  import * as os from 'os';
4
4
  import { versions, env } from 'process';
@@ -522,15 +522,9 @@ function stopSpanProfile(span, profile_id) {
522
522
  return profile;
523
523
  }
524
524
 
525
- var ProfileFormat; (function (ProfileFormat) {
526
- const THREAD = 0; ProfileFormat[ProfileFormat["THREAD"] = THREAD] = "THREAD";
527
- const CHUNK = 1; ProfileFormat[ProfileFormat["CHUNK"] = CHUNK] = "CHUNK";
528
- })(ProfileFormat || (ProfileFormat = {}));
529
-
530
525
  /* eslint-disable max-lines */
531
526
 
532
-
533
- const CHUNK_INTERVAL_MS = 5000;
527
+ const CHUNK_INTERVAL_MS = 1000 * 60;
534
528
  const PROFILE_MAP = new LRUMap(50);
535
529
  const PROFILE_TIMEOUTS = {};
536
530
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/debug-build.ts","../../src/nodeVersion.ts","../../src/utils.ts","../../src/spanProfileUtils.ts","../../src/types.ts","../../src/integration.ts"],"sourcesContent":["declare const __DEBUG_BUILD__: boolean;\n\n/**\n * 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.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nexport const DEBUG_BUILD = __DEBUG_BUILD__;\n","import { parseSemver } from '@sentry/core';\n\nexport const NODE_VERSION = parseSemver(process.versions.node) as { major: number; minor: number; patch: number };\nexport const NODE_MAJOR = NODE_VERSION.major;\n","import * as os from 'os';\nimport type {\n Client,\n ContinuousThreadCpuProfile,\n DebugImage,\n DsnComponents,\n Envelope,\n Event,\n EventEnvelopeHeaders,\n Profile,\n ProfileChunk,\n ProfileChunkEnvelope,\n ProfileChunkItem,\n SdkInfo,\n ThreadCpuProfile,\n TransactionEvent,\n} from '@sentry/core';\nimport {\n createEnvelope,\n dsnToString,\n forEachEnvelopeItem,\n getDebugImagesForResources,\n logger,\n uuid4,\n} from '@sentry/core';\n\nimport { env, versions } from 'process';\nimport { isMainThread, threadId } from 'worker_threads';\n\nimport { DEBUG_BUILD } from './debug-build';\nimport type { RawChunkCpuProfile, RawThreadCpuProfile } from './types';\n\n// We require the file because if we import it, it will be included in the bundle.\n// I guess tsc does not check file contents when it's imported.\nexport const PROFILER_THREAD_ID_STRING = String(threadId);\nexport const PROFILER_THREAD_NAME = isMainThread ? 'main' : 'worker';\nconst FORMAT_VERSION = '1';\nconst CONTINUOUS_FORMAT_VERSION = '2';\n\n// Machine properties (eval only once)\nconst PLATFORM = os.platform();\nconst RELEASE = os.release();\nconst VERSION = os.version();\nconst TYPE = os.type();\nconst MODEL = os.machine();\nconst ARCH = os.arch();\n\n/**\n * Checks if the profile is a raw profile or a profile enriched with thread information.\n * @param {ThreadCpuProfile | RawThreadCpuProfile} profile\n * @returns {boolean}\n */\nfunction isRawThreadCpuProfile(\n profile: ThreadCpuProfile | RawThreadCpuProfile | ContinuousThreadCpuProfile | RawChunkCpuProfile,\n): profile is RawThreadCpuProfile | RawChunkCpuProfile {\n return !('thread_metadata' in profile);\n}\n\n/**\n * Enriches the profile with threadId of the current thread.\n * This is done in node as we seem to not be able to get the info from C native code.\n *\n * @param {ThreadCpuProfile | RawThreadCpuProfile} profile\n * @returns {ThreadCpuProfile}\n */\nexport function enrichWithThreadInformation(\n profile: ThreadCpuProfile | RawThreadCpuProfile | ContinuousThreadCpuProfile | RawChunkCpuProfile,\n): ThreadCpuProfile | ContinuousThreadCpuProfile {\n if (!isRawThreadCpuProfile(profile)) {\n return profile;\n }\n\n return {\n samples: profile.samples,\n frames: profile.frames,\n stacks: profile.stacks,\n thread_metadata: {\n [PROFILER_THREAD_ID_STRING]: {\n name: PROFILER_THREAD_NAME,\n },\n },\n } as ThreadCpuProfile | ContinuousThreadCpuProfile;\n}\n\n/**\n * Creates a profiling envelope item, if the profile does not pass validation, returns null.\n * @param {RawThreadCpuProfile}\n * @param {Event}\n * @returns {Profile | null}\n */\nexport function createProfilingEvent(client: Client, profile: RawThreadCpuProfile, event: Event): Profile | null {\n if (!isValidProfile(profile)) {\n return null;\n }\n\n return createProfilePayload(client, profile, {\n release: event.release ?? '',\n environment: event.environment ?? '',\n event_id: event.event_id ?? '',\n transaction: event.transaction ?? '',\n start_timestamp: event.start_timestamp ? event.start_timestamp * 1000 : Date.now(),\n trace_id: event.contexts?.trace?.trace_id ?? '',\n profile_id: profile.profile_id,\n });\n}\n\n/**\n * Create a profile\n * @param {RawThreadCpuProfile} cpuProfile\n * @param {options}\n * @returns {Profile}\n */\nfunction createProfilePayload(\n client: Client,\n cpuProfile: RawThreadCpuProfile,\n {\n release,\n environment,\n event_id,\n transaction,\n start_timestamp,\n trace_id,\n profile_id,\n }: {\n release: string;\n environment: string;\n event_id: string;\n transaction: string;\n start_timestamp: number;\n trace_id: string | undefined;\n profile_id: string;\n },\n): Profile {\n // Log a warning if the profile has an invalid traceId (should be uuidv4).\n // All profiles and transactions are rejected if this is the case and we want to\n // warn users that this is happening if they enable debug flag\n if (trace_id?.length !== 32) {\n DEBUG_BUILD && logger.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`);\n }\n\n const enrichedThreadProfile = enrichWithThreadInformation(cpuProfile);\n\n const profile: Profile = {\n event_id: profile_id,\n timestamp: new Date(start_timestamp).toISOString(),\n platform: 'node',\n version: FORMAT_VERSION,\n release: release,\n environment: environment,\n measurements: cpuProfile.measurements,\n runtime: {\n name: 'node',\n version: versions.node || '',\n },\n os: {\n name: PLATFORM,\n version: RELEASE,\n build_number: VERSION,\n },\n device: {\n locale: env['LC_ALL'] || env['LC_MESSAGES'] || env['LANG'] || env['LANGUAGE'] || '',\n model: MODEL,\n manufacturer: TYPE,\n architecture: ARCH,\n is_emulator: false,\n },\n debug_meta: {\n images: applyDebugMetadata(client, cpuProfile.resources),\n },\n profile: enrichedThreadProfile as ThreadCpuProfile,\n transaction: {\n name: transaction,\n id: event_id,\n trace_id: trace_id || '',\n active_thread_id: PROFILER_THREAD_ID_STRING,\n },\n };\n\n return profile;\n}\n\n/**\n * Create a profile chunk from raw thread profile\n * @param {RawThreadCpuProfile} cpuProfile\n * @param {options}\n * @returns {Profile}\n */\nfunction createProfileChunkPayload(\n client: Client,\n cpuProfile: RawChunkCpuProfile,\n {\n release,\n environment,\n trace_id,\n profiler_id,\n chunk_id,\n sdk,\n }: {\n release: string;\n environment: string;\n trace_id: string | undefined;\n chunk_id: string;\n profiler_id: string;\n sdk: SdkInfo | undefined;\n },\n): ProfileChunk {\n // Log a warning if the profile has an invalid traceId (should be uuidv4).\n // All profiles and transactions are rejected if this is the case and we want to\n // warn users that this is happening if they enable debug flag\n if (trace_id?.length !== 32) {\n DEBUG_BUILD && logger.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`);\n }\n\n const enrichedThreadProfile = enrichWithThreadInformation(cpuProfile);\n\n const profile: ProfileChunk = {\n chunk_id: chunk_id,\n client_sdk: {\n name: sdk?.name ?? 'sentry.javascript.node',\n version: sdk?.version ?? '0.0.0',\n },\n profiler_id: profiler_id,\n platform: 'node',\n version: CONTINUOUS_FORMAT_VERSION,\n release: release,\n environment: environment,\n measurements: cpuProfile.measurements,\n debug_meta: {\n images: applyDebugMetadata(client, cpuProfile.resources),\n },\n profile: enrichedThreadProfile as ContinuousThreadCpuProfile,\n };\n\n return profile;\n}\n\n/**\n * Creates a profiling chunk envelope item, if the profile does not pass validation, returns null.\n */\nexport function createProfilingChunkEvent(\n client: Client,\n options: { release?: string; environment?: string },\n profile: RawChunkCpuProfile,\n sdk: SdkInfo | undefined,\n identifiers: { trace_id: string | undefined; chunk_id: string; profiler_id: string },\n): ProfileChunk | null {\n if (!isValidProfileChunk(profile)) {\n return null;\n }\n\n return createProfileChunkPayload(client, profile, {\n release: options.release ?? '',\n environment: options.environment ?? '',\n trace_id: identifiers.trace_id ?? '',\n chunk_id: identifiers.chunk_id,\n profiler_id: identifiers.profiler_id,\n sdk,\n });\n}\n\n/**\n * Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1).\n * @param {unknown} rate\n * @returns {boolean}\n */\nexport function isValidSampleRate(rate: unknown): boolean {\n // we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck\n if ((typeof rate !== 'number' && typeof rate !== 'boolean') || (typeof rate === 'number' && isNaN(rate))) {\n DEBUG_BUILD &&\n logger.warn(\n `[Profiling] Invalid sample rate. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(\n rate,\n )} of type ${JSON.stringify(typeof rate)}.`,\n );\n return false;\n }\n\n // Boolean sample rates are always valid\n if (rate === true || rate === false) {\n return true;\n }\n\n // in case sampleRate is a boolean, it will get automatically cast to 1 if it's true and 0 if it's false\n if (rate < 0 || rate > 1) {\n DEBUG_BUILD && logger.warn(`[Profiling] Invalid sample rate. Sample rate must be between 0 and 1. Got ${rate}.`);\n return false;\n }\n return true;\n}\n\n/**\n * Checks if the profile is valid and can be sent to Sentry.\n * @param {RawThreadCpuProfile} profile\n * @returns {boolean}\n */\nexport function isValidProfile(profile: RawThreadCpuProfile): profile is RawThreadCpuProfile & { profile_id: string } {\n if (profile.samples.length <= 1) {\n DEBUG_BUILD &&\n // Log a warning if the profile has less than 2 samples so users can know why\n // they are not seeing any profiling data and we cant avoid the back and forth\n // of asking them to provide us with a dump of the profile data.\n logger.log('[Profiling] Discarding profile because it contains less than 2 samples');\n return false;\n }\n\n if (!profile.profile_id) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Checks if the profile chunk is valid and can be sent to Sentry.\n * @param profile\n * @returns\n */\nexport function isValidProfileChunk(profile: RawChunkCpuProfile): profile is RawChunkCpuProfile {\n if (profile.samples.length <= 1) {\n DEBUG_BUILD &&\n // Log a warning if the profile has less than 2 samples so users can know why\n // they are not seeing any profiling data and we cant avoid the back and forth\n // of asking them to provide us with a dump of the profile data.\n logger.log('[Profiling] Discarding profile chunk because it contains less than 2 samples');\n return false;\n }\n\n return true;\n}\n\n/**\n * Adds items to envelope if they are not already present - mutates the envelope.\n * @param {Envelope} envelope\n * @param {Profile[]} profiles\n * @returns {Envelope}\n */\nexport function addProfilesToEnvelope(envelope: Envelope, profiles: Profile[]): Envelope {\n if (!profiles.length) {\n return envelope;\n }\n\n for (const profile of profiles) {\n // @ts-expect-error untyped envelope\n envelope[1].push([{ type: 'profile' }, profile]);\n }\n return envelope;\n}\n\n/**\n * Finds transactions with profile_id context in the envelope\n * @param {Envelope} envelope\n * @returns {Event[]}\n */\nexport function findProfiledTransactionsFromEnvelope(envelope: Envelope): Event[] {\n const events: TransactionEvent[] = [];\n\n forEachEnvelopeItem(envelope, (item, type) => {\n if (type !== 'transaction') {\n return;\n }\n\n // First item is the type, so we can skip it, everything else is an event\n for (let j = 1; j < item.length; j++) {\n const event = item[j] as TransactionEvent;\n\n if (!event) {\n // Shouldn't happen, but lets be safe\n continue;\n }\n\n const profile_id = event.contexts?.profile?.profile_id;\n\n if (event && profile_id) {\n events.push(event);\n }\n }\n });\n\n return events;\n}\n\n/**\n * Creates event envelope headers for a profile chunk. This is separate from createEventEnvelopeHeaders util\n * as the profile chunk does not conform to the sentry event type\n */\nexport function createEventEnvelopeHeaders(\n sdkInfo: SdkInfo | undefined,\n tunnel: string | undefined,\n dsn?: DsnComponents,\n): EventEnvelopeHeaders {\n return {\n event_id: uuid4(),\n sent_at: new Date().toISOString(),\n ...(sdkInfo && { sdk: sdkInfo }),\n ...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),\n };\n}\n\n/**\n * Creates a standalone profile_chunk envelope.\n */\nexport function makeProfileChunkEnvelope(\n chunk: ProfileChunk,\n sdkInfo: SdkInfo | undefined,\n tunnel: string | undefined,\n dsn?: DsnComponents,\n): ProfileChunkEnvelope {\n const profileChunkHeader: ProfileChunkItem[0] = {\n type: 'profile_chunk',\n };\n\n return createEnvelope<ProfileChunkEnvelope>(createEventEnvelopeHeaders(sdkInfo, tunnel, dsn), [\n [profileChunkHeader, chunk],\n ]);\n}\n\n/**\n * Cross reference profile collected resources with debug_ids and return a list of debug images.\n * @param {string[]} resource_paths\n * @returns {DebugImage[]}\n */\nexport function applyDebugMetadata(client: Client, resource_paths: ReadonlyArray<string>): DebugImage[] {\n const options = client.getOptions();\n\n if (!options?.stackParser) {\n return [];\n }\n\n return getDebugImagesForResources(options.stackParser, resource_paths);\n}\n","import { CpuProfilerBindings } from '@sentry-internal/node-cpu-profiler';\nimport type { CustomSamplingContext, Span } from '@sentry/core';\nimport { logger, spanIsSampled, spanToJSON, uuid4 } from '@sentry/core';\nimport type { NodeClient } from '@sentry/node';\nimport { DEBUG_BUILD } from './debug-build';\nimport type { RawThreadCpuProfile } from './types';\nimport { isValidSampleRate } from './utils';\n\nexport const MAX_PROFILE_DURATION_MS = 30 * 1000;\n\n/**\n * Takes a transaction and determines if it should be profiled or not. If it should be profiled, it returns the\n * profile_id, otherwise returns undefined. Takes care of setting profile context on transaction as well\n */\nexport function maybeProfileSpan(\n client: NodeClient | undefined,\n span: Span,\n customSamplingContext?: CustomSamplingContext,\n): string | undefined {\n // profilesSampleRate is multiplied with tracesSampleRate to get the final sampling rate. We dont perform\n // the actual multiplication to get the final rate, but we discard the profile if the span was sampled,\n // so anything after this block from here is based on the span sampling.\n if (!spanIsSampled(span)) {\n return;\n }\n\n // Client and options are required for profiling\n if (!client) {\n DEBUG_BUILD && logger.log('[Profiling] Profiling disabled, no client found.');\n return;\n }\n\n const options = client.getOptions();\n if (!options) {\n DEBUG_BUILD && logger.log('[Profiling] Profiling disabled, no options found.');\n return;\n }\n\n const profilesSampler = options.profilesSampler;\n let profilesSampleRate: number | boolean | undefined = options.profilesSampleRate;\n\n // Prefer sampler to sample rate if both are provided.\n if (typeof profilesSampler === 'function') {\n const { description: spanName = '<unknown>', data } = spanToJSON(span);\n // We bail out early if that is not the case\n const parentSampled = true;\n\n profilesSampleRate = profilesSampler({\n name: spanName,\n attributes: data,\n parentSampled,\n ...customSamplingContext,\n });\n }\n\n // Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The\n // only valid values are booleans or numbers between 0 and 1.)\n if (!isValidSampleRate(profilesSampleRate)) {\n DEBUG_BUILD && logger.warn('[Profiling] Discarding profile because of invalid sample rate.');\n return;\n }\n\n // if the function returned 0 (or false), or if `profileSampleRate` is 0, it's a sign the profile should be dropped\n if (!profilesSampleRate) {\n DEBUG_BUILD &&\n logger.log(\n `[Profiling] Discarding profile because ${\n typeof profilesSampler === 'function'\n ? 'profileSampler returned 0 or false'\n : 'a negative sampling decision was inherited or profileSampleRate is set to 0'\n }`,\n );\n return;\n }\n\n // Now we roll the dice. Math.random is inclusive of 0, but not of 1, so strict < is safe here. In case sampleRate is\n // a boolean, the < comparison will cause it to be automatically cast to 1 if it's true and 0 if it's false.\n const sampled = profilesSampleRate === true ? true : Math.random() < profilesSampleRate;\n // Check if we should sample this profile\n if (!sampled) {\n DEBUG_BUILD &&\n logger.log(\n `[Profiling] Discarding profile because it's not included in the random sample (sampling rate = ${Number(\n profilesSampleRate,\n )})`,\n );\n return;\n }\n\n const profile_id = uuid4();\n CpuProfilerBindings.startProfiling(profile_id);\n DEBUG_BUILD && logger.log(`[Profiling] started profiling transaction: ${spanToJSON(span).description}`);\n\n // set transaction context - do this regardless if profiling fails down the line\n // so that we can still see the profile_id in the transaction context\n return profile_id;\n}\n\n/**\n * Stops the profiler for profile_id and returns the profile\n * @param transaction\n * @param profile_id\n * @returns\n */\nexport function stopSpanProfile(span: Span, profile_id: string | undefined): RawThreadCpuProfile | null {\n // Should not happen, but satisfy the type checker and be safe regardless.\n if (!profile_id) {\n return null;\n }\n\n const profile = CpuProfilerBindings.stopProfiling(profile_id, 0);\n DEBUG_BUILD && logger.log(`[Profiling] stopped profiling of transaction: ${spanToJSON(span).description}`);\n\n // In case of an overlapping span, stopProfiling may return null and silently ignore the overlapping profile.\n if (!profile) {\n DEBUG_BUILD &&\n logger.log(\n `[Profiling] profiler returned null profile for: ${spanToJSON(span).description}`,\n 'this may indicate an overlapping span or a call to stopProfiling with a profile title that was never started',\n );\n return null;\n }\n\n // Assign profile_id to the profile\n profile.profile_id = profile_id;\n return profile;\n}\n","import type { Event } from '@sentry/core';\n\ninterface Sample {\n stack_id: number;\n thread_id: string;\n elapsed_since_start_ns: string;\n}\n\ninterface ChunkSample {\n stack_id: number;\n thread_id: string;\n timestamp: number;\n}\n\ntype Frame = {\n function: string;\n file: string;\n lineno: number;\n colno: number;\n};\n\ninterface Measurement {\n unit: string;\n values: {\n elapsed_since_start_ns: number;\n value: number;\n }[];\n}\n\n// Profile is marked as optional because it is deleted from the metadata\n// by the integration before the event is processed by other integrations.\nexport interface ProfiledEvent extends Event {\n sdkProcessingMetadata: {\n profile?: RawThreadCpuProfile;\n };\n}\n\ninterface BaseProfile {\n profile_id?: string;\n stacks: number[][];\n frames: Frame[];\n resources: string[];\n profiler_logging_mode: 'eager' | 'lazy';\n measurements: Record<string, Measurement>;\n}\nexport interface RawThreadCpuProfile extends BaseProfile {\n samples: Sample[];\n}\n\nexport interface RawChunkCpuProfile extends BaseProfile {\n samples: ChunkSample[];\n}\n\nexport interface PrivateV8CpuProfilerBindings {\n startProfiling?: (name: string) => void;\n\n stopProfiling?(\n name: string,\n format: ProfileFormat.THREAD,\n threadId: number,\n collectResources: boolean,\n ): RawThreadCpuProfile | null;\n stopProfiling?(\n name: string,\n format: ProfileFormat.CHUNK,\n threadId: number,\n collectResources: boolean,\n ): RawChunkCpuProfile | null;\n\n // Helper methods exposed for testing\n getFrameModule(abs_path: string): string;\n}\n\nexport enum ProfileFormat {\n THREAD = 0,\n CHUNK = 1,\n}\n\nexport interface V8CpuProfilerBindings {\n startProfiling(name: string): void;\n\n stopProfiling(name: string, format: ProfileFormat.THREAD): RawThreadCpuProfile | null;\n stopProfiling(name: string, format: ProfileFormat.CHUNK): RawChunkCpuProfile | null;\n}\n","/* eslint-disable max-lines */\n\nimport { CpuProfilerBindings } from '@sentry-internal/node-cpu-profiler';\nimport type { Event, IntegrationFn, Profile, ProfileChunk, ProfilingIntegration, Span } from '@sentry/core';\nimport {\n LRUMap,\n consoleSandbox,\n defineIntegration,\n getCurrentScope,\n getGlobalScope,\n getIsolationScope,\n getRootSpan,\n logger,\n spanToJSON,\n uuid4,\n} from '@sentry/core';\nimport type { NodeClient } from '@sentry/node';\nimport { DEBUG_BUILD } from './debug-build';\nimport { NODE_MAJOR, NODE_VERSION } from './nodeVersion';\nimport { MAX_PROFILE_DURATION_MS, maybeProfileSpan, stopSpanProfile } from './spanProfileUtils';\nimport type { RawThreadCpuProfile } from './types';\nimport { ProfileFormat } from './types';\nimport {\n PROFILER_THREAD_ID_STRING,\n PROFILER_THREAD_NAME,\n addProfilesToEnvelope,\n createProfilingChunkEvent,\n createProfilingEvent,\n findProfiledTransactionsFromEnvelope,\n makeProfileChunkEnvelope,\n} from './utils';\n\nconst CHUNK_INTERVAL_MS = 5000;\nconst PROFILE_MAP = new LRUMap<string, RawThreadCpuProfile>(50);\nconst PROFILE_TIMEOUTS: Record<string, NodeJS.Timeout> = {};\n\nfunction addToProfileQueue(profile_id: string, profile: RawThreadCpuProfile): void {\n PROFILE_MAP.set(profile_id, profile);\n}\n\nfunction takeFromProfileQueue(profile_id: string): RawThreadCpuProfile | undefined {\n const profile = PROFILE_MAP.get(profile_id);\n PROFILE_MAP.remove(profile_id);\n return profile;\n}\n\n/**\n * Instruments the client to automatically invoke the profiler on span start and stop events.\n * @param client\n */\nfunction setupAutomatedSpanProfiling(client: NodeClient): void {\n const spanToProfileIdMap = new WeakMap<Span, string>();\n\n client.on('spanStart', span => {\n if (span !== getRootSpan(span)) {\n return;\n }\n\n const profile_id = maybeProfileSpan(client, span);\n\n if (profile_id) {\n const options = client.getOptions();\n // Not intended for external use, hence missing types, but we want to profile a couple of things at Sentry that\n // currently exceed the default timeout set by the SDKs.\n const maxProfileDurationMs = options._experiments?.maxProfileDurationMs || MAX_PROFILE_DURATION_MS;\n\n if (PROFILE_TIMEOUTS[profile_id]) {\n global.clearTimeout(PROFILE_TIMEOUTS[profile_id]);\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete PROFILE_TIMEOUTS[profile_id];\n }\n\n // Enqueue a timeout to prevent profiles from running over max duration.\n const timeout = global.setTimeout(() => {\n DEBUG_BUILD &&\n logger.log('[Profiling] max profile duration elapsed, stopping profiling for:', spanToJSON(span).description);\n\n const profile = stopSpanProfile(span, profile_id);\n if (profile) {\n addToProfileQueue(profile_id, profile);\n }\n }, maxProfileDurationMs);\n\n // Unref timeout so it doesn't keep the process alive.\n timeout.unref();\n\n getIsolationScope().setContext('profile', { profile_id });\n spanToProfileIdMap.set(span, profile_id);\n }\n });\n\n client.on('spanEnd', span => {\n const profile_id = spanToProfileIdMap.get(span);\n\n if (profile_id) {\n if (PROFILE_TIMEOUTS[profile_id]) {\n global.clearTimeout(PROFILE_TIMEOUTS[profile_id]);\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete PROFILE_TIMEOUTS[profile_id];\n }\n const profile = stopSpanProfile(span, profile_id);\n\n if (profile) {\n addToProfileQueue(profile_id, profile);\n }\n }\n });\n\n client.on('beforeEnvelope', (envelope): void => {\n // if not profiles are in queue, there is nothing to add to the envelope.\n if (!PROFILE_MAP.size) {\n return;\n }\n\n const profiledTransactionEvents = findProfiledTransactionsFromEnvelope(envelope);\n if (!profiledTransactionEvents.length) {\n return;\n }\n\n const profilesToAddToEnvelope: Profile[] = [];\n\n for (const profiledTransaction of profiledTransactionEvents) {\n const profileContext = profiledTransaction.contexts?.profile;\n const profile_id = profileContext?.profile_id;\n\n if (!profile_id) {\n throw new TypeError('[Profiling] cannot find profile for a transaction without a profile context');\n }\n\n // Remove the profile from the transaction context before sending, relay will take care of the rest.\n if (profileContext) {\n delete profiledTransaction.contexts?.profile;\n }\n\n const cpuProfile = takeFromProfileQueue(profile_id);\n if (!cpuProfile) {\n DEBUG_BUILD && logger.log(`[Profiling] Could not retrieve profile for transaction: ${profile_id}`);\n continue;\n }\n\n const profile = createProfilingEvent(client, cpuProfile, profiledTransaction);\n if (!profile) return;\n\n profilesToAddToEnvelope.push(profile);\n\n // @ts-expect-error profile does not inherit from Event\n client.emit('preprocessEvent', profile, {\n event_id: profiledTransaction.event_id,\n });\n\n // @ts-expect-error profile does not inherit from Event\n client.emit('postprocessEvent', profile, {\n event_id: profiledTransaction.event_id,\n });\n }\n\n addProfilesToEnvelope(envelope, profilesToAddToEnvelope);\n });\n}\n\ninterface ChunkData {\n id: string;\n timer: NodeJS.Timeout | undefined;\n startTraceID: string;\n}\n\nclass ContinuousProfiler {\n private _profilerId: string | undefined;\n private _client: NodeClient | undefined = undefined;\n private _chunkData: ChunkData | undefined = undefined;\n\n /**\n * Called when the profiler is attached to the client (continuous mode is enabled). If of the profiler\n * methods called before the profiler is initialized will result in a noop action with debug logs.\n * @param client\n */\n public initialize(client: NodeClient): void {\n this._client = client;\n\n // Attaches a listener to beforeSend which will add the threadId data to the event being sent.\n // This adds a constant overhead to all events being sent which could be improved to only attach\n // and detach the listener during a profiler session\n this._client.on('beforeSendEvent', this._onBeforeSendThreadContextAssignment.bind(this));\n }\n\n /**\n * Initializes a new profilerId session and schedules chunk profiling.\n * @returns void\n */\n public start(): void {\n if (!this._client) {\n DEBUG_BUILD && logger.log('[Profiling] Failed to start, sentry client was never attached to the profiler.');\n return;\n }\n\n // Flush any existing chunks before starting a new one.\n this._chunkStop();\n\n // Restart the profiler session\n this._setupSpanChunkInstrumentation();\n this._chunkStart();\n }\n\n /**\n * Stops the current chunk and flushes the profile to Sentry.\n * @returns void\n */\n public stop(): void {\n if (!this._client) {\n DEBUG_BUILD && logger.log('[Profiling] Failed to stop, sentry client was never attached to the profiler.');\n return;\n }\n this._chunkStop();\n this._teardownSpanChunkInstrumentation();\n }\n\n /**\n * Stop profiler and initializes profiling of the next chunk\n */\n private _chunkStart(): void {\n if (!this._client) {\n // The client is not attached to the profiler if the user has not enabled continuous profiling.\n // In this case, calling start() and stop() is a noop action.The reason this exists is because\n // it makes the types easier to work with and avoids users having to do null checks.\n DEBUG_BUILD && logger.log('[Profiling] Profiler was never attached to the client.');\n return;\n }\n if (this._chunkData) {\n DEBUG_BUILD &&\n logger.log(\n `[Profiling] Chunk with chunk_id ${this._chunkData.id} is still running, current chunk will be stopped a new chunk will be started.`,\n );\n this._chunkStop();\n }\n\n this._startChunkProfiling();\n }\n\n /**\n * Stops profiling of the current chunks and flushes the profile to Sentry\n */\n private _chunkStop(): void {\n if (this._chunkData?.timer) {\n global.clearTimeout(this._chunkData.timer);\n this._chunkData.timer = undefined;\n DEBUG_BUILD && logger.log(`[Profiling] Stopping profiling chunk: ${this._chunkData.id}`);\n }\n if (!this._client) {\n DEBUG_BUILD &&\n logger.log('[Profiling] Failed to collect profile, sentry client was never attached to the profiler.');\n return;\n }\n if (!this._chunkData?.id) {\n DEBUG_BUILD &&\n logger.log(`[Profiling] Failed to collect profile for: ${this._chunkData?.id}, the chunk_id is missing.`);\n return;\n }\n\n const profile = CpuProfilerBindings.stopProfiling(this._chunkData.id, ProfileFormat.CHUNK);\n\n if (!profile) {\n DEBUG_BUILD && logger.log(`[Profiling] _chunkiledStartTraceID to collect profile for: ${this._chunkData.id}`);\n return;\n }\n if (!this._profilerId) {\n DEBUG_BUILD &&\n logger.log('[Profiling] Profile chunk does not contain a valid profiler_id, this is a bug in the SDK');\n return;\n }\n if (profile) {\n DEBUG_BUILD && logger.log(`[Profiling] Sending profile chunk ${this._chunkData.id}.`);\n }\n\n DEBUG_BUILD && logger.log(`[Profiling] Profile chunk ${this._chunkData.id} sent to Sentry.`);\n const chunk = createProfilingChunkEvent(\n this._client,\n this._client.getOptions(),\n profile,\n this._client.getSdkMetadata()?.sdk,\n {\n chunk_id: this._chunkData.id,\n trace_id: this._chunkData.startTraceID,\n profiler_id: this._profilerId,\n },\n );\n\n if (!chunk) {\n DEBUG_BUILD && logger.log(`[Profiling] Failed to create profile chunk for: ${this._chunkData.id}`);\n this._resetChunkData();\n return;\n }\n\n this._flush(chunk);\n // Depending on the profile and stack sizes, stopping the profile and converting\n // the format may negatively impact the performance of the application. To avoid\n // blocking for too long, enqueue the next chunk start inside the next macrotask.\n // clear current chunk\n this._resetChunkData();\n }\n\n /**\n * Flushes the profile chunk to Sentry.\n * @param chunk\n */\n private _flush(chunk: ProfileChunk): void {\n if (!this._client) {\n DEBUG_BUILD &&\n logger.log('[Profiling] Failed to collect profile, sentry client was never attached to the profiler.');\n return;\n }\n\n const transport = this._client.getTransport();\n if (!transport) {\n DEBUG_BUILD && logger.log('[Profiling] No transport available to send profile chunk.');\n return;\n }\n\n const dsn = this._client.getDsn();\n const metadata = this._client.getSdkMetadata();\n const tunnel = this._client.getOptions().tunnel;\n\n const envelope = makeProfileChunkEnvelope(chunk, metadata?.sdk, tunnel, dsn);\n transport.send(envelope).then(null, reason => {\n DEBUG_BUILD && logger.error('Error while sending profile chunk envelope:', reason);\n });\n }\n\n /**\n * Starts the profiler and registers the flush timer for a given chunk.\n * @param chunk\n */\n private _startChunkProfiling(): void {\n const traceId =\n getCurrentScope().getPropagationContext().traceId || getIsolationScope().getPropagationContext().traceId;\n const chunk = this._initializeChunk(traceId);\n\n CpuProfilerBindings.startProfiling(chunk.id);\n DEBUG_BUILD && logger.log(`[Profiling] starting profiling chunk: ${chunk.id}`);\n\n chunk.timer = global.setTimeout(() => {\n DEBUG_BUILD && logger.log(`[Profiling] Stopping profiling chunk: ${chunk.id}`);\n this._chunkStop();\n DEBUG_BUILD && logger.log('[Profiling] Starting new profiling chunk.');\n setImmediate(this._chunkStart.bind(this));\n }, CHUNK_INTERVAL_MS);\n\n // Unref timeout so it doesn't keep the process alive.\n chunk.timer.unref();\n }\n\n /**\n * Attaches profiling information to spans that were started\n * during a profiling session.\n */\n private _setupSpanChunkInstrumentation(): void {\n if (!this._client) {\n DEBUG_BUILD &&\n logger.log(\n '[Profiling] Failed to initialize span profiling, sentry client was never attached to the profiler.',\n );\n return;\n }\n\n this._profilerId = uuid4();\n getGlobalScope().setContext('profile', {\n profiler_id: this._profilerId,\n });\n }\n\n /**\n * Assigns thread_id and thread name context to a profiled event if there is an active profiler session\n */\n private _onBeforeSendThreadContextAssignment(event: Event): void {\n if (!this._client || !this._profilerId) return;\n this._assignThreadIdContext(event);\n }\n\n /**\n * Clear profiling information from global context when a profile is not running.\n */\n private _teardownSpanChunkInstrumentation(): void {\n this._profilerId = undefined;\n const globalScope = getGlobalScope();\n globalScope.setContext('profile', {});\n }\n\n /**\n * Initializes new profile chunk metadata\n */\n private _initializeChunk(traceId: string): ChunkData {\n this._chunkData = {\n id: uuid4(),\n startTraceID: traceId,\n timer: undefined,\n };\n return this._chunkData;\n }\n\n /**\n * Assigns thread_id and thread name context to a profiled event.\n */\n private _assignThreadIdContext(event: Event): void {\n if (!event?.contexts?.profile) {\n return;\n }\n\n if (!event.contexts) {\n return;\n }\n\n // @ts-expect-error the trace fallback value is wrong, though it should never happen\n // and in case it does, we dont want to override whatever was passed initially.\n event.contexts.trace = {\n ...(event.contexts?.trace ?? {}),\n data: {\n ...(event.contexts?.trace?.data ?? {}),\n ['thread.id']: PROFILER_THREAD_ID_STRING,\n ['thread.name']: PROFILER_THREAD_NAME,\n },\n };\n }\n\n /**\n * Resets the current chunk state.\n */\n private _resetChunkData(): void {\n this._chunkData = undefined;\n }\n}\n\n/** Exported only for tests. */\nexport const _nodeProfilingIntegration = ((): ProfilingIntegration<NodeClient> => {\n if (![16, 18, 20, 22].includes(NODE_MAJOR)) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry Profiling] You are using a Node.js version that does not have prebuilt binaries (${NODE_VERSION}).`,\n 'The @sentry/profiling-node package only has prebuilt support for the following LTS versions of Node.js: 16, 18, 20, 22.',\n 'To use the @sentry/profiling-node package with this version of Node.js, you will need to compile the native addon from source.',\n 'See: https://github.com/getsentry/sentry-javascript/tree/develop/packages/profiling-node#building-the-package-from-source',\n );\n });\n }\n\n return {\n name: 'ProfilingIntegration',\n _profiler: new ContinuousProfiler(),\n setup(client: NodeClient) {\n DEBUG_BUILD && logger.log('[Profiling] Profiling integration setup.');\n const options = client.getOptions();\n\n const mode =\n (options.profilesSampleRate === undefined ||\n options.profilesSampleRate === null ||\n options.profilesSampleRate === 0) &&\n !options.profilesSampler\n ? 'continuous'\n : 'span';\n switch (mode) {\n case 'continuous': {\n DEBUG_BUILD && logger.log('[Profiling] Continuous profiler mode enabled.');\n this._profiler.initialize(client);\n break;\n }\n // Default to span profiling when no mode profiler mode is set\n case 'span':\n case undefined: {\n DEBUG_BUILD && logger.log('[Profiling] Span profiler mode enabled.');\n setupAutomatedSpanProfiling(client);\n break;\n }\n default: {\n DEBUG_BUILD && logger.warn(`[Profiling] Unknown profiler mode: ${mode}, profiler was not initialized`);\n }\n }\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * We need this integration in order to send data to Sentry. We hook into the event processor\n * and inspect each event to see if it is a transaction event and if that transaction event\n * contains a profile on it's metadata. If that is the case, we create a profiling event envelope\n * and delete the profile from the transaction metadata.\n */\nexport const nodeProfilingIntegration = defineIntegration(_nodeProfilingIntegration);\n"],"names":[],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACO,MAAM,WAAY,IAAiB,OAAA,gBAAA,KAAA,WAAA,IAAA,gBAAA,CAAA;;ACLnC,MAAM,YAAa,GAAE,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAE;AACxD,MAAM,UAAA,GAAa,YAAY,CAAC,KAAK;;AC6B5C;AACA;AACO,MAAM,yBAA0B,GAAE,MAAM,CAAC,QAAQ,CAAC;AAClD,MAAM,oBAAqB,GAAE,eAAe,MAAA,GAAS,QAAQ;AACpE,MAAM,cAAA,GAAiB,GAAG;AAC1B,MAAM,yBAAA,GAA4B,GAAG;;AAErC;AACA,MAAM,WAAW,EAAE,CAAC,QAAQ,EAAE;AAC9B,MAAM,UAAU,EAAE,CAAC,OAAO,EAAE;AAC5B,MAAM,UAAU,EAAE,CAAC,OAAO,EAAE;AAC5B,MAAM,OAAO,EAAE,CAAC,IAAI,EAAE;AACtB,MAAM,QAAQ,EAAE,CAAC,OAAO,EAAE;AAC1B,MAAM,OAAO,EAAE,CAAC,IAAI,EAAE;;AAEtB;AACA;AACA;AACA;AACA;AACA,SAAS,qBAAqB;AAC9B,EAAE,OAAO;AACT,EAAuD;AACvD,EAAE,OAAO,EAAE,iBAAkB,IAAG,OAAO,CAAC;AACxC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,2BAA2B;AAC3C,EAAE,OAAO;AACT,EAAiD;AACjD,EAAE,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE;AACvC,IAAI,OAAO,OAAO;AAClB;;AAEA,EAAE,OAAO;AACT,IAAI,OAAO,EAAE,OAAO,CAAC,OAAO;AAC5B,IAAI,MAAM,EAAE,OAAO,CAAC,MAAM;AAC1B,IAAI,MAAM,EAAE,OAAO,CAAC,MAAM;AAC1B,IAAI,eAAe,EAAE;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AAA,8BAAA,CAAA,CAAA;AACA;AACA;AACA,KAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAA,wBAAA,GAAA,iBAAA,CAAA,yBAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/debug-build.ts","../../src/nodeVersion.ts","../../src/utils.ts","../../src/spanProfileUtils.ts","../../src/integration.ts"],"sourcesContent":["declare const __DEBUG_BUILD__: boolean;\n\n/**\n * 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.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nexport const DEBUG_BUILD = __DEBUG_BUILD__;\n","import { parseSemver } from '@sentry/core';\n\nexport const NODE_VERSION = parseSemver(process.versions.node) as { major: number; minor: number; patch: number };\nexport const NODE_MAJOR = NODE_VERSION.major;\n","import * as os from 'os';\nimport type {\n Client,\n ContinuousThreadCpuProfile,\n DebugImage,\n DsnComponents,\n Envelope,\n Event,\n EventEnvelopeHeaders,\n Profile,\n ProfileChunk,\n ProfileChunkEnvelope,\n ProfileChunkItem,\n SdkInfo,\n ThreadCpuProfile,\n TransactionEvent,\n} from '@sentry/core';\nimport {\n createEnvelope,\n dsnToString,\n forEachEnvelopeItem,\n getDebugImagesForResources,\n logger,\n uuid4,\n} from '@sentry/core';\n\nimport { env, versions } from 'process';\nimport { isMainThread, threadId } from 'worker_threads';\n\nimport type { RawChunkCpuProfile, RawThreadCpuProfile } from '@sentry-internal/node-cpu-profiler';\nimport { DEBUG_BUILD } from './debug-build';\n\n// We require the file because if we import it, it will be included in the bundle.\n// I guess tsc does not check file contents when it's imported.\nexport const PROFILER_THREAD_ID_STRING = String(threadId);\nexport const PROFILER_THREAD_NAME = isMainThread ? 'main' : 'worker';\nconst FORMAT_VERSION = '1';\nconst CONTINUOUS_FORMAT_VERSION = '2';\n\n// Machine properties (eval only once)\nconst PLATFORM = os.platform();\nconst RELEASE = os.release();\nconst VERSION = os.version();\nconst TYPE = os.type();\nconst MODEL = os.machine();\nconst ARCH = os.arch();\n\n/**\n * Checks if the profile is a raw profile or a profile enriched with thread information.\n * @param {ThreadCpuProfile | RawThreadCpuProfile} profile\n * @returns {boolean}\n */\nfunction isRawThreadCpuProfile(\n profile: ThreadCpuProfile | RawThreadCpuProfile | ContinuousThreadCpuProfile | RawChunkCpuProfile,\n): profile is RawThreadCpuProfile | RawChunkCpuProfile {\n return !('thread_metadata' in profile);\n}\n\n/**\n * Enriches the profile with threadId of the current thread.\n * This is done in node as we seem to not be able to get the info from C native code.\n *\n * @param {ThreadCpuProfile | RawThreadCpuProfile} profile\n * @returns {ThreadCpuProfile}\n */\nexport function enrichWithThreadInformation(\n profile: ThreadCpuProfile | RawThreadCpuProfile | ContinuousThreadCpuProfile | RawChunkCpuProfile,\n): ThreadCpuProfile | ContinuousThreadCpuProfile {\n if (!isRawThreadCpuProfile(profile)) {\n return profile;\n }\n\n return {\n samples: profile.samples,\n frames: profile.frames,\n stacks: profile.stacks,\n thread_metadata: {\n [PROFILER_THREAD_ID_STRING]: {\n name: PROFILER_THREAD_NAME,\n },\n },\n } as ThreadCpuProfile | ContinuousThreadCpuProfile;\n}\n\n/**\n * Creates a profiling envelope item, if the profile does not pass validation, returns null.\n * @param {RawThreadCpuProfile}\n * @param {Event}\n * @returns {Profile | null}\n */\nexport function createProfilingEvent(client: Client, profile: RawThreadCpuProfile, event: Event): Profile | null {\n if (!isValidProfile(profile)) {\n return null;\n }\n\n return createProfilePayload(client, profile, {\n release: event.release ?? '',\n environment: event.environment ?? '',\n event_id: event.event_id ?? '',\n transaction: event.transaction ?? '',\n start_timestamp: event.start_timestamp ? event.start_timestamp * 1000 : Date.now(),\n trace_id: event.contexts?.trace?.trace_id ?? '',\n profile_id: profile.profile_id,\n });\n}\n\n/**\n * Create a profile\n * @param {RawThreadCpuProfile} cpuProfile\n * @param {options}\n * @returns {Profile}\n */\nfunction createProfilePayload(\n client: Client,\n cpuProfile: RawThreadCpuProfile,\n {\n release,\n environment,\n event_id,\n transaction,\n start_timestamp,\n trace_id,\n profile_id,\n }: {\n release: string;\n environment: string;\n event_id: string;\n transaction: string;\n start_timestamp: number;\n trace_id: string | undefined;\n profile_id: string;\n },\n): Profile {\n // Log a warning if the profile has an invalid traceId (should be uuidv4).\n // All profiles and transactions are rejected if this is the case and we want to\n // warn users that this is happening if they enable debug flag\n if (trace_id?.length !== 32) {\n DEBUG_BUILD && logger.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`);\n }\n\n const enrichedThreadProfile = enrichWithThreadInformation(cpuProfile);\n\n const profile: Profile = {\n event_id: profile_id,\n timestamp: new Date(start_timestamp).toISOString(),\n platform: 'node',\n version: FORMAT_VERSION,\n release: release,\n environment: environment,\n measurements: cpuProfile.measurements,\n runtime: {\n name: 'node',\n version: versions.node || '',\n },\n os: {\n name: PLATFORM,\n version: RELEASE,\n build_number: VERSION,\n },\n device: {\n locale: env['LC_ALL'] || env['LC_MESSAGES'] || env['LANG'] || env['LANGUAGE'] || '',\n model: MODEL,\n manufacturer: TYPE,\n architecture: ARCH,\n is_emulator: false,\n },\n debug_meta: {\n images: applyDebugMetadata(client, cpuProfile.resources),\n },\n profile: enrichedThreadProfile as ThreadCpuProfile,\n transaction: {\n name: transaction,\n id: event_id,\n trace_id: trace_id || '',\n active_thread_id: PROFILER_THREAD_ID_STRING,\n },\n };\n\n return profile;\n}\n\n/**\n * Create a profile chunk from raw thread profile\n * @param {RawThreadCpuProfile} cpuProfile\n * @param {options}\n * @returns {Profile}\n */\nfunction createProfileChunkPayload(\n client: Client,\n cpuProfile: RawChunkCpuProfile,\n {\n release,\n environment,\n trace_id,\n profiler_id,\n chunk_id,\n sdk,\n }: {\n release: string;\n environment: string;\n trace_id: string | undefined;\n chunk_id: string;\n profiler_id: string;\n sdk: SdkInfo | undefined;\n },\n): ProfileChunk {\n // Log a warning if the profile has an invalid traceId (should be uuidv4).\n // All profiles and transactions are rejected if this is the case and we want to\n // warn users that this is happening if they enable debug flag\n if (trace_id?.length !== 32) {\n DEBUG_BUILD && logger.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`);\n }\n\n const enrichedThreadProfile = enrichWithThreadInformation(cpuProfile);\n\n const profile: ProfileChunk = {\n chunk_id: chunk_id,\n client_sdk: {\n name: sdk?.name ?? 'sentry.javascript.node',\n version: sdk?.version ?? '0.0.0',\n },\n profiler_id: profiler_id,\n platform: 'node',\n version: CONTINUOUS_FORMAT_VERSION,\n release: release,\n environment: environment,\n measurements: cpuProfile.measurements,\n debug_meta: {\n images: applyDebugMetadata(client, cpuProfile.resources),\n },\n profile: enrichedThreadProfile as ContinuousThreadCpuProfile,\n };\n\n return profile;\n}\n\n/**\n * Creates a profiling chunk envelope item, if the profile does not pass validation, returns null.\n */\nexport function createProfilingChunkEvent(\n client: Client,\n options: { release?: string; environment?: string },\n profile: RawChunkCpuProfile,\n sdk: SdkInfo | undefined,\n identifiers: { trace_id: string | undefined; chunk_id: string; profiler_id: string },\n): ProfileChunk | null {\n if (!isValidProfileChunk(profile)) {\n return null;\n }\n\n return createProfileChunkPayload(client, profile, {\n release: options.release ?? '',\n environment: options.environment ?? '',\n trace_id: identifiers.trace_id ?? '',\n chunk_id: identifiers.chunk_id,\n profiler_id: identifiers.profiler_id,\n sdk,\n });\n}\n\n/**\n * Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1).\n * @param {unknown} rate\n * @returns {boolean}\n */\nexport function isValidSampleRate(rate: unknown): boolean {\n // we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck\n if ((typeof rate !== 'number' && typeof rate !== 'boolean') || (typeof rate === 'number' && isNaN(rate))) {\n DEBUG_BUILD &&\n logger.warn(\n `[Profiling] Invalid sample rate. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(\n rate,\n )} of type ${JSON.stringify(typeof rate)}.`,\n );\n return false;\n }\n\n // Boolean sample rates are always valid\n if (rate === true || rate === false) {\n return true;\n }\n\n // in case sampleRate is a boolean, it will get automatically cast to 1 if it's true and 0 if it's false\n if (rate < 0 || rate > 1) {\n DEBUG_BUILD && logger.warn(`[Profiling] Invalid sample rate. Sample rate must be between 0 and 1. Got ${rate}.`);\n return false;\n }\n return true;\n}\n\n/**\n * Checks if the profile is valid and can be sent to Sentry.\n * @param {RawThreadCpuProfile} profile\n * @returns {boolean}\n */\nexport function isValidProfile(profile: RawThreadCpuProfile): profile is RawThreadCpuProfile & { profile_id: string } {\n if (profile.samples.length <= 1) {\n DEBUG_BUILD &&\n // Log a warning if the profile has less than 2 samples so users can know why\n // they are not seeing any profiling data and we cant avoid the back and forth\n // of asking them to provide us with a dump of the profile data.\n logger.log('[Profiling] Discarding profile because it contains less than 2 samples');\n return false;\n }\n\n if (!profile.profile_id) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Checks if the profile chunk is valid and can be sent to Sentry.\n * @param profile\n * @returns\n */\nexport function isValidProfileChunk(profile: RawChunkCpuProfile): profile is RawChunkCpuProfile {\n if (profile.samples.length <= 1) {\n DEBUG_BUILD &&\n // Log a warning if the profile has less than 2 samples so users can know why\n // they are not seeing any profiling data and we cant avoid the back and forth\n // of asking them to provide us with a dump of the profile data.\n logger.log('[Profiling] Discarding profile chunk because it contains less than 2 samples');\n return false;\n }\n\n return true;\n}\n\n/**\n * Adds items to envelope if they are not already present - mutates the envelope.\n * @param {Envelope} envelope\n * @param {Profile[]} profiles\n * @returns {Envelope}\n */\nexport function addProfilesToEnvelope(envelope: Envelope, profiles: Profile[]): Envelope {\n if (!profiles.length) {\n return envelope;\n }\n\n for (const profile of profiles) {\n // @ts-expect-error untyped envelope\n envelope[1].push([{ type: 'profile' }, profile]);\n }\n return envelope;\n}\n\n/**\n * Finds transactions with profile_id context in the envelope\n * @param {Envelope} envelope\n * @returns {Event[]}\n */\nexport function findProfiledTransactionsFromEnvelope(envelope: Envelope): Event[] {\n const events: TransactionEvent[] = [];\n\n forEachEnvelopeItem(envelope, (item, type) => {\n if (type !== 'transaction') {\n return;\n }\n\n // First item is the type, so we can skip it, everything else is an event\n for (let j = 1; j < item.length; j++) {\n const event = item[j] as TransactionEvent;\n\n if (!event) {\n // Shouldn't happen, but lets be safe\n continue;\n }\n\n const profile_id = event.contexts?.profile?.profile_id;\n\n if (event && profile_id) {\n events.push(event);\n }\n }\n });\n\n return events;\n}\n\n/**\n * Creates event envelope headers for a profile chunk. This is separate from createEventEnvelopeHeaders util\n * as the profile chunk does not conform to the sentry event type\n */\nexport function createEventEnvelopeHeaders(\n sdkInfo: SdkInfo | undefined,\n tunnel: string | undefined,\n dsn?: DsnComponents,\n): EventEnvelopeHeaders {\n return {\n event_id: uuid4(),\n sent_at: new Date().toISOString(),\n ...(sdkInfo && { sdk: sdkInfo }),\n ...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),\n };\n}\n\n/**\n * Creates a standalone profile_chunk envelope.\n */\nexport function makeProfileChunkEnvelope(\n chunk: ProfileChunk,\n sdkInfo: SdkInfo | undefined,\n tunnel: string | undefined,\n dsn?: DsnComponents,\n): ProfileChunkEnvelope {\n const profileChunkHeader: ProfileChunkItem[0] = {\n type: 'profile_chunk',\n };\n\n return createEnvelope<ProfileChunkEnvelope>(createEventEnvelopeHeaders(sdkInfo, tunnel, dsn), [\n [profileChunkHeader, chunk],\n ]);\n}\n\n/**\n * Cross reference profile collected resources with debug_ids and return a list of debug images.\n * @param {string[]} resource_paths\n * @returns {DebugImage[]}\n */\nexport function applyDebugMetadata(client: Client, resource_paths: ReadonlyArray<string>): DebugImage[] {\n const options = client.getOptions();\n\n if (!options?.stackParser) {\n return [];\n }\n\n return getDebugImagesForResources(options.stackParser, resource_paths);\n}\n","import { CpuProfilerBindings, type RawThreadCpuProfile } from '@sentry-internal/node-cpu-profiler';\nimport type { CustomSamplingContext, Span } from '@sentry/core';\nimport { logger, spanIsSampled, spanToJSON, uuid4 } from '@sentry/core';\nimport type { NodeClient } from '@sentry/node';\nimport { DEBUG_BUILD } from './debug-build';\nimport { isValidSampleRate } from './utils';\n\nexport const MAX_PROFILE_DURATION_MS = 30 * 1000;\n\n/**\n * Takes a transaction and determines if it should be profiled or not. If it should be profiled, it returns the\n * profile_id, otherwise returns undefined. Takes care of setting profile context on transaction as well\n */\nexport function maybeProfileSpan(\n client: NodeClient | undefined,\n span: Span,\n customSamplingContext?: CustomSamplingContext,\n): string | undefined {\n // profilesSampleRate is multiplied with tracesSampleRate to get the final sampling rate. We dont perform\n // the actual multiplication to get the final rate, but we discard the profile if the span was sampled,\n // so anything after this block from here is based on the span sampling.\n if (!spanIsSampled(span)) {\n return;\n }\n\n // Client and options are required for profiling\n if (!client) {\n DEBUG_BUILD && logger.log('[Profiling] Profiling disabled, no client found.');\n return;\n }\n\n const options = client.getOptions();\n if (!options) {\n DEBUG_BUILD && logger.log('[Profiling] Profiling disabled, no options found.');\n return;\n }\n\n const profilesSampler = options.profilesSampler;\n let profilesSampleRate: number | boolean | undefined = options.profilesSampleRate;\n\n // Prefer sampler to sample rate if both are provided.\n if (typeof profilesSampler === 'function') {\n const { description: spanName = '<unknown>', data } = spanToJSON(span);\n // We bail out early if that is not the case\n const parentSampled = true;\n\n profilesSampleRate = profilesSampler({\n name: spanName,\n attributes: data,\n parentSampled,\n ...customSamplingContext,\n });\n }\n\n // Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The\n // only valid values are booleans or numbers between 0 and 1.)\n if (!isValidSampleRate(profilesSampleRate)) {\n DEBUG_BUILD && logger.warn('[Profiling] Discarding profile because of invalid sample rate.');\n return;\n }\n\n // if the function returned 0 (or false), or if `profileSampleRate` is 0, it's a sign the profile should be dropped\n if (!profilesSampleRate) {\n DEBUG_BUILD &&\n logger.log(\n `[Profiling] Discarding profile because ${\n typeof profilesSampler === 'function'\n ? 'profileSampler returned 0 or false'\n : 'a negative sampling decision was inherited or profileSampleRate is set to 0'\n }`,\n );\n return;\n }\n\n // Now we roll the dice. Math.random is inclusive of 0, but not of 1, so strict < is safe here. In case sampleRate is\n // a boolean, the < comparison will cause it to be automatically cast to 1 if it's true and 0 if it's false.\n const sampled = profilesSampleRate === true ? true : Math.random() < profilesSampleRate;\n // Check if we should sample this profile\n if (!sampled) {\n DEBUG_BUILD &&\n logger.log(\n `[Profiling] Discarding profile because it's not included in the random sample (sampling rate = ${Number(\n profilesSampleRate,\n )})`,\n );\n return;\n }\n\n const profile_id = uuid4();\n CpuProfilerBindings.startProfiling(profile_id);\n DEBUG_BUILD && logger.log(`[Profiling] started profiling transaction: ${spanToJSON(span).description}`);\n\n // set transaction context - do this regardless if profiling fails down the line\n // so that we can still see the profile_id in the transaction context\n return profile_id;\n}\n\n/**\n * Stops the profiler for profile_id and returns the profile\n * @param transaction\n * @param profile_id\n * @returns\n */\nexport function stopSpanProfile(span: Span, profile_id: string | undefined): RawThreadCpuProfile | null {\n // Should not happen, but satisfy the type checker and be safe regardless.\n if (!profile_id) {\n return null;\n }\n\n const profile = CpuProfilerBindings.stopProfiling(profile_id, 0);\n DEBUG_BUILD && logger.log(`[Profiling] stopped profiling of transaction: ${spanToJSON(span).description}`);\n\n // In case of an overlapping span, stopProfiling may return null and silently ignore the overlapping profile.\n if (!profile) {\n DEBUG_BUILD &&\n logger.log(\n `[Profiling] profiler returned null profile for: ${spanToJSON(span).description}`,\n 'this may indicate an overlapping span or a call to stopProfiling with a profile title that was never started',\n );\n return null;\n }\n\n // Assign profile_id to the profile\n profile.profile_id = profile_id;\n return profile;\n}\n","/* eslint-disable max-lines */\nimport { CpuProfilerBindings, ProfileFormat, type RawThreadCpuProfile } from '@sentry-internal/node-cpu-profiler';\nimport type { Event, IntegrationFn, Profile, ProfileChunk, ProfilingIntegration, Span } from '@sentry/core';\nimport {\n LRUMap,\n consoleSandbox,\n defineIntegration,\n getCurrentScope,\n getGlobalScope,\n getIsolationScope,\n getRootSpan,\n logger,\n spanToJSON,\n uuid4,\n} from '@sentry/core';\nimport type { NodeClient } from '@sentry/node';\nimport { DEBUG_BUILD } from './debug-build';\nimport { NODE_MAJOR, NODE_VERSION } from './nodeVersion';\nimport { MAX_PROFILE_DURATION_MS, maybeProfileSpan, stopSpanProfile } from './spanProfileUtils';\nimport {\n PROFILER_THREAD_ID_STRING,\n PROFILER_THREAD_NAME,\n addProfilesToEnvelope,\n createProfilingChunkEvent,\n createProfilingEvent,\n findProfiledTransactionsFromEnvelope,\n makeProfileChunkEnvelope,\n} from './utils';\n\nconst CHUNK_INTERVAL_MS = 1000 * 60;\nconst PROFILE_MAP = new LRUMap<string, RawThreadCpuProfile>(50);\nconst PROFILE_TIMEOUTS: Record<string, NodeJS.Timeout> = {};\n\nfunction addToProfileQueue(profile_id: string, profile: RawThreadCpuProfile): void {\n PROFILE_MAP.set(profile_id, profile);\n}\n\nfunction takeFromProfileQueue(profile_id: string): RawThreadCpuProfile | undefined {\n const profile = PROFILE_MAP.get(profile_id);\n PROFILE_MAP.remove(profile_id);\n return profile;\n}\n\n/**\n * Instruments the client to automatically invoke the profiler on span start and stop events.\n * @param client\n */\nfunction setupAutomatedSpanProfiling(client: NodeClient): void {\n const spanToProfileIdMap = new WeakMap<Span, string>();\n\n client.on('spanStart', span => {\n if (span !== getRootSpan(span)) {\n return;\n }\n\n const profile_id = maybeProfileSpan(client, span);\n\n if (profile_id) {\n const options = client.getOptions();\n // Not intended for external use, hence missing types, but we want to profile a couple of things at Sentry that\n // currently exceed the default timeout set by the SDKs.\n const maxProfileDurationMs = options._experiments?.maxProfileDurationMs || MAX_PROFILE_DURATION_MS;\n\n if (PROFILE_TIMEOUTS[profile_id]) {\n global.clearTimeout(PROFILE_TIMEOUTS[profile_id]);\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete PROFILE_TIMEOUTS[profile_id];\n }\n\n // Enqueue a timeout to prevent profiles from running over max duration.\n const timeout = global.setTimeout(() => {\n DEBUG_BUILD &&\n logger.log('[Profiling] max profile duration elapsed, stopping profiling for:', spanToJSON(span).description);\n\n const profile = stopSpanProfile(span, profile_id);\n if (profile) {\n addToProfileQueue(profile_id, profile);\n }\n }, maxProfileDurationMs);\n\n // Unref timeout so it doesn't keep the process alive.\n timeout.unref();\n\n getIsolationScope().setContext('profile', { profile_id });\n spanToProfileIdMap.set(span, profile_id);\n }\n });\n\n client.on('spanEnd', span => {\n const profile_id = spanToProfileIdMap.get(span);\n\n if (profile_id) {\n if (PROFILE_TIMEOUTS[profile_id]) {\n global.clearTimeout(PROFILE_TIMEOUTS[profile_id]);\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete PROFILE_TIMEOUTS[profile_id];\n }\n const profile = stopSpanProfile(span, profile_id);\n\n if (profile) {\n addToProfileQueue(profile_id, profile);\n }\n }\n });\n\n client.on('beforeEnvelope', (envelope): void => {\n // if not profiles are in queue, there is nothing to add to the envelope.\n if (!PROFILE_MAP.size) {\n return;\n }\n\n const profiledTransactionEvents = findProfiledTransactionsFromEnvelope(envelope);\n if (!profiledTransactionEvents.length) {\n return;\n }\n\n const profilesToAddToEnvelope: Profile[] = [];\n\n for (const profiledTransaction of profiledTransactionEvents) {\n const profileContext = profiledTransaction.contexts?.profile;\n const profile_id = profileContext?.profile_id;\n\n if (!profile_id) {\n throw new TypeError('[Profiling] cannot find profile for a transaction without a profile context');\n }\n\n // Remove the profile from the transaction context before sending, relay will take care of the rest.\n if (profileContext) {\n delete profiledTransaction.contexts?.profile;\n }\n\n const cpuProfile = takeFromProfileQueue(profile_id);\n if (!cpuProfile) {\n DEBUG_BUILD && logger.log(`[Profiling] Could not retrieve profile for transaction: ${profile_id}`);\n continue;\n }\n\n const profile = createProfilingEvent(client, cpuProfile, profiledTransaction);\n if (!profile) return;\n\n profilesToAddToEnvelope.push(profile);\n\n // @ts-expect-error profile does not inherit from Event\n client.emit('preprocessEvent', profile, {\n event_id: profiledTransaction.event_id,\n });\n\n // @ts-expect-error profile does not inherit from Event\n client.emit('postprocessEvent', profile, {\n event_id: profiledTransaction.event_id,\n });\n }\n\n addProfilesToEnvelope(envelope, profilesToAddToEnvelope);\n });\n}\n\ninterface ChunkData {\n id: string;\n timer: NodeJS.Timeout | undefined;\n startTraceID: string;\n}\n\nclass ContinuousProfiler {\n private _profilerId: string | undefined;\n private _client: NodeClient | undefined = undefined;\n private _chunkData: ChunkData | undefined = undefined;\n\n /**\n * Called when the profiler is attached to the client (continuous mode is enabled). If of the profiler\n * methods called before the profiler is initialized will result in a noop action with debug logs.\n * @param client\n */\n public initialize(client: NodeClient): void {\n this._client = client;\n\n // Attaches a listener to beforeSend which will add the threadId data to the event being sent.\n // This adds a constant overhead to all events being sent which could be improved to only attach\n // and detach the listener during a profiler session\n this._client.on('beforeSendEvent', this._onBeforeSendThreadContextAssignment.bind(this));\n }\n\n /**\n * Initializes a new profilerId session and schedules chunk profiling.\n * @returns void\n */\n public start(): void {\n if (!this._client) {\n DEBUG_BUILD && logger.log('[Profiling] Failed to start, sentry client was never attached to the profiler.');\n return;\n }\n\n // Flush any existing chunks before starting a new one.\n this._chunkStop();\n\n // Restart the profiler session\n this._setupSpanChunkInstrumentation();\n this._chunkStart();\n }\n\n /**\n * Stops the current chunk and flushes the profile to Sentry.\n * @returns void\n */\n public stop(): void {\n if (!this._client) {\n DEBUG_BUILD && logger.log('[Profiling] Failed to stop, sentry client was never attached to the profiler.');\n return;\n }\n this._chunkStop();\n this._teardownSpanChunkInstrumentation();\n }\n\n /**\n * Stop profiler and initializes profiling of the next chunk\n */\n private _chunkStart(): void {\n if (!this._client) {\n // The client is not attached to the profiler if the user has not enabled continuous profiling.\n // In this case, calling start() and stop() is a noop action.The reason this exists is because\n // it makes the types easier to work with and avoids users having to do null checks.\n DEBUG_BUILD && logger.log('[Profiling] Profiler was never attached to the client.');\n return;\n }\n if (this._chunkData) {\n DEBUG_BUILD &&\n logger.log(\n `[Profiling] Chunk with chunk_id ${this._chunkData.id} is still running, current chunk will be stopped a new chunk will be started.`,\n );\n this._chunkStop();\n }\n\n this._startChunkProfiling();\n }\n\n /**\n * Stops profiling of the current chunks and flushes the profile to Sentry\n */\n private _chunkStop(): void {\n if (this._chunkData?.timer) {\n global.clearTimeout(this._chunkData.timer);\n this._chunkData.timer = undefined;\n DEBUG_BUILD && logger.log(`[Profiling] Stopping profiling chunk: ${this._chunkData.id}`);\n }\n if (!this._client) {\n DEBUG_BUILD &&\n logger.log('[Profiling] Failed to collect profile, sentry client was never attached to the profiler.');\n return;\n }\n if (!this._chunkData?.id) {\n DEBUG_BUILD &&\n logger.log(`[Profiling] Failed to collect profile for: ${this._chunkData?.id}, the chunk_id is missing.`);\n return;\n }\n\n const profile = CpuProfilerBindings.stopProfiling(this._chunkData.id, ProfileFormat.CHUNK);\n\n if (!profile) {\n DEBUG_BUILD && logger.log(`[Profiling] _chunkiledStartTraceID to collect profile for: ${this._chunkData.id}`);\n return;\n }\n if (!this._profilerId) {\n DEBUG_BUILD &&\n logger.log('[Profiling] Profile chunk does not contain a valid profiler_id, this is a bug in the SDK');\n return;\n }\n if (profile) {\n DEBUG_BUILD && logger.log(`[Profiling] Sending profile chunk ${this._chunkData.id}.`);\n }\n\n DEBUG_BUILD && logger.log(`[Profiling] Profile chunk ${this._chunkData.id} sent to Sentry.`);\n const chunk = createProfilingChunkEvent(\n this._client,\n this._client.getOptions(),\n profile,\n this._client.getSdkMetadata()?.sdk,\n {\n chunk_id: this._chunkData.id,\n trace_id: this._chunkData.startTraceID,\n profiler_id: this._profilerId,\n },\n );\n\n if (!chunk) {\n DEBUG_BUILD && logger.log(`[Profiling] Failed to create profile chunk for: ${this._chunkData.id}`);\n this._resetChunkData();\n return;\n }\n\n this._flush(chunk);\n // Depending on the profile and stack sizes, stopping the profile and converting\n // the format may negatively impact the performance of the application. To avoid\n // blocking for too long, enqueue the next chunk start inside the next macrotask.\n // clear current chunk\n this._resetChunkData();\n }\n\n /**\n * Flushes the profile chunk to Sentry.\n * @param chunk\n */\n private _flush(chunk: ProfileChunk): void {\n if (!this._client) {\n DEBUG_BUILD &&\n logger.log('[Profiling] Failed to collect profile, sentry client was never attached to the profiler.');\n return;\n }\n\n const transport = this._client.getTransport();\n if (!transport) {\n DEBUG_BUILD && logger.log('[Profiling] No transport available to send profile chunk.');\n return;\n }\n\n const dsn = this._client.getDsn();\n const metadata = this._client.getSdkMetadata();\n const tunnel = this._client.getOptions().tunnel;\n\n const envelope = makeProfileChunkEnvelope(chunk, metadata?.sdk, tunnel, dsn);\n transport.send(envelope).then(null, reason => {\n DEBUG_BUILD && logger.error('Error while sending profile chunk envelope:', reason);\n });\n }\n\n /**\n * Starts the profiler and registers the flush timer for a given chunk.\n * @param chunk\n */\n private _startChunkProfiling(): void {\n const traceId =\n getCurrentScope().getPropagationContext().traceId || getIsolationScope().getPropagationContext().traceId;\n const chunk = this._initializeChunk(traceId);\n\n CpuProfilerBindings.startProfiling(chunk.id);\n DEBUG_BUILD && logger.log(`[Profiling] starting profiling chunk: ${chunk.id}`);\n\n chunk.timer = global.setTimeout(() => {\n DEBUG_BUILD && logger.log(`[Profiling] Stopping profiling chunk: ${chunk.id}`);\n this._chunkStop();\n DEBUG_BUILD && logger.log('[Profiling] Starting new profiling chunk.');\n setImmediate(this._chunkStart.bind(this));\n }, CHUNK_INTERVAL_MS);\n\n // Unref timeout so it doesn't keep the process alive.\n chunk.timer.unref();\n }\n\n /**\n * Attaches profiling information to spans that were started\n * during a profiling session.\n */\n private _setupSpanChunkInstrumentation(): void {\n if (!this._client) {\n DEBUG_BUILD &&\n logger.log(\n '[Profiling] Failed to initialize span profiling, sentry client was never attached to the profiler.',\n );\n return;\n }\n\n this._profilerId = uuid4();\n getGlobalScope().setContext('profile', {\n profiler_id: this._profilerId,\n });\n }\n\n /**\n * Assigns thread_id and thread name context to a profiled event if there is an active profiler session\n */\n private _onBeforeSendThreadContextAssignment(event: Event): void {\n if (!this._client || !this._profilerId) return;\n this._assignThreadIdContext(event);\n }\n\n /**\n * Clear profiling information from global context when a profile is not running.\n */\n private _teardownSpanChunkInstrumentation(): void {\n this._profilerId = undefined;\n const globalScope = getGlobalScope();\n globalScope.setContext('profile', {});\n }\n\n /**\n * Initializes new profile chunk metadata\n */\n private _initializeChunk(traceId: string): ChunkData {\n this._chunkData = {\n id: uuid4(),\n startTraceID: traceId,\n timer: undefined,\n };\n return this._chunkData;\n }\n\n /**\n * Assigns thread_id and thread name context to a profiled event.\n */\n private _assignThreadIdContext(event: Event): void {\n if (!event?.contexts?.profile) {\n return;\n }\n\n if (!event.contexts) {\n return;\n }\n\n // @ts-expect-error the trace fallback value is wrong, though it should never happen\n // and in case it does, we dont want to override whatever was passed initially.\n event.contexts.trace = {\n ...(event.contexts?.trace ?? {}),\n data: {\n ...(event.contexts?.trace?.data ?? {}),\n ['thread.id']: PROFILER_THREAD_ID_STRING,\n ['thread.name']: PROFILER_THREAD_NAME,\n },\n };\n }\n\n /**\n * Resets the current chunk state.\n */\n private _resetChunkData(): void {\n this._chunkData = undefined;\n }\n}\n\n/** Exported only for tests. */\nexport const _nodeProfilingIntegration = ((): ProfilingIntegration<NodeClient> => {\n if (![16, 18, 20, 22].includes(NODE_MAJOR)) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[Sentry Profiling] You are using a Node.js version that does not have prebuilt binaries (${NODE_VERSION}).`,\n 'The @sentry/profiling-node package only has prebuilt support for the following LTS versions of Node.js: 16, 18, 20, 22.',\n 'To use the @sentry/profiling-node package with this version of Node.js, you will need to compile the native addon from source.',\n 'See: https://github.com/getsentry/sentry-javascript/tree/develop/packages/profiling-node#building-the-package-from-source',\n );\n });\n }\n\n return {\n name: 'ProfilingIntegration',\n _profiler: new ContinuousProfiler(),\n setup(client: NodeClient) {\n DEBUG_BUILD && logger.log('[Profiling] Profiling integration setup.');\n const options = client.getOptions();\n\n const mode =\n (options.profilesSampleRate === undefined ||\n options.profilesSampleRate === null ||\n options.profilesSampleRate === 0) &&\n !options.profilesSampler\n ? 'continuous'\n : 'span';\n switch (mode) {\n case 'continuous': {\n DEBUG_BUILD && logger.log('[Profiling] Continuous profiler mode enabled.');\n this._profiler.initialize(client);\n break;\n }\n // Default to span profiling when no mode profiler mode is set\n case 'span':\n case undefined: {\n DEBUG_BUILD && logger.log('[Profiling] Span profiler mode enabled.');\n setupAutomatedSpanProfiling(client);\n break;\n }\n default: {\n DEBUG_BUILD && logger.warn(`[Profiling] Unknown profiler mode: ${mode}, profiler was not initialized`);\n }\n }\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * We need this integration in order to send data to Sentry. We hook into the event processor\n * and inspect each event to see if it is a transaction event and if that transaction event\n * contains a profile on it's metadata. If that is the case, we create a profiling event envelope\n * and delete the profile from the transaction metadata.\n */\nexport const nodeProfilingIntegration = defineIntegration(_nodeProfilingIntegration);\n"],"names":[],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACO,MAAM,WAAY,IAAiB,OAAA,gBAAA,KAAA,WAAA,IAAA,gBAAA,CAAA;;ACLnC,MAAM,YAAa,GAAE,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAE;AACxD,MAAM,UAAA,GAAa,YAAY,CAAC,KAAK;;AC6B5C;AACA;AACO,MAAM,yBAA0B,GAAE,MAAM,CAAC,QAAQ,CAAC;AAClD,MAAM,oBAAqB,GAAE,eAAe,MAAA,GAAS,QAAQ;AACpE,MAAM,cAAA,GAAiB,GAAG;AAC1B,MAAM,yBAAA,GAA4B,GAAG;;AAErC;AACA,MAAM,WAAW,EAAE,CAAC,QAAQ,EAAE;AAC9B,MAAM,UAAU,EAAE,CAAC,OAAO,EAAE;AAC5B,MAAM,UAAU,EAAE,CAAC,OAAO,EAAE;AAC5B,MAAM,OAAO,EAAE,CAAC,IAAI,EAAE;AACtB,MAAM,QAAQ,EAAE,CAAC,OAAO,EAAE;AAC1B,MAAM,OAAO,EAAE,CAAC,IAAI,EAAE;;AAEtB;AACA;AACA;AACA;AACA;AACA,SAAS,qBAAqB;AAC9B,EAAE,OAAO;AACT,EAAuD;AACvD,EAAE,OAAO,EAAE,iBAAkB,IAAG,OAAO,CAAC;AACxC;;AAEA;AACA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A,8BAAA,CAAA,CAAA;AACA;AACA;AACA,KAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAA,wBAAA,GAAA,iBAAA,CAAA,yBAAA;;;;"}
@@ -1 +1 @@
1
- {"type":"module","version":"9.1.0","sideEffects":false}
1
+ {"type":"module","version":"9.2.0-alpha.0","sideEffects":false}
@@ -1 +1 @@
1
- {"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../../src/integration.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAA+C,oBAAoB,EAAQ,MAAM,cAAc,CAAC;AAa5G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA8Z/C,+BAA+B;AAC/B,eAAO,MAAM,yBAAyB,QAAQ,qBAAqB,UAAU,CA8CnD,CAAC;AAE3B;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,0CAA+C,CAAC"}
1
+ {"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../../src/integration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA+C,oBAAoB,EAAQ,MAAM,cAAc,CAAC;AAa5G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA4Z/C,+BAA+B;AAC/B,eAAO,MAAM,yBAAyB,QAAQ,qBAAqB,UAAU,CA8CnD,CAAC;AAE3B;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,0CAA+C,CAAC"}
@@ -1,6 +1,6 @@
1
+ import { type RawThreadCpuProfile } from '@sentry-internal/node-cpu-profiler';
1
2
  import type { CustomSamplingContext, Span } from '@sentry/core';
2
3
  import type { NodeClient } from '@sentry/node';
3
- import type { RawThreadCpuProfile } from './types';
4
4
  export declare const MAX_PROFILE_DURATION_MS: number;
5
5
  /**
6
6
  * Takes a transaction and determines if it should be profiled or not. If it should be profiled, it returns the
@@ -1 +1 @@
1
- {"version":3,"file":"spanProfileUtils.d.ts","sourceRoot":"","sources":["../../src/spanProfileUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAGnD,eAAO,MAAM,uBAAuB,QAAY,CAAC;AAEjD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,UAAU,GAAG,SAAS,EAC9B,IAAI,EAAE,IAAI,EACV,qBAAqB,CAAC,EAAE,qBAAqB,GAC5C,MAAM,GAAG,SAAS,CA8EpB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,mBAAmB,GAAG,IAAI,CAsBtG"}
1
+ {"version":3,"file":"spanProfileUtils.d.ts","sourceRoot":"","sources":["../../src/spanProfileUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACnG,OAAO,KAAK,EAAE,qBAAqB,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/C,eAAO,MAAM,uBAAuB,QAAY,CAAC;AAEjD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,UAAU,GAAG,SAAS,EAC9B,IAAI,EAAE,IAAI,EACV,qBAAqB,CAAC,EAAE,qBAAqB,GAC5C,MAAM,GAAG,SAAS,CA8EpB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,mBAAmB,GAAG,IAAI,CAsBtG"}
@@ -1,5 +1,5 @@
1
1
  import type { Client, ContinuousThreadCpuProfile, DebugImage, DsnComponents, Envelope, Event, EventEnvelopeHeaders, Profile, ProfileChunk, ProfileChunkEnvelope, SdkInfo, ThreadCpuProfile } from '@sentry/core';
2
- import type { RawChunkCpuProfile, RawThreadCpuProfile } from './types';
2
+ import type { RawChunkCpuProfile, RawThreadCpuProfile } from '@sentry-internal/node-cpu-profiler';
3
3
  export declare const PROFILER_THREAD_ID_STRING: string;
4
4
  export declare const PROFILER_THREAD_NAME: string;
5
5
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,MAAM,EACN,0BAA0B,EAC1B,UAAU,EACV,aAAa,EACb,QAAQ,EACR,KAAK,EACL,oBAAoB,EACpB,OAAO,EACP,YAAY,EACZ,oBAAoB,EAEpB,OAAO,EACP,gBAAgB,EAEjB,MAAM,cAAc,CAAC;AActB,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAIvE,eAAO,MAAM,yBAAyB,QAAmB,CAAC;AAC1D,eAAO,MAAM,oBAAoB,QAAmC,CAAC;AAuBrE;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,gBAAgB,GAAG,mBAAmB,GAAG,0BAA0B,GAAG,kBAAkB,GAChG,gBAAgB,GAAG,0BAA0B,CAe/C;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,GAAG,IAAI,CAc/G;AAoID;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,EACnD,OAAO,EAAE,kBAAkB,EAC3B,GAAG,EAAE,OAAO,GAAG,SAAS,EACxB,WAAW,EAAE;IAAE,QAAQ,EAAE,MAAM,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B,GAAG,OAAO,IAAI,kBAAkB,CAW9F;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,QAAQ,CAUvF;AAED;;;;GAIG;AACH,wBAAgB,oCAAoC,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,CA0BhF;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,GAAG,CAAC,EAAE,aAAa,GAClB,oBAAoB,CAOtB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,GAAG,CAAC,EAAE,aAAa,GAClB,oBAAoB,CAQtB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,UAAU,EAAE,CAQtG"}
@@ -1,6 +1,6 @@
1
+ import { RawThreadCpuProfile } from '@sentry-internal/node-cpu-profiler';
1
2
  import { CustomSamplingContext, Span } from '@sentry/core';
2
3
  import { NodeClient } from '@sentry/node';
3
- import { RawThreadCpuProfile } from './types';
4
4
  export declare const MAX_PROFILE_DURATION_MS: number;
5
5
  /**
6
6
  * Takes a transaction and determines if it should be profiled or not. If it should be profiled, it returns the
@@ -1,5 +1,5 @@
1
1
  import { Client, ContinuousThreadCpuProfile, DebugImage, DsnComponents, Envelope, Event, EventEnvelopeHeaders, Profile, ProfileChunk, ProfileChunkEnvelope, SdkInfo, ThreadCpuProfile } from '@sentry/core';
2
- import { RawChunkCpuProfile, RawThreadCpuProfile } from './types';
2
+ import { RawChunkCpuProfile, RawThreadCpuProfile } from '@sentry-internal/node-cpu-profiler';
3
3
  export declare const PROFILER_THREAD_ID_STRING: string;
4
4
  export declare const PROFILER_THREAD_NAME: string;
5
5
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/profiling-node",
3
- "version": "9.1.0",
3
+ "version": "9.2.0-alpha.0",
4
4
  "description": "Official Sentry SDK for Node.js Profiling",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/profiling-node",
@@ -63,8 +63,8 @@
63
63
  },
64
64
  "dependencies": {
65
65
  "@sentry-internal/node-cpu-profiler": "^2.0.0",
66
- "@sentry/core": "9.1.0",
67
- "@sentry/node": "9.1.0"
66
+ "@sentry/core": "9.2.0-alpha.0",
67
+ "@sentry/node": "9.2.0-alpha.0"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/node": "^18.19.1"
@@ -1,60 +0,0 @@
1
- import type { Event } from '@sentry/core';
2
- interface Sample {
3
- stack_id: number;
4
- thread_id: string;
5
- elapsed_since_start_ns: string;
6
- }
7
- interface ChunkSample {
8
- stack_id: number;
9
- thread_id: string;
10
- timestamp: number;
11
- }
12
- type Frame = {
13
- function: string;
14
- file: string;
15
- lineno: number;
16
- colno: number;
17
- };
18
- interface Measurement {
19
- unit: string;
20
- values: {
21
- elapsed_since_start_ns: number;
22
- value: number;
23
- }[];
24
- }
25
- export interface ProfiledEvent extends Event {
26
- sdkProcessingMetadata: {
27
- profile?: RawThreadCpuProfile;
28
- };
29
- }
30
- interface BaseProfile {
31
- profile_id?: string;
32
- stacks: number[][];
33
- frames: Frame[];
34
- resources: string[];
35
- profiler_logging_mode: 'eager' | 'lazy';
36
- measurements: Record<string, Measurement>;
37
- }
38
- export interface RawThreadCpuProfile extends BaseProfile {
39
- samples: Sample[];
40
- }
41
- export interface RawChunkCpuProfile extends BaseProfile {
42
- samples: ChunkSample[];
43
- }
44
- export interface PrivateV8CpuProfilerBindings {
45
- startProfiling?: (name: string) => void;
46
- stopProfiling?(name: string, format: ProfileFormat.THREAD, threadId: number, collectResources: boolean): RawThreadCpuProfile | null;
47
- stopProfiling?(name: string, format: ProfileFormat.CHUNK, threadId: number, collectResources: boolean): RawChunkCpuProfile | null;
48
- getFrameModule(abs_path: string): string;
49
- }
50
- export declare enum ProfileFormat {
51
- THREAD = 0,
52
- CHUNK = 1
53
- }
54
- export interface V8CpuProfilerBindings {
55
- startProfiling(name: string): void;
56
- stopProfiling(name: string, format: ProfileFormat.THREAD): RawThreadCpuProfile | null;
57
- stopProfiling(name: string, format: ProfileFormat.CHUNK): RawChunkCpuProfile | null;
58
- }
59
- export {};
60
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE1C,UAAU,MAAM;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,EAAE,MAAM,CAAC;CAChC;AAED,UAAU,WAAW;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE;QACN,sBAAsB,EAAE,MAAM,CAAC;QAC/B,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;CACL;AAID,MAAM,WAAW,aAAc,SAAQ,KAAK;IAC1C,qBAAqB,EAAE;QACrB,OAAO,CAAC,EAAE,mBAAmB,CAAC;KAC/B,CAAC;CACH;AAED,UAAU,WAAW;IACnB,UAAU,CAA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I,CAAC;CACrF"}
@@ -1,60 +0,0 @@
1
- import { Event } from '@sentry/core';
2
- interface Sample {
3
- stack_id: number;
4
- thread_id: string;
5
- elapsed_since_start_ns: string;
6
- }
7
- interface ChunkSample {
8
- stack_id: number;
9
- thread_id: string;
10
- timestamp: number;
11
- }
12
- type Frame = {
13
- function: string;
14
- file: string;
15
- lineno: number;
16
- colno: number;
17
- };
18
- interface Measurement {
19
- unit: string;
20
- values: {
21
- elapsed_since_start_ns: number;
22
- value: number;
23
- }[];
24
- }
25
- export interface ProfiledEvent extends Event {
26
- sdkProcessingMetadata: {
27
- profile?: RawThreadCpuProfile;
28
- };
29
- }
30
- interface BaseProfile {
31
- profile_id?: string;
32
- stacks: number[][];
33
- frames: Frame[];
34
- resources: string[];
35
- profiler_logging_mode: 'eager' | 'lazy';
36
- measurements: Record<string, Measurement>;
37
- }
38
- export interface RawThreadCpuProfile extends BaseProfile {
39
- samples: Sample[];
40
- }
41
- export interface RawChunkCpuProfile extends BaseProfile {
42
- samples: ChunkSample[];
43
- }
44
- export interface PrivateV8CpuProfilerBindings {
45
- startProfiling?: (name: string) => void;
46
- stopProfiling?(name: string, format: ProfileFormat.THREAD, threadId: number, collectResources: boolean): RawThreadCpuProfile | null;
47
- stopProfiling?(name: string, format: ProfileFormat.CHUNK, threadId: number, collectResources: boolean): RawChunkCpuProfile | null;
48
- getFrameModule(abs_path: string): string;
49
- }
50
- export declare enum ProfileFormat {
51
- THREAD = 0,
52
- CHUNK = 1
53
- }
54
- export interface V8CpuProfilerBindings {
55
- startProfiling(name: string): void;
56
- stopProfiling(name: string, format: ProfileFormat.THREAD): RawThreadCpuProfile | null;
57
- stopProfiling(name: string, format: ProfileFormat.CHUNK): RawChunkCpuProfile | null;
58
- }
59
- export {};
60
- //# sourceMappingURL=types.d.ts.map