Skip to content

Commit

Permalink
test: remove circular dep
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasBa committed Jun 22, 2023
1 parent b95becd commit efada28
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
6 changes: 4 additions & 2 deletions packages/browser/src/profiling/hubextensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import type { Transaction } from '@sentry/types';
import { logger, uuid4 } from '@sentry/utils';

import { WINDOW } from '../helpers';
import { addToProfileQueue } from './integration';
import type {
JSSelfProfile,
JSSelfProfiler,
JSSelfProfilerConstructor,
ProcessedJSSelfProfile,
} from './jsSelfProfiling';
import { isValidSampleRate } from './utils';
import { addToProfileQueue , isValidSampleRate } from './utils';


export const MAX_PROFILE_DURATION_MS = 30_000;
// Keep a flag value to avoid re-initializing the profiler constructor. If it fails
Expand Down Expand Up @@ -270,3 +270,5 @@ export function wrapTransactionWithProfiling(transaction: Transaction): Transact
transaction.finish = profilingWrappedTransactionFinish;
return transaction;
}


18 changes: 1 addition & 17 deletions packages/browser/src/profiling/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,8 @@ import { logger } from '@sentry/utils';

import type { BrowserClient } from './../client';
import { wrapTransactionWithProfiling } from './hubextensions';
import type { ProcessedJSSelfProfile } from './jsSelfProfiling';
import type { ProfiledEvent } from './utils';
import { addProfilesToEnvelope, createProfilingEvent, findProfiledTransactionsFromEnvelope } from './utils';

const MAX_PROFILE_QUEUE_SIZE = 50;
const PROFILE_QUEUE: ProcessedJSSelfProfile[] = [];

/**
* Adds the profile to the queue of profiles to be sent
*/
export function addToProfileQueue(profile: ProcessedJSSelfProfile): void {
PROFILE_QUEUE.push(profile);

// We only want to keep the last n profiles in the queue.
if (PROFILE_QUEUE.length > MAX_PROFILE_QUEUE_SIZE) {
PROFILE_QUEUE.shift();
}
}
import { addProfilesToEnvelope, createProfilingEvent, findProfiledTransactionsFromEnvelope,PROFILE_QUEUE } from './utils';

/**
* Browser profiling integration. Stores any event that has contexts["profile"]["profile_id"]
Expand Down
14 changes: 14 additions & 0 deletions packages/browser/src/profiling/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,17 @@ export function createProfilingEvent(profile: ProcessedJSSelfProfile, event: Pro

return createProfilePayload(event, profile);
}

const MAX_PROFILE_QUEUE_SIZE = 50;
export const PROFILE_QUEUE: ProcessedJSSelfProfile[] = [];
/**
* Adds the profile to the queue of profiles to be sent
*/
export function addToProfileQueue(profile: ProcessedJSSelfProfile): void {
PROFILE_QUEUE.push(profile);

// We only want to keep the last n profiles in the queue.
if (PROFILE_QUEUE.length > MAX_PROFILE_QUEUE_SIZE) {
PROFILE_QUEUE.shift();
}
}

0 comments on commit efada28

Please sign in to comment.