@sentry/profiling-node 9.38.0 → 9.39.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/build/cjs/index.js +56 -58
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.js +57 -59
- package/build/esm/index.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/types/integration.d.ts.map +1 -1
- package/package.json +3 -3
package/build/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseSemver, forEachEnvelopeItem, createEnvelope,
|
|
1
|
+
import { parseSemver, forEachEnvelopeItem, createEnvelope, debug, dsnToString, uuid4, getDebugImagesForResources, spanIsSampled, spanToJSON, LRUMap, defineIntegration, consoleSandbox, getRootSpan, getIsolationScope, getCurrentScope, getGlobalScope } from '@sentry/core';
|
|
2
2
|
import { CpuProfilerBindings, ProfileFormat } from '@sentry-internal/node-cpu-profiler';
|
|
3
3
|
import * as os from 'os';
|
|
4
4
|
import { env, versions } from 'process';
|
|
@@ -113,7 +113,7 @@ function createProfilePayload(
|
|
|
113
113
|
// All profiles and transactions are rejected if this is the case and we want to
|
|
114
114
|
// warn users that this is happening if they enable debug flag
|
|
115
115
|
if (trace_id?.length !== 32) {
|
|
116
|
-
DEBUG_BUILD &&
|
|
116
|
+
DEBUG_BUILD && debug.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
const enrichedThreadProfile = enrichWithThreadInformation(cpuProfile);
|
|
@@ -181,7 +181,7 @@ function createProfileChunkPayload(
|
|
|
181
181
|
// All profiles and transactions are rejected if this is the case and we want to
|
|
182
182
|
// warn users that this is happening if they enable debug flag
|
|
183
183
|
if (trace_id?.length !== 32) {
|
|
184
|
-
DEBUG_BUILD &&
|
|
184
|
+
DEBUG_BUILD && debug.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`);
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
const enrichedThreadProfile = enrichWithThreadInformation(cpuProfile);
|
|
@@ -240,7 +240,7 @@ function isValidSampleRate(rate) {
|
|
|
240
240
|
// we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck
|
|
241
241
|
if ((typeof rate !== 'number' && typeof rate !== 'boolean') || (typeof rate === 'number' && isNaN(rate))) {
|
|
242
242
|
DEBUG_BUILD &&
|
|
243
|
-
|
|
243
|
+
debug.warn(
|
|
244
244
|
`[Profiling] Invalid sample rate. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(
|
|
245
245
|
rate,
|
|
246
246
|
)} of type ${JSON.stringify(typeof rate)}.`,
|
|
@@ -255,7 +255,7 @@ function isValidSampleRate(rate) {
|
|
|
255
255
|
|
|
256
256
|
// in case sampleRate is a boolean, it will get automatically cast to 1 if it's true and 0 if it's false
|
|
257
257
|
if (rate < 0 || rate > 1) {
|
|
258
|
-
DEBUG_BUILD &&
|
|
258
|
+
DEBUG_BUILD && debug.warn(`[Profiling] Invalid sample rate. Sample rate must be between 0 and 1. Got ${rate}.`);
|
|
259
259
|
return false;
|
|
260
260
|
}
|
|
261
261
|
return true;
|
|
@@ -272,7 +272,7 @@ function isValidProfile(profile) {
|
|
|
272
272
|
// Log a warning if the profile has less than 2 samples so users can know why
|
|
273
273
|
// they are not seeing any profiling data and we cant avoid the back and forth
|
|
274
274
|
// of asking them to provide us with a dump of the profile data.
|
|
275
|
-
|
|
275
|
+
debug.log('[Profiling] Discarding profile because it contains less than 2 samples');
|
|
276
276
|
return false;
|
|
277
277
|
}
|
|
278
278
|
|
|
@@ -294,7 +294,7 @@ function isValidProfileChunk(profile) {
|
|
|
294
294
|
// Log a warning if the profile has less than 2 samples so users can know why
|
|
295
295
|
// they are not seeing any profiling data and we cant avoid the back and forth
|
|
296
296
|
// of asking them to provide us with a dump of the profile data.
|
|
297
|
-
|
|
297
|
+
debug.log('[Profiling] Discarding profile chunk because it contains less than 2 samples');
|
|
298
298
|
return false;
|
|
299
299
|
}
|
|
300
300
|
|
|
@@ -424,13 +424,13 @@ function maybeProfileSpan(
|
|
|
424
424
|
|
|
425
425
|
// Client and options are required for profiling
|
|
426
426
|
if (!client) {
|
|
427
|
-
DEBUG_BUILD &&
|
|
427
|
+
DEBUG_BUILD && debug.log('[Profiling] Profiling disabled, no client found.');
|
|
428
428
|
return;
|
|
429
429
|
}
|
|
430
430
|
|
|
431
431
|
const options = client.getOptions();
|
|
432
432
|
if (!options) {
|
|
433
|
-
DEBUG_BUILD &&
|
|
433
|
+
DEBUG_BUILD && debug.log('[Profiling] Profiling disabled, no options found.');
|
|
434
434
|
return;
|
|
435
435
|
}
|
|
436
436
|
|
|
@@ -454,14 +454,14 @@ function maybeProfileSpan(
|
|
|
454
454
|
// Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The
|
|
455
455
|
// only valid values are booleans or numbers between 0 and 1.)
|
|
456
456
|
if (!isValidSampleRate(profilesSampleRate)) {
|
|
457
|
-
DEBUG_BUILD &&
|
|
457
|
+
DEBUG_BUILD && debug.warn('[Profiling] Discarding profile because of invalid sample rate.');
|
|
458
458
|
return;
|
|
459
459
|
}
|
|
460
460
|
|
|
461
461
|
// if the function returned 0 (or false), or if `profileSampleRate` is 0, it's a sign the profile should be dropped
|
|
462
462
|
if (!profilesSampleRate) {
|
|
463
463
|
DEBUG_BUILD &&
|
|
464
|
-
|
|
464
|
+
debug.log(
|
|
465
465
|
`[Profiling] Discarding profile because ${
|
|
466
466
|
typeof profilesSampler === 'function'
|
|
467
467
|
? 'profileSampler returned 0 or false'
|
|
@@ -477,7 +477,7 @@ function maybeProfileSpan(
|
|
|
477
477
|
// Check if we should sample this profile
|
|
478
478
|
if (!sampled) {
|
|
479
479
|
DEBUG_BUILD &&
|
|
480
|
-
|
|
480
|
+
debug.log(
|
|
481
481
|
`[Profiling] Discarding profile because it's not included in the random sample (sampling rate = ${Number(
|
|
482
482
|
profilesSampleRate,
|
|
483
483
|
)})`,
|
|
@@ -487,7 +487,7 @@ function maybeProfileSpan(
|
|
|
487
487
|
|
|
488
488
|
const profile_id = uuid4();
|
|
489
489
|
CpuProfilerBindings.startProfiling(profile_id);
|
|
490
|
-
DEBUG_BUILD &&
|
|
490
|
+
DEBUG_BUILD && debug.log(`[Profiling] started profiling transaction: ${spanToJSON(span).description}`);
|
|
491
491
|
|
|
492
492
|
// set transaction context - do this regardless if profiling fails down the line
|
|
493
493
|
// so that we can still see the profile_id in the transaction context
|
|
@@ -507,12 +507,12 @@ function stopSpanProfile(span, profile_id) {
|
|
|
507
507
|
}
|
|
508
508
|
|
|
509
509
|
const profile = CpuProfilerBindings.stopProfiling(profile_id, 0);
|
|
510
|
-
DEBUG_BUILD &&
|
|
510
|
+
DEBUG_BUILD && debug.log(`[Profiling] stopped profiling of transaction: ${spanToJSON(span).description}`);
|
|
511
511
|
|
|
512
512
|
// In case of an overlapping span, stopProfiling may return null and silently ignore the overlapping profile.
|
|
513
513
|
if (!profile) {
|
|
514
514
|
DEBUG_BUILD &&
|
|
515
|
-
|
|
515
|
+
debug.log(
|
|
516
516
|
`[Profiling] profiler returned null profile for: ${spanToJSON(span).description}`,
|
|
517
517
|
'this may indicate an overlapping span or a call to stopProfiling with a profile title that was never started',
|
|
518
518
|
);
|
|
@@ -566,7 +566,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
566
566
|
this._legacyProfilerMode =
|
|
567
567
|
'profilesSampleRate' in options || 'profilesSampler' in options ? 'span' : 'continuous';
|
|
568
568
|
|
|
569
|
-
DEBUG_BUILD &&
|
|
569
|
+
DEBUG_BUILD && debug.log(`[Profiling] Profiling mode is ${this._legacyProfilerMode}.`);
|
|
570
570
|
|
|
571
571
|
switch (this._legacyProfilerMode) {
|
|
572
572
|
case 'span': {
|
|
@@ -579,7 +579,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
579
579
|
}
|
|
580
580
|
default: {
|
|
581
581
|
DEBUG_BUILD &&
|
|
582
|
-
|
|
582
|
+
debug.warn(
|
|
583
583
|
`[Profiling] Unknown profiler mode: ${this._legacyProfilerMode}, profiler was not initialized`,
|
|
584
584
|
);
|
|
585
585
|
break;
|
|
@@ -591,7 +591,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
591
591
|
case 'current': {
|
|
592
592
|
this._setupSpanChunkInstrumentation();
|
|
593
593
|
|
|
594
|
-
DEBUG_BUILD &&
|
|
594
|
+
DEBUG_BUILD && debug.log(`[Profiling] Profiling mode is ${this._profileLifecycle}.`);
|
|
595
595
|
|
|
596
596
|
switch (this._profileLifecycle) {
|
|
597
597
|
case 'trace': {
|
|
@@ -604,14 +604,14 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
604
604
|
}
|
|
605
605
|
default: {
|
|
606
606
|
DEBUG_BUILD &&
|
|
607
|
-
|
|
607
|
+
debug.warn(`[Profiling] Unknown profiler mode: ${this._profileLifecycle}, profiler was not initialized`);
|
|
608
608
|
break;
|
|
609
609
|
}
|
|
610
610
|
}
|
|
611
611
|
break;
|
|
612
612
|
}
|
|
613
613
|
default: {
|
|
614
|
-
DEBUG_BUILD &&
|
|
614
|
+
DEBUG_BUILD && debug.warn(`[Profiling] Unknown profiler mode: ${this._mode}, profiler was not initialized`);
|
|
615
615
|
break;
|
|
616
616
|
}
|
|
617
617
|
}
|
|
@@ -633,17 +633,17 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
633
633
|
}
|
|
634
634
|
|
|
635
635
|
if (!this._client) {
|
|
636
|
-
DEBUG_BUILD &&
|
|
636
|
+
DEBUG_BUILD && debug.log('[Profiling] Failed to start, sentry client was never attached to the profiler.');
|
|
637
637
|
return;
|
|
638
638
|
}
|
|
639
639
|
|
|
640
640
|
if (this._mode !== 'legacy') {
|
|
641
|
-
DEBUG_BUILD &&
|
|
641
|
+
DEBUG_BUILD && debug.log('[Profiling] Continuous profiling is not supported in the current mode.');
|
|
642
642
|
return;
|
|
643
643
|
}
|
|
644
644
|
|
|
645
645
|
if (this._legacyProfilerMode === 'span') {
|
|
646
|
-
DEBUG_BUILD &&
|
|
646
|
+
DEBUG_BUILD && debug.log('[Profiling] Calls to profiler.start() are not supported in span profiling mode.');
|
|
647
647
|
return;
|
|
648
648
|
}
|
|
649
649
|
|
|
@@ -667,17 +667,17 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
667
667
|
}
|
|
668
668
|
|
|
669
669
|
if (!this._client) {
|
|
670
|
-
DEBUG_BUILD &&
|
|
670
|
+
DEBUG_BUILD && debug.log('[Profiling] Failed to stop, sentry client was never attached to the profiler.');
|
|
671
671
|
return;
|
|
672
672
|
}
|
|
673
673
|
|
|
674
674
|
if (this._mode !== 'legacy') {
|
|
675
|
-
DEBUG_BUILD &&
|
|
675
|
+
DEBUG_BUILD && debug.log('[Profiling] Continuous profiling is not supported in the current mode.');
|
|
676
676
|
return;
|
|
677
677
|
}
|
|
678
678
|
|
|
679
679
|
if (this._legacyProfilerMode === 'span') {
|
|
680
|
-
DEBUG_BUILD &&
|
|
680
|
+
DEBUG_BUILD && debug.log('[Profiling] Calls to profiler.stop() are not supported in span profiling mode.');
|
|
681
681
|
return;
|
|
682
682
|
}
|
|
683
683
|
|
|
@@ -687,25 +687,25 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
687
687
|
|
|
688
688
|
_startProfiler() {
|
|
689
689
|
if (this._mode !== 'current') {
|
|
690
|
-
DEBUG_BUILD &&
|
|
690
|
+
DEBUG_BUILD && debug.log('[Profiling] Continuous profiling is not supported in the current mode.');
|
|
691
691
|
return;
|
|
692
692
|
}
|
|
693
693
|
|
|
694
694
|
if (this._chunkData !== undefined) {
|
|
695
|
-
DEBUG_BUILD &&
|
|
695
|
+
DEBUG_BUILD && debug.log('[Profiling] Profile session already running, no-op.');
|
|
696
696
|
return;
|
|
697
697
|
}
|
|
698
698
|
|
|
699
699
|
if (this._mode === 'current') {
|
|
700
700
|
if (!this._sampled) {
|
|
701
|
-
DEBUG_BUILD &&
|
|
701
|
+
DEBUG_BUILD && debug.log('[Profiling] Profile session not sampled, no-op.');
|
|
702
702
|
return;
|
|
703
703
|
}
|
|
704
704
|
}
|
|
705
705
|
|
|
706
706
|
if (this._profileLifecycle === 'trace') {
|
|
707
707
|
DEBUG_BUILD &&
|
|
708
|
-
|
|
708
|
+
debug.log(
|
|
709
709
|
'[Profiling] You are using the trace profile lifecycle, manual calls to profiler.startProfiler() and profiler.stopProfiler() will be ignored.',
|
|
710
710
|
);
|
|
711
711
|
return;
|
|
@@ -716,20 +716,20 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
716
716
|
|
|
717
717
|
_stopProfiler() {
|
|
718
718
|
if (this._mode !== 'current') {
|
|
719
|
-
DEBUG_BUILD &&
|
|
719
|
+
DEBUG_BUILD && debug.log('[Profiling] Continuous profiling is not supported in the current mode.');
|
|
720
720
|
return;
|
|
721
721
|
}
|
|
722
722
|
|
|
723
723
|
if (this._profileLifecycle === 'trace') {
|
|
724
724
|
DEBUG_BUILD &&
|
|
725
|
-
|
|
725
|
+
debug.log(
|
|
726
726
|
'[Profiling] You are using the trace profile lifecycle, manual calls to profiler.startProfiler() and profiler.stopProfiler() will be ignored.',
|
|
727
727
|
);
|
|
728
728
|
return;
|
|
729
729
|
}
|
|
730
730
|
|
|
731
731
|
if (!this._chunkData) {
|
|
732
|
-
DEBUG_BUILD &&
|
|
732
|
+
DEBUG_BUILD && debug.log('[Profiling] No profile session running, no-op.');
|
|
733
733
|
return;
|
|
734
734
|
}
|
|
735
735
|
|
|
@@ -742,7 +742,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
742
742
|
_startTraceLifecycleProfiling() {
|
|
743
743
|
if (!this._client) {
|
|
744
744
|
DEBUG_BUILD &&
|
|
745
|
-
|
|
745
|
+
debug.log(
|
|
746
746
|
'[Profiling] Failed to start trace lifecycle profiling, sentry client was never attached to the profiler.',
|
|
747
747
|
);
|
|
748
748
|
return;
|
|
@@ -767,7 +767,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
767
767
|
_setupAutomaticSpanProfiling() {
|
|
768
768
|
if (!this._client) {
|
|
769
769
|
DEBUG_BUILD &&
|
|
770
|
-
|
|
770
|
+
debug.log(
|
|
771
771
|
'[Profiling] Failed to setup automatic span profiling, sentry client was never attached to the profiler.',
|
|
772
772
|
);
|
|
773
773
|
return;
|
|
@@ -798,7 +798,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
798
798
|
// Enqueue a timeout to prevent profiles from running over max duration.
|
|
799
799
|
const timeout = global.setTimeout(() => {
|
|
800
800
|
DEBUG_BUILD &&
|
|
801
|
-
|
|
801
|
+
debug.log(
|
|
802
802
|
'[Profiling] max profile duration elapsed, stopping profiling for:',
|
|
803
803
|
spanToJSON(span).description,
|
|
804
804
|
);
|
|
@@ -862,7 +862,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
862
862
|
|
|
863
863
|
const cpuProfile = takeFromProfileQueue(profile_id);
|
|
864
864
|
if (!cpuProfile) {
|
|
865
|
-
DEBUG_BUILD &&
|
|
865
|
+
DEBUG_BUILD && debug.log(`[Profiling] Could not retrieve profile for transaction: ${profile_id}`);
|
|
866
866
|
continue;
|
|
867
867
|
}
|
|
868
868
|
|
|
@@ -897,13 +897,13 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
897
897
|
// The client is not attached to the profiler if the user has not enabled continuous profiling.
|
|
898
898
|
// In this case, calling start() and stop() is a noop action.The reason this exists is because
|
|
899
899
|
// it makes the types easier to work with and avoids users having to do null checks.
|
|
900
|
-
DEBUG_BUILD &&
|
|
900
|
+
DEBUG_BUILD && debug.log('[Profiling] Profiler was never attached to the client.');
|
|
901
901
|
return;
|
|
902
902
|
}
|
|
903
903
|
|
|
904
904
|
if (this._chunkData) {
|
|
905
905
|
DEBUG_BUILD &&
|
|
906
|
-
|
|
906
|
+
debug.log(
|
|
907
907
|
`[Profiling] Chunk with chunk_id ${this._chunkData.id} is still running, current chunk will be stopped a new chunk will be started.`,
|
|
908
908
|
);
|
|
909
909
|
this._stopChunkProfiling();
|
|
@@ -917,26 +917,26 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
917
917
|
*/
|
|
918
918
|
_stopChunkProfiling() {
|
|
919
919
|
if (!this._chunkData) {
|
|
920
|
-
DEBUG_BUILD &&
|
|
920
|
+
DEBUG_BUILD && debug.log('[Profiling] No chunk data found, no-op.');
|
|
921
921
|
return;
|
|
922
922
|
}
|
|
923
923
|
|
|
924
924
|
if (this._chunkData?.timer) {
|
|
925
925
|
global.clearTimeout(this._chunkData.timer);
|
|
926
926
|
this._chunkData.timer = undefined;
|
|
927
|
-
DEBUG_BUILD &&
|
|
927
|
+
DEBUG_BUILD && debug.log(`[Profiling] Stopping profiling chunk: ${this._chunkData.id}`);
|
|
928
928
|
}
|
|
929
929
|
|
|
930
930
|
if (!this._client) {
|
|
931
931
|
DEBUG_BUILD &&
|
|
932
|
-
|
|
932
|
+
debug.log('[Profiling] Failed to collect profile, sentry client was never attached to the profiler.');
|
|
933
933
|
this._resetChunkData();
|
|
934
934
|
return;
|
|
935
935
|
}
|
|
936
936
|
|
|
937
937
|
if (!this._chunkData?.id) {
|
|
938
938
|
DEBUG_BUILD &&
|
|
939
|
-
|
|
939
|
+
debug.log(`[Profiling] Failed to collect profile for: ${this._chunkData?.id}, the chunk_id is missing.`);
|
|
940
940
|
this._resetChunkData();
|
|
941
941
|
return;
|
|
942
942
|
}
|
|
@@ -944,22 +944,22 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
944
944
|
const profile = CpuProfilerBindings.stopProfiling(this._chunkData.id, ProfileFormat.CHUNK);
|
|
945
945
|
|
|
946
946
|
if (!profile) {
|
|
947
|
-
DEBUG_BUILD &&
|
|
947
|
+
DEBUG_BUILD && debug.log(`[Profiling] Failed to collect profile for: ${this._chunkData.id}`);
|
|
948
948
|
this._resetChunkData();
|
|
949
949
|
return;
|
|
950
950
|
}
|
|
951
951
|
|
|
952
952
|
if (!this._profilerId) {
|
|
953
953
|
DEBUG_BUILD &&
|
|
954
|
-
|
|
954
|
+
debug.log('[Profiling] Profile chunk does not contain a valid profiler_id, this is a bug in the SDK');
|
|
955
955
|
this._resetChunkData();
|
|
956
956
|
return;
|
|
957
957
|
}
|
|
958
958
|
if (profile) {
|
|
959
|
-
DEBUG_BUILD &&
|
|
959
|
+
DEBUG_BUILD && debug.log(`[Profiling] Sending profile chunk ${this._chunkData.id}.`);
|
|
960
960
|
}
|
|
961
961
|
|
|
962
|
-
DEBUG_BUILD &&
|
|
962
|
+
DEBUG_BUILD && debug.log(`[Profiling] Profile chunk ${this._chunkData.id} sent to Sentry.`);
|
|
963
963
|
const chunk = createProfilingChunkEvent(
|
|
964
964
|
this._client,
|
|
965
965
|
this._client.getOptions(),
|
|
@@ -973,7 +973,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
973
973
|
);
|
|
974
974
|
|
|
975
975
|
if (!chunk) {
|
|
976
|
-
DEBUG_BUILD &&
|
|
976
|
+
DEBUG_BUILD && debug.log(`[Profiling] Failed to create profile chunk for: ${this._chunkData.id}`);
|
|
977
977
|
this._resetChunkData();
|
|
978
978
|
return;
|
|
979
979
|
}
|
|
@@ -993,13 +993,13 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
993
993
|
_flush(chunk) {
|
|
994
994
|
if (!this._client) {
|
|
995
995
|
DEBUG_BUILD &&
|
|
996
|
-
|
|
996
|
+
debug.log('[Profiling] Failed to collect profile, sentry client was never attached to the profiler.');
|
|
997
997
|
return;
|
|
998
998
|
}
|
|
999
999
|
|
|
1000
1000
|
const transport = this._client.getTransport();
|
|
1001
1001
|
if (!transport) {
|
|
1002
|
-
DEBUG_BUILD &&
|
|
1002
|
+
DEBUG_BUILD && debug.log('[Profiling] No transport available to send profile chunk.');
|
|
1003
1003
|
return;
|
|
1004
1004
|
}
|
|
1005
1005
|
|
|
@@ -1009,7 +1009,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
1009
1009
|
|
|
1010
1010
|
const envelope = makeProfileChunkEnvelope('node', chunk, metadata?.sdk, tunnel, dsn);
|
|
1011
1011
|
transport.send(envelope).then(null, reason => {
|
|
1012
|
-
DEBUG_BUILD &&
|
|
1012
|
+
DEBUG_BUILD && debug.error('Error while sending profile chunk envelope:', reason);
|
|
1013
1013
|
});
|
|
1014
1014
|
}
|
|
1015
1015
|
|
|
@@ -1019,7 +1019,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
1019
1019
|
*/
|
|
1020
1020
|
_startChunkProfiling() {
|
|
1021
1021
|
if (this._chunkData) {
|
|
1022
|
-
DEBUG_BUILD &&
|
|
1022
|
+
DEBUG_BUILD && debug.log('[Profiling] Chunk is already running, no-op.');
|
|
1023
1023
|
return;
|
|
1024
1024
|
}
|
|
1025
1025
|
|
|
@@ -1028,12 +1028,12 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
1028
1028
|
const chunk = this._initializeChunk(traceId);
|
|
1029
1029
|
|
|
1030
1030
|
CpuProfilerBindings.startProfiling(chunk.id);
|
|
1031
|
-
DEBUG_BUILD &&
|
|
1031
|
+
DEBUG_BUILD && debug.log(`[Profiling] starting profiling chunk: ${chunk.id}`);
|
|
1032
1032
|
|
|
1033
1033
|
chunk.timer = global.setTimeout(() => {
|
|
1034
|
-
DEBUG_BUILD &&
|
|
1034
|
+
DEBUG_BUILD && debug.log(`[Profiling] Stopping profiling chunk: ${chunk.id}`);
|
|
1035
1035
|
this._stopChunkProfiling();
|
|
1036
|
-
DEBUG_BUILD &&
|
|
1036
|
+
DEBUG_BUILD && debug.log('[Profiling] Starting new profiling chunk.');
|
|
1037
1037
|
setImmediate(this._restartChunkProfiling.bind(this));
|
|
1038
1038
|
}, CHUNK_INTERVAL_MS);
|
|
1039
1039
|
|
|
@@ -1048,9 +1048,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
|
|
|
1048
1048
|
_setupSpanChunkInstrumentation() {
|
|
1049
1049
|
if (!this._client) {
|
|
1050
1050
|
DEBUG_BUILD &&
|
|
1051
|
-
|
|
1052
|
-
'[Profiling] Failed to initialize span profiling, sentry client was never attached to the profiler.',
|
|
1053
|
-
);
|
|
1051
|
+
debug.log('[Profiling] Failed to initialize span profiling, sentry client was never attached to the profiler.');
|
|
1054
1052
|
return;
|
|
1055
1053
|
}
|
|
1056
1054
|
|
|
@@ -1139,7 +1137,7 @@ const _nodeProfilingIntegration = (() => {
|
|
|
1139
1137
|
name: 'ProfilingIntegration',
|
|
1140
1138
|
_profiler: new ContinuousProfiler(),
|
|
1141
1139
|
setup(client) {
|
|
1142
|
-
DEBUG_BUILD &&
|
|
1140
|
+
DEBUG_BUILD && debug.log('[Profiling] Profiling integration setup.');
|
|
1143
1141
|
this._profiler.initialize(client);
|
|
1144
1142
|
return;
|
|
1145
1143
|
},
|