Skip to content

Commit

Permalink
fix: remove profilesSampler
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasBa committed Jun 23, 2023
1 parent 5c29fa2 commit d93d94c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
20 changes: 2 additions & 18 deletions packages/browser/src/profiling/hubextensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,8 @@ export function wrapTransactionWithProfiling(transaction: Transaction): Transact
return transaction;
}

// @ts-ignore profilesSampler is not part of the browser options yet
const profilesSampler = options.profilesSampler;
// @ts-ignore profilesSampleRate is not part of the browser options yet
let profilesSampleRate: number | boolean | undefined = options.profilesSampleRate;

// Prefer sampler to sample rate if both are provided.
if (typeof profilesSampler === 'function') {
const transactionContext = transaction.toContext();
profilesSampleRate = profilesSampler({
parentSampled: transactionContext.parentSampled,
transactionContext: transactionContext,
...transaction.getDynamicSamplingContext(),
});
}
const profilesSampleRate: number | boolean | undefined = options.profilesSampleRate;

// Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The
// only valid values are booleans or numbers between 0 and 1.)
Expand All @@ -97,11 +85,7 @@ export function wrapTransactionWithProfiling(transaction: Transaction): Transact
if (!profilesSampleRate) {
__DEBUG_BUILD__ &&
logger.log(
`[Profiling] Discarding profile because ${
typeof profilesSampler === 'function'
? 'profileSampler returned 0 or false'
: 'a negative sampling decision was inherited or profileSampleRate is set to 0'
}`,
'[Profiling] Discarding profile because a negative sampling decision was inherited or profileSampleRate is set to 0',
);
return transaction;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/browser/src/profiling/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export class BrowserProfilingIntegration implements Integration {
}

// Remove the profile from the transaction context before sending, relay will take care of the rest.
if (profiledTransaction && profiledTransaction.contexts && profiledTransaction.contexts['profile']) {
delete profiledTransaction.contexts.profile;
if (context && context['profile']) {
delete context.profile;
}

const profile = PROFILE_MAP.get(profile_id);
Expand Down

0 comments on commit d93d94c

Please sign in to comment.