Using New Relic with Sitecore - 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.

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.

There is a module on the marketplace that sorts all this out:
http://marketplace.sitecore.net/en/Modules/New_Relic.aspx

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).

Related

Two different interfaces for AWS Tag Editor?

It seems that there are two different Web UI for AWS Tag Editor (you need an AWS account to try them):
https://resources.console.aws.amazon.com/r/tags
I got this link from AWS Doc
https://eu-west-1.console.aws.amazon.com/resource-groups/tag-editor/find-resources?region=eu-west-1
In Management Console, if you select Resource Group > Tag Editor on the top of the console page, it will take you to this page
The two WebUI behave differently:
The former is global but the latter is region-specific (it will put you into a region even if you don't put the region parameter in the URL)
The former allows you to search for Not tagged in the filter; but the latter does not
The UI are slightly different
Is one of UI a newer version?
Update (2019-05-14)
(Please also see an explanation about the two links being NEW and OLD UIs that AWS offered at a certain point in time) By now the first link is gone. If you visit it, you will get a 404 Not Found error from AWS.
I am part of the team building the new Tag Editor. Yes, you are correct: Classic Tag Editor is deprecated, and will be shut down soon entirely. We are working on full feature parity between the two Editors, so you will very soon find everything you can do in the old one as well in the new one.
To add some more context on your different items below:
1) Both old and new Tag Editor use the same underlying tagging infrastructure, so this should never happen. Maybe there is some browser issue involved here? Feel free to open a support issue so we can look deeper into it, if this continues the case.
2) Yes, the new one also includes Lambda, and will very soon add more resource types. The same by the way for regions: The old Tag Editor supports not all regions, for example eu-north-1 or eu-west-3.
3) No, Route53 Hosted Zones are supported in both Editors. Route53 resources only exists in the us-east-1 region, so maybe you used the Tag Editor in another region?
4) Both Editors show the same data. The old editor merged what you used as Name Tag and the ID in the same field - in the new one, you see only the ID in the column ID, and the Name Tag is displayed in the column Tag: Name.
Searching across regions is something the new Editor soon will support, too, and the same applies for the filter you mention. For showing resources without a specific tag, there is a workaround you already can do: Click on the settings icon in the top right of the table, and enable the tag you are interested in as a column. You then can sort this column so that all untagged ones show up on top.
If you have any other ideas or requests for the Tag Editor, please let us know. The fastest and most reliable way is to just use the 'Feedback' Button in the console in the bottom left.
Cheers,
Florian
Hi I am providing my own answer here (thanks my colleagues Kannan for the insight)
#1 above is what AWS called Class Tag Editor. If you click on the Question mark on the Web UI (upper right corner), you will be taken to a page that says:
This documentation is for classic Tag Editor, which has been
deprecated
So #2 is the version that AWS want us to use.
Below I will called #1 Old and #2 New
I compared the example outputs from our environment (about 50 resources). The two outputs differ in these respects:
New seems to retain past resources for a longer time. For example, if an EC2 instance has been terminated, it may take a
longer time to be removed from the listing of New
New seems to include resources for DynamoDB but Old does not
Old seems to include resources for Route 53 Hosted Zones but New does not.
Both New and Old show Security Groups, but the ID strings are rendered slightly differently.
New renders an ID as sg-xxxxxxxxxxxxxxxxxxxxxx
Old renders an ID as someName (sg-xxxxxxxxxxxxxxxxx)

Refresh Sitecore index to include CD's

I've written some code to refresh an index when an item is programmatically added to Sitecore. Now as the live system is made up of 1 CM and 2 CD Servers I need my code to also trigger the indexing to be refreshed on the CD Servers (unfortunately my dev machine is just a single box so I can't test this fully). I've looked online but can't find anything about this when triggering a re-index programmatically.
So the question is do I need to write code for this or does Sitecore do this by default and if I do need to write code, does anyone have ideas how I go about this. My current code is below.
ISearchIndex index = ContentSearchManager.GetIndex("GeorgeDrexler_web_index");
Sitecore.Data.Database database = Sitecore.Configuration.Factory.GetDatabase("web");
Item item = database.GetItem("/sitecore/content/GeorgeDrexler/Global/Applications");
index.Refresh(new SitecoreIndexableItem(item));
My config for the index has the remotebuild strategy enabled
<strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/remoteRebuild" />
As #Hishaam Namooya pointed out in his comment, publishing from master to web should trigger the web index updates out of the box, unless you've disabled something in the configurations.
Note that items won't publish unless they are in a final workflow state, so if you want a completely automated process that creates the item, updates the local index, and then immediately updates the web index, you will also need to update the workflow state to your final approved state and then trigger a publish of the item.

Sitecore Scheduled Task: Cannot access any items in run class

I configured a scheduled task via database, which is triggered as expected and calls a method "Execute" in a C# class. My problem is that in my Execute method no Sitecore items can be accessed. I even get a NullPointerExecption when calling Sitecore.Context.Database.
I guess this must be a security problem, which makes sense. So I tried to get the permissions using UserSwitcher and SecurityDisabler, but that did not help.
Can anyone point me to what I'm missing?
You cannot use Sitecore.Context in a scheduled task. It does not exist there. Sitecore.Context is tied with HttpRequest, and there is no request in a scheduled task. And as John W writes in his article (The Sitecore Context):
The Sitecore context, exposed by the static Sitecore.Context class, contains information about the Sitecore installation and the current HTTP request. Processors in the httpRequestBegin pipeline defined in the web.config file are largely responsible for defining the Sitecore context. After Sitecore determines the context database, it determines the context item in that database.
In a schedule job you should get the database by its name, e.g.:
var masterDb = Sitecore.Data.Database.GetDatabase("master");
var webDb = Sitecore.Data.Database.GetDatabase("web");

Sitecore Commerce Connect > Refreshing a Cache via code

I am trying to update the commerce catalog from external source. After the incremental update I need to have fresh data in Sitecore tree(data provider should return correct data instead of old(cached) ones). However, if I go to Sitecore right after the data import I can see only the old data till I click on "Refresh Catalog Cache" button in Sitecore Commerce menu.
I found the same info in the documentation for Sitecore Commerce Connect, however I can't find any example how to clean cache via code.
I found several types in "Sitecore.Commerce.Connect.CommerceServer.Caching" namespace. For example, CacheRefresh static class. It has RefreshCatalogCaches method which needs ICommerceServerContextManager contextManager as input parameter. If I create contextManager just using constructor new CommerceServerContextManager() and passing it to the method - it doesn't work(at least I still need to clean cache manually).
I would appreciate any advise/suggestion.
Thank you in advance.
You should do in your code same that happens on "Refresh Catalog Cache" button click:
CacheRefreshEvent eventX = new CacheRefreshEvent("catalogcache", "master", = ID.Null);
EventManager.QueueEvent<CacheRefreshEvent>(eventX, true, true);
For more details, look on Sitecore.Commerce.Connect.CommerceServer.Caching.RefreshCache, Sitecore.Commerce.Connect.CommerceServer implementation via reflector.

Autonomy - Force reindexing without losing data

I need to add a new parameter to my Autonomy HTTP fetch configuration.
ImportFieldOp2=Expand
ImportFieldOpApplyTo2=AUTHOR
ImportFieldOpParam2=;;AUTHOR_M
I stop the HTTPFetch service and, after the config modification, I started the service.
The problem is that the change made is only applied to the new documents.
The old documents don't have the new parameter.
If I remove all the documents indexed works, but is a production environment and I can't do that.
How can i force the indexation of the old documents without losing data?
Thank you.
Look at the Content engine parameter KillDuplicates.
KillDuplicates=DREREFERENCE should do what you want.
A full re-crawl would be required to update the existing documents with the new ones.