Skip to content

Commit ce227d0

Browse files
committed
s/sampleContext/samplingContext
1 parent 8305b71 commit ce227d0

File tree

8 files changed

+34
-31
lines changed

8 files changed

+34
-31
lines changed

packages/gatsby/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ To enable tracing, supply either `tracesSampleRate` or `tracesSampler` to the op
5656
tracesSampleRate: 1,
5757

5858
// Alternatively:
59-
tracesSampler: sampleContext => {
59+
tracesSampler: samplingContext => {
6060
// Examine provided context data (along with anything in the global namespace) to decide the sample rate
6161
// for this transaction.
6262
// Can return 0 to drop the transaction entirely.

packages/hub/src/hub.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
Breadcrumb,
44
BreadcrumbHint,
55
Client,
6-
CustomSampleContext,
6+
CustomSamplingContext,
77
Event,
88
EventHint,
99
Extra,
@@ -370,8 +370,8 @@ export class Hub implements HubInterface {
370370
/**
371371
* @inheritDoc
372372
*/
373-
public startTransaction(context: TransactionContext, customSampleContext?: CustomSampleContext): Transaction {
374-
return this._callExtensionMethod('startTransaction', context, customSampleContext);
373+
public startTransaction(context: TransactionContext, customSamplingContext?: CustomSamplingContext): Transaction {
374+
return this._callExtensionMethod('startTransaction', context, customSamplingContext);
375375
}
376376

377377
/**

packages/minimal/src/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { getCurrentHub, Hub, Scope } from '@sentry/hub';
22
import {
33
Breadcrumb,
44
CaptureContext,
5-
CustomSampleContext,
5+
CustomSamplingContext,
66
Event,
77
Extra,
88
Extras,
@@ -202,11 +202,14 @@ export function _callOnClient(method: string, ...args: any[]): void {
202202
* finished child spans will be sent to Sentry.
203203
*
204204
* @param context Properties of the new `Transaction`.
205-
* @param customSampleContext Information given to the transaction sampling function (along with context-dependent
205+
* @param customSamplingContext Information given to the transaction sampling function (along with context-dependent
206206
* default values). See {@link Options.tracesSampler}.
207207
*
208208
* @returns The transaction which was just started
209209
*/
210-
export function startTransaction(context: TransactionContext, customSampleContext?: CustomSampleContext): Transaction {
211-
return callOnHub('startTransaction', { ...context }, customSampleContext);
210+
export function startTransaction(
211+
context: TransactionContext,
212+
customSamplingContext?: CustomSamplingContext,
213+
): Transaction {
214+
return callOnHub('startTransaction', { ...context }, customSamplingContext);
212215
}

packages/tracing/src/hubextensions.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getActiveDomain, getMainCarrier, Hub } from '@sentry/hub';
2-
import { CustomSampleContext, SampleContext, TransactionContext } from '@sentry/types';
2+
import { CustomSamplingContext, SamplingContext, TransactionContext } from '@sentry/types';
33
import {
44
dynamicRequire,
55
extractNodeRequestData,
@@ -48,11 +48,11 @@ function _inheritOrUseGivenRate(parentSampled: boolean | undefined, givenRate: u
4848
*
4949
* @param hub: The hub off of which to read config options
5050
* @param transaction: The transaction needing a sampling decision
51-
* @param sampleContext: Default and user-provided data which may be used to help make the decision
51+
* @param samplingContext: Default and user-provided data which may be used to help make the decision
5252
*
5353
* @returns The given transaction with its `sampled` value set
5454
*/
55-
function sample<T extends Transaction>(hub: Hub, transaction: T, sampleContext: SampleContext = {}): T {
55+
function sample<T extends Transaction>(hub: Hub, transaction: T, samplingContext: SamplingContext = {}): T {
5656
const client = hub.getClient();
5757
const options = (client && client.getOptions()) || {};
5858

@@ -66,8 +66,8 @@ function sample<T extends Transaction>(hub: Hub, transaction: T, sampleContext:
6666
// work; prefer the hook if so
6767
const sampleRate =
6868
typeof options.tracesSampler === 'function'
69-
? options.tracesSampler(sampleContext)
70-
: _inheritOrUseGivenRate(sampleContext.parentSampled, options.tracesSampleRate);
69+
? options.tracesSampler(samplingContext)
70+
: _inheritOrUseGivenRate(samplingContext.parentSampled, options.tracesSampleRate);
7171

7272
// Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The
7373
// only valid values are booleans or numbers between 0 and 1.)
@@ -116,12 +116,12 @@ function sample<T extends Transaction>(hub: Hub, transaction: T, sampleContext:
116116
*
117117
* @returns The default sample context
118118
*/
119-
function getDefaultSampleContext<T extends Transaction>(transaction: T): SampleContext {
120-
const defaultSampleContext: SampleContext = {};
119+
function getDefaultSamplingContext<T extends Transaction>(transaction: T): SamplingContext {
120+
const defaultSamplingContext: SamplingContext = {};
121121

122122
// include parent's sampling decision, if there is one
123123
if (transaction.parentSpanId && transaction.sampled !== undefined) {
124-
defaultSampleContext.parentSampled = transaction.sampled;
124+
defaultSamplingContext.parentSampled = transaction.sampled;
125125
}
126126

127127
if (isNodeEnv()) {
@@ -142,7 +142,7 @@ function getDefaultSampleContext<T extends Transaction>(transaction: T): SampleC
142142
const request = domain.members.find((member: any) => isInstanceOf(member, requestType));
143143

144144
if (request) {
145-
defaultSampleContext.request = extractNodeRequestData(request);
145+
defaultSamplingContext.request = extractNodeRequestData(request);
146146
}
147147
}
148148
}
@@ -154,11 +154,11 @@ function getDefaultSampleContext<T extends Transaction>(transaction: T): SampleC
154154

155155
if ('location' in globalObject) {
156156
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
157-
defaultSampleContext.location = { ...(globalObject as any).location };
157+
defaultSamplingContext.location = { ...(globalObject as any).location };
158158
}
159159
}
160160

161-
return defaultSampleContext;
161+
return defaultSamplingContext;
162162
}
163163

164164
/**
@@ -197,10 +197,10 @@ function isValidSampleRate(rate: unknown): boolean {
197197
function _startTransaction(
198198
this: Hub,
199199
context: TransactionContext,
200-
customSampleContext?: CustomSampleContext,
200+
customSamplingContext?: CustomSamplingContext,
201201
): Transaction {
202202
const transaction = new Transaction(context, this);
203-
return sample(this, transaction, { ...getDefaultSampleContext(transaction), ...customSampleContext });
203+
return sample(this, transaction, { ...getDefaultSamplingContext(transaction), ...customSamplingContext });
204204
}
205205

206206
/**
@@ -213,7 +213,7 @@ export function startIdleTransaction(
213213
onScope?: boolean,
214214
): IdleTransaction {
215215
const transaction = new IdleTransaction(context, hub, idleTimeout, onScope);
216-
return sample(hub, transaction, getDefaultSampleContext(transaction));
216+
return sample(hub, transaction, getDefaultSamplingContext(transaction));
217217
}
218218

219219
/**

packages/types/src/hub.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Integration, IntegrationClass } from './integration';
66
import { Scope } from './scope';
77
import { Severity } from './severity';
88
import { Span, SpanContext } from './span';
9-
import { CustomSampleContext, Transaction, TransactionContext } from './transaction';
9+
import { CustomSamplingContext, Transaction, TransactionContext } from './transaction';
1010
import { User } from './user';
1111

1212
/**
@@ -194,10 +194,10 @@ export interface Hub {
194194
* finished child spans will be sent to Sentry.
195195
*
196196
* @param context Properties of the new `Transaction`.
197-
* @param customSampleContext Information given to the transaction sampling function (along with context-dependent
197+
* @param customSamplingContext Information given to the transaction sampling function (along with context-dependent
198198
* default values). See {@link Options.tracesSampler}.
199199
*
200200
* @returns The transaction which was just started
201201
*/
202-
startTransaction(context: TransactionContext, customSampleContext?: CustomSampleContext): Transaction;
202+
startTransaction(context: TransactionContext, customSamplingContext?: CustomSamplingContext): Transaction;
203203
}

packages/types/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export { Span, SpanContext } from './span';
2323
export { StackFrame } from './stackframe';
2424
export { Stacktrace } from './stacktrace';
2525
export { Status } from './status';
26-
export { CustomSampleContext, SampleContext, Transaction, TransactionContext } from './transaction';
26+
export { CustomSamplingContext, SamplingContext, Transaction, TransactionContext } from './transaction';
2727
export { Thread } from './thread';
2828
export { Transport, TransportOptions, TransportClass } from './transport';
2929
export { User } from './user';

packages/types/src/options.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Breadcrumb, BreadcrumbHint } from './breadcrumb';
22
import { Event, EventHint } from './event';
33
import { Integration } from './integration';
44
import { LogLevel } from './loglevel';
5-
import { SampleContext } from './transaction';
5+
import { SamplingContext } from './transaction';
66
import { Transport, TransportClass, TransportOptions } from './transport';
77

88
/** Base configuration options for every SDK. */
@@ -130,12 +130,12 @@ export interface Options {
130130
* ignored.
131131
*
132132
* Will automatically be passed a context object of default and optional custom data. See
133-
* {@link Transaction.sampleContext} and {@link Hub.startTransaction}.
133+
* {@link Transaction.samplingContext} and {@link Hub.startTransaction}.
134134
*
135135
* @returns A sample rate between 0 and 1 (0 drops the trace, 1 guarantees it will be sent). Returning `true` is
136136
* equivalent to returning 1 and returning `false` is equivalent to returning 0.
137137
*/
138-
tracesSampler?(sampleContext: SampleContext): number | boolean;
138+
tracesSampler?(samplingContext: SamplingContext): number | boolean;
139139

140140
/**
141141
* A callback invoked during event submission, allowing to optionally modify

packages/types/src/transaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export interface Transaction extends TransactionContext, Span {
5353
/**
5454
* Context data passed by the user when starting a transaction, to be used by the tracesSampler method.
5555
*/
56-
export interface CustomSampleContext {
56+
export interface CustomSamplingContext {
5757
[key: string]: any;
5858
}
5959

@@ -62,7 +62,7 @@ export interface CustomSampleContext {
6262
*
6363
* Adds default data to data provided by the user. See {@link Hub.startTransaction}
6464
*/
65-
export interface SampleContext extends CustomSampleContext {
65+
export interface SamplingContext extends CustomSamplingContext {
6666
/**
6767
* Object representing the URL of the current page or worker script. Passed by default in a browser or service worker
6868
* context.

0 commit comments

Comments
 (0)