QuestionQ113

VerifiedMonitor and troubleshoot Azure solutions

You need to implement telemetry for non-user actions.

How should you complete the Filter class? Each code segment may be used once, more than once, or not at all.

Drag & Drop
public class Filter : 
{
    private readonly  _next;
    public Filter( next)
    {
        _next = next;
    }
    public void Process(ITelemetry item)
    {
        var x = item as ;
        if (x?.Url.AbsolutePath == "")
        {
            return;
        }
        _next.Process(item);
    }
}
Explanation

To filter telemetry you implement ITelemetryProcessor, which appears three times in the Filter class: the class implements the interface, the Next field is typed as ITelemetryProcessor, and the constructor takes an ITelemetryProcessor next parameter. In the Process method the item is cast to RequestTelemetry so request-specific properties (such as the URL path) can be inspected. Non-user actions are the automated health-check requests, so the code drops telemetry whose path equals /health by returning without calling Next.Process. PageViewTelemetry and ITelemetryInitializer are wrong: initializers add/modify properties rather than drop items, and page views represent user actions, not the health-check traffic being filtered.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!