@@ -3,6 +3,7 @@ import { isNaN, logger } from '@sentry/utils';
33
44import { DEBUG_BUILD } from '../debug-build';
55import { hasTracingEnabled } from '../utils/hasTracingEnabled';
6+ import { spanSetMetadata } from '../utils/spanUtils';
67import type { Transaction } from './transaction';
78
89/**
@@ -27,7 +28,7 @@ export function sampleTransaction<T extends Transaction>(
2728
2829 // if the user has forced a sampling decision by passing a `sampled` value in their transaction context, go with that
2930 if (transaction.sampled !== undefined) {
30- transaction.setMetadata( {
31+ spanSetMetadata(transaction, {
3132 sampleRate: Number(transaction.sampled),
3233 });
3334 return transaction;
@@ -38,20 +39,20 @@ export function sampleTransaction<T extends Transaction>(
3839 let sampleRate;
3940 if (typeof options.tracesSampler === 'function') {
4041 sampleRate = options.tracesSampler(samplingContext);
41- transaction.setMetadata( {
42+ spanSetMetadata(transaction, {
4243 sampleRate: Number(sampleRate),
4344 });
4445 } else if (samplingContext.parentSampled !== undefined) {
4546 sampleRate = samplingContext.parentSampled;
4647 } else if (typeof options.tracesSampleRate !== 'undefined') {
4748 sampleRate = options.tracesSampleRate;
48- transaction.setMetadata( {
49- sampleRate: Number(sampleRate) ,
49+ spanSetMetadata(transaction, {
50+ sampleRate,
5051 });
5152 } else {
5253 // When `enableTracing === true`, we use a sample rate of 100%
5354 sampleRate = 1;
54- transaction.setMetadata( {
55+ spanSetMetadata(transaction, {
5556 sampleRate,
5657 });
5758 }
0 commit comments