* Create a profile * @param {RawThreadCpuProfile} cpuProfile * @param {options} * @returns {Profile}
(
client: Client,
cpuProfile: RawThreadCpuProfile,
{
release,
environment,
event_id,
transaction,
start_timestamp,
trace_id,
profile_id,
}: {
release: string;
environment: string;
event_id: string;
transaction: string;
start_timestamp: number;
trace_id: string | undefined;
profile_id: string;
},
)
| 109 | * @returns {Profile} |
| 110 | */ |
| 111 | function createProfilePayload( |
| 112 | client: Client, |
| 113 | cpuProfile: RawThreadCpuProfile, |
| 114 | { |
| 115 | release, |
| 116 | environment, |
| 117 | event_id, |
| 118 | transaction, |
| 119 | start_timestamp, |
| 120 | trace_id, |
| 121 | profile_id, |
| 122 | }: { |
| 123 | release: string; |
| 124 | environment: string; |
| 125 | event_id: string; |
| 126 | transaction: string; |
| 127 | start_timestamp: number; |
| 128 | trace_id: string | undefined; |
| 129 | profile_id: string; |
| 130 | }, |
| 131 | ): Profile { |
| 132 | // Log a warning if the profile has an invalid traceId (should be uuidv4). |
| 133 | // All profiles and transactions are rejected if this is the case and we want to |
| 134 | // warn users that this is happening if they enable debug flag |
| 135 | if (trace_id?.length !== 32) { |
| 136 | DEBUG_BUILD && debug.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`); |
| 137 | } |
| 138 | |
| 139 | const enrichedThreadProfile = enrichWithThreadInformation(cpuProfile); |
| 140 | |
| 141 | const profile: Profile = { |
| 142 | event_id: profile_id, |
| 143 | timestamp: new Date(start_timestamp).toISOString(), |
| 144 | platform: 'node', |
| 145 | version: FORMAT_VERSION, |
| 146 | release: release, |
| 147 | environment: environment, |
| 148 | measurements: cpuProfile.measurements, |
| 149 | runtime: { |
| 150 | name: 'node', |
| 151 | version: versions.node || '', |
| 152 | }, |
| 153 | os: { |
| 154 | name: PLATFORM, |
| 155 | version: RELEASE, |
| 156 | build_number: VERSION, |
| 157 | }, |
| 158 | device: { |
| 159 | locale: env['LC_ALL'] || env['LC_MESSAGES'] || env['LANG'] || env['LANGUAGE'] || '', |
| 160 | model: MODEL, |
| 161 | manufacturer: TYPE, |
| 162 | architecture: ARCH, |
| 163 | is_emulator: false, |
| 164 | }, |
| 165 | debug_meta: { |
| 166 | images: applyDebugMetadata(client, cpuProfile.resources), |
| 167 | }, |
| 168 | profile: enrichedThreadProfile as ThreadCpuProfile, |
no test coverage detected