@@ -17,7 +17,7 @@ You can write and configure plug-ins for the Application Insights SDK to customi
17
17
18
18
Before you start:
19
19
20
- * 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 )
20
+ * 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 [ JavaScript] ( javascript.md )
21
21
22
22
<a name =" filtering " ></a >
23
23
@@ -81,8 +81,8 @@ Insert this snippet in ApplicationInsights.config:
81
81
```xml
82
82
< TelemetryProcessors >
83
83
< Add Type = " WebApplication9.SuccessfulDependencyFilter, WebApplication9" >
84
- < ! -- Set public property -- >
85
- < MyParamFromConfigFile > 2 - beta < / MyParamFromConfigFile >
84
+ < ! -- Set public property -- >
85
+ < MyParamFromConfigFile > 2 - beta < / MyParamFromConfigFile >
86
86
< / Add >
87
87
< / TelemetryProcessors >
88
88
```
@@ -200,7 +200,7 @@ public void Process(ITelemetry item)
200
200
``` JS
201
201
var filteringFunction = (envelope ) => {
202
202
if (envelope .data .someField === ' tobefilteredout' ) {
203
- return false ;
203
+ return false ;
204
204
}
205
205
206
206
return true ;
@@ -241,24 +241,24 @@ namespace MvcWebRole.Telemetry
241
241
*/
242
242
public class MyTelemetryInitializer : ITelemetryInitializer
243
243
{
244
- public void Initialize (ITelemetry telemetry )
245
- {
246
- var requestTelemetry = telemetry as RequestTelemetry ;
247
- // Is this a TrackRequest() ?
248
- if (requestTelemetry == null ) return ;
249
- int code ;
250
- bool parsed = Int32 .TryParse (requestTelemetry .ResponseCode , out code );
251
- if (! parsed ) return ;
252
- if (code >= 400 && code < 500 )
253
- {
254
- // If we set the Success property, the SDK won't change it:
255
- requestTelemetry .Success = true ;
256
-
257
- // Allow us to filter these requests in the portal:
258
- requestTelemetry .Properties [" Overridden400s" ] = " true" ;
259
- }
260
- // else leave the SDK to set the Success property
261
- }
244
+ public void Initialize (ITelemetry telemetry )
245
+ {
246
+ var requestTelemetry = telemetry as RequestTelemetry ;
247
+ // Is this a TrackRequest() ?
248
+ if (requestTelemetry == null ) return ;
249
+ int code ;
250
+ bool parsed = Int32 .TryParse (requestTelemetry .ResponseCode , out code );
251
+ if (! parsed ) return ;
252
+ if (code >= 400 && code < 500 )
253
+ {
254
+ // If we set the Success property, the SDK won't change it:
255
+ requestTelemetry .Success = true ;
256
+
257
+ // Allow us to filter these requests in the portal:
258
+ requestTelemetry .Properties [" Overridden400s" ] = " true" ;
259
+ }
260
+ // else leave the SDK to set the Success property
261
+ }
262
262
}
263
263
}
264
264
```
@@ -270,9 +270,9 @@ In ApplicationInsights.config:
270
270
``` xml
271
271
<ApplicationInsights >
272
272
<TelemetryInitializers >
273
- <!-- Fully qualified type name, assembly name: -->
274
- <Add Type =" MvcWebRole.Telemetry.MyTelemetryInitializer, MvcWebRole" />
275
- ...
273
+ <!-- Fully qualified type name, assembly name: -->
274
+ <Add Type =" MvcWebRole.Telemetry.MyTelemetryInitializer, MvcWebRole" />
275
+ ...
276
276
</TelemetryInitializers >
277
277
</ApplicationInsights >
278
278
```
@@ -331,40 +331,40 @@ Insert a telemetry initializer immediately after the initialization code that yo
331
331
332
332
``` JS
333
333
< script type= " text/javascript" >
334
- // ... initialization code
335
- ... ({
336
- instrumentationKey: " your instrumentation key"
337
- });
338
- window .appInsights = appInsights;
334
+ // ... initialization code
335
+ ... ({
336
+ instrumentationKey: " your instrumentation key"
337
+ });
338
+ window .appInsights = appInsights;
339
339
340
340
341
- // Adding telemetry initializer.
342
- // This is called whenever a new telemetry item
343
- // is created.
341
+ // Adding telemetry initializer.
342
+ // This is called whenever a new telemetry item
343
+ // is created.
344
344
345
- appInsights .queue .push (function () {
346
- appInsights .context .addTelemetryInitializer (function (envelope ) {
347
- var telemetryItem = envelope .data .baseData ;
345
+ appInsights .queue .push (function () {
346
+ appInsights .context .addTelemetryInitializer (function (envelope ) {
347
+ var telemetryItem = envelope .data .baseData ;
348
348
349
- // To check the telemetry items type - for example PageView:
350
- if (envelope .name == Microsoft .ApplicationInsights .Telemetry .PageView .envelopeType ) {
351
- // this statement removes url from all page view documents
352
- telemetryItem .url = " URL CENSORED" ;
353
- }
349
+ // To check the telemetry items type - for example PageView:
350
+ if (envelope .name == Microsoft .ApplicationInsights .Telemetry .PageView .envelopeType ) {
351
+ // this statement removes url from all page view documents
352
+ telemetryItem .url = " URL CENSORED" ;
353
+ }
354
354
355
- // To set custom properties:
356
- telemetryItem .properties = telemetryItem .properties || {};
357
- telemetryItem .properties [" globalProperty" ] = " boo" ;
355
+ // To set custom properties:
356
+ telemetryItem .properties = telemetryItem .properties || {};
357
+ telemetryItem .properties [" globalProperty" ] = " boo" ;
358
358
359
- // To set custom metrics:
360
- telemetryItem .measurements = telemetryItem .measurements || {};
361
- telemetryItem .measurements [" globalMetric" ] = 100 ;
362
- });
363
- });
359
+ // To set custom metrics:
360
+ telemetryItem .measurements = telemetryItem .measurements || {};
361
+ telemetryItem .measurements [" globalMetric" ] = 100 ;
362
+ });
363
+ });
364
364
365
- // End of inserted code.
365
+ // End of inserted code.
366
366
367
- appInsights .trackPageView ();
367
+ appInsights .trackPageView ();
368
368
< / script>
369
369
```
370
370
@@ -381,7 +381,7 @@ Telemetry processors in OpenCensus Python are simply callback functions called t
381
381
382
382
``` python
383
383
def callback_function (envelope ):
384
- envelope.tags[' ai.cloud.role' ] = ' new_role_name.py'
384
+ envelope.tags[' ai.cloud.role' ] = ' new_role_name.py'
385
385
```
386
386
387
387
``` python
@@ -394,8 +394,8 @@ logger = logging.getLogger(__name__)
394
394
395
395
# Callback function to append '_hello' to each log message telemetry
396
396
def callback_function (envelope ):
397
- envelope.data.baseData.message += ' _hello'
398
- return True
397
+ envelope.data.baseData.message += ' _hello'
398
+ return True
399
399
400
400
handler = AzureLogHandler(connection_string = ' InstrumentationKey=<your-instrumentation_key-here>' )
401
401
handler.add_telemetry_processor(callback_function)
@@ -415,11 +415,11 @@ config_integration.trace_integrations(['requests'])
415
415
416
416
# Callback function to add os_type: linux to span properties
417
417
def callback_function (envelope ):
418
- envelope.data.baseData.properties[' os_type' ] = ' linux'
419
- return True
418
+ envelope.data.baseData.properties[' os_type' ] = ' linux'
419
+ return True
420
420
421
421
exporter = AzureExporter(
422
- connection_string = ' InstrumentationKey=<your-instrumentation-key-here>'
422
+ connection_string = ' InstrumentationKey=<your-instrumentation-key-here>'
423
423
)
424
424
exporter.add_telemetry_processor(callback_function)
425
425
tracer = Tracer(exporter = exporter, sampler = ProbabilitySampler(1.0 ))
0 commit comments