biswpo
biswpo

Reputation: 809

Can we determine which dependency is associated with which request telemetry in the code in appication Insights

I have a requirement to suppress all the auto generated dependency telemetries that is getting generated for the health check api request. Is there a way to identify in code which dependency telemetry is generated from which request telemetry and then in a Telemetry processor remove them

Upvotes: 0

Views: 171

Answers (1)

Ivan Glasenberg
Ivan Glasenberg

Reputation: 29985

If you know the operation name of the health check api request, then it's possible. For how to get the operation name of the api request, you can set a checkpoint in your Telemetry processor class.

For example, the operation name is "Get api/check", then you can write the following code in your custom Telemetry processor class:

    //your other code

    public void Process(ITelemetry item)
    {
        if (!ProcessItem(item)) { return; }
        this.Next.Process(item);
    }

    private bool ProcessItem(ITelemetry item)
    {            
        if (item is DependencyTelemetry dependencyTelemetry)
        {
            var op_name = dependencyTelemetry.Context.Operation.Name;

            if (op_name == "Get api/check")//please remember replace it to the real operation name.
            {
                return false;
            }
        }

        return true;

    }

Upvotes: 1

Related Questions