-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
startTransaction method no longer returning transaction #4731
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
Comments
Hi, @crice88. This is very odd. I can't think right now of any change we've made at all recently which would affect that. Would you be able to provide a minimal repro for us to poke at? |
This repo is not mine, but is affected with the same issue If you were to update the sentry SDK to current in the project, you'll see the error being thrown. |
Thanks @crice88, saw your message on StackOverflow. I am the owner of the Nest.js example. I can reproduce the bug on my side as well. I am not sure what's happening so far. It seems I have another error in my log:
As you said this started after upgrading from 6.11. My repo hasn't changed since Aug 18, 2021. |
I am also getting the undefined transaction issue for a Nest JS API. In my case it only happens on windows, I tested on a Macbook Air with an M1 chip and transactions where working properly but tested on two PCs (Windows 10 and 11) and I am not able to create transactions. I also got the idea of trying with version 6.11.0 of @sentry/node and transactions started working |
I have the same problem here when I tried to implement https://blog.sentry.io/2021/08/31/guest-post-performance-monitoring-in-graphql#solution it seems I have to use version 6.11.0 for @sentry/node @sentry/tracing and @sentry/types for now. |
Same problem, |
Importing the |
You can use: Name-space imports such as: |
Encountered the same problem. Confirming that |
just a question for this, is this means that this issue is fixed by this? getsentry/sentry-docs#4876 and doesn't need to import |
@j-elmer123 no, that's just documentation. When a fix has been merged, they'll close this issue. |
Encountering the same issue after updating to sentry sdk latest version Adding |
@SimonSchick Sometimes your bundler might be a little too smart and will remove the import statement that has no use. Try |
Manually reverting eb09c28 solved this for me. 6.19.4 confirmed good |
Concur with @kpdecker - 6.19.4 has the issue resolved. |
In 6.19.6 having a |
I'm on 6.19.7 and still have this issue, the result is undefined unless I import |
@lforst Yes, 100% sure. Here's the breakdown of what happened... We were working great in production, then we shipped this upgrade: - "@sentry/node": "^6.17.7",
- "@sentry/tracing": "^6.17.7",
+ "@sentry/node": "^6.19.7",
+ "@sentry/tracing": "^6.19.7", Production went down because We updated the file that calls +// TODO: This is a workaround; see https://github.com/getsentry/sentry-javascript/issues/4731
+// Check for updates, maybe they have a fix
+import '@sentry/tracing'; And then production recovered. Here is the full file with the patch included: import * as Sentry from '@sentry/node';
import { Transaction } from '@sentry/types';
import { ApolloServerPlugin, GraphQLRequestListener } from 'apollo-server-plugin-base';
// TODO: This is a workaround; see https://github.com/getsentry/sentry-javascript/issues/4731
// Check for updates, maybe they have a fix
import '@sentry/tracing';
export interface Context {
transaction: Transaction;
}
export function createContext(): Context {
const transaction = Sentry.startTransaction({
op: 'gql',
name: 'GraphQLTransaction', // this will be the default name, unless the gql query has a name
});
return { transaction };
}
export const SentryPlugin: ApolloServerPlugin<Context> = {
async requestDidStart(requestContext): Promise<GraphQLRequestListener<Context>> {
const context = requestContext.context;
const request = requestContext.request;
if (request.operationName) {
// set the transaction Name if we have named queries
context.transaction.setName(request.operationName);
}
return {
willSendResponse(): any {
context.transaction.finish();
},
executionDidStart(): any {
return {
willResolveField({ info }): any {
// hook for each new resolver
const span = context.transaction.startChild({
op: 'resolver',
description: `${info.parentType.name}.${info.fieldName}`,
});
return () => {
// this will execute once the resolver is finished
span.finish();
};
},
};
},
};
},
}; ^ this file was working fine on
|
@JVMartin just checked back with the rest of the team. In short: The way you've set up things right now is the intended and correct way. We have updated the docs to list For anyone stumbling onto this issue, please import as follows for tracing to work: import * as Sentry from "@sentry/node";
import "@sentry/tracing"; |
FWIW, none of these solutions above helped me until I upgraded all my Sentry packages to |
Still facing this issue with version |
@lforst Even tho it's documented like that, given all the comments and confusion in this ticket, it's rather unexpected. How about something like this: import { NodeTracing } "@sentry/tracing";
Sentry.init({
// ...
integrations: [new NodeTracing()],
}); Even if its useless and does nothing, but it adds the syntactic sugar to avoid confusion. |
@MichaelSp Good idea. Our long-term plan for this is probably to merge the tracing packages into the respective packages and to export some kind of tracing integration as you mentioned. It would be pretty easy to do that for |
Is there an existing issue for this?
How do you use Sentry?
Saas (sentry.io)
Which package are you using?
@sentry/node
SDK Version
6.18.2
Framework Version
No response
Link to Sentry event
No response
Steps to Reproduce
We are using Nestjs and create spanned transactions for logging. Recently upgraded from
6.11.0
to6.18.2
and began seeing the issue. Here's just a bit of sample usage:Transaction is undefined in this instance so a scope is never configured. I have tested the
startTransaction
method in two separate projects and both are experiencing the same issue. Downgrading library back to6.11.0
fixes the issue.Expected Result
startTransaction
method should return an instance of transaction so it can be used for proper scoping.Actual Result
When pulling the scoped span via
Sentry.getCurrentHub().getScope()?.getSpan();
I am receiving undefined as the span was never created properly due to the transaction being undefined.The text was updated successfully, but these errors were encountered: