Skip to content

Instantly share code, notes, and snippets.

@rajeshkrishnakumar
Last active November 16, 2021 06:11
Show Gist options
  • Save rajeshkrishnakumar/732017a7b63139240dc0302c3ffc6aae to your computer and use it in GitHub Desktop.
Save rajeshkrishnakumar/732017a7b63139240dc0302c3ffc6aae to your computer and use it in GitHub Desktop.
import newrelic from "newrelic"; // import the new relic package
/**
instead of
import newrelic from 'newrelic';
use this if you get error newrelic.setTransactionName is not a function or _newrelic.default.setTransactionName is not a function
import newrelic from 'newrelic/index';
**/
const helloWorld = async (parent, args, context, info) => {
newrelic.setTransactionName(info.fieldName);
//Calling Nodejs agent api to set the transaction name
const helloWorldResponse = {};
try {
const { name } = args.input;
helloWorldResponse = {
status: false,
message: `Hello World! ${name}`,
return helloWorldResponse;
} catch (error) {
console.log(error);
return handleError(error);
}
};
export default helloWorld;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment