Skip to content

Commit

Permalink
Merge pull request #42172 from ramthi/patch-3
Browse files Browse the repository at this point in the history
Update api-filtering-sampling.md
  • Loading branch information
ktoliver authored Nov 8, 2019
2 parents 85d56c3 + f020040 commit 9e083cb
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions articles/azure-monitor/app/api-filtering-sampling.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ You can write and configure plug-ins for the Application Insights SDK to customi

Before you start:

* Install the appropriate SDK for your application: [ASP.NET](asp-net.md), [ASP.NET Core](asp-net-core.md), [Non HTTP/Worker for .NET/.NET Core](worker-service.md), or [Java](../../azure-monitor/app/java-get-started.md).
* Install the appropriate SDK for your application: [ASP.NET](asp-net.md), [ASP.NET Core](asp-net-core.md), [Non HTTP/Worker for .NET/.NET Core](worker-service.md), [Java](../../azure-monitor/app/java-get-started.md) or [JavaScript](javascript.md)

<a name="filtering"></a>

## Filtering: ITelemetryProcessor
## Filtering

This technique gives you 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.

Expand Down Expand Up @@ -195,7 +195,30 @@ public void Process(ITelemetry item)

<a name="add-properties"></a>

## Add properties: ITelemetryInitializer
### JavaScript Web applications

**Filtering using ITelemetryInitializer**

1. Create a telemetry initializer callback function. The callback function takes `ITelemetryItem` as a parameter, which is the event that is being processed. Returning `false` from this callback results in the telemetry item to be filtered out.

```JS
var filteringFunction = (envelope) => {
if (envelope.data.someField === 'tobefilteredout') {
return false;
}

return true;
};
```

2. Add your telemetry initializer callback:

```JS
appInsights.addTelemetryInitializer(filteringFunction);
```

## Add/modify properties: ITelemetryInitializer


Use telemetry initializers to enrich telemetry with additional information and/or to override telemetry properties set by the standard telemetry modules.

Expand Down

0 comments on commit 9e083cb

Please sign in to comment.