@sentry/profiling-node 8.7.0 → 8.9.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.
Files changed (81) hide show
  1. package/bindings/cpu_profiler.cc +174 -73
  2. package/lib/cjs/index.js +479 -154
  3. package/lib/cjs/index.js.map +1 -1
  4. package/lib/esm/index.js +478 -154
  5. package/lib/esm/index.js.map +1 -1
  6. package/lib/sentry_cpu_profiler-darwin-arm64-108.node +0 -0
  7. package/lib/sentry_cpu_profiler-darwin-arm64-115.node +0 -0
  8. package/lib/sentry_cpu_profiler-darwin-arm64-127.node +0 -0
  9. package/lib/sentry_cpu_profiler-darwin-arm64-93.node +0 -0
  10. package/lib/sentry_cpu_profiler-darwin-x64-108.node +0 -0
  11. package/lib/sentry_cpu_profiler-darwin-x64-115.node +0 -0
  12. package/lib/sentry_cpu_profiler-darwin-x64-127.node +0 -0
  13. package/lib/sentry_cpu_profiler-darwin-x64-93.node +0 -0
  14. package/lib/sentry_cpu_profiler-linux-arm64-glibc-108.node +0 -0
  15. package/lib/sentry_cpu_profiler-linux-arm64-glibc-115.node +0 -0
  16. package/lib/sentry_cpu_profiler-linux-arm64-glibc-127.node +0 -0
  17. package/lib/sentry_cpu_profiler-linux-arm64-glibc-93.node +0 -0
  18. package/lib/sentry_cpu_profiler-linux-arm64-musl-108.node +0 -0
  19. package/lib/sentry_cpu_profiler-linux-arm64-musl-115.node +0 -0
  20. package/lib/sentry_cpu_profiler-linux-arm64-musl-127.node +0 -0
  21. package/lib/sentry_cpu_profiler-linux-arm64-musl-93.node +0 -0
  22. package/lib/sentry_cpu_profiler-linux-x64-glibc-108.node +0 -0
  23. package/lib/sentry_cpu_profiler-linux-x64-glibc-115.node +0 -0
  24. package/lib/sentry_cpu_profiler-linux-x64-glibc-127.node +0 -0
  25. package/lib/sentry_cpu_profiler-linux-x64-glibc-93.node +0 -0
  26. package/lib/sentry_cpu_profiler-linux-x64-musl-108.node +0 -0
  27. package/lib/sentry_cpu_profiler-linux-x64-musl-115.node +0 -0
  28. package/lib/sentry_cpu_profiler-linux-x64-musl-127.node +0 -0
  29. package/lib/sentry_cpu_profiler-linux-x64-musl-93.node +0 -0
  30. package/lib/sentry_cpu_profiler-win32-x64-108.node +0 -0
  31. package/lib/sentry_cpu_profiler-win32-x64-115.node +0 -0
  32. package/lib/sentry_cpu_profiler-win32-x64-127.node +0 -0
  33. package/lib/sentry_cpu_profiler-win32-x64-93.node +0 -0
  34. package/lib/types/profiling-node/src/cpu_profiler.d.ts +16 -0
  35. package/lib/types/profiling-node/src/cpu_profiler.d.ts.map +1 -0
  36. package/lib/types/profiling-node/src/debug-build.d.ts.map +1 -0
  37. package/lib/types/profiling-node/src/index.d.ts.map +1 -0
  38. package/lib/types/profiling-node/src/integration.d.ts +57 -0
  39. package/lib/types/profiling-node/src/integration.d.ts.map +1 -0
  40. package/lib/types/profiling-node/src/nodeVersion.d.ts.map +1 -0
  41. package/lib/types/{spanProfileUtils.d.ts → profiling-node/src/spanProfileUtils.d.ts} +2 -2
  42. package/lib/types/profiling-node/src/spanProfileUtils.d.ts.map +1 -0
  43. package/lib/types/profiling-node/src/types.d.ts +60 -0
  44. package/lib/types/profiling-node/src/types.d.ts.map +1 -0
  45. package/lib/types/{utils.d.ts → profiling-node/src/utils.d.ts} +30 -4
  46. package/lib/types/profiling-node/src/utils.d.ts.map +1 -0
  47. package/lib/types/types/src/debugMeta.d.ts +28 -0
  48. package/lib/types/types/src/debugMeta.d.ts.map +1 -0
  49. package/lib/types/types/src/measurement.d.ts +24 -0
  50. package/lib/types/types/src/measurement.d.ts.map +1 -0
  51. package/lib/types/types/src/profiling.d.ts +126 -0
  52. package/lib/types/types/src/profiling.d.ts.map +1 -0
  53. package/lib/types-ts3.8/profiling-node/src/cpu_profiler.d.ts +16 -0
  54. package/lib/types-ts3.8/profiling-node/src/integration.d.ts +57 -0
  55. package/lib/types-ts3.8/{spanProfileUtils.d.ts → profiling-node/src/spanProfileUtils.d.ts} +2 -2
  56. package/lib/types-ts3.8/profiling-node/src/types.d.ts +60 -0
  57. package/lib/types-ts3.8/{utils.d.ts → profiling-node/src/utils.d.ts} +30 -4
  58. package/lib/types-ts3.8/types/src/debugMeta.d.ts +28 -0
  59. package/lib/types-ts3.8/types/src/measurement.d.ts +24 -0
  60. package/lib/types-ts3.8/types/src/profiling.d.ts +126 -0
  61. package/package.json +5 -5
  62. package/lib/types/cpu_profiler.d.ts +0 -10
  63. package/lib/types/cpu_profiler.d.ts.map +0 -1
  64. package/lib/types/debug-build.d.ts.map +0 -1
  65. package/lib/types/index.d.ts.map +0 -1
  66. package/lib/types/integration.d.ts +0 -14
  67. package/lib/types/integration.d.ts.map +0 -1
  68. package/lib/types/nodeVersion.d.ts.map +0 -1
  69. package/lib/types/spanProfileUtils.d.ts.map +0 -1
  70. package/lib/types/types.d.ts +0 -100
  71. package/lib/types/types.d.ts.map +0 -1
  72. package/lib/types/utils.d.ts.map +0 -1
  73. package/lib/types-ts3.8/cpu_profiler.d.ts +0 -10
  74. package/lib/types-ts3.8/integration.d.ts +0 -14
  75. package/lib/types-ts3.8/types.d.ts +0 -100
  76. /package/lib/types/{debug-build.d.ts → profiling-node/src/debug-build.d.ts} +0 -0
  77. /package/lib/types/{index.d.ts → profiling-node/src/index.d.ts} +0 -0
  78. /package/lib/types/{nodeVersion.d.ts → profiling-node/src/nodeVersion.d.ts} +0 -0
  79. /package/lib/types-ts3.8/{debug-build.d.ts → profiling-node/src/debug-build.d.ts} +0 -0
  80. /package/lib/types-ts3.8/{index.d.ts → profiling-node/src/index.d.ts} +0 -0
  81. /package/lib/types-ts3.8/{nodeVersion.d.ts → profiling-node/src/nodeVersion.d.ts} +0 -0
@@ -0,0 +1,126 @@
1
+ import type { DebugImage } from './debugMeta';
2
+ import type { MeasurementUnit } from './measurement';
3
+ export type ThreadId = string;
4
+ export type FrameId = number;
5
+ export type StackId = number;
6
+ export interface ThreadCpuSample {
7
+ stack_id: StackId;
8
+ thread_id: ThreadId;
9
+ queue_address?: string;
10
+ elapsed_since_start_ns: string;
11
+ }
12
+ export interface ContinuousThreadCpuSample {
13
+ stack_id: StackId;
14
+ thread_id: ThreadId;
15
+ queue_address?: string;
16
+ timestamp: number;
17
+ }
18
+ export type ThreadCpuStack = FrameId[];
19
+ export type ThreadCpuFrame = {
20
+ function?: string;
21
+ file?: string;
22
+ lineno?: number;
23
+ colno?: number;
24
+ abs_path?: string;
25
+ platform?: string;
26
+ instruction_addr?: string;
27
+ module?: string;
28
+ in_app?: boolean;
29
+ };
30
+ export interface ThreadCpuProfile {
31
+ samples: ThreadCpuSample[];
32
+ stacks: ThreadCpuStack[];
33
+ frames: ThreadCpuFrame[];
34
+ thread_metadata: Record<ThreadId, {
35
+ name?: string;
36
+ priority?: number;
37
+ }>;
38
+ queue_metadata?: Record<string, {
39
+ label: string;
40
+ }>;
41
+ }
42
+ export interface ContinuousThreadCpuProfile {
43
+ samples: ContinuousThreadCpuSample[];
44
+ stacks: ThreadCpuStack[];
45
+ frames: ThreadCpuFrame[];
46
+ thread_metadata: Record<ThreadId, {
47
+ name?: string;
48
+ priority?: number;
49
+ }>;
50
+ queue_metadata?: Record<string, {
51
+ label: string;
52
+ }>;
53
+ }
54
+ interface BaseProfile<T> {
55
+ timestamp: string;
56
+ version: string;
57
+ release: string;
58
+ environment: string;
59
+ platform: string;
60
+ profile: T;
61
+ debug_meta?: {
62
+ images: DebugImage[];
63
+ };
64
+ measurements?: Record<string, {
65
+ unit: MeasurementUnit;
66
+ values: {
67
+ elapsed_since_start_ns: number;
68
+ value: number;
69
+ }[];
70
+ }>;
71
+ }
72
+ export interface Profile extends BaseProfile<ThreadCpuProfile> {
73
+ event_id: string;
74
+ version: string;
75
+ os: {
76
+ name: string;
77
+ version: string;
78
+ build_number?: string;
79
+ };
80
+ runtime: {
81
+ name: string;
82
+ version: string;
83
+ };
84
+ device: {
85
+ architecture: string;
86
+ is_emulator: boolean;
87
+ locale: string;
88
+ manufacturer: string;
89
+ model: string;
90
+ };
91
+ timestamp: string;
92
+ release: string;
93
+ environment: string;
94
+ platform: string;
95
+ profile: ThreadCpuProfile;
96
+ debug_meta?: {
97
+ images: DebugImage[];
98
+ };
99
+ transaction?: {
100
+ name: string;
101
+ id: string;
102
+ trace_id: string;
103
+ active_thread_id: string;
104
+ };
105
+ transactions?: {
106
+ name: string;
107
+ id: string;
108
+ trace_id: string;
109
+ active_thread_id: string;
110
+ relative_start_ns: string;
111
+ relative_end_ns: string;
112
+ }[];
113
+ measurements?: Record<string, {
114
+ unit: MeasurementUnit;
115
+ values: {
116
+ elapsed_since_start_ns: number;
117
+ value: number;
118
+ }[];
119
+ }>;
120
+ }
121
+ export interface ProfileChunk extends BaseProfile<ContinuousThreadCpuProfile> {
122
+ chunk_id: string;
123
+ profiler_id: string;
124
+ }
125
+ export {};
126
+ //# sourceMappingURL=profiling.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profiling.d.ts","sourceRoot":"","sources":["../../../../../types/src/profiling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAC9B,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAC7B,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,QAAQ,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sBAAsB,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,QAAQ,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,cAAc,GAAG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BAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,YAAY,CAAC,EAAE;QACb,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,CAAC;QACX,QAAQ,EAAE,MAAM,CAAC;QACjB,gBAAgB,EAAE,MAAM,CAAC;QACzB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,eAAe,EAAE,MAAM,CAAC;KACzB,EAAE,CAAC;IACJ,YAAY,CAAC,EAAE,MAAM,CACnB,MAAM,EACN;QACE,IAAI,EAAE,eAAe,CAAC;QACtB,MAAM,EAAE;YACN,sBAAsB,EAAE,MAAM,CAAC;YAC/B,KAAK,EAAE,MAAM,CAAC;SACf,EAAE,CAAC;KACL,CACF,CAAC;CACH;AAED,MAAM,WAAW,YAAa,SAAQ,WAAW,CAAC,0BAA0B,CAAC;IAC3E,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,16 @@
1
+ import { PrivateV8CpuProfilerBindings, RawChunkCpuProfile, RawThreadCpuProfile, V8CpuProfilerBindings } from './types';
2
+ import { ProfileFormat } from './types';
3
+ /**
4
+ * Imports cpp bindings based on the current platform and architecture.
5
+ */
6
+ export declare function importCppBindingsModule(): PrivateV8CpuProfilerBindings;
7
+ declare const PrivateCpuProfilerBindings: PrivateV8CpuProfilerBindings;
8
+ declare class Bindings implements V8CpuProfilerBindings {
9
+ startProfiling(name: string): void;
10
+ stopProfiling(name: string, format: ProfileFormat.THREAD): RawThreadCpuProfile | null;
11
+ stopProfiling(name: string, format: ProfileFormat.CHUNK): RawChunkCpuProfile | null;
12
+ }
13
+ declare const CpuProfilerBindings: Bindings;
14
+ export { PrivateCpuProfilerBindings };
15
+ export { CpuProfilerBindings };
16
+ //# sourceMappingURL=cpu_profiler.d.ts.map
@@ -0,0 +1,57 @@
1
+ import { NodeClient } from '@sentry/node';
2
+ import { Integration } from '@sentry/types';
3
+ declare class ContinuousProfiler {
4
+ private _profilerId;
5
+ private _client;
6
+ private _chunkData;
7
+ /**
8
+ * Called when the profiler is attached to the client (continuous mode is enabled). If of the profiler
9
+ * methods called before the profiler is initialized will result in a noop action with debug logs.
10
+ * @param client
11
+ */
12
+ initialize(client: NodeClient): void;
13
+ /**
14
+ * Recursively schedules chunk profiling to start and stop at a set interval.
15
+ * Once the user calls stop(), the current chunk will be stopped and flushed to Sentry and no new chunks will
16
+ * will be started. To restart continuous mode after calling stop(), the user must call start() again.
17
+ * @returns void
18
+ */
19
+ start(): void;
20
+ /**
21
+ * Stops the current chunk and flushes the profile to Sentry.
22
+ * @returns void
23
+ */
24
+ stop(): void;
25
+ /**
26
+ * Flushes the profile chunk to Sentry.
27
+ * @param chunk
28
+ */
29
+ private _flush;
30
+ /**
31
+ * Starts the profiler and registers the flush timer for a given chunk.
32
+ * @param chunk
33
+ */
34
+ private _startChunkProfiling;
35
+ /**
36
+ * Initializes new profile chunk metadata
37
+ */
38
+ private _initializeChunk;
39
+ /**
40
+ * Resets the current chunk state.
41
+ */
42
+ private _reset;
43
+ }
44
+ export interface ProfilingIntegration extends Integration {
45
+ _profiler: ContinuousProfiler;
46
+ }
47
+ /** Exported only for tests. */
48
+ export declare const _nodeProfilingIntegration: () => ProfilingIntegration;
49
+ /**
50
+ * We need this integration in order to send data to Sentry. We hook into the event processor
51
+ * and inspect each event to see if it is a transaction event and if that transaction event
52
+ * contains a profile on it's metadata. If that is the case, we create a profiling event envelope
53
+ * and delete the profile from the transaction metadata.
54
+ */
55
+ export declare const nodeProfilingIntegration: () => Integration;
56
+ export {};
57
+ //# sourceMappingURL=integration.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { NodeClient } from '@sentry/node';
2
2
  import { CustomSamplingContext, Span } from '@sentry/types';
3
- import { CpuProfilerBindings } from './cpu_profiler';
3
+ import { RawThreadCpuProfile } from './types';
4
4
  export declare const MAX_PROFILE_DURATION_MS: number;
5
5
  /**
6
6
  * Takes a transaction and determines if it should be profiled or not. If it should be profiled, it returns the
@@ -13,5 +13,5 @@ export declare function maybeProfileSpan(client: NodeClient | undefined, span: S
13
13
  * @param profile_id
14
14
  * @returns
15
15
  */
16
- export declare function stopSpanProfile(span: Span, profile_id: string | undefined): ReturnType<(typeof CpuProfilerBindings)['stopProfiling']> | null;
16
+ export declare function stopSpanProfile(span: Span, profile_id: string | undefined): RawThreadCpuProfile | null;
17
17
  //# sourceMappingURL=spanProfileUtils.d.ts.map
@@ -0,0 +1,60 @@
1
+ import { Event } from '@sentry/types';
2
+ interface Sample {
3
+ stack_id: number;
4
+ thread_id: string;
5
+ elapsed_since_start_ns: string;
6
+ }
7
+ interface ChunkSample {
8
+ stack_id: number;
9
+ thread_id: string;
10
+ timestamp: number;
11
+ }
12
+ type Frame = {
13
+ function: string;
14
+ file: string;
15
+ lineno: number;
16
+ colno: number;
17
+ };
18
+ interface Measurement {
19
+ unit: string;
20
+ values: {
21
+ elapsed_since_start_ns: number;
22
+ value: number;
23
+ }[];
24
+ }
25
+ export interface ProfiledEvent extends Event {
26
+ sdkProcessingMetadata: {
27
+ profile?: RawThreadCpuProfile;
28
+ };
29
+ }
30
+ interface BaseProfile {
31
+ profile_id?: string;
32
+ stacks: number[][];
33
+ frames: Frame[];
34
+ resources: string[];
35
+ profiler_logging_mode: 'eager' | 'lazy';
36
+ measurements: Record<string, Measurement>;
37
+ }
38
+ export interface RawThreadCpuProfile extends BaseProfile {
39
+ samples: Sample[];
40
+ }
41
+ export interface RawChunkCpuProfile extends BaseProfile {
42
+ samples: ChunkSample[];
43
+ }
44
+ export interface PrivateV8CpuProfilerBindings {
45
+ startProfiling(name: string): void;
46
+ stopProfiling(name: string, format: ProfileFormat.THREAD, threadId: number, collectResources: boolean): RawThreadCpuProfile | null;
47
+ stopProfiling(name: string, format: ProfileFormat.CHUNK, threadId: number, collectResources: boolean): RawChunkCpuProfile | null;
48
+ getFrameModule(abs_path: string): string;
49
+ }
50
+ export declare enum ProfileFormat {
51
+ THREAD = 0,
52
+ CHUNK = 1
53
+ }
54
+ export interface V8CpuProfilerBindings {
55
+ startProfiling(name: string): void;
56
+ stopProfiling(name: string, format: ProfileFormat.THREAD): RawThreadCpuProfile | null;
57
+ stopProfiling(name: string, format: ProfileFormat.CHUNK): RawChunkCpuProfile | null;
58
+ }
59
+ export {};
60
+ //# sourceMappingURL=types.d.ts.map
@@ -1,6 +1,6 @@
1
- import { Client, Envelope, Event } from '@sentry/types';
2
- import { Profile, RawThreadCpuProfile, ThreadCpuProfile } from './types';
3
- import { DebugImage } from './types';
1
+ import { Client, DebugImage, DsnComponents, Envelope, Event, EventEnvelopeHeaders, Profile, ProfileChunk, ProfileChunkEnvelope, SdkInfo, ThreadCpuProfile } from '@sentry/types';
2
+ import { ContinuousThreadCpuProfile } from '../../types/src/profiling';
3
+ import { RawChunkCpuProfile, RawThreadCpuProfile } from './types';
4
4
  /**
5
5
  * Enriches the profile with threadId of the current thread.
6
6
  * This is done in node as we seem to not be able to get the info from C native code.
@@ -8,7 +8,7 @@ import { DebugImage } from './types';
8
8
  * @param {ThreadCpuProfile | RawThreadCpuProfile} profile
9
9
  * @returns {ThreadCpuProfile}
10
10
  */
11
- export declare function enrichWithThreadInformation(profile: ThreadCpuProfile | RawThreadCpuProfile): ThreadCpuProfile;
11
+ export declare function enrichWithThreadInformation(profile: ThreadCpuProfile | RawThreadCpuProfile | ContinuousThreadCpuProfile | RawChunkCpuProfile): ThreadCpuProfile | ContinuousThreadCpuProfile;
12
12
  /**
13
13
  * Creates a profiling envelope item, if the profile does not pass validation, returns null.
14
14
  * @param {RawThreadCpuProfile}
@@ -16,6 +16,17 @@ export declare function enrichWithThreadInformation(profile: ThreadCpuProfile |
16
16
  * @returns {Profile | null}
17
17
  */
18
18
  export declare function createProfilingEvent(client: Client, profile: RawThreadCpuProfile, event: Event): Profile | null;
19
+ /**
20
+ * Creates a profiling chunk envelope item, if the profile does not pass validation, returns null.
21
+ */
22
+ export declare function createProfilingChunkEvent(start_timestamp: number, client: Client, options: {
23
+ release?: string;
24
+ environment?: string;
25
+ }, profile: RawChunkCpuProfile, identifiers: {
26
+ trace_id: string | undefined;
27
+ chunk_id: string;
28
+ profiler_id: string;
29
+ }): ProfileChunk | null;
19
30
  /**
20
31
  * Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1).
21
32
  * @param {unknown} rate
@@ -30,6 +41,12 @@ export declare function isValidSampleRate(rate: unknown): boolean;
30
41
  export declare function isValidProfile(profile: RawThreadCpuProfile): profile is RawThreadCpuProfile & {
31
42
  profile_id: string;
32
43
  };
44
+ /**
45
+ * Checks if the profile chunk is valid and can be sent to Sentry.
46
+ * @param profile
47
+ * @returns
48
+ */
49
+ export declare function isValidProfileChunk(profile: RawChunkCpuProfile): profile is RawChunkCpuProfile;
33
50
  /**
34
51
  * Adds items to envelope if they are not already present - mutates the envelope.
35
52
  * @param {Envelope} envelope
@@ -43,6 +60,15 @@ export declare function addProfilesToEnvelope(envelope: Envelope, profiles: Prof
43
60
  * @returns {Event[]}
44
61
  */
45
62
  export declare function findProfiledTransactionsFromEnvelope(envelope: Envelope): Event[];
63
+ /**
64
+ * Creates event envelope headers for a profile chunk. This is separate from createEventEnvelopeHeaders util
65
+ * as the profile chunk does not conform to the sentry event type
66
+ */
67
+ export declare function createEventEnvelopeHeaders(sdkInfo: SdkInfo | undefined, tunnel: string | undefined, dsn?: DsnComponents): EventEnvelopeHeaders;
68
+ /**
69
+ * Creates a standalone profile_chunk envelope.
70
+ */
71
+ export declare function makeProfileChunkEnvelope(chunk: ProfileChunk, sdkInfo: SdkInfo | undefined, tunnel: string | undefined, dsn?: DsnComponents): ProfileChunkEnvelope;
46
72
  /**
47
73
  * Cross reference profile collected resources with debug_ids and return a list of debug images.
48
74
  * @param {string[]} resource_paths
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Holds meta information to customize the behavior of Sentry's server-side event processing.
3
+ **/
4
+ export interface DebugMeta {
5
+ images?: Array<DebugImage>;
6
+ }
7
+ export type DebugImage = WasmDebugImage | SourceMapDebugImage | MachoDebugImage;
8
+ interface WasmDebugImage {
9
+ type: 'wasm';
10
+ debug_id: string;
11
+ code_id?: string | null;
12
+ code_file: string;
13
+ debug_file?: string | null;
14
+ }
15
+ interface SourceMapDebugImage {
16
+ type: 'sourcemap';
17
+ code_file: string;
18
+ debug_id: string;
19
+ }
20
+ interface MachoDebugImage {
21
+ type: 'macho';
22
+ debug_id: string;
23
+ image_addr: string;
24
+ image_size?: number;
25
+ code_file?: string;
26
+ }
27
+ export {};
28
+ //# sourceMappingURL=debugMeta.d.ts.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * A time duration.
3
+ */
4
+ export type DurationUnit = 'nanosecond' | 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week';
5
+ /**
6
+ * Size of information derived from bytes.
7
+ */
8
+ export type InformationUnit = 'bit' | 'byte' | 'kilobyte' | 'kibibyte' | 'megabyte' | 'mebibyte' | 'gigabyte' | 'terabyte' | 'tebibyte' | 'petabyte' | 'exabyte' | 'exbibyte';
9
+ /**
10
+ * Fractions such as percentages.
11
+ */
12
+ export type FractionUnit = 'ratio' | 'percent';
13
+ /**
14
+ * Untyped value without a unit.
15
+ */
16
+ export type NoneUnit = '' | 'none';
17
+ type LiteralUnion<T extends string> = T | Pick<T, Exclude<keyof T, T>>;
18
+ export type MeasurementUnit = LiteralUnion<DurationUnit | InformationUnit | FractionUnit | NoneUnit>;
19
+ export type Measurements = Record<string, {
20
+ value: number;
21
+ unit: MeasurementUnit;
22
+ }>;
23
+ export {};
24
+ //# sourceMappingURL=measurement.d.ts.map
@@ -0,0 +1,126 @@
1
+ import { DebugImage } from './debugMeta';
2
+ import { MeasurementUnit } from './measurement';
3
+ export type ThreadId = string;
4
+ export type FrameId = number;
5
+ export type StackId = number;
6
+ export interface ThreadCpuSample {
7
+ stack_id: StackId;
8
+ thread_id: ThreadId;
9
+ queue_address?: string;
10
+ elapsed_since_start_ns: string;
11
+ }
12
+ export interface ContinuousThreadCpuSample {
13
+ stack_id: StackId;
14
+ thread_id: ThreadId;
15
+ queue_address?: string;
16
+ timestamp: number;
17
+ }
18
+ export type ThreadCpuStack = FrameId[];
19
+ export type ThreadCpuFrame = {
20
+ function?: string;
21
+ file?: string;
22
+ lineno?: number;
23
+ colno?: number;
24
+ abs_path?: string;
25
+ platform?: string;
26
+ instruction_addr?: string;
27
+ module?: string;
28
+ in_app?: boolean;
29
+ };
30
+ export interface ThreadCpuProfile {
31
+ samples: ThreadCpuSample[];
32
+ stacks: ThreadCpuStack[];
33
+ frames: ThreadCpuFrame[];
34
+ thread_metadata: Record<ThreadId, {
35
+ name?: string;
36
+ priority?: number;
37
+ }>;
38
+ queue_metadata?: Record<string, {
39
+ label: string;
40
+ }>;
41
+ }
42
+ export interface ContinuousThreadCpuProfile {
43
+ samples: ContinuousThreadCpuSample[];
44
+ stacks: ThreadCpuStack[];
45
+ frames: ThreadCpuFrame[];
46
+ thread_metadata: Record<ThreadId, {
47
+ name?: string;
48
+ priority?: number;
49
+ }>;
50
+ queue_metadata?: Record<string, {
51
+ label: string;
52
+ }>;
53
+ }
54
+ interface BaseProfile<T> {
55
+ timestamp: string;
56
+ version: string;
57
+ release: string;
58
+ environment: string;
59
+ platform: string;
60
+ profile: T;
61
+ debug_meta?: {
62
+ images: DebugImage[];
63
+ };
64
+ measurements?: Record<string, {
65
+ unit: MeasurementUnit;
66
+ values: {
67
+ elapsed_since_start_ns: number;
68
+ value: number;
69
+ }[];
70
+ }>;
71
+ }
72
+ export interface Profile extends BaseProfile<ThreadCpuProfile> {
73
+ event_id: string;
74
+ version: string;
75
+ os: {
76
+ name: string;
77
+ version: string;
78
+ build_number?: string;
79
+ };
80
+ runtime: {
81
+ name: string;
82
+ version: string;
83
+ };
84
+ device: {
85
+ architecture: string;
86
+ is_emulator: boolean;
87
+ locale: string;
88
+ manufacturer: string;
89
+ model: string;
90
+ };
91
+ timestamp: string;
92
+ release: string;
93
+ environment: string;
94
+ platform: string;
95
+ profile: ThreadCpuProfile;
96
+ debug_meta?: {
97
+ images: DebugImage[];
98
+ };
99
+ transaction?: {
100
+ name: string;
101
+ id: string;
102
+ trace_id: string;
103
+ active_thread_id: string;
104
+ };
105
+ transactions?: {
106
+ name: string;
107
+ id: string;
108
+ trace_id: string;
109
+ active_thread_id: string;
110
+ relative_start_ns: string;
111
+ relative_end_ns: string;
112
+ }[];
113
+ measurements?: Record<string, {
114
+ unit: MeasurementUnit;
115
+ values: {
116
+ elapsed_since_start_ns: number;
117
+ value: number;
118
+ }[];
119
+ }>;
120
+ }
121
+ export interface ProfileChunk extends BaseProfile<ContinuousThreadCpuProfile> {
122
+ chunk_id: string;
123
+ profiler_id: string;
124
+ }
125
+ export {};
126
+ //# sourceMappingURL=profiling.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/profiling-node",
3
- "version": "8.7.0",
3
+ "version": "8.9.0",
4
4
  "description": "Official Sentry SDK for Node.js Profiling",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/profiling-node",
@@ -77,10 +77,10 @@
77
77
  "test": "cross-env SENTRY_PROFILER_BINARY_DIR=lib jest --config jest.config.js"
78
78
  },
79
79
  "dependencies": {
80
- "@sentry/core": "8.7.0",
81
- "@sentry/node": "8.7.0",
82
- "@sentry/types": "8.7.0",
83
- "@sentry/utils": "8.7.0",
80
+ "@sentry/core": "8.9.0",
81
+ "@sentry/node": "8.9.0",
82
+ "@sentry/types": "8.9.0",
83
+ "@sentry/utils": "8.9.0",
84
84
  "detect-libc": "^2.0.2",
85
85
  "node-abi": "^3.61.0"
86
86
  },
@@ -1,10 +0,0 @@
1
- import type { PrivateV8CpuProfilerBindings, V8CpuProfilerBindings } from './types';
2
- /**
3
- * Imports cpp bindings based on the current platform and architecture.
4
- */
5
- export declare function importCppBindingsModule(): PrivateV8CpuProfilerBindings;
6
- declare const PrivateCpuProfilerBindings: PrivateV8CpuProfilerBindings;
7
- declare const CpuProfilerBindings: V8CpuProfilerBindings;
8
- export { PrivateCpuProfilerBindings };
9
- export { CpuProfilerBindings };
10
- //# sourceMappingURL=cpu_profiler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cpu_profiler.d.ts","sourceRoot":"","sources":["../../src/cpu_profiler.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAUnF;;GAEG;AAEH,wBAAgB,uBAAuB,IAAI,4BAA4B,CA+HtE;AAED,QAAA,MAAM,0BAA0B,EAAE,4BAAwD,CAAC;AAC3F,QAAA,MAAM,mBAAmB,EAAE,qBAiB1B,CAAC;AAEF,OAAO,EAAE,0BAA0B,EAAE,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"debug-build.d.ts","sourceRoot":"","sources":["../../src/debug-build.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,WAAW,SAAkB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC"}
@@ -1,14 +0,0 @@
1
- import type { NodeClient } from '@sentry/node';
2
- /** Exported only for tests. */
3
- export declare const _nodeProfilingIntegration: () => {
4
- name: string;
5
- setup(client: NodeClient): void;
6
- };
7
- /**
8
- * We need this integration in order to send data to Sentry. We hook into the event processor
9
- * and inspect each event to see if it is a transaction event and if that transaction event
10
- * contains a profile on it's metadata. If that is the case, we create a profiling event envelope
11
- * and delete the profile from the transaction metadata.
12
- */
13
- export declare const nodeProfilingIntegration: () => import("@sentry/types").Integration;
14
- //# sourceMappingURL=integration.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../../src/integration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAyB/C,+BAA+B;AAC/B,eAAO,MAAM,yBAAyB;;kBAYpB,UAAU;CA6HF,CAAC;AAE3B;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,2CAA+C,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"nodeVersion.d.ts","sourceRoot":"","sources":["../../src/nodeVersion.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;WAAkD,MAAM;WAAS,MAAM;WAAS,MAAM;CAAE,CAAC;AAClH,eAAO,MAAM,UAAU,QAAqB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"spanProfileUtils.d.ts","sourceRoot":"","sources":["../../src/spanProfileUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAGjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAIrD,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,CAkFpB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,UAAU,CAAC,CAAC,OAAO,mBAAmB,CAAC,CAAC,eAAe,CAAC,CAAC,GAAG,IAAI,CAuBlE"}