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
Alternatively, youcaninitializethefilterincode. Inasuitableinitialization class, for example, AppStart in `Global.asax.cs`, insert your processor into the chain:
108
-
109
-
```csharp
110
-
var builder = TelemetryConfiguration.Active.DefaultTelemetrySink.TelemetryProcessorChainBuilder;
Telemetry clients created after this point use your processors.
120
-
121
-
ASP.NET **Core/Worker service apps**
122
-
123
-
> [!NOTE]
124
-
> Adding a processor by using `ApplicationInsights.config` or `TelemetryConfiguration.Active` isn't valid for ASP.NET Core applications or if you're using the Microsoft.ApplicationInsights.WorkerService SDK.
125
-
126
-
For apps written by using [ASP.NET Core](asp-net-core.md#add-telemetry-processors) or [WorkerService](worker-service.md#add-telemetry-processors), adding a new telemetry processor is done by using the `AddApplicationInsightsTelemetryProcessor` extension method on `IServiceCollection`, as shown. This method is called in the `ConfigureServices` method of your `Startup.cs` class.
Alternatively, youcaninitializethefilterincode. Inasuitableinitialization class, for example, AppStart in `Global.asax.cs`, insert your processor into the chain:
108
+
109
+
```csharp
110
+
var builder = TelemetryConfiguration.Active.DefaultTelemetrySink.TelemetryProcessorChainBuilder;
To register telemetry processors that need parameters in ASP.NET Core, create a custom class implementing **ITelemetryProcessorFactory**. Call the constructor with the desired parameters in the **Create** method and then use **AddSingleton<ITelemetryProcessorFactory, MyTelemetryProcessorFactory>()**.
141
-
142
-
### Example filters
143
-
144
-
#### Synthetic requests
145
-
146
-
Filter out bots and web tests. Although Metrics Explorer gives you the option to filter out synthetic sources, this option reduces traffic and ingestion size by filtering them at the SDK itself.
147
-
148
-
```csharp
149
-
publicvoidProcess(ITelemetryitem)
150
-
{
151
-
if (!string.IsNullOrEmpty(item.Context.Operation.SyntheticSource)) {return;}
>Addingaprocessorbyusing `ApplicationInsights.config` or `TelemetryConfiguration.Active` isn'tvalidforASP.NETCoreapplicationsorifyou'reusingtheMicrosoft.ApplicationInsights.WorkerServiceSDK.
ToregistertelemetryprocessorsthatneedparametersinASP.NETCore, createacustomclassimplementing **ITelemetryProcessorFactory**. Call the constructor with the desired parameters in the **Create** method and then use **AddSingleton<ITelemetryProcessorFactory, MyTelemetryProcessorFactory>()**.
141
+
142
+
### Example filters
143
+
144
+
#### Synthetic requests
145
+
146
+
Filter out bots and web tests. Although Metrics Explorer gives you the option to filter out synthetic sources, this option reduces traffic and ingestion size by filtering them at the SDK itself.
147
+
148
+
```csharp
149
+
public void Process(ITelemetryitem)
150
+
{
151
+
if (!string.IsNullOrEmpty(item.Context.Operation.SyntheticSource)) {return;}
152
+
153
+
// Send everything else:
154
+
this.Next.Process(item);
155
+
}
156
+
```
157
157
158
158
#### Failed authentication
159
159
@@ -233,13 +233,13 @@ To learn more about telemetry processors and their implementation in Java, refer
233
233
234
234
Use telemetry initializers to enrich telemetry with additional information or to override telemetry properties set by the standard telemetry modules.
235
235
236
-
For example, Application Insights for a web package collects telemetry about HTTPrequests. 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.
236
+
For example, Application Insights for a web package collects telemetry about HTTPrequests. By default, it flags any request with a response code >=400 as failed. If instead you want to treat 400 as a success, you can provide a telemetry initializer that sets the success property.
237
237
238
-
If you provide a telemetry initializer, it's called whenever any of the Track*() methods are called. This initializer includes `Track()` methods called by the standard telemetry modules. By convention, these modules don't set any property that was already set by an initializer. Telemetry initializers are called before calling telemetry processors. So any enrichments done by initializers are visible to processors.
238
+
If you provide a telemetry initializer, it's called whenever any of the Track*() methods are called. This initializer includes `Track()` methods called by the standard telemetry modules. By convention, these modules don't set any property that was already set by an initializer. Telemetry initializers are called before calling telemetry processors, so any enrichments done by initializers are visible to processors.
See more of [this sample](https://github.com/MohanGsk/ApplicationInsights-Home/tree/master/Samples/AzureEmailService/MvcWebRole).
306
308
307
-
ASP.NET**Core/Worker service apps: Load your initializer**
309
+
**ASP.NET Core/Worker service apps**
308
310
309
311
> [!NOTE]
310
312
> Adding an initializer by using `ApplicationInsights.config` or `TelemetryConfiguration.Active` isn't valid for ASP.NET Core applications or if you're using the Microsoft.ApplicationInsights.WorkerServiceSDK.
0 commit comments