UNPKG

3.24 kBTypeScriptView Raw
1import type { DebugImage, Envelope, Event, EventEnvelope, Transaction } from '@sentry/types';
2import type { Profile, ThreadCpuProfile } from '@sentry/types/src/profiling';
3import type { JSSelfProfile, JSSelfProfiler } from './jsSelfProfiling';
4/**
5 *
6 */
7export declare function enrichWithThreadInformation(profile: ThreadCpuProfile | JSSelfProfile): ThreadCpuProfile;
8export interface ProfiledEvent extends Event {
9 sdkProcessingMetadata: {
10 profile?: JSSelfProfile;
11 };
12}
13/**
14 * Creates a profiling event envelope from a Sentry event. If profile does not pass
15 * validation, returns null.
16 * @param event
17 * @param dsn
18 * @param metadata
19 * @param tunnel
20 * @returns {EventEnvelope | null}
21 */
22/**
23 * Creates a profiling event envelope from a Sentry event.
24 */
25export declare function createProfilePayload(profile_id: string, start_timestamp: number | undefined, processed_profile: JSSelfProfile, event: ProfiledEvent): Profile;
26/**
27 *
28 */
29export declare function isProfiledTransactionEvent(event: Event): event is ProfiledEvent;
30/**
31 *
32 */
33export declare function isAutomatedPageLoadTransaction(transaction: Transaction): boolean;
34/**
35 * Converts a JSSelfProfile to a our sampled format.
36 * Does not currently perform stack indexing.
37 */
38export declare function convertJSSelfProfileToSampledFormat(input: JSSelfProfile): Profile['profile'];
39/**
40 * Adds items to envelope if they are not already present - mutates the envelope.
41 * @param envelope
42 */
43export declare function addProfilesToEnvelope(envelope: EventEnvelope, profiles: Profile[]): Envelope;
44/**
45 * Finds transactions with profile_id context in the envelope
46 * @param envelope
47 * @returns
48 */
49export declare function findProfiledTransactionsFromEnvelope(envelope: Envelope): Event[];
50/**
51 * Applies debug meta data to an event from a list of paths to resources (sourcemaps)
52 */
53export declare function applyDebugMetadata(resource_paths: ReadonlyArray<string>): DebugImage[];
54/**
55 * Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1).
56 */
57export declare function isValidSampleRate(rate: unknown): boolean;
58export declare const MAX_PROFILE_DURATION_MS = 30000;
59/**
60 * Starts the profiler and returns the profiler instance.
61 */
62export declare function startJSSelfProfile(): JSSelfProfiler | undefined;
63/**
64 * Determine if a profile should be profiled.
65 */
66export declare function shouldProfileTransaction(transaction: Transaction): boolean;
67/**
68 * Creates a profiling envelope item, if the profile does not pass validation, returns null.
69 * @param event
70 * @returns {Profile | null}
71 */
72export declare function createProfilingEvent(profile_id: string, start_timestamp: number | undefined, profile: JSSelfProfile, event: ProfiledEvent): Profile | null;
73/**
74 *
75 */
76export declare function getActiveProfilesCount(): number;
77/**
78 * Retrieves profile from global cache and removes it.
79 */
80export declare function takeProfileFromGlobalCache(profile_id: string): JSSelfProfile | undefined;
81/**
82 * Adds profile to global cache and evicts the oldest profile if the cache is full.
83 */
84export declare function addProfileToGlobalCache(profile_id: string, profile: JSSelfProfile): void;
85//# sourceMappingURL=utils.d.ts.map
\No newline at end of file