Skip to content

Commit 3f40e64

Browse files
committed
Apply code review suggestions
Simplify applyToEvent logic
1 parent 8054398 commit 3f40e64

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

packages/hub/src/scope.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,12 +471,7 @@ export class Scope implements ScopeInterface {
471471
event.breadcrumbs = [...(event.breadcrumbs || []), ...this._breadcrumbs];
472472
event.breadcrumbs = event.breadcrumbs.length > 0 ? event.breadcrumbs : undefined;
473473

474-
// Since we're storing dynamic sampling context data in the event.sdkProcessingMetadata
475-
// field We have to re-apply it after we applied the Scope's field.
476-
// (This is because we're storing this data on the span and not on the scope)
477-
const baggage = event.sdkProcessingMetadata && event.sdkProcessingMetadata.baggage;
478-
event.sdkProcessingMetadata = this._sdkProcessingMetadata || {};
479-
event.sdkProcessingMetadata.baggage = baggage;
474+
event.sdkProcessingMetadata = { ...event.sdkProcessingMetadata, ...this._sdkProcessingMetadata };
480475

481476
return this._notifyEventProcessors([...getGlobalEventProcessors(), ...this._eventProcessors], event, hint);
482477
}

packages/tracing/src/span.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ export class Span implements SpanInterface {
384384
const { publicKey } = (client && client.getDsn()) || {};
385385

386386
const metadata = this.transaction && this.transaction.metadata;
387-
const sampelRate = metadata && metadata.transactionSampling && metadata.transactionSampling.rate;
387+
const sampleRate = metadata && metadata.transactionSampling && metadata.transactionSampling.rate;
388388

389389
const traceId = this.traceId;
390390

@@ -402,15 +402,15 @@ export class Span implements SpanInterface {
402402
transactionName && setBaggageValue(baggage, 'transaction', transactionName);
403403
userId && setBaggageValue(baggage, 'userid', userId);
404404
userSegment && setBaggageValue(baggage, 'usersegment', userSegment);
405-
sampelRate &&
405+
sampleRate &&
406406
setBaggageValue(
407407
baggage,
408408
'samplerate',
409409
// This will make sure that expnent notation (e.g. 1.45e-14) is converted to simple decimal representation
410410
// Another edge case would be something like Number.NEGATIVE_INFINITY in which case we could still
411411
// add something like .replace(/-?∞/, '0'). For the sake of saving bytes, I'll not add this until
412412
// it becomes a problem
413-
sampelRate.toLocaleString('fullwide', { useGrouping: false, maximumFractionDigits: 16 }),
413+
sampleRate.toLocaleString('fullwide', { useGrouping: false, maximumFractionDigits: 16 }),
414414
);
415415
publicKey && setBaggageValue(baggage, 'publickey', publicKey);
416416
traceId && setBaggageValue(baggage, 'traceid', traceId);

0 commit comments

Comments
 (0)