You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-monitor/app/api-filtering-sampling.md
+7-10Lines changed: 7 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ ms.author: mbullwin
17
17
---
18
18
# Filtering and preprocessing telemetry in the Application Insights SDK
19
19
20
-
You can write and configure plug-ins for the Application Insights SDK to customize how telemetry can be enriched and processed before it is sent to the Application Insights service.
20
+
You can write and configure plug-ins for the Application Insights SDK to customize how telemetry can be enriched and processed before it's sent to the Application Insights service.
21
21
22
22
*[Sampling](../../azure-monitor/app/sampling.md) reduces the volume of telemetry without affecting your statistics. It keeps together related data points so that you can navigate between them when diagnosing a problem. In the portal, the total counts are multiplied to compensate for the sampling.
23
23
* Filtering with Telemetry Processors [for ASP.NET or ASP.NET Core](#filtering) or [Java](../../azure-monitor/app/java-filter-telemetry.md) lets you select or modify telemetry in the SDK before it is sent to the server. For example, you could reduce the volume of telemetry by excluding requests from robots. But filtering is a more basic approach to reducing traffic than sampling. It allows you more control over what is transmitted, but you have to be aware that it affects your statistics - for example, if you filter out all successful requests.
@@ -34,7 +34,7 @@ Before you start:
34
34
35
35
This technique gives you more direct control over what is included or excluded from the telemetry stream. Filtering can be used to drop telemetry items from being sent to Application Insights. You can use it in conjunction with Sampling, or separately.
36
36
37
-
To filter telemetry, you write a telemetry processor and register it with the `TelemetryConfiguration`. All telemetry goes through your processor, and you can choose to drop it from the stream, or add properties. This includes telemetry from the standard modules such as the HTTP request collector and the dependency collector, as well as telemetry you have written yourself. You can, for example, filter out telemetry about requests from robots, or successful dependency calls.
37
+
To filter telemetry, you write a telemetry processor and register it with the `TelemetryConfiguration`. All telemetry goes through your processor, and you can choose to drop it from the stream or give it to the next processor in the chain. This includes telemetry from the standard modules such as the HTTP request collector and the dependency collector, and telemetry you have tracked yourself. You can, for example, filter out telemetry about requests from robots, or successful dependency calls.
38
38
39
39
> [!WARNING]
40
40
> Filtering the telemetry sent from the SDK using processors can skew the statistics that you see in the portal, and make it difficult to follow related items.
@@ -45,7 +45,7 @@ To filter telemetry, you write a telemetry processor and register it with the `T
45
45
46
46
### Create a telemetry processor (C#)
47
47
48
-
1. To create a filter, implement ITelemetryProcessor. This is another extensibility point like telemetry module, telemetry initializer, and telemetry channel.
48
+
1. To create a filter, implement `ITelemetryProcessor`. `ITelemetryProcessor` is another extensibility point like telemetry module, telemetry initializer, and telemetry channel.
49
49
50
50
Notice that Telemetry Processors construct a chain of processing. When you instantiate a telemetry processor, you are given a reference to the next processor in the chain. When a telemetry data point is passed to the Process method, it does its work and then calls (or not calls) the next Telemetry Processor in the chain.
51
51
@@ -85,7 +85,7 @@ public class SuccessfulDependencyFilter : ITelemetryProcessor
85
85
2. Add your processor
86
86
87
87
**ASP.NET apps**
88
-
Insert this in ApplicationInsights.config:
88
+
Insert this snippet in ApplicationInsights.config:
89
89
90
90
```xml
91
91
<TelemetryProcessors>
@@ -96,14 +96,11 @@ Insert this in ApplicationInsights.config:
96
96
</TelemetryProcessors>
97
97
```
98
98
99
-
(This is the same section where you initialize a sampling filter.)
100
-
101
99
You can pass string values from the .config file by providing public named properties in your class.
102
100
103
101
> [!WARNING]
104
102
> Take care to match the type name and any property names in the .config file to the class and property names in the code. If the .config file references a non-existent type or property, the SDK may silently fail to send any telemetry.
105
103
>
106
-
>
107
104
108
105
**Alternatively,** you can initialize the filter in code. In a suitable initialization class - for example AppStart in Global.asax.cs - insert your processor into the chain:
109
106
@@ -124,7 +121,7 @@ TelemetryClients created after this point will use your processors.
124
121
> [!NOTE]
125
122
> Adding processor using `ApplicationInsights.config` or using `TelemetryConfiguration.Active` is not valid for ASP.NET Core applications or if you are using Microsoft.ApplicationInsights.WorkerService SDK.
126
123
127
-
For apps written using [ASP.NET Core](asp-net-core.md#adding-telemetry-processors) pr [WorkerService](worker-service.md#adding-telemetry-processors), adding a new `TelemetryProcessor` is done by using `AddApplicationInsightsTelemetryProcessor` extension method on `IServiceCollection`, as shown below. This is done in `ConfigureServices` method of your `Startup.cs` class.
124
+
For apps written using [ASP.NET Core](asp-net-core.md#adding-telemetry-processors) pr [WorkerService](worker-service.md#adding-telemetry-processors), adding a new `TelemetryProcessor` is done by using `AddApplicationInsightsTelemetryProcessor` extension method on `IServiceCollection`, as shown below. This method is called in `ConfigureServices` method of your `Startup.cs` class.
@@ -207,9 +204,9 @@ public void Process(ITelemetry item)
207
204
208
205
Use telemetry initializers to enrich telemetry with additional information and/or to override telemetry properties set by the standard telemetry modules.
209
206
210
-
For example, the Application Insights for Web package collects telemetry about HTTP requests. By default, it flags as failed any request with a response code >= 400. But if you want to treat 400 as a success, you can provide a telemetry initializer that sets the Success property.
207
+
For example, the Application Insights for Web package collect telemetry about HTTP requests. By default, it flags as failed any request with a response code >= 400. But if you want to treat 400 as a success, you can provide a telemetry initializer that sets the Success property.
211
208
212
-
If you provide a telemetry initializer, it is called whenever any of the Track*() methods are called. This includes methods called by the standard telemetry modules. By convention, these modules do not set any property that has already been set by an initializer. Telemetry initializers are called before calling telemetry processors. So any enrichment done by initializers are visible to processors.
209
+
If you provide a telemetry initializer, it is called whenever any of the Track*() methods are called. This includes `Track()`methods called by the standard telemetry modules. By convention, these modules do not set any property that has already been set by an initializer. Telemetry initializers are called before calling telemetry processors. So any enrichments done by initializers are visible to processors.
0 commit comments