Skip to content

Commit 76ff267

Browse files
authored
Merge pull request #109431 from MS-jgol/remove-java-info
Remove java info
2 parents 04bfe24 + cfe2c59 commit 76ff267

File tree

1 file changed

+57
-77
lines changed

1 file changed

+57
-77
lines changed

articles/azure-monitor/app/api-filtering-sampling.md

Lines changed: 57 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ You can write and configure plug-ins for the Application Insights SDK to customi
1717

1818
Before you start:
1919

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)
2121

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

@@ -81,8 +81,8 @@ Insert this snippet in ApplicationInsights.config:
8181
```xml
8282
<TelemetryProcessors>
8383
<Add Type="WebApplication9.SuccessfulDependencyFilter, WebApplication9">
84-
<!-- Set public property -->
85-
<MyParamFromConfigFile>2-beta</MyParamFromConfigFile>
84+
<!-- Set public property -->
85+
<MyParamFromConfigFile>2-beta</MyParamFromConfigFile>
8686
</Add>
8787
</TelemetryProcessors>
8888
```
@@ -200,7 +200,7 @@ public void Process(ITelemetry item)
200200
```JS
201201
var filteringFunction = (envelope) => {
202202
if (envelope.data.someField === 'tobefilteredout') {
203-
return false;
203+
return false;
204204
}
205205

206206
return true;
@@ -241,24 +241,24 @@ namespace MvcWebRole.Telemetry
241241
*/
242242
public class MyTelemetryInitializer : ITelemetryInitializer
243243
{
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+
}
262262
}
263263
}
264264
```
@@ -270,9 +270,9 @@ In ApplicationInsights.config:
270270
```xml
271271
<ApplicationInsights>
272272
<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+
...
276276
</TelemetryInitializers>
277277
</ApplicationInsights>
278278
```
@@ -304,67 +304,47 @@ For apps written using [ASP.NET Core](asp-net-core.md#adding-telemetryinitialize
304304
services.AddSingleton<ITelemetryInitializer, MyTelemetryInitializer>();
305305
}
306306
```
307-
308-
### Java telemetry initializers
309-
310-
[Java SDK documentation](https://docs.microsoft.com/java/api/com.microsoft.applicationinsights.extensibility.telemetryinitializer?view=azure-java-stable)
311-
312-
```Java
313-
public interface TelemetryInitializer
314-
{ /** Initializes properties of the specified object. * @param telemetry The {@link com.microsoft.applicationinsights.telemetry.Telemetry} to initialize. */
315-
316-
void initialize(Telemetry telemetry); }
317-
```
318-
319-
Then register the custom initializer in your applicationinsights.xml file.
320-
321-
```xml
322-
<Add type="mypackage.MyConfigurableContextInitializer">
323-
<Param name="some_config_property" value="some_value" />
324-
</Add>
325-
```
326-
327307
### JavaScript telemetry initializers
328308
*JavaScript*
329309

330310
Insert a telemetry initializer immediately after the initialization code that you got from the portal:
331311

332312
```JS
333313
<script type="text/javascript">
334-
// ... initialization code
335-
...({
336-
instrumentationKey: "your instrumentation key"
337-
});
338-
window.appInsights = appInsights;
314+
// ... initialization code
315+
...({
316+
instrumentationKey: "your instrumentation key"
317+
});
318+
window.appInsights = appInsights;
339319

340320

341-
// Adding telemetry initializer.
342-
// This is called whenever a new telemetry item
343-
// is created.
321+
// Adding telemetry initializer.
322+
// This is called whenever a new telemetry item
323+
// is created.
344324

345-
appInsights.queue.push(function () {
346-
appInsights.context.addTelemetryInitializer(function (envelope) {
347-
var telemetryItem = envelope.data.baseData;
325+
appInsights.queue.push(function () {
326+
appInsights.context.addTelemetryInitializer(function (envelope) {
327+
var telemetryItem = envelope.data.baseData;
348328

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-
}
329+
// To check the telemetry items type - for example PageView:
330+
if (envelope.name == Microsoft.ApplicationInsights.Telemetry.PageView.envelopeType) {
331+
// this statement removes url from all page view documents
332+
telemetryItem.url = "URL CENSORED";
333+
}
354334

355-
// To set custom properties:
356-
telemetryItem.properties = telemetryItem.properties || {};
357-
telemetryItem.properties["globalProperty"] = "boo";
335+
// To set custom properties:
336+
telemetryItem.properties = telemetryItem.properties || {};
337+
telemetryItem.properties["globalProperty"] = "boo";
358338

359-
// To set custom metrics:
360-
telemetryItem.measurements = telemetryItem.measurements || {};
361-
telemetryItem.measurements["globalMetric"] = 100;
362-
});
363-
});
339+
// To set custom metrics:
340+
telemetryItem.measurements = telemetryItem.measurements || {};
341+
telemetryItem.measurements["globalMetric"] = 100;
342+
});
343+
});
364344

365-
// End of inserted code.
345+
// End of inserted code.
366346

367-
appInsights.trackPageView();
347+
appInsights.trackPageView();
368348
</script>
369349
```
370350

@@ -381,7 +361,7 @@ Telemetry processors in OpenCensus Python are simply callback functions called t
381361
382362
```python
383363
def callback_function(envelope):
384-
envelope.tags['ai.cloud.role'] = 'new_role_name.py'
364+
envelope.tags['ai.cloud.role'] = 'new_role_name.py'
385365
```
386366

387367
```python
@@ -394,8 +374,8 @@ logger = logging.getLogger(__name__)
394374

395375
# Callback function to append '_hello' to each log message telemetry
396376
def callback_function(envelope):
397-
envelope.data.baseData.message += '_hello'
398-
return True
377+
envelope.data.baseData.message += '_hello'
378+
return True
399379

400380
handler = AzureLogHandler(connection_string='InstrumentationKey=<your-instrumentation_key-here>')
401381
handler.add_telemetry_processor(callback_function)
@@ -415,11 +395,11 @@ config_integration.trace_integrations(['requests'])
415395

416396
# Callback function to add os_type: linux to span properties
417397
def callback_function(envelope):
418-
envelope.data.baseData.properties['os_type'] = 'linux'
419-
return True
398+
envelope.data.baseData.properties['os_type'] = 'linux'
399+
return True
420400

421401
exporter = AzureExporter(
422-
connection_string='InstrumentationKey=<your-instrumentation-key-here>'
402+
connection_string='InstrumentationKey=<your-instrumentation-key-here>'
423403
)
424404
exporter.add_telemetry_processor(callback_function)
425405
tracer = Tracer(exporter=exporter, sampler=ProbabilitySampler(1.0))

0 commit comments

Comments
 (0)