Skip to content

Commit 5d84228

Browse files
committed
random language cleanup
1 parent b18cd37 commit 5d84228

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

packages/tracing/src/browser/browsertracing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ export class BrowserTracing implements Integration {
201201
}
202202

203203
const hub = this._getCurrentHub();
204-
logger.log(`[Tracing] starting ${modifiedContext.op} idleTransaction on scope`);
205204
const idleTransaction = startIdleTransaction(hub, modifiedContext, idleTimeout, true);
205+
logger.log(`[Tracing] Starting ${modifiedContext.op} transaction on scope`);
206206
idleTransaction.registerBeforeFinishCallback((transaction, endTimestamp) => {
207207
this._metrics.addPerformanceEntries(transaction);
208208
adjustTransactionDuration(secToMs(maxTransactionDuration), transaction, endTimestamp);

packages/tracing/src/browser/request.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface RequestInstrumentationOptions {
4141
/** Data returned from fetch callback */
4242
export interface FetchData {
4343
// eslint-disable-next-line @typescript-eslint/no-explicit-any
44-
args: any[];
44+
args: any[]; // the arguments passed to the fetch call itself
4545
fetchData?: {
4646
method: string;
4747
url: string;
@@ -217,6 +217,7 @@ function xhrCallback(
217217
return;
218218
}
219219

220+
// check first if the request has finished and is tracked by an existing span which should now end
220221
if (handlerData.endTimestamp && handlerData.xhr.__sentry_xhr_span_id__) {
221222
const span = spans[handlerData.xhr.__sentry_xhr_span_id__];
222223
if (span) {
@@ -231,6 +232,7 @@ function xhrCallback(
231232
return;
232233
}
233234

235+
// if not, create a new span to track it
234236
const activeTransaction = getActiveTransaction();
235237
if (activeTransaction) {
236238
const span = activeTransaction.startChild({

packages/tracing/src/hubextensions.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,9 @@ function isValidSampleRate(rate: unknown): boolean {
184184
/**
185185
* Creates a new transaction and adds a sampling decision if it doesn't yet have one.
186186
*
187-
* The Hub.startTransaction method delegates to this method to do its work, passing the Hub instance in as `this`.
188-
* Exists as a separate function so that it can be injected into the class as an "extension method."
187+
* The Hub.startTransaction method delegates to this method to do its work, passing the Hub instance in as `this`, as if
188+
* it had been called on the hub directly. Exists as a separate function so that it can be injected into the class as an
189+
* "extension method."
189190
*
190191
* @param this: The Hub starting the transaction
191192
* @param transactionContext: Data used to configure the transaction

packages/tracing/test/hub.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ describe('Hub', () => {
156156
expect(transaction.sampled).toBe(false);
157157
});
158158

159-
it('should not sample transactions when tracesSampleRate is 0', () => {
159+
it('should set sampled = false if tracesSampleRate is 0', () => {
160160
const hub = new Hub(new BrowserClient({ tracesSampleRate: 0 }));
161161
const transaction = hub.startTransaction({ name: 'dogpark' });
162162

163163
expect(transaction.sampled).toBe(false);
164164
});
165165

166-
it('should sample transactions when tracesSampleRate is 1', () => {
166+
it('should set sampled = true if tracesSampleRate is 1', () => {
167167
const hub = new Hub(new BrowserClient({ tracesSampleRate: 1 }));
168168
const transaction = hub.startTransaction({ name: 'dogpark' });
169169

packages/utils/src/instrument.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function instrumentFetch(): void {
141141

142142
fill(global, 'fetch', function(originalFetch: () => void): () => void {
143143
return function(...args: any[]): void {
144-
const commonHandlerData = {
144+
const handlerData = {
145145
args,
146146
fetchData: {
147147
method: getFetchMethod(args),
@@ -151,22 +151,22 @@ function instrumentFetch(): void {
151151
};
152152

153153
triggerHandlers('fetch', {
154-
...commonHandlerData,
154+
...handlerData,
155155
});
156156

157157
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
158158
return originalFetch.apply(global, args).then(
159159
(response: Response) => {
160160
triggerHandlers('fetch', {
161-
...commonHandlerData,
161+
...handlerData,
162162
endTimestamp: Date.now(),
163163
response,
164164
});
165165
return response;
166166
},
167167
(error: Error) => {
168168
triggerHandlers('fetch', {
169-
...commonHandlerData,
169+
...handlerData,
170170
endTimestamp: Date.now(),
171171
error,
172172
});
@@ -223,7 +223,7 @@ function instrumentXHR(): void {
223223
return;
224224
}
225225

226-
// Poor man implementation of ES6 `Map` by tracking and keeping in sync key and value separately.
226+
// Poor man's implementation of ES6 `Map`, tracking and keeping in sync key and value separately.
227227
const requestKeys: XMLHttpRequest[] = [];
228228
const requestValues: Array<any>[] = [];
229229
const xhrproto = XMLHttpRequest.prototype;
@@ -260,7 +260,7 @@ function instrumentXHR(): void {
260260
try {
261261
const requestPos = requestKeys.indexOf(xhr);
262262
if (requestPos !== -1) {
263-
// Make sure to pop both, key and value to keep it in sync.
263+
// Make sure to pop both key and value to keep it in sync.
264264
requestKeys.splice(requestPos);
265265
const args = requestValues.splice(requestPos)[0];
266266
if (xhr.__sentry_xhr__ && args[0] !== undefined) {

0 commit comments

Comments
 (0)