Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit 9d7e706

Browse files
authored
ref(format): remove transactions array in favor of transaction property (#108)
ref(format): remove transactions array in favour of transaction property
1 parent dc37cbf commit 9d7e706

File tree

7 files changed

+15
-36
lines changed

7 files changed

+15
-36
lines changed

bindings/cpu_profiler.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,6 @@ std::tuple <v8::Local<v8::Value>, v8::Local<v8::Value>, v8::Local<v8::Value>> Ge
246246
v8::Local<v8::Value> CreateProfile(const v8::CpuProfile* profile, uint32_t thread_id, std::string app_root_directory) {
247247
v8::Local<v8::Object> js_profile = Nan::New<v8::Object>();
248248

249-
Nan::Set(js_profile, Nan::New<v8::String>("profile_relative_started_at_ns").ToLocalChecked(), Nan::New<v8::Number>(profile->GetStartTime() * 1000));
250-
Nan::Set(js_profile, Nan::New<v8::String>("profile_relative_ended_at_ns").ToLocalChecked(), Nan::New<v8::Number>(profile->GetEndTime() * 1000));
251-
252249
Nan::Set(js_profile, Nan::New<v8::String>("profiler_logging_mode").ToLocalChecked(), Nan::New<v8::String>(getLoggingMode() == v8::CpuProfilingLoggingMode::kEagerLogging ? "eager" : "lazy").ToLocalChecked());
253250

254251

src/cpu_profiler.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ export interface RawThreadCpuProfile {
5151
stacks: Stack[];
5252
samples: Sample[];
5353
frames: Frame[];
54-
// These fields are relative to transaction ended at
55-
profile_relative_started_at_ns: number;
56-
profile_relative_ended_at_ns: number;
5754
profiler_logging_mode: 'eager' | 'lazy';
5855
}
5956
export interface ThreadCpuProfile {

src/hubextensions.hub.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ describe('hubextensions', () => {
108108
],
109109
stacks: [[0]],
110110
frames: [],
111-
profile_relative_ended_at_ns: 0,
112-
profile_relative_started_at_ns: 0,
113111
profiler_logging_mode: 'lazy'
114112
};
115113
});
@@ -157,8 +155,6 @@ describe('hubextensions', () => {
157155
],
158156
stacks: [[0]],
159157
frames: [],
160-
profile_relative_ended_at_ns: 0,
161-
profile_relative_started_at_ns: 0,
162158
profiler_logging_mode: 'lazy'
163159
};
164160
});

src/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ describe('Sentry - Profiling', () => {
6363

6464
await Sentry.flush(500);
6565

66-
expect(findAllProfiles()?.[0]?.[0]?.[1]?.[0]?.[1].transactions[0].name).toBe('inner');
67-
expect(findAllProfiles()?.[1]?.[0]?.[1]?.[0]?.[1].transactions[0].name).toBe('outer');
66+
expect(findAllProfiles()?.[0]?.[0]?.[1]?.[0]?.[1].transaction.name).toBe('inner');
67+
expect(findAllProfiles()?.[1]?.[0]?.[1]?.[0]?.[1].transaction.name).toBe('outer');
6868
expect(findAllProfiles()).toHaveLength(2);
6969
expect(findProfile()).not.toBe(null);
7070
});

src/integration.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ function makeProfiledEvent(): ProfiledEvent {
1515
profile: {
1616
profile_id: 'id',
1717
profiler_logging_mode: 'lazy',
18-
profile_relative_ended_at_ns: 1,
19-
profile_relative_started_at_ns: 0,
2018
samples: [
2119
{
2220
elapsed_since_start_ns: '0',

src/utils.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ function makeProfile(
3737
): NonNullable<ProfiledEvent['sdkProcessingMetadata']['profile']> {
3838
return {
3939
profile_id: '1',
40-
profile_relative_ended_at_ns: 1,
41-
profile_relative_started_at_ns: 0,
4240
profiler_logging_mode: 'lazy',
4341
stacks: [],
4442
samples: [
@@ -251,9 +249,9 @@ describe('createProfilingEventEnvelope', () => {
251249

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

254-
expect(profile.transactions?.[0]?.name).toBe('transaction-name');
255-
expect(typeof profile.transactions?.[0]?.id).toBe('string');
256-
expect(profile.transactions?.[0]?.id?.length).toBe(32);
257-
expect(profile.transactions?.[0]?.trace_id).toBe('trace_id');
252+
expect(profile.transaction.name).toBe('transaction-name');
253+
expect(typeof profile.transaction.id).toBe('string');
254+
expect(profile.transaction.id?.length).toBe(32);
255+
expect(profile.transaction.trace_id).toBe('trace_id');
258256
});
259257
});

src/utils.ts

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,12 @@ export interface Profile {
6565
image_vmaddr: string;
6666
}[];
6767
};
68-
transactions: {
68+
transaction: {
6969
name: string;
70-
trace_id: string;
7170
id: string;
71+
trace_id: string;
7272
active_thread_id: string;
73-
relative_start_ns: string;
74-
relative_end_ns: string;
75-
}[];
73+
};
7674
}
7775

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

204201
const traceId = (event?.contexts?.['trace']?.['trace_id'] as string) ?? '';
205202
// Log a warning if the profile has an invalid traceId (should be uuidv4).
@@ -236,16 +233,12 @@ export function createProfilingEventEnvelope(
236233
is_emulator: false
237234
},
238235
profile: enrichedThreadProfile,
239-
transactions: [
240-
{
241-
name: event.transaction || '',
242-
id: event.event_id || uuid4(),
243-
trace_id: traceId,
244-
active_thread_id: THREAD_ID_STRING,
245-
relative_start_ns: '0',
246-
relative_end_ns: ((transactionEndMs - transactionStartMs) * 1e6).toFixed(0)
247-
}
248-
]
236+
transaction: {
237+
name: event.transaction || '',
238+
id: event.event_id || uuid4(),
239+
trace_id: traceId,
240+
active_thread_id: THREAD_ID_STRING
241+
}
249242
};
250243

251244
const envelopeItem: EventItem = [

0 commit comments

Comments
 (0)