Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Log warning when tracing extensions are missing #7601

Merged
merged 9 commits into from
Apr 11, 2023
22 changes: 20 additions & 2 deletions packages/core/src/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,17 @@ export class Hub implements HubInterface {
* @inheritDoc
*/
public startTransaction(context: TransactionContext, customSamplingContext?: CustomSamplingContext): Transaction {
return this._callExtensionMethod('startTransaction', context, customSamplingContext);
const result = this._callExtensionMethod<Transaction>('startTransaction', context, customSamplingContext);

if (__DEBUG_BUILD__ && !result) {
throw new Error(`Tracing extension 'startTransaction' has not been added. Call 'addTracingExtensions' before calling 'init':
timfish marked this conversation as resolved.
Show resolved Hide resolved

Sentry.addTracingExtensions();
Sentry.init({...});
`);
}

return result;
}

/**
Expand Down Expand Up @@ -480,7 +490,15 @@ export class Hub implements HubInterface {
if (sentry && sentry.extensions && typeof sentry.extensions[method] === 'function') {
return sentry.extensions[method].apply(this, args);
}
__DEBUG_BUILD__ && logger.warn(`Extension method ${method} couldn't be found, doing nothing.`);
throw new Error(`Tracing extension '${method}' has not been added.
Call 'addTracingExtensions' before calling 'init':

Sentry.addTracingExtensions();

Sentry.init({
...
});
`);
}
}

Expand Down