Sitecore Email Campaign Manager 2.1 appears to get stuck on sending emails whenever New Relic Application Performance Monitoring (APM) with Real User Monitoring (RUM) is Enabled, if New Relic is disabled the Email Campaign Manager sends as usual. The following conditions are apparent when New Relic RUM is Enabled.
- No errors reported in the Sitecore Logs
- Request just stops processing and that thread id never shows up in the log again
- IIS Log shows return codes of 200 so no failures there either
- When performing an IIS reset sometimes the email is received but in a delayed fashion, such as 30 minutes after an IIS Reset
- Below are the logs with Sitecore ECM debug set to True:
2016-11-28 12:00:57 ManagedPoolThread #4 INFO Job started: Sending message (86B4501BEE95446BAD97171F3316226E) 2016-11-28 12:00:57 ManagedPoolThread #4 INFO EmailCampaign: 'SendAnEmail': 1 recipient is added to the queue. 2016-11-28 12:00:57 ManagedPoolThread #4 INFO EmailCampaign: Dispatch Message (SendAnEmail): Started 2016-11-28 12:00:57 2600 INFO EmailCampaign: BodyLink -> GetTargetItemUrl: 00:00:00.0150126 2016-11-28 12:00:57 2600 INFO EmailCampaign: Get body link: 00:00:00.0180269 2016-11-28 12:00:58 2600 INFO EmailCampaign: Download string content(url): 00:00:00.6559992 2016-11-28 12:00:59 2600 INFO EmailCampaign: ReplaceTokens -> Find/Add $title$ token: 00:00:00.6088072 2016-11-28 12:00:59 2600 INFO EmailCampaign: Replace tokens: 00:00:00 2016-11-28 12:00:59 2600 INFO EmailCampaign: Remove 'form' tag: 00:00:00.0157781 2016-11-28 12:00:59 2600 INFO EmailCampaign: Remove VIEWSTATE: 00:00:00 2016-11-28 12:00:59 2600 INFO EmailCampaign: Insert style sheets: 00:00:00 2016-11-28 12:00:59 2600 INFO EmailCampaign: Modify 'href' links: 00:00:00.0491805
When the New Relic Configuration for Browser Monitoring is set for Auto Instrumentation a block of JavaScript is injected into the pseudo page used by Email Campaign Manager.
browserMonitoring autoInstrument="true"
This RUM block is improperly injected into the Email Templates within Sitecore as each page based email is assembled using Sitecore Presentation Details, when viewing the rendered source of the email the New Relic RUM Script is present is the source code.
(window.NREUM||(NREUM={}))
Sitecore Email Campaign Manager reads the output of the email which is a page in the Sitecore Content tree, including New Relic RUM, and then parses it to replace any tokens such as replacing $UserName$ with the actual user name. Part of this output processing includes updating any hyperlinks which are in the content as relative URL’s to be absolute path’s which are required for emails, this part was fails when New Relic RUM with Auto Instrumentation is enabled as verified via debugging. The previous step which completed was “Insert Style Sheets” which always completes but the following step, “Modify href links” consistently failed.Since emails don’t support JavaScript there is no value in having New Relic RUM enabled for Email Campaign Manager pages.
To remove New Relic RUM from being injected into these emails while leaving Auto Instrumentation enabled the New Relic Agent API NuGet Package and the following C# snipped added to either the MVC View Layout or Web Forms Page_Load event to stop New Relic from injecting the Browser Monitoring.
NewRelic.Api.Agent.NewRelic.DisableBrowserMonitoring();
This post on based on my StackOverflow Question titled Sitecore ECM 2.1 on Sitecore 7.2 Not Sending Emails when New Relic APM is Enabled.
Leave a Reply