@sentry/profiling-node 11.0.0-alpha.0 → 11.0.0-alpha.2

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.
@@ -1 +1 @@
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 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 debug,\n dsnToString,\n forEachEnvelopeItem,\n getDebugImagesForResources,\n uuid4,\n} from '@sentry/core';\nimport type { RawChunkCpuProfile, RawThreadCpuProfile } from '@sentry/node-cpu-profiler';\nimport * as os from 'os';\nimport { env, versions } from 'process';\nimport { isMainThread, threadId } from 'worker_threads';\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 && debug.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 && debug.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 debug.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 && debug.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 debug.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 debug.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 platform: 'node',\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 platform,\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","/* eslint-disable typescript/no-deprecated */\nimport type { CustomSamplingContext, Span } from '@sentry/core';\nimport { debug, spanIsSampled, spanToJSON, uuid4 } from '@sentry/core';\nimport type { NodeClient } from '@sentry/node';\nimport { CpuProfilerBindings, type RawThreadCpuProfile } from '@sentry/node-cpu-profiler';\nimport { isMainThread } from 'worker_threads';\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 // Profiling is not supported in worker threads as the native CPU profiler's\n // sampling thread can race with V8's GC across isolates, causing heap corruption.\n if (!isMainThread) {\n DEBUG_BUILD && debug.log('[Profiling] Skipping span profiling in worker thread.');\n return;\n }\n\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 && debug.log('[Profiling] Profiling disabled, no client found.');\n return;\n }\n\n const options = client.getOptions();\n if (!options) {\n DEBUG_BUILD && debug.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 && debug.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 debug.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 debug.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 && debug.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 && debug.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 debug.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 type { Event, IntegrationFn, Profile, ProfileChunk, ProfilingIntegration, Span } from '@sentry/core';\nimport {\n consoleSandbox,\n debug,\n defineIntegration,\n getCurrentScope,\n getGlobalScope,\n getIsolationScope,\n getRootSpan,\n LRUMap,\n spanToJSON,\n uuid4,\n} from '@sentry/core';\nimport type { NodeClient, NodeOptions } from '@sentry/node';\nimport { CpuProfilerBindings, ProfileFormat, type RawThreadCpuProfile } from '@sentry/node-cpu-profiler';\nimport { isMainThread } from 'worker_threads';\nimport { DEBUG_BUILD } from './debug-build';\nimport { NODE_MAJOR } from './nodeVersion';\nimport { MAX_PROFILE_DURATION_MS, maybeProfileSpan, stopSpanProfile } from './spanProfileUtils';\nimport {\n addProfilesToEnvelope,\n createProfilingChunkEvent,\n createProfilingEvent,\n findProfiledTransactionsFromEnvelope,\n makeProfileChunkEnvelope,\n PROFILER_THREAD_ID_STRING,\n PROFILER_THREAD_NAME,\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\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 private _mode: 'legacy' | 'current' | undefined = undefined;\n private _legacyProfilerMode: 'span' | 'continuous' | undefined = undefined;\n private _profileLifecycle: 'manual' | 'trace' | undefined = undefined;\n private _sampled: boolean | undefined = undefined;\n private _sessionSamplingRate: number | undefined = undefined;\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 if (!isMainThread) {\n DEBUG_BUILD &&\n debug.warn(\n '[Profiling] nodeProfilingIntegration() does not support worker threads — profiling will be disabled for this thread.',\n );\n return;\n }\n\n this._client = client;\n const options = client.getOptions();\n\n this._mode = getProfilingMode(options);\n this._sessionSamplingRate = Math.random();\n this._sampled = this._sessionSamplingRate < (options.profileSessionSampleRate ?? 0);\n this._profileLifecycle = options.profileLifecycle ?? 'manual';\n\n switch (this._mode) {\n case 'legacy': {\n this._legacyProfilerMode =\n 'profilesSampleRate' in options || 'profilesSampler' in options ? 'span' : 'continuous';\n\n DEBUG_BUILD && debug.log(`[Profiling] Profiling mode is ${this._legacyProfilerMode}.`);\n\n switch (this._legacyProfilerMode) {\n case 'span': {\n this._setupAutomaticSpanProfiling();\n break;\n }\n case 'continuous': {\n // Continous mode requires manual calls to profiler.start() and profiler.stop()\n break;\n }\n default: {\n DEBUG_BUILD &&\n debug.warn(\n `[Profiling] Unknown profiler mode: ${this._legacyProfilerMode}, profiler was not initialized`,\n );\n break;\n }\n }\n break;\n }\n\n case 'current': {\n this._setupSpanChunkInstrumentation();\n\n DEBUG_BUILD && debug.log(`[Profiling] Profiling mode is ${this._profileLifecycle}.`);\n\n switch (this._profileLifecycle) {\n case 'trace': {\n this._startTraceLifecycleProfiling();\n break;\n }\n case 'manual': {\n // Manual mode requires manual calls to profiler.startProfiler() and profiler.stopProfiler()\n break;\n }\n default: {\n DEBUG_BUILD &&\n debug.warn(`[Profiling] Unknown profiler mode: ${this._profileLifecycle}, profiler was not initialized`);\n break;\n }\n }\n break;\n }\n default: {\n DEBUG_BUILD && debug.warn(`[Profiling] Unknown profiler mode: ${this._mode}, profiler was not initialized`);\n break;\n }\n }\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._mode === 'current') {\n this._startProfiler();\n return;\n }\n\n if (!this._client) {\n DEBUG_BUILD && debug.log('[Profiling] Failed to start, sentry client was never attached to the profiler.');\n return;\n }\n\n if (this._mode !== 'legacy') {\n DEBUG_BUILD && debug.log('[Profiling] Continuous profiling is not supported in the current mode.');\n return;\n }\n\n if (this._legacyProfilerMode === 'span') {\n DEBUG_BUILD && debug.log('[Profiling] Calls to profiler.start() are not supported in span profiling mode.');\n return;\n }\n\n // Flush any existing chunks before starting a new one.\n\n this._stopChunkProfiling();\n\n // Restart the profiler session\n this._setupSpanChunkInstrumentation();\n this._restartChunkProfiling();\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._mode === 'current') {\n this._stopProfiler();\n return;\n }\n\n if (!this._client) {\n DEBUG_BUILD && debug.log('[Profiling] Failed to stop, sentry client was never attached to the profiler.');\n return;\n }\n\n if (this._mode !== 'legacy') {\n DEBUG_BUILD && debug.log('[Profiling] Continuous profiling is not supported in the current mode.');\n return;\n }\n\n if (this._legacyProfilerMode === 'span') {\n DEBUG_BUILD && debug.log('[Profiling] Calls to profiler.stop() are not supported in span profiling mode.');\n return;\n }\n\n this._stopChunkProfiling();\n this._teardownSpanChunkInstrumentation();\n }\n\n private _startProfiler(): void {\n if (this._mode !== 'current') {\n DEBUG_BUILD && debug.log('[Profiling] Continuous profiling is not supported in the current mode.');\n return;\n }\n\n if (this._chunkData !== undefined) {\n DEBUG_BUILD && debug.log('[Profiling] Profile session already running, no-op.');\n return;\n }\n\n if (this._mode === 'current') {\n if (!this._sampled) {\n DEBUG_BUILD && debug.log('[Profiling] Profile session not sampled, no-op.');\n return;\n }\n }\n\n if (this._profileLifecycle === 'trace') {\n DEBUG_BUILD &&\n debug.log(\n '[Profiling] You are using the trace profile lifecycle, manual calls to profiler.startProfiler() and profiler.stopProfiler() will be ignored.',\n );\n return;\n }\n\n this._startChunkProfiling();\n }\n\n private _stopProfiler(): void {\n if (this._mode !== 'current') {\n DEBUG_BUILD && debug.log('[Profiling] Continuous profiling is not supported in the current mode.');\n return;\n }\n\n if (this._profileLifecycle === 'trace') {\n DEBUG_BUILD &&\n debug.log(\n '[Profiling] You are using the trace profile lifecycle, manual calls to profiler.startProfiler() and profiler.stopProfiler() will be ignored.',\n );\n return;\n }\n\n if (!this._chunkData) {\n DEBUG_BUILD && debug.log('[Profiling] No profile session running, no-op.');\n return;\n }\n\n this._stopChunkProfiling();\n }\n\n /**\n * Starts trace lifecycle profiling. Profiling will remain active as long as there is an active span.\n */\n private _startTraceLifecycleProfiling(): void {\n if (!this._sampled) {\n DEBUG_BUILD &&\n debug.log('[Profiling] Profile session not sampled, trace lifecycle profiling will not be started.');\n return;\n }\n\n if (!this._client) {\n DEBUG_BUILD &&\n debug.log(\n '[Profiling] Failed to start trace lifecycle profiling, sentry client was never attached to the profiler.',\n );\n return;\n }\n\n let activeSpanCounter = 0;\n this._client.on('spanStart', _span => {\n if (activeSpanCounter === 0) {\n this._startChunkProfiling();\n }\n activeSpanCounter++;\n });\n\n this._client.on('spanEnd', _span => {\n if (activeSpanCounter === 1) {\n this._stopChunkProfiling();\n }\n activeSpanCounter--;\n });\n }\n\n private _setupAutomaticSpanProfiling(): void {\n if (!this._client) {\n DEBUG_BUILD &&\n debug.log(\n '[Profiling] Failed to setup automatic span profiling, sentry client was never attached to the profiler.',\n );\n return;\n }\n\n const spanToProfileIdMap = new WeakMap<Span, string>();\n\n this._client.on('spanStart', span => {\n if (span !== getRootSpan(span)) {\n return;\n }\n\n const profile_id = maybeProfileSpan(this._client, span);\n\n if (profile_id) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const options = this._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 debug.log(\n '[Profiling] max profile duration elapsed, stopping profiling for:',\n spanToJSON(span).description,\n );\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 this._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 this._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 && debug.log(`[Profiling] Could not retrieve profile for transaction: ${profile_id}`);\n continue;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const profile = createProfilingEvent(this._client!, cpuProfile, profiledTransaction);\n if (!profile) return;\n\n profilesToAddToEnvelope.push(profile);\n\n // @ts-expect-error profile does not inherit from Event\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._client!.emit('preprocessEvent', profile, {\n event_id: profiledTransaction.event_id,\n });\n\n // @ts-expect-error profile does not inherit from Event\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._client!.emit('postprocessEvent', profile, {\n event_id: profiledTransaction.event_id,\n });\n }\n\n addProfilesToEnvelope(envelope, profilesToAddToEnvelope);\n });\n }\n\n /**\n * Stop profiler and initializes profiling of the next chunk\n */\n private _restartChunkProfiling(): 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 && debug.log('[Profiling] Profiler was never attached to the client.');\n return;\n }\n\n if (this._chunkData) {\n DEBUG_BUILD &&\n debug.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._stopChunkProfiling();\n }\n\n this._startChunkProfiling();\n }\n\n /**\n * Stops profiling of the current chunks and flushes the profile to Sentry\n */\n private _stopChunkProfiling(): void {\n if (!this._chunkData) {\n DEBUG_BUILD && debug.log('[Profiling] No chunk data found, no-op.');\n return;\n }\n\n if (this._chunkData?.timer) {\n global.clearTimeout(this._chunkData.timer);\n this._chunkData.timer = undefined;\n DEBUG_BUILD && debug.log(`[Profiling] Stopping profiling chunk: ${this._chunkData.id}`);\n }\n\n if (!this._client) {\n DEBUG_BUILD &&\n debug.log('[Profiling] Failed to collect profile, sentry client was never attached to the profiler.');\n this._resetChunkData();\n return;\n }\n\n if (!this._chunkData?.id) {\n DEBUG_BUILD &&\n debug.log(`[Profiling] Failed to collect profile for: ${this._chunkData?.id}, the chunk_id is missing.`);\n this._resetChunkData();\n return;\n }\n\n const profile = CpuProfilerBindings.stopProfiling(this._chunkData.id, ProfileFormat.CHUNK);\n\n if (!profile) {\n DEBUG_BUILD && debug.log(`[Profiling] Failed to collect profile for: ${this._chunkData.id}`);\n this._resetChunkData();\n return;\n }\n\n if (!this._profilerId) {\n DEBUG_BUILD &&\n debug.log('[Profiling] Profile chunk does not contain a valid profiler_id, this is a bug in the SDK');\n this._resetChunkData();\n return;\n }\n if (profile) {\n DEBUG_BUILD && debug.log(`[Profiling] Sending profile chunk ${this._chunkData.id}.`);\n }\n\n DEBUG_BUILD && debug.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 && debug.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 debug.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 && debug.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('node', chunk, metadata?.sdk, tunnel, dsn);\n transport.send(envelope).then(null, reason => {\n DEBUG_BUILD && debug.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 if (this._chunkData) {\n DEBUG_BUILD && debug.log('[Profiling] Chunk is already running, no-op.');\n return;\n }\n\n const traceId = getCurrentScope().getPropagationContext().traceId;\n const chunk = this._initializeChunk(traceId);\n\n CpuProfilerBindings.startProfiling(chunk.id);\n DEBUG_BUILD && debug.log(`[Profiling] starting profiling chunk: ${chunk.id}`);\n\n chunk.timer = global.setTimeout(() => {\n DEBUG_BUILD && debug.log(`[Profiling] Stopping profiling chunk: ${chunk.id}`);\n this._stopChunkProfiling();\n DEBUG_BUILD && debug.log('[Profiling] Starting new profiling chunk.');\n setImmediate(this._restartChunkProfiling.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 debug.log('[Profiling] Failed to initialize span profiling, sentry client was never attached to the profiler.');\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, 24, 26].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_MAJOR}).`,\n 'The @sentry/profiling-node package only has prebuilt support for the following LTS versions of Node.js: 16, 18, 20, 22, 24, 26.',\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' as const,\n _profiler: new ContinuousProfiler(),\n setup(client: NodeClient) {\n DEBUG_BUILD && debug.log('[Profiling] Profiling integration setup.');\n this._profiler.initialize(client);\n return;\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Determines the profiling mode based on the options.\n * @param options\n * @returns 'legacy' if the options are using the legacy profiling API, 'current' if the options are using the current profiling API\n */\nfunction getProfilingMode(options: NodeOptions): 'legacy' | 'current' {\n // Legacy mode takes precedence over current mode\n if ('profilesSampleRate' in options || 'profilesSampler' in options) {\n return 'legacy';\n }\n\n if ('profileSessionSampleRate' in options || 'profileLifecycle' in options) {\n return 'current';\n }\n\n // If neither are set, we are in the legacy continuous profiling mode\n return 'legacy';\n}\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":";;;;;;AAOO,MAAM,WAAA,IAAc,OAAA,gBAAA,KAAA,WAAA,IAAA,gBAAA,CAAA;;ACLpB,MAAM,YAAA,GAAe,WAAA,CAAY,OAAA,CAAQ,QAAA,CAAS,IAAI,CAAA;AACtD,MAAM,aAAa,YAAA,CAAa,KAAA;;AC6BhC,MAAM,yBAAA,GAA4B,OAAO,QAAQ,CAAA;AACjD,MAAM,oBAAA,GAAuB,eAAe,MAAA,GAAS,QAAA;AAC5D,MAAM,cAAA,GAAiB,GAAA;AACvB,MAAM,yBAAA,GAA4B,GAAA;AAGlC,MAAM,QAAA,GAAW,GAAG,QAAA,EAAS;AAC7B,MAAM,OAAA,GAAU,GAAG,OAAA,EAAQ;AAC3B,MAAM,OAAA,GAAU,GAAG,OAAA,EAAQ;AAC3B,MAAM,IAAA,GAAO,GAAG,IAAA,EAAK;AACrB,MAAM,KAAA,GAAQ,GAAG,OAAA,EAAQ;AACzB,MAAM,IAAA,GAAO,GAAG,IAAA,EAAK;AAOrB,SAAS,sBACP,OAAA,EACqD;AACrD,EAAA,OAAO,EAAE,iBAAA,IAAqB,OAAA,CAAA;AAChC;AASO,SAAS,4BACd,OAAA,EAC+C;AAC/C,EAAA,IAAI,CAAC,qBAAA,CAAsB,OAAO,CAAA,EAAG;AACnC,IAAA,OAAO,OAAA;AAAA,EACT;AAEA,EAAA,OAAO;AAAA,IACL,SAAS,OAAA,CAAQ,OAAA;AAAA,IACjB,QAAQ,OAAA,CAAQ,MAAA;AAAA,IAChB,QAAQ,OAAA,CAAQ,MAAA;AAAA,IAChB,eAAA,EAAiB;AAAA,MACf,CAAC,yBAAyB,GAAG;AAAA,QAC3B,IAAA,EAAM;AAAA;AACR;AACF,GACF;AACF;AAQO,SAAS,oBAAA,CAAqB,MAAA,EAAgB,OAAA,EAA8B,KAAA,EAA8B;AAC/G,EAA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C,MAAM,MAAA,EAAoB;AACxB,MAAA,WAAA,IAAe,KAAA,CAAM,IAAI,0CAA0C,CAAA;AACnE,MAAA,IAAA,CAAK,SAAA,CAAU,WAAW,MAAM,CAAA;AAChC,MAAA;AAAA,IACF;AAAA,GACF;AACF,CAAA,CAAA;AAOA,SAAS,iBAAiB,OAAA,EAA4C;AAEpE,EAAA,IAAI,oBAAA,IAAwB,OAAA,IAAW,iBAAA,IAAqB,OAAA,EAAS;AACnE,IAAA,OAAO,QAAA;AAAA,EACT;AAEA,EAAA,IAAI,0BAAA,IAA8B,OAAA,IAAW,kBAAA,IAAsB,OAAA,EAAS;AAC1E,IAAA,OAAO,SAAA;AAAA,EACT;AAGA,EAAA,OAAO,QAAA;AACT;AAQO,MAAM,wBAAA,GAA2B,kBAAkB,yBAAyB;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/debug-build.ts","../../src/nodeVersion.ts","../../src/utils.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 type {\n Client,\n ContinuousThreadCpuProfile,\n DebugImage,\n DsnComponents,\n EventEnvelopeHeaders,\n ProfileChunk,\n ProfileChunkEnvelope,\n ProfileChunkItem,\n SdkInfo,\n} from '@sentry/core';\nimport { createEnvelope, debug, dsnToString, getDebugImagesForResources, uuid4 } from '@sentry/core';\nimport type { RawChunkCpuProfile } from '@sentry/node-cpu-profiler';\nimport { isMainThread, threadId } from 'worker_threads';\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 CONTINUOUS_FORMAT_VERSION = '2';\n\n/**\n * Checks if the profile is a raw profile or a profile enriched with thread information.\n * @param {ContinuousThreadCpuProfile | RawChunkCpuProfile} profile\n * @returns {boolean}\n */\nfunction isRawThreadCpuProfile(\n profile: ContinuousThreadCpuProfile | RawChunkCpuProfile,\n): profile is 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 {ContinuousThreadCpuProfile | RawChunkCpuProfile} profile\n * @returns {ContinuousThreadCpuProfile}\n */\nexport function enrichWithThreadInformation(\n profile: ContinuousThreadCpuProfile | RawChunkCpuProfile,\n): 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 };\n}\n\n/**\n * Create a profile chunk from raw thread profile\n * @param {RawChunkCpuProfile} cpuProfile\n * @returns {ProfileChunk}\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 && debug.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,\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 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 debug.log('[Profiling] Discarding profile chunk because it contains less than 2 samples');\n return false;\n }\n\n return true;\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 platform: 'node',\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 platform,\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","/* eslint-disable max-lines */\nimport type { Event, IntegrationFn, ProfileChunk, ProfilingIntegration } from '@sentry/core';\nimport { consoleSandbox, debug, defineIntegration, getCurrentScope, getGlobalScope, uuid4 } from '@sentry/core';\nimport type { NodeClient } from '@sentry/node';\nimport { CpuProfilerBindings, ProfileFormat } from '@sentry/node-cpu-profiler';\nimport { isMainThread } from 'worker_threads';\nimport { DEBUG_BUILD } from './debug-build';\nimport { NODE_MAJOR } from './nodeVersion';\nimport {\n createProfilingChunkEvent,\n makeProfileChunkEnvelope,\n PROFILER_THREAD_ID_STRING,\n PROFILER_THREAD_NAME,\n} from './utils';\n\nconst CHUNK_INTERVAL_MS = 1000 * 60;\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 private _profileLifecycle: 'manual' | 'trace' | undefined = undefined;\n private _sampled: boolean | undefined = undefined;\n private _sessionSamplingRate: number | undefined = undefined;\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 if (!isMainThread) {\n DEBUG_BUILD &&\n debug.warn(\n '[Profiling] nodeProfilingIntegration() does not support worker threads — profiling will be disabled for this thread.',\n );\n return;\n }\n\n this._client = client;\n const options = client.getOptions();\n\n this._sessionSamplingRate = Math.random();\n this._sampled = this._sessionSamplingRate < (options.profileSessionSampleRate ?? 0);\n this._profileLifecycle = options.profileLifecycle ?? 'manual';\n\n this._setupSpanChunkInstrumentation();\n\n DEBUG_BUILD && debug.log(`[Profiling] Profiling mode is ${this._profileLifecycle}.`);\n\n switch (this._profileLifecycle) {\n case 'trace': {\n this._startTraceLifecycleProfiling();\n break;\n }\n case 'manual': {\n // Manual mode requires manual calls to profiler.startProfiler() and profiler.stopProfiler().\n break;\n }\n default: {\n DEBUG_BUILD &&\n debug.warn(`[Profiling] Unknown profiler mode: ${this._profileLifecycle}, profiler was not initialized`);\n break;\n }\n }\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 && debug.log('[Profiling] Failed to start, Sentry client was never attached to the profiler.');\n return;\n }\n\n this._startProfiler();\n }\n\n /**\n * Stops the current chunk and flushes the profile to Sentry.\n */\n public stop(): void {\n this._stopProfiler();\n }\n\n private _startProfiler(): void {\n if (this._chunkData !== undefined) {\n DEBUG_BUILD && debug.log('[Profiling] Profile session already running, no-op.');\n return;\n }\n\n if (!this._sampled) {\n DEBUG_BUILD && debug.log('[Profiling] Profile session not sampled, no-op.');\n return;\n }\n\n if (this._profileLifecycle === 'trace') {\n DEBUG_BUILD &&\n debug.log(\n '[Profiling] You are using the trace profile lifecycle, manual calls to profiler.startProfiler() and profiler.stopProfiler() will be ignored.',\n );\n return;\n }\n\n this._startChunkProfiling();\n }\n\n private _stopProfiler(): void {\n if (this._profileLifecycle === 'trace') {\n DEBUG_BUILD &&\n debug.log(\n '[Profiling] You are using the trace profile lifecycle, manual calls to profiler.startProfiler() and profiler.stopProfiler() will be ignored.',\n );\n return;\n }\n\n if (!this._chunkData) {\n DEBUG_BUILD && debug.log('[Profiling] No profile session running, no-op.');\n return;\n }\n\n this._stopChunkProfiling();\n }\n\n /**\n * Starts trace lifecycle profiling. Profiling will remain active as long as there is an active span.\n */\n private _startTraceLifecycleProfiling(): void {\n if (!this._sampled) {\n DEBUG_BUILD &&\n debug.log('[Profiling] Profile session not sampled, trace lifecycle profiling will not be started.');\n return;\n }\n\n if (!this._client) {\n DEBUG_BUILD &&\n debug.log(\n '[Profiling] Failed to start trace lifecycle profiling, sentry client was never attached to the profiler.',\n );\n return;\n }\n\n let activeSpanCounter = 0;\n this._client.on('spanStart', _span => {\n if (activeSpanCounter === 0) {\n this._startChunkProfiling();\n }\n activeSpanCounter++;\n });\n\n this._client.on('spanEnd', _span => {\n if (activeSpanCounter === 1) {\n this._stopChunkProfiling();\n }\n activeSpanCounter--;\n });\n }\n\n /**\n * Stop profiler and initializes profiling of the next chunk\n */\n private _restartChunkProfiling(): 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 && debug.log('[Profiling] Profiler was never attached to the client.');\n return;\n }\n\n if (this._chunkData) {\n DEBUG_BUILD &&\n debug.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._stopChunkProfiling();\n }\n\n this._startChunkProfiling();\n }\n\n /**\n * Stops profiling of the current chunks and flushes the profile to Sentry\n */\n private _stopChunkProfiling(): void {\n if (!this._chunkData) {\n DEBUG_BUILD && debug.log('[Profiling] No chunk data found, no-op.');\n return;\n }\n\n if (this._chunkData?.timer) {\n global.clearTimeout(this._chunkData.timer);\n this._chunkData.timer = undefined;\n DEBUG_BUILD && debug.log(`[Profiling] Stopping profiling chunk: ${this._chunkData.id}`);\n }\n\n if (!this._client) {\n DEBUG_BUILD &&\n debug.log('[Profiling] Failed to collect profile, sentry client was never attached to the profiler.');\n this._resetChunkData();\n return;\n }\n\n if (!this._chunkData?.id) {\n DEBUG_BUILD &&\n debug.log(`[Profiling] Failed to collect profile for: ${this._chunkData?.id}, the chunk_id is missing.`);\n this._resetChunkData();\n return;\n }\n\n const profile = CpuProfilerBindings.stopProfiling(this._chunkData.id, ProfileFormat.CHUNK);\n\n if (!profile) {\n DEBUG_BUILD && debug.log(`[Profiling] Failed to collect profile for: ${this._chunkData.id}`);\n this._resetChunkData();\n return;\n }\n\n if (!this._profilerId) {\n DEBUG_BUILD &&\n debug.log('[Profiling] Profile chunk does not contain a valid profiler_id, this is a bug in the SDK');\n this._resetChunkData();\n return;\n }\n if (profile) {\n DEBUG_BUILD && debug.log(`[Profiling] Sending profile chunk ${this._chunkData.id}.`);\n }\n\n DEBUG_BUILD && debug.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 && debug.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 debug.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 && debug.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('node', chunk, metadata?.sdk, tunnel, dsn);\n transport.send(envelope).then(null, reason => {\n DEBUG_BUILD && debug.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 if (this._chunkData) {\n DEBUG_BUILD && debug.log('[Profiling] Chunk is already running, no-op.');\n return;\n }\n\n const traceId = getCurrentScope().getPropagationContext().traceId;\n const chunk = this._initializeChunk(traceId);\n\n CpuProfilerBindings.startProfiling(chunk.id);\n DEBUG_BUILD && debug.log(`[Profiling] starting profiling chunk: ${chunk.id}`);\n\n chunk.timer = global.setTimeout(() => {\n DEBUG_BUILD && debug.log(`[Profiling] Stopping profiling chunk: ${chunk.id}`);\n this._stopChunkProfiling();\n DEBUG_BUILD && debug.log('[Profiling] Starting new profiling chunk.');\n setImmediate(this._restartChunkProfiling.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 debug.log('[Profiling] Failed to initialize span profiling, sentry client was never attached to the profiler.');\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, 24, 26].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_MAJOR}).`,\n 'The @sentry/profiling-node package only has prebuilt support for the following LTS versions of Node.js: 16, 18, 20, 22, 24, 26.',\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' as const,\n _profiler: new ContinuousProfiler(),\n setup(client: NodeClient) {\n DEBUG_BUILD && debug.log('[Profiling] Profiling integration setup.');\n this._profiler.initialize(client);\n return;\n },\n };\n}) satisfies IntegrationFn;\n\nexport const nodeProfilingIntegration = def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AAAA,MAC9B,IAAA,EAAM;AAAA,QACJ,GAAI,KAAA,CAAM,QAAA,EAAU,KAAA,EAAO,QAAQ,EAAC;AAAA,QACpC,CAAC,WAAW,GAAG,yBAAA;AAAA,QACf,CAAC,aAAa,GAAG;AAAA;AACnB,KACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKQ,eAAA,GAAwB;AAC9B,IAAA,IAAA,CAAK,UAAA,GAAa,MAAA;AAAA,EACpB;AACF;AAGO,MAAM,6BAA6B,MAAwC;AAChF,EAAA,IAAI,CAAC,CAAC,EAAA,EAAI,EAAA,EAAI,EAAA,EAAI,EAAA,EAAI,EAAA,EAAI,EAAE,CAAA,CAAE,QAAA,CAAS,UAAU,CAAA,EAAG;AAClD,IAAA,cAAA,CAAe,MAAM;AAEnB,MAAA,OAAA,CAAQ,IAAA;AAAA,QACN,4FAA4F,UAAU,CAAA,EAAA,CAAA;AAAA,QACtG,iIAAA;AAAA,QACA,gIAAA;AAAA,QACA;AAAA,OACF;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,sBAAA;AAAA,IACN,SAAA,EAAW,IAAI,kBAAA,EAAmB;AAAA,IAClC,MAAM,MAAA,EAAoB;AACxB,MAAA,WAAA,IAAe,KAAA,CAAM,IAAI,0CAA0C,CAAA;AACnE,MAAA,IAAA,CAAK,SAAA,CAAU,WAAW,MAAM,CAAA;AAChC,MAAA;AAAA,IACF;AAAA,GACF;AACF,CAAA,CAAA;AAEO,MAAM,wBAAA,GAA2B,kBAAkB,yBAAyB;;;;"}
@@ -1 +1 @@
1
- {"type":"module","version":"11.0.0-alpha.0","sideEffects":false}
1
+ {"type":"module","version":"11.0.0-alpha.2","sideEffects":false}
@@ -2,12 +2,6 @@ import type { ProfilingIntegration } from '@sentry/core';
2
2
  import type { NodeClient } from '@sentry/node';
3
3
  /** Exported only for tests. */
4
4
  export declare const _nodeProfilingIntegration: () => ProfilingIntegration<NodeClient>;
5
- /**
6
- * We need this integration in order to send data to Sentry. We hook into the event processor
7
- * and inspect each event to see if it is a transaction event and if that transaction event
8
- * contains a profile on it's metadata. If that is the case, we create a profiling event envelope
9
- * and delete the profile from the transaction metadata.
10
- */
11
5
  export declare const nodeProfilingIntegration: () => import("@sentry/core").Integration & {
12
6
  name: string;
13
7
  };
@@ -1 +1 @@
1
- {"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../../src/integration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA+C,oBAAoB,EAAQ,MAAM,cAAc,CAAC;AAa5G,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,cAAc,CAAC;AAsnB5D,+BAA+B;AAC/B,eAAO,MAAM,yBAAyB,QAAQ,oBAAoB,CAAC,UAAU,CAsBnD,CAAC;AAqB3B;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB;;CAA+C,CAAC"}
1
+ {"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../../src/integration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAsC,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAE7F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA2Y/C,+BAA+B;AAC/B,eAAO,MAAM,yBAAyB,QAAQ,oBAAoB,CAAC,UAAU,CAsBnD,CAAC;AAE3B,eAAO,MAAM,wBAAwB;;CAA+C,CAAC"}
@@ -1,22 +1,15 @@
1
- import type { Client, ContinuousThreadCpuProfile, DebugImage, DsnComponents, Envelope, Event, EventEnvelopeHeaders, Profile, ProfileChunk, ProfileChunkEnvelope, SdkInfo, ThreadCpuProfile } from '@sentry/core';
2
- import type { RawChunkCpuProfile, RawThreadCpuProfile } from '@sentry/node-cpu-profiler';
1
+ import type { Client, ContinuousThreadCpuProfile, DebugImage, DsnComponents, EventEnvelopeHeaders, ProfileChunk, ProfileChunkEnvelope, SdkInfo } from '@sentry/core';
2
+ import type { RawChunkCpuProfile } from '@sentry/node-cpu-profiler';
3
3
  export declare const PROFILER_THREAD_ID_STRING: string;
4
4
  export declare const PROFILER_THREAD_NAME: string;
5
5
  /**
6
6
  * Enriches the profile with threadId of the current thread.
7
7
  * This is done in node as we seem to not be able to get the info from C native code.
8
8
  *
9
- * @param {ThreadCpuProfile | RawThreadCpuProfile} profile
10
- * @returns {ThreadCpuProfile}
9
+ * @param {ContinuousThreadCpuProfile | RawChunkCpuProfile} profile
10
+ * @returns {ContinuousThreadCpuProfile}
11
11
  */
12
- export declare function enrichWithThreadInformation(profile: ThreadCpuProfile | RawThreadCpuProfile | ContinuousThreadCpuProfile | RawChunkCpuProfile): ThreadCpuProfile | ContinuousThreadCpuProfile;
13
- /**
14
- * Creates a profiling envelope item, if the profile does not pass validation, returns null.
15
- * @param {RawThreadCpuProfile}
16
- * @param {Event}
17
- * @returns {Profile | null}
18
- */
19
- export declare function createProfilingEvent(client: Client, profile: RawThreadCpuProfile, event: Event): Profile | null;
12
+ export declare function enrichWithThreadInformation(profile: ContinuousThreadCpuProfile | RawChunkCpuProfile): ContinuousThreadCpuProfile;
20
13
  /**
21
14
  * Creates a profiling chunk envelope item, if the profile does not pass validation, returns null.
22
15
  */
@@ -28,39 +21,12 @@ export declare function createProfilingChunkEvent(client: Client, options: {
28
21
  chunk_id: string;
29
22
  profiler_id: string;
30
23
  }): ProfileChunk | null;
31
- /**
32
- * Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1).
33
- * @param {unknown} rate
34
- * @returns {boolean}
35
- */
36
- export declare function isValidSampleRate(rate: unknown): boolean;
37
- /**
38
- * Checks if the profile is valid and can be sent to Sentry.
39
- * @param {RawThreadCpuProfile} profile
40
- * @returns {boolean}
41
- */
42
- export declare function isValidProfile(profile: RawThreadCpuProfile): profile is RawThreadCpuProfile & {
43
- profile_id: string;
44
- };
45
24
  /**
46
25
  * Checks if the profile chunk is valid and can be sent to Sentry.
47
26
  * @param profile
48
27
  * @returns
49
28
  */
50
29
  export declare function isValidProfileChunk(profile: RawChunkCpuProfile): profile is RawChunkCpuProfile;
51
- /**
52
- * Adds items to envelope if they are not already present - mutates the envelope.
53
- * @param {Envelope} envelope
54
- * @param {Profile[]} profiles
55
- * @returns {Envelope}
56
- */
57
- export declare function addProfilesToEnvelope(envelope: Envelope, profiles: Profile[]): Envelope;
58
- /**
59
- * Finds transactions with profile_id context in the envelope
60
- * @param {Envelope} envelope
61
- * @returns {Event[]}
62
- */
63
- export declare function findProfiledTransactionsFromEnvelope(envelope: Envelope): Event[];
64
30
  /**
65
31
  * Creates event envelope headers for a profile chunk. This is separate from createEventEnvelopeHeaders util
66
32
  * as the profile chunk does not conform to the sentry event type
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,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;AAStB,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAQzF,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;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O,EAAE,OAAO,GAAG,SAAS,EAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,GAAG,CAAC,EAAE,aAAa,GAClB,oBAAoB,CAStB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,UAAU,EAAE,CAQtG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/profiling-node",
3
- "version": "11.0.0-alpha.0",
3
+ "version": "11.0.0-alpha.2",
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",
@@ -35,6 +35,7 @@
35
35
  "scripts": {
36
36
  "clean": "rm -rf build",
37
37
  "lint": "oxlint . --type-aware",
38
+ "lint:types": "oxlint src --type-aware --type-check",
38
39
  "lint:es-compatibility": "es-check es2022 ./build/cjs/*.js && es-check es2022 ./build/esm/*.js --module",
39
40
  "lint:fix": "oxlint . --fix --type-aware",
40
41
  "build": "yarn build:types && yarn build:transpile",
@@ -50,8 +51,8 @@
50
51
  },
51
52
  "dependencies": {
52
53
  "@sentry/node-cpu-profiler": "^2.4.3",
53
- "@sentry/core": "11.0.0-alpha.0",
54
- "@sentry/node": "11.0.0-alpha.0"
54
+ "@sentry/core": "11.0.0-alpha.2",
55
+ "@sentry/node": "11.0.0-alpha.2"
55
56
  },
56
57
  "devDependencies": {
57
58
  "@types/node": "^18.19.1"
@@ -1,17 +0,0 @@
1
- import type { CustomSamplingContext, Span } from '@sentry/core';
2
- import type { NodeClient } from '@sentry/node';
3
- import { type RawThreadCpuProfile } from '@sentry/node-cpu-profiler';
4
- export declare const MAX_PROFILE_DURATION_MS: number;
5
- /**
6
- * Takes a transaction and determines if it should be profiled or not. If it should be profiled, it returns the
7
- * profile_id, otherwise returns undefined. Takes care of setting profile context on transaction as well
8
- */
9
- export declare function maybeProfileSpan(client: NodeClient | undefined, span: Span, customSamplingContext?: CustomSamplingContext): string | undefined;
10
- /**
11
- * Stops the profiler for profile_id and returns the profile
12
- * @param transaction
13
- * @param profile_id
14
- * @returns
15
- */
16
- export declare function stopSpanProfile(span: Span, profile_id: string | undefined): RawThreadCpuProfile | null;
17
- //# sourceMappingURL=spanProfileUtils.d.ts.map
@@ -1 +0,0 @@
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;AAC/C,OAAO,EAAuB,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAK1F,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,CAqFpB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,mBAAmB,GAAG,IAAI,CAsBtG"}