Application Insights records requests for all content pages in Sitecore as being for “Sitecore/Index”. That’s because this is the controller route under which those pages are processed – but it’s not that helpful if you want to see things like the performance of individual pages. Well, there is an answer, as detailed by Per Osbeck – Application Insights: GETing a fix for Sitecore/Index | by Per Osbeck | Medium .
The short form of this is he used a TelemetryProcessor to update the item.Context.Operation.Name and request.Name to the absoluteUrl being processed.
I’ve included the relevant code below, just in case the article vanishes off Medium.com.
public class SitecoreIndexSplitter : ITelemetryProcessor
{
private ITelemetryProcessor Next { get; set; }
// next will point to the next TelemetryProcessor in the chain.
public SitecoreIndexSplitter(ITelemetryProcessor next)
{
this.Next = next;
}
public void Process(ITelemetry item)
{
if (item is RequestTelemetry request && request?.Url != null)
{
switch (item.Context?.Operation?.Name)
{
// Others?
case "GET Sitecore/Index":
case "POST Sitecore/Index":
case "HEAD Sitecore/Index":
case "OPTIONS Sitecore/Index":
var method = request.Name.Split(' ')[0];
item.Context.Operation.Name = request.Name = $"{method} {request.Url.AbsolutePath}";
break;
case "GET Sitecore.LayoutService.Mvc.Controllers.LayoutServiceController, Sitecore.LayoutService.Mvc/render":
if (request.Url?.Query == null)
{
break;
}
var query = System.Web.HttpUtility.ParseQueryString(request.Url.Query);
item.Context.Operation.Name = request.Name = $"{request.Name.Split(' ')[0]} /{query.Get("sc_lang")?.ToLowerInvariant()}{query.Get("item")}".TrimEnd('/') + " [platform]";
break;
}
}
Next.Process(item);
}
}