Skip to content

Commit 8e43a3f

Browse files
committed
always expect client, change some comments
1 parent d8ec911 commit 8e43a3f

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

packages/core/src/utils/dsn.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ export function extractOrgIdFromDsnHost(host: string): string | undefined {
135135
*
136136
* The organization ID is extracted from the DSN. If the client options include a `orgId`, this will always take precedence.
137137
*/
138-
export function deriveOrgIdFromClient(client: Client | undefined): string | undefined {
139-
const options = client?.getOptions();
138+
export function deriveOrgIdFromClient(client: Client): string | undefined {
139+
const options = client.getOptions();
140140

141-
const { host } = client?.getDsn() || {};
141+
const { host } = client.getDsn() || {};
142142

143143
let org_id: string | undefined;
144144

packages/core/src/utils/tracing.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,32 +129,32 @@ function getSampleRandFromTraceparentAndDsc(
129129
}
130130

131131
/**
132-
* Determines whether a new trace should be continued based on the provided client and baggage org ID.
132+
* Determines whether a new trace should be continued based on the provided baggage org ID and the client's `strictTraceContinuation` option.
133133
* If the trace should not be continued, a new trace will be started.
134134
*
135135
* The result is dependent on the `strictTraceContinuation` option in the client.
136136
* See https://develop.sentry.dev/sdk/telemetry/traces/#stricttracecontinuation
137137
*/
138-
export function shouldContinueTrace(client: Client | undefined, baggageOrgId?: string): boolean {
138+
export function shouldContinueTrace(client: Client, baggageOrgId?: string): boolean {
139139
const sdkOptionOrgId = deriveOrgIdFromClient(client);
140140

141-
// Case: baggage orgID and SDK orgID don't match - always start new trace
141+
// Case: baggage orgID and Client orgID don't match - always start new trace
142142
if (baggageOrgId && sdkOptionOrgId && baggageOrgId !== sdkOptionOrgId) {
143143
debug.log(
144144
`Starting a new trace because org IDs don't match (incoming baggage: ${baggageOrgId}, SDK options: ${sdkOptionOrgId})`,
145145
);
146146
return false;
147147
}
148148

149-
const strictTraceContinuation = client?.getOptions()?.strictTraceContinuation || false; // default for `strictTraceContinuation` is `false`
149+
const strictTraceContinuation = client.getOptions()?.strictTraceContinuation || false; // default for `strictTraceContinuation` is `false`
150150

151151
if (strictTraceContinuation) {
152152
// With strict continuation enabled, start new trace if:
153-
// - Baggage has orgID, but SDK doesn't have one
154-
// - SDK has orgID, but baggage doesn't have one
153+
// - Baggage has orgID, but Client doesn't have one
154+
// - Client has orgID, but baggage doesn't have one
155155
if ((baggageOrgId && !sdkOptionOrgId) || (!baggageOrgId && sdkOptionOrgId)) {
156156
debug.log(
157-
`Starting a new trace because strict trace continuation is enabled and one org ID is missing (incoming baggage: ${baggageOrgId}, SDK options: ${sdkOptionOrgId})`,
157+
`Starting a new trace because strict trace continuation is enabled but one org ID is missing (incoming baggage: ${baggageOrgId}, SDK options: ${sdkOptionOrgId})`,
158158
);
159159
return false;
160160
}

packages/core/test/lib/utils/tracing.test.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,4 @@ describe('shouldContinueTrace', () => {
176176
const result = shouldContinueTrace(client, '123456');
177177
expect(result).toBe(false);
178178
});
179-
180-
test('returns true when client is undefined', () => {
181-
const result = shouldContinueTrace(undefined, '123456');
182-
expect(result).toBe(true);
183-
});
184-
185-
test('returns true when both org IDs and client are undefined', () => {
186-
const result = shouldContinueTrace(undefined, undefined);
187-
expect(result).toBe(true);
188-
});
189179
});

0 commit comments

Comments
 (0)