Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions bindings/cpu_profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,6 @@ std::tuple <v8::Local<v8::Value>, v8::Local<v8::Value>, v8::Local<v8::Value>> Ge
v8::Local<v8::Value> CreateProfile(const v8::CpuProfile* profile, uint32_t thread_id, std::string app_root_directory) {
v8::Local<v8::Object> js_profile = Nan::New<v8::Object>();

Nan::Set(js_profile, Nan::New<v8::String>("profile_relative_started_at_ns").ToLocalChecked(), Nan::New<v8::Number>(profile->GetStartTime() * 1000));
Nan::Set(js_profile, Nan::New<v8::String>("profile_relative_ended_at_ns").ToLocalChecked(), Nan::New<v8::Number>(profile->GetEndTime() * 1000));

Nan::Set(js_profile, Nan::New<v8::String>("profiler_logging_mode").ToLocalChecked(), Nan::New<v8::String>(getLoggingMode() == v8::CpuProfilingLoggingMode::kEagerLogging ? "eager" : "lazy").ToLocalChecked());


Expand Down
3 changes: 0 additions & 3 deletions src/cpu_profiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ export interface RawThreadCpuProfile {
stacks: Stack[];
samples: Sample[];
frames: Frame[];
// These fields are relative to transaction ended at
profile_relative_started_at_ns: number;
profile_relative_ended_at_ns: number;
profiler_logging_mode: 'eager' | 'lazy';
}
export interface ThreadCpuProfile {
Expand Down
4 changes: 0 additions & 4 deletions src/hubextensions.hub.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ describe('hubextensions', () => {
],
stacks: [[0]],
frames: [],
profile_relative_ended_at_ns: 0,
profile_relative_started_at_ns: 0,
profiler_logging_mode: 'lazy'
};
});
Expand Down Expand Up @@ -157,8 +155,6 @@ describe('hubextensions', () => {
],
stacks: [[0]],
frames: [],
profile_relative_ended_at_ns: 0,
profile_relative_started_at_ns: 0,
profiler_logging_mode: 'lazy'
};
});
Expand Down
4 changes: 2 additions & 2 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ describe('Sentry - Profiling', () => {

await Sentry.flush(500);

expect(findAllProfiles()?.[0]?.[0]?.[1]?.[0]?.[1].transactions[0].name).toBe('inner');
expect(findAllProfiles()?.[1]?.[0]?.[1]?.[0]?.[1].transactions[0].name).toBe('outer');
expect(findAllProfiles()?.[0]?.[0]?.[1]?.[0]?.[1].transaction.name).toBe('inner');
expect(findAllProfiles()?.[1]?.[0]?.[1]?.[0]?.[1].transaction.name).toBe('outer');
expect(findAllProfiles()).toHaveLength(2);
expect(findProfile()).not.toBe(null);
});
Expand Down
2 changes: 0 additions & 2 deletions src/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ function makeProfiledEvent(): ProfiledEvent {
profile: {
profile_id: 'id',
profiler_logging_mode: 'lazy',
profile_relative_ended_at_ns: 1,
profile_relative_started_at_ns: 0,
samples: [
{
elapsed_since_start_ns: '0',
Expand Down
10 changes: 4 additions & 6 deletions src/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ function makeProfile(
): NonNullable<ProfiledEvent['sdkProcessingMetadata']['profile']> {
return {
profile_id: '1',
profile_relative_ended_at_ns: 1,
profile_relative_started_at_ns: 0,
profiler_logging_mode: 'lazy',
stacks: [],
samples: [
Expand Down Expand Up @@ -251,9 +249,9 @@ describe('createProfilingEventEnvelope', () => {

const profile = envelope?.[1][0]?.[1] as unknown as Profile;

expect(profile.transactions?.[0]?.name).toBe('transaction-name');
expect(typeof profile.transactions?.[0]?.id).toBe('string');
expect(profile.transactions?.[0]?.id?.length).toBe(32);
expect(profile.transactions?.[0]?.trace_id).toBe('trace_id');
expect(profile.transaction.name).toBe('transaction-name');
expect(typeof profile.transaction.id).toBe('string');
expect(profile.transaction.id?.length).toBe(32);
expect(profile.transaction.trace_id).toBe('trace_id');
});
});
25 changes: 9 additions & 16 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,12 @@ export interface Profile {
image_vmaddr: string;
}[];
};
transactions: {
transaction: {
name: string;
trace_id: string;
id: string;
trace_id: string;
active_thread_id: string;
relative_start_ns: string;
relative_end_ns: string;
}[];
};
}

function isRawThreadCpuProfile(profile: ThreadCpuProfile | RawThreadCpuProfile): profile is RawThreadCpuProfile {
Expand Down Expand Up @@ -199,7 +197,6 @@ export function createProfilingEventEnvelope(
const envelopeHeaders = createEventEnvelopeHeaders(event, sdkInfo, tunnel, dsn);
const enrichedThreadProfile = enrichWithThreadInformation(rawProfile);
const transactionStartMs = typeof event.start_timestamp === 'number' ? event.start_timestamp * 1000 : Date.now();
const transactionEndMs = typeof event.timestamp === 'number' ? event.timestamp * 1000 : Date.now();

const traceId = (event?.contexts?.['trace']?.['trace_id'] as string) ?? '';
// Log a warning if the profile has an invalid traceId (should be uuidv4).
Expand Down Expand Up @@ -236,16 +233,12 @@ export function createProfilingEventEnvelope(
is_emulator: false
},
profile: enrichedThreadProfile,
transactions: [
{
name: event.transaction || '',
id: event.event_id || uuid4(),
trace_id: traceId,
active_thread_id: THREAD_ID_STRING,
relative_start_ns: '0',
relative_end_ns: ((transactionEndMs - transactionStartMs) * 1e6).toFixed(0)
}
]
transaction: {
name: event.transaction || '',
id: event.event_id || uuid4(),
trace_id: traceId,
active_thread_id: THREAD_ID_STRING
}
};

const envelopeItem: EventItem = [
Expand Down