garner
garner

Reputation: 85

Using New Relic with Sitecore

I am testing New Relic with Sitecore CMS. All of the New Relic web transactions are being sent to the items layout file, so I am unable to drill into item level details in New Relic.

I am trying to use the New Relic API to call SetTransactionName and set it to the items URL, but I can't seem to make it work. I have created an httprequestbegin pipeline processor, and I have put it right at the end, right after:

<processor type="Sitecore.Pipelines.HttpRequest.ExecuteRequest, Sitecore.Kernel"/>

I have the New Relic API assembly installed, and is also in my bin folder. Here is the line of code that I am trying to run.

NewRelic.Api.Agent.NewRelic.SetTransactionName("Custom", Sitecore.Context.RawUrl);

Any ideas what I am possibly doing wrong? All web transactions still show up as the items layout file.

Upvotes: 4

Views: 2343

Answers (3)

Andy
Andy

Reputation: 180

There is a module on the marketplace that sorts all this out:

http://marketplace.sitecore.net/en/Modules/New_Relic.aspx

Upvotes: 1

Kyle Heon
Kyle Heon

Reputation: 412

We had similar issues when we started using New Relic with our Sitecore application about 18 or so months back. Unfortunately nobody was using New Relic with Sitecore at the time. What we settled on was to add the following code to a base Page class that every page in our site inherits:

    // --- Set custom transaction name for New Relic.
NewRelic.Api.Agent.NewRelic.SetTransactionName("Pages", Sitecore.Context.Item.Template.FullName));

// --- Set custom parameter to store raw url to assist with diagnostics.
NewRelic.Api.Agent.NewRelic.AddCustomParameter("RawUrl", Request.RawUrl);

For our application template names are enough to distinguish trends and we added the custom parameter to stuff the entire RawUrl (we noticed oddities at the time where New Relic wasn't capturing the complete url for us, that might not be the case any longer).

Upvotes: 0

pbering
pbering

Reputation: 943

I'm setting the transaction name in the httpRequestProcessed pipeline and that works. Started out using the httpRequestBegin but I found that is was not working every time. Also remember that your request must take longer than 500 ms to execute before NewRelic picks it up.

Additional integration points I did with Sitecore:

  • Log4Net Appender that reports to NewRelic using NoticeError
  • HttpModule picking up Application_Error and reporting to NewRelic using NoticeError
  • Use Item path to name transactions and use AddCustomParameter to add Language, Database, User etc.

Upvotes: 1

Related Questions