Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update api-filtering-sampling.md #42172

Merged
merged 4 commits into from
Nov 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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