@sentry/profiling-node 8.53.0 → 9.0.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/README.md +2 -3
- package/lib/cjs/index.js +34 -45
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/index.js +33 -39
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/package.json +1 -1
- package/lib/sentry_cpu_profiler-darwin-arm64-108.node +0 -0
- package/lib/sentry_cpu_profiler-darwin-arm64-115.node +0 -0
- package/lib/sentry_cpu_profiler-darwin-arm64-127.node +0 -0
- package/lib/sentry_cpu_profiler-darwin-x64-108.node +0 -0
- package/lib/sentry_cpu_profiler-darwin-x64-115.node +0 -0
- package/lib/sentry_cpu_profiler-darwin-x64-127.node +0 -0
- package/lib/sentry_cpu_profiler-win32-x64-108.node +0 -0
- package/lib/sentry_cpu_profiler-win32-x64-115.node +0 -0
- package/lib/sentry_cpu_profiler-win32-x64-127.node +0 -0
- package/lib/types/integration.d.ts.map +1 -1
- package/lib/types/spanProfileUtils.d.ts.map +1 -1
- package/lib/types/utils.d.ts.map +1 -1
- package/package.json +6 -6
- package/lib/sentry_cpu_profiler-darwin-arm64-93.node +0 -0
- package/lib/sentry_cpu_profiler-darwin-x64-93.node +0 -0
- package/lib/sentry_cpu_profiler-linux-arm64-glibc-93.node +0 -0
- package/lib/sentry_cpu_profiler-linux-arm64-musl-93.node +0 -0
- package/lib/sentry_cpu_profiler-linux-x64-glibc-93.node +0 -0
- package/lib/sentry_cpu_profiler-linux-x64-musl-93.node +0 -0
- package/lib/sentry_cpu_profiler-win32-x64-93.node +0 -0
package/README.md
CHANGED
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
15
|
-
Profiling works as an extension of tracing so you will need both @sentry/node and @sentry/profiling-node installed.
|
|
16
|
-
minimum required major version of @sentry/node that supports profiling is 7.x.
|
|
15
|
+
Profiling works as an extension of tracing so you will need both @sentry/node and @sentry/profiling-node installed.
|
|
17
16
|
|
|
18
17
|
```bash
|
|
19
18
|
# Using yarn
|
|
@@ -84,7 +83,7 @@ After the binaries are built, you should see them inside the profiling-node/lib
|
|
|
84
83
|
|
|
85
84
|
### Prebuilt binaries
|
|
86
85
|
|
|
87
|
-
We currently ship prebuilt binaries for a few of the most common platforms and node versions (
|
|
86
|
+
We currently ship prebuilt binaries for a few of the most common platforms and node versions (v18-22).
|
|
88
87
|
|
|
89
88
|
- macOS x64
|
|
90
89
|
- Linux ARM64 (musl)
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
_nullishCoalesce,
|
|
3
|
-
_optionalChain,
|
|
4
|
-
_optionalChainDelete
|
|
5
|
-
} = require('@sentry/core');
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
8
2
|
|
|
9
3
|
const core = require('@sentry/core');
|
|
10
4
|
const node_module = require('node:module');
|
|
@@ -228,7 +222,6 @@ const CpuProfilerBindings = new Bindings();
|
|
|
228
222
|
const NODE_VERSION = core.parseSemver(process.versions.node) ;
|
|
229
223
|
const NODE_MAJOR = NODE_VERSION.major;
|
|
230
224
|
|
|
231
|
-
function _nullishCoalesce$1(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
232
225
|
// We require the file because if we import it, it will be included in the bundle.
|
|
233
226
|
// I guess tsc does not check file contents when it's imported.
|
|
234
227
|
const PROFILER_THREAD_ID_STRING = String(worker_threads.threadId);
|
|
@@ -236,16 +229,12 @@ const PROFILER_THREAD_NAME = worker_threads.isMainThread ? 'main' : 'worker';
|
|
|
236
229
|
const FORMAT_VERSION = '1';
|
|
237
230
|
const CONTINUOUS_FORMAT_VERSION = '2';
|
|
238
231
|
|
|
239
|
-
// Os machine was backported to 16.18, but this was not reflected in the types
|
|
240
|
-
// @ts-expect-error ignore missing
|
|
241
|
-
const machine = typeof os.machine === 'function' ? os.machine() : os.arch();
|
|
242
|
-
|
|
243
232
|
// Machine properties (eval only once)
|
|
244
233
|
const PLATFORM = os.platform();
|
|
245
234
|
const RELEASE = os.release();
|
|
246
235
|
const VERSION = os.version();
|
|
247
236
|
const TYPE = os.type();
|
|
248
|
-
const MODEL = machine;
|
|
237
|
+
const MODEL = os.machine();
|
|
249
238
|
const ARCH = os.arch();
|
|
250
239
|
|
|
251
240
|
/**
|
|
@@ -297,12 +286,12 @@ function createProfilingEvent(client, profile, event) {
|
|
|
297
286
|
}
|
|
298
287
|
|
|
299
288
|
return createProfilePayload(client, profile, {
|
|
300
|
-
release:
|
|
301
|
-
environment:
|
|
302
|
-
event_id:
|
|
303
|
-
transaction:
|
|
289
|
+
release: event.release ?? '',
|
|
290
|
+
environment: event.environment ?? '',
|
|
291
|
+
event_id: event.event_id ?? '',
|
|
292
|
+
transaction: event.transaction ?? '',
|
|
304
293
|
start_timestamp: event.start_timestamp ? event.start_timestamp * 1000 : Date.now(),
|
|
305
|
-
trace_id:
|
|
294
|
+
trace_id: event.contexts?.['trace']?.['trace_id'] ?? '',
|
|
306
295
|
profile_id: profile.profile_id,
|
|
307
296
|
});
|
|
308
297
|
}
|
|
@@ -331,7 +320,7 @@ function createProfilePayload(
|
|
|
331
320
|
// Log a warning if the profile has an invalid traceId (should be uuidv4).
|
|
332
321
|
// All profiles and transactions are rejected if this is the case and we want to
|
|
333
322
|
// warn users that this is happening if they enable debug flag
|
|
334
|
-
if (trace_id
|
|
323
|
+
if (trace_id?.length !== 32) {
|
|
335
324
|
DEBUG_BUILD && core.logger.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`);
|
|
336
325
|
}
|
|
337
326
|
|
|
@@ -399,7 +388,7 @@ function createProfileChunkPayload(
|
|
|
399
388
|
// Log a warning if the profile has an invalid traceId (should be uuidv4).
|
|
400
389
|
// All profiles and transactions are rejected if this is the case and we want to
|
|
401
390
|
// warn users that this is happening if they enable debug flag
|
|
402
|
-
if (trace_id
|
|
391
|
+
if (trace_id?.length !== 32) {
|
|
403
392
|
DEBUG_BUILD && core.logger.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`);
|
|
404
393
|
}
|
|
405
394
|
|
|
@@ -408,8 +397,8 @@ function createProfileChunkPayload(
|
|
|
408
397
|
const profile = {
|
|
409
398
|
chunk_id: chunk_id,
|
|
410
399
|
client_sdk: {
|
|
411
|
-
name:
|
|
412
|
-
version:
|
|
400
|
+
name: sdk?.name ?? 'sentry.javascript.node',
|
|
401
|
+
version: sdk?.version ?? '0.0.0',
|
|
413
402
|
},
|
|
414
403
|
profiler_id: profiler_id,
|
|
415
404
|
platform: 'node',
|
|
@@ -441,9 +430,9 @@ function createProfilingChunkEvent(
|
|
|
441
430
|
}
|
|
442
431
|
|
|
443
432
|
return createProfileChunkPayload(client, profile, {
|
|
444
|
-
release:
|
|
445
|
-
environment:
|
|
446
|
-
trace_id:
|
|
433
|
+
release: options.release ?? '',
|
|
434
|
+
environment: options.environment ?? '',
|
|
435
|
+
trace_id: identifiers.trace_id ?? '',
|
|
447
436
|
chunk_id: identifiers.chunk_id,
|
|
448
437
|
profiler_id: identifiers.profiler_id,
|
|
449
438
|
sdk,
|
|
@@ -561,7 +550,7 @@ function findProfiledTransactionsFromEnvelope(envelope) {
|
|
|
561
550
|
}
|
|
562
551
|
|
|
563
552
|
// @ts-expect-error profile_id is not part of the metadata type
|
|
564
|
-
const profile_id =
|
|
553
|
+
const profile_id = (event.contexts )?.['profile']?.['profile_id'];
|
|
565
554
|
|
|
566
555
|
if (event && profile_id) {
|
|
567
556
|
events.push(item[j] );
|
|
@@ -615,7 +604,7 @@ function makeProfileChunkEnvelope(
|
|
|
615
604
|
function applyDebugMetadata(client, resource_paths) {
|
|
616
605
|
const options = client.getOptions();
|
|
617
606
|
|
|
618
|
-
if (!options
|
|
607
|
+
if (!options?.stackParser) {
|
|
619
608
|
return [];
|
|
620
609
|
}
|
|
621
610
|
|
|
@@ -664,10 +653,6 @@ function maybeProfileSpan(
|
|
|
664
653
|
profilesSampleRate = profilesSampler({
|
|
665
654
|
name: spanName,
|
|
666
655
|
attributes: data,
|
|
667
|
-
transactionContext: {
|
|
668
|
-
name: spanName,
|
|
669
|
-
parentSampled,
|
|
670
|
-
},
|
|
671
656
|
parentSampled,
|
|
672
657
|
...customSamplingContext,
|
|
673
658
|
});
|
|
@@ -746,7 +731,7 @@ function stopSpanProfile(span, profile_id) {
|
|
|
746
731
|
return profile;
|
|
747
732
|
}
|
|
748
733
|
|
|
749
|
-
var ProfileFormat;(function (ProfileFormat) {
|
|
734
|
+
var ProfileFormat; (function (ProfileFormat) {
|
|
750
735
|
const THREAD = 0; ProfileFormat[ProfileFormat["THREAD"] = THREAD] = "THREAD";
|
|
751
736
|
const CHUNK = 1; ProfileFormat[ProfileFormat["CHUNK"] = CHUNK] = "CHUNK";
|
|
752
737
|
})(ProfileFormat || (ProfileFormat = {}));
|
|
@@ -783,8 +768,7 @@ function setupAutomatedSpanProfiling(client) {
|
|
|
783
768
|
const options = client.getOptions();
|
|
784
769
|
// Not intended for external use, hence missing types, but we want to profile a couple of things at Sentry that
|
|
785
770
|
// currently exceed the default timeout set by the SDKs.
|
|
786
|
-
const maxProfileDurationMs =
|
|
787
|
-
(options._experiments && options._experiments['maxProfileDurationMs']) || MAX_PROFILE_DURATION_MS;
|
|
771
|
+
const maxProfileDurationMs = options._experiments?.maxProfileDurationMs || MAX_PROFILE_DURATION_MS;
|
|
788
772
|
|
|
789
773
|
if (PROFILE_TIMEOUTS[profile_id]) {
|
|
790
774
|
global.clearTimeout(PROFILE_TIMEOUTS[profile_id]);
|
|
@@ -842,8 +826,8 @@ function setupAutomatedSpanProfiling(client) {
|
|
|
842
826
|
const profilesToAddToEnvelope = [];
|
|
843
827
|
|
|
844
828
|
for (const profiledTransaction of profiledTransactionEvents) {
|
|
845
|
-
const profileContext =
|
|
846
|
-
const profile_id =
|
|
829
|
+
const profileContext = profiledTransaction.contexts?.['profile'];
|
|
830
|
+
const profile_id = profileContext?.['profile_id'];
|
|
847
831
|
|
|
848
832
|
if (!profile_id) {
|
|
849
833
|
throw new TypeError('[Profiling] cannot find profile for a transaction without a profile context');
|
|
@@ -851,7 +835,7 @@ function setupAutomatedSpanProfiling(client) {
|
|
|
851
835
|
|
|
852
836
|
// Remove the profile from the transaction context before sending, relay will take care of the rest.
|
|
853
837
|
if (profileContext) {
|
|
854
|
-
|
|
838
|
+
delete profiledTransaction.contexts?.['profile'];
|
|
855
839
|
}
|
|
856
840
|
|
|
857
841
|
const cpuProfile = takeFromProfileQueue(profile_id);
|
|
@@ -869,6 +853,11 @@ function setupAutomatedSpanProfiling(client) {
|
|
|
869
853
|
client.emit('preprocessEvent', profile, {
|
|
870
854
|
event_id: profiledTransaction.event_id,
|
|
871
855
|
});
|
|
856
|
+
|
|
857
|
+
// @ts-expect-error profile does not inherit from Event
|
|
858
|
+
client.emit('postprocessEvent', profile, {
|
|
859
|
+
event_id: profiledTransaction.event_id,
|
|
860
|
+
});
|
|
872
861
|
}
|
|
873
862
|
|
|
874
863
|
addProfilesToEnvelope(envelope, profilesToAddToEnvelope);
|
|
@@ -951,7 +940,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
951
940
|
* Stops profiling of the current chunks and flushes the profile to Sentry
|
|
952
941
|
*/
|
|
953
942
|
_chunkStop() {
|
|
954
|
-
if (
|
|
943
|
+
if (this._chunkData?.timer) {
|
|
955
944
|
global.clearTimeout(this._chunkData.timer);
|
|
956
945
|
this._chunkData.timer = undefined;
|
|
957
946
|
DEBUG_BUILD && core.logger.log(`[Profiling] Stopping profiling chunk: ${this._chunkData.id}`);
|
|
@@ -961,9 +950,9 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
961
950
|
core.logger.log('[Profiling] Failed to collect profile, sentry client was never attached to the profiler.');
|
|
962
951
|
return;
|
|
963
952
|
}
|
|
964
|
-
if (!
|
|
953
|
+
if (!this._chunkData?.id) {
|
|
965
954
|
DEBUG_BUILD &&
|
|
966
|
-
core.logger.log(`[Profiling] Failed to collect profile for: ${
|
|
955
|
+
core.logger.log(`[Profiling] Failed to collect profile for: ${this._chunkData?.id}, the chunk_id is missing.`);
|
|
967
956
|
return;
|
|
968
957
|
}
|
|
969
958
|
|
|
@@ -987,7 +976,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
987
976
|
this._client,
|
|
988
977
|
this._client.getOptions(),
|
|
989
978
|
profile,
|
|
990
|
-
|
|
979
|
+
this._client.getSdkMetadata()?.sdk,
|
|
991
980
|
{
|
|
992
981
|
chunk_id: this._chunkData.id,
|
|
993
982
|
trace_id: this._chunkData.startTraceID,
|
|
@@ -1030,7 +1019,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
1030
1019
|
const metadata = this._client.getSdkMetadata();
|
|
1031
1020
|
const tunnel = this._client.getOptions().tunnel;
|
|
1032
1021
|
|
|
1033
|
-
const envelope = makeProfileChunkEnvelope(chunk,
|
|
1022
|
+
const envelope = makeProfileChunkEnvelope(chunk, metadata?.sdk, tunnel, dsn);
|
|
1034
1023
|
transport.send(envelope).then(null, reason => {
|
|
1035
1024
|
DEBUG_BUILD && core.logger.error('Error while sending profile chunk envelope:', reason);
|
|
1036
1025
|
});
|
|
@@ -1111,7 +1100,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
1111
1100
|
* Assigns thread_id and thread name context to a profiled event.
|
|
1112
1101
|
*/
|
|
1113
1102
|
_assignThreadIdContext(event) {
|
|
1114
|
-
if (!
|
|
1103
|
+
if (!event?.['contexts']?.['profile']) {
|
|
1115
1104
|
return;
|
|
1116
1105
|
}
|
|
1117
1106
|
|
|
@@ -1122,9 +1111,9 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
1122
1111
|
// @ts-expect-error the trace fallback value is wrong, though it should never happen
|
|
1123
1112
|
// and in case it does, we dont want to override whatever was passed initially.
|
|
1124
1113
|
event.contexts['trace'] = {
|
|
1125
|
-
...(
|
|
1114
|
+
...(event.contexts?.['trace'] ?? {}),
|
|
1126
1115
|
data: {
|
|
1127
|
-
...(
|
|
1116
|
+
...(event.contexts?.['trace']?.['data'] ?? {}),
|
|
1128
1117
|
['thread.id']: PROFILER_THREAD_ID_STRING,
|
|
1129
1118
|
['thread.name']: PROFILER_THREAD_NAME,
|
|
1130
1119
|
},
|