@azure/mcp-linux-arm64 2.0.0-beta.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.txt +5683 -4849
- package/README.md +149 -26
- package/dist/Azure.Mcp.Tools.AzureMigrate.xml +1060 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/ActivityProcessors.md +119 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/AddApplicationInsightsTelemetry.md +129 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/AddApplicationInsightsTelemetryWorkerService.md +115 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/AddOpenTelemetry.md +153 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/ApplicationInsightsWeb.md +103 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/AzureMonitorExporter.md +137 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/ConfigureOpenTelemetryProvider.md +218 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/ConfigureResource.md +119 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/ConsoleExporter.md +47 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/EntityFrameworkInstrumentation.md +56 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/HttpInstrumentation.md +109 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/LogProcessors.md +101 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/OpenTelemetrySdkCreate.md +146 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/OtlpExporter.md +88 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/RedisInstrumentation.md +63 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/Sampling.md +86 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/SdkCreateTracerProviderBuilder.md +127 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/SqlClientInstrumentation.md +53 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/TelemetryClient.md +122 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/TelemetryConfigurationBuilder.md +173 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/UseAzureMonitor.md +96 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/UseAzureMonitorExporter.md +146 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/WithLogging.md +109 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/WithMetrics.md +105 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/WithTracing.md +91 -0
- package/dist/Instrumentation/Resources/concepts/dotnet/appinsights-aspnetcore.md +113 -0
- package/dist/Instrumentation/Resources/concepts/dotnet/aspnet-classic-appinsights.md +95 -0
- package/dist/Instrumentation/Resources/concepts/dotnet/azure-monitor-distro.md +102 -0
- package/dist/Instrumentation/Resources/concepts/dotnet/opentelemetry-pipeline.md +57 -0
- package/dist/Instrumentation/Resources/concepts/nodejs/azure-monitor-overview.md +106 -0
- package/dist/Instrumentation/Resources/concepts/nodejs/opentelemetry-pipeline.md +201 -0
- package/dist/Instrumentation/Resources/concepts/python/azure-monitor-overview.md +122 -0
- package/dist/Instrumentation/Resources/concepts/python/opentelemetry-pipeline.md +154 -0
- package/dist/Instrumentation/Resources/examples/dotnet/aspnet-classic-setup.md +80 -0
- package/dist/Instrumentation/Resources/examples/dotnet/aspnetcore-distro-setup.md +156 -0
- package/dist/Instrumentation/Resources/examples/dotnet/aspnetcore-setup.md +160 -0
- package/dist/Instrumentation/Resources/examples/dotnet/workerservice-setup.md +154 -0
- package/dist/Instrumentation/Resources/examples/nodejs/bunyan-setup.md +301 -0
- package/dist/Instrumentation/Resources/examples/nodejs/console-setup.md +284 -0
- package/dist/Instrumentation/Resources/examples/nodejs/express-setup.md +169 -0
- package/dist/Instrumentation/Resources/examples/nodejs/fastify-setup.md +237 -0
- package/dist/Instrumentation/Resources/examples/nodejs/langchain-js-setup.md +310 -0
- package/dist/Instrumentation/Resources/examples/nodejs/mongodb-setup.md +185 -0
- package/dist/Instrumentation/Resources/examples/nodejs/mysql-setup.md +231 -0
- package/dist/Instrumentation/Resources/examples/nodejs/nestjs-setup.md +184 -0
- package/dist/Instrumentation/Resources/examples/nodejs/nextjs-setup.md +320 -0
- package/dist/Instrumentation/Resources/examples/nodejs/postgres-setup.md +147 -0
- package/dist/Instrumentation/Resources/examples/nodejs/redis-setup.md +198 -0
- package/dist/Instrumentation/Resources/examples/nodejs/winston-setup.md +260 -0
- package/dist/Instrumentation/Resources/examples/python/console-setup.md +392 -0
- package/dist/Instrumentation/Resources/examples/python/django-setup.md +269 -0
- package/dist/Instrumentation/Resources/examples/python/fastapi-setup.md +256 -0
- package/dist/Instrumentation/Resources/examples/python/flask-setup.md +218 -0
- package/dist/Instrumentation/Resources/examples/python/genai-setup.md +214 -0
- package/dist/Instrumentation/Resources/examples/python/generic-setup.md +164 -0
- package/dist/Instrumentation/Resources/migration/dotnet/aad-authentication-migration.md +150 -0
- package/dist/Instrumentation/Resources/migration/dotnet/appinsights-2x-to-3x-code-migration.md +164 -0
- package/dist/Instrumentation/Resources/migration/dotnet/appinsights-2x-to-3x-no-code-change.md +92 -0
- package/dist/Instrumentation/Resources/migration/dotnet/aspnet-classic-2x-to-3x-code-migration.md +190 -0
- package/dist/Instrumentation/Resources/migration/dotnet/console-2x-to-3x-code-migration.md +106 -0
- package/dist/Instrumentation/Resources/migration/dotnet/ilogger-migration.md +54 -0
- package/dist/Instrumentation/Resources/migration/dotnet/workerservice-2x-to-3x-code-migration.md +126 -0
- package/dist/Instrumentation/Resources/migration/dotnet/workerservice-2x-to-3x-no-code-change.md +102 -0
- package/dist/appsettings.json +5 -0
- package/dist/azmcp +0 -0
- package/package.json +1 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: WithMetrics
|
|
3
|
+
category: api-reference
|
|
4
|
+
applies-to: 1.x
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# .WithMetrics()
|
|
8
|
+
|
|
9
|
+
## API surface
|
|
10
|
+
|
|
11
|
+
| Method | Purpose |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| `.WithMetrics()` | Enable metrics with no additional configuration |
|
|
14
|
+
| `.WithMetrics(Action<MeterProviderBuilder>)` | Enable metrics and configure the `MeterProviderBuilder` |
|
|
15
|
+
| `builder.AddMeter(params string[] names)` | Subscribe to one or more `Meter` names |
|
|
16
|
+
| `builder.AddReader(MetricReader)` | Add a metric reader instance |
|
|
17
|
+
| `builder.AddReader<T>()` | Add a reader resolved from DI (registered as singleton) |
|
|
18
|
+
| `builder.AddReader(Func<IServiceProvider, MetricReader>)` | Add a reader via factory |
|
|
19
|
+
| `builder.AddView(string instrumentName, string name)` | Rename a metric stream (no wildcards) |
|
|
20
|
+
| `builder.AddView(string instrumentName, MetricStreamConfiguration)` | Customize aggregation for an instrument (wildcards allowed) |
|
|
21
|
+
| `builder.AddView(Func<Instrument, MetricStreamConfiguration?>)` | Programmatic view selection |
|
|
22
|
+
| `builder.SetMaxMetricStreams(int)` | Set max metric streams (default: 1000) |
|
|
23
|
+
| `builder.SetExemplarFilter(ExemplarFilterType)` | Set exemplar filter (`AlwaysOff`, `AlwaysOn`, `TraceBased`) |
|
|
24
|
+
|
|
25
|
+
See also: ConfigureResource.md for resource configuration
|
|
26
|
+
|
|
27
|
+
## When to use
|
|
28
|
+
|
|
29
|
+
- Enable metrics collection in an ASP.NET Core or Worker Service app via `AddOpenTelemetry()`.
|
|
30
|
+
- Enable metrics in a standalone/console app via `OpenTelemetrySdk.Create()`.
|
|
31
|
+
- Subscribe to `Meter` names from your application code or instrumentation libraries.
|
|
32
|
+
- Configure views to customize aggregation, rename streams, or set cardinality limits.
|
|
33
|
+
- Call multiple times safely — only one `MeterProvider` is created per `IServiceCollection`.
|
|
34
|
+
|
|
35
|
+
## Minimal example
|
|
36
|
+
|
|
37
|
+
```csharp
|
|
38
|
+
using OpenTelemetry;
|
|
39
|
+
using OpenTelemetry.Metrics;
|
|
40
|
+
|
|
41
|
+
var builder = WebApplication.CreateBuilder(args);
|
|
42
|
+
|
|
43
|
+
builder.Services.AddOpenTelemetry()
|
|
44
|
+
.WithMetrics(metrics => metrics
|
|
45
|
+
.AddMeter("MyApp")
|
|
46
|
+
.AddOtlpExporter());
|
|
47
|
+
|
|
48
|
+
var app = builder.Build();
|
|
49
|
+
app.Run();
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Full example
|
|
53
|
+
|
|
54
|
+
```csharp
|
|
55
|
+
using OpenTelemetry;
|
|
56
|
+
using OpenTelemetry.Metrics;
|
|
57
|
+
using OpenTelemetry.Resources;
|
|
58
|
+
|
|
59
|
+
var builder = WebApplication.CreateBuilder(args);
|
|
60
|
+
|
|
61
|
+
builder.Services.AddOpenTelemetry()
|
|
62
|
+
.ConfigureResource(r => r.AddService("order-api"))
|
|
63
|
+
.WithMetrics(metrics => metrics
|
|
64
|
+
.AddMeter("OrderService", "PaymentService")
|
|
65
|
+
.AddAspNetCoreInstrumentation()
|
|
66
|
+
.AddHttpClientInstrumentation()
|
|
67
|
+
.AddView("request-duration", new ExplicitBucketHistogramConfiguration
|
|
68
|
+
{
|
|
69
|
+
Boundaries = new double[] { 0.01, 0.05, 0.1, 0.5, 1, 5, 10 }
|
|
70
|
+
})
|
|
71
|
+
.SetMaxMetricStreams(500)
|
|
72
|
+
.SetExemplarFilter(ExemplarFilterType.TraceBased)
|
|
73
|
+
.AddOtlpExporter());
|
|
74
|
+
|
|
75
|
+
var app = builder.Build();
|
|
76
|
+
app.Run();
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Standalone (non-host) usage
|
|
80
|
+
|
|
81
|
+
```csharp
|
|
82
|
+
using OpenTelemetry;
|
|
83
|
+
using OpenTelemetry.Metrics;
|
|
84
|
+
|
|
85
|
+
using var sdk = OpenTelemetrySdk.Create(builder => builder
|
|
86
|
+
.WithMetrics(metrics => metrics
|
|
87
|
+
.AddMeter("MyConsoleApp")
|
|
88
|
+
.AddOtlpExporter()));
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Key parameters
|
|
92
|
+
|
|
93
|
+
| Parameter | Type | Default | Description |
|
|
94
|
+
| --- | --- | --- | --- |
|
|
95
|
+
| `maxMetricStreams` | `int` | 1000 | Maximum number of metric streams allowed (min: 1) |
|
|
96
|
+
| `exemplarFilter` | `ExemplarFilterType` | `AlwaysOff` | Controls how measurements are offered to exemplar reservoirs |
|
|
97
|
+
|
|
98
|
+
## Behavior notes
|
|
99
|
+
|
|
100
|
+
- `AddMeter()` accepts exact `Meter` names — unregistered meters are ignored.
|
|
101
|
+
- `AddView()` with a wildcard (`*`) in `instrumentName` cannot rename a stream (would cause conflicts).
|
|
102
|
+
- Views are applied in registration order. The first matching view wins per instrument.
|
|
103
|
+
- `SetMaxMetricPointsPerMetricStream()` is obsolete since 1.10.0 — use `MetricStreamConfiguration.CardinalityLimit` via `AddView` instead.
|
|
104
|
+
- `WithMetrics()` automatically registers an `IMetricsListener` named `"OpenTelemetry"` to bridge `System.Diagnostics.Metrics`.
|
|
105
|
+
- When used with `AddOpenTelemetry()`, the host manages `MeterProvider` lifecycle — do **not** call `Dispose()` manually.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: WithTracing
|
|
3
|
+
category: api-reference
|
|
4
|
+
applies-to: 1.x
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# .WithTracing()
|
|
8
|
+
|
|
9
|
+
## API surface
|
|
10
|
+
|
|
11
|
+
| Method | Purpose |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| `.WithTracing()` | Enable tracing with no additional configuration |
|
|
14
|
+
| `.WithTracing(Action<TracerProviderBuilder>)` | Enable tracing and configure the `TracerProviderBuilder` |
|
|
15
|
+
| `builder.AddSource(params string[] names)` | Subscribe to one or more `ActivitySource` names |
|
|
16
|
+
| `builder.AddInstrumentation<T>()` | Add an instrumentation library via DI |
|
|
17
|
+
| `builder.AddProcessor(BaseProcessor<Activity>)` | Add an activity processor instance |
|
|
18
|
+
| `builder.AddProcessor<T>()` | Add a processor resolved from DI (registered as singleton) |
|
|
19
|
+
| `builder.AddProcessor(Func<IServiceProvider, BaseProcessor<Activity>>)` | Add a processor via factory |
|
|
20
|
+
| `builder.SetErrorStatusOnException(bool)` | Auto-set `Status.Error` on unhandled exceptions (default `true`) |
|
|
21
|
+
|
|
22
|
+
See also: Sampling.md for `SetSampler()` overloads · ConfigureResource.md for resource configuration
|
|
23
|
+
|
|
24
|
+
## When to use
|
|
25
|
+
|
|
26
|
+
- Enable distributed tracing in an ASP.NET Core or Worker Service app via `AddOpenTelemetry()`.
|
|
27
|
+
- Enable tracing in a standalone/console app via `OpenTelemetrySdk.Create()`.
|
|
28
|
+
- Subscribe to `ActivitySource` names so the SDK captures spans from your code or instrumentation libraries.
|
|
29
|
+
- Attach processors (e.g., `BatchActivityExportProcessor`) or set a custom sampler.
|
|
30
|
+
- Call multiple times safely — only one `TracerProvider` is created per `IServiceCollection`.
|
|
31
|
+
|
|
32
|
+
## Minimal example
|
|
33
|
+
|
|
34
|
+
```csharp
|
|
35
|
+
using OpenTelemetry;
|
|
36
|
+
using OpenTelemetry.Trace;
|
|
37
|
+
|
|
38
|
+
var builder = WebApplication.CreateBuilder(args);
|
|
39
|
+
|
|
40
|
+
builder.Services.AddOpenTelemetry()
|
|
41
|
+
.WithTracing(tracing => tracing
|
|
42
|
+
.AddSource("MyApp")
|
|
43
|
+
.AddOtlpExporter());
|
|
44
|
+
|
|
45
|
+
var app = builder.Build();
|
|
46
|
+
app.Run();
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Full example
|
|
50
|
+
|
|
51
|
+
```csharp
|
|
52
|
+
using OpenTelemetry;
|
|
53
|
+
using OpenTelemetry.Resources;
|
|
54
|
+
using OpenTelemetry.Trace;
|
|
55
|
+
|
|
56
|
+
var builder = WebApplication.CreateBuilder(args);
|
|
57
|
+
|
|
58
|
+
builder.Services.AddOpenTelemetry()
|
|
59
|
+
.ConfigureResource(r => r.AddService("order-api"))
|
|
60
|
+
.WithTracing(tracing => tracing
|
|
61
|
+
.AddSource("OrderService", "PaymentService")
|
|
62
|
+
.AddAspNetCoreInstrumentation()
|
|
63
|
+
.AddHttpClientInstrumentation()
|
|
64
|
+
.SetSampler(new ParentBasedSampler(new TraceIdRatioBasedSampler(0.5)))
|
|
65
|
+
.AddProcessor<MyFilteringProcessor>()
|
|
66
|
+
.AddOtlpExporter());
|
|
67
|
+
|
|
68
|
+
var app = builder.Build();
|
|
69
|
+
app.Run();
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Standalone (non-host) usage
|
|
73
|
+
|
|
74
|
+
```csharp
|
|
75
|
+
using OpenTelemetry;
|
|
76
|
+
using OpenTelemetry.Trace;
|
|
77
|
+
|
|
78
|
+
using var sdk = OpenTelemetrySdk.Create(builder => builder
|
|
79
|
+
.WithTracing(tracing => tracing
|
|
80
|
+
.AddSource("MyConsoleApp")
|
|
81
|
+
.AddOtlpExporter()));
|
|
82
|
+
|
|
83
|
+
// sdk.TracerProvider is available if needed
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Behavior notes
|
|
87
|
+
|
|
88
|
+
- `AddSource()` accepts wildcard-free `ActivitySource` names. Activities from unregistered sources are dropped.
|
|
89
|
+
- Processors run in registration order. Export processors should be added last.
|
|
90
|
+
- When used with `AddOpenTelemetry()`, the host manages `TracerProvider` lifecycle — do **not** call `Dispose()` manually.
|
|
91
|
+
- When used with `OpenTelemetrySdk.Create()`, you own the `OpenTelemetrySdk` instance and must dispose it.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Application Insights for ASP.NET Core
|
|
3
|
+
category: concept
|
|
4
|
+
applies-to: 3.x
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Application Insights for ASP.NET Core
|
|
8
|
+
|
|
9
|
+
**Category:** Concept
|
|
10
|
+
**Applies to:** 3.x
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
The `Microsoft.ApplicationInsights.AspNetCore` package provides built-in telemetry collection for ASP.NET Core applications, sending data to Azure Application Insights.
|
|
15
|
+
|
|
16
|
+
## What It Provides
|
|
17
|
+
|
|
18
|
+
One line of code enables full observability:
|
|
19
|
+
|
|
20
|
+
```csharp
|
|
21
|
+
builder.Services.AddApplicationInsightsTelemetry();
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Automatic Collection
|
|
25
|
+
- **Requests** — All incoming HTTP requests with timing, status codes, and URLs
|
|
26
|
+
- **Dependencies** — Outgoing HTTP calls, SQL queries, and Azure SDK calls
|
|
27
|
+
- **Exceptions** — Unhandled exceptions with full stack traces
|
|
28
|
+
- **Performance Counters** — CPU, memory, GC, and thread pool metrics
|
|
29
|
+
- **Logs** — ILogger output (Information level and above by default)
|
|
30
|
+
|
|
31
|
+
### Built-in Features
|
|
32
|
+
- **Live Metrics** — Real-time monitoring via QuickPulse
|
|
33
|
+
- **Adaptive Sampling** — Automatic volume control (configurable via `TracesPerSecond`)
|
|
34
|
+
- **JavaScript Snippet** — Browser-side telemetry injection for Razor pages
|
|
35
|
+
- **AAD Authentication** — Token-based auth via `TokenCredential`
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
### 1. Install Package
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
dotnet add package Microsoft.ApplicationInsights.AspNetCore
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 2. Add to Program.cs
|
|
46
|
+
|
|
47
|
+
```csharp
|
|
48
|
+
var builder = WebApplication.CreateBuilder(args);
|
|
49
|
+
builder.Services.AddApplicationInsightsTelemetry();
|
|
50
|
+
var app = builder.Build();
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 3. Configure Connection String
|
|
54
|
+
|
|
55
|
+
**Environment variable (recommended):**
|
|
56
|
+
```bash
|
|
57
|
+
APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=xxx;IngestionEndpoint=https://...
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Or in appsettings.json:**
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"ApplicationInsights": {
|
|
64
|
+
"ConnectionString": "InstrumentationKey=xxx;IngestionEndpoint=https://..."
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Configuration Options
|
|
70
|
+
|
|
71
|
+
Use `ApplicationInsightsServiceOptions` to customize behavior:
|
|
72
|
+
|
|
73
|
+
```csharp
|
|
74
|
+
builder.Services.AddApplicationInsightsTelemetry(options =>
|
|
75
|
+
{
|
|
76
|
+
options.ConnectionString = "InstrumentationKey=...;IngestionEndpoint=...";
|
|
77
|
+
options.EnableQuickPulseMetricStream = true;
|
|
78
|
+
options.SamplingRatio = 0.5f; // Collect 50% of telemetry
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
| Property | Default | Description |
|
|
83
|
+
|----------|---------|-------------|
|
|
84
|
+
| `ConnectionString` | `null` | Application Insights connection string |
|
|
85
|
+
| `Credential` | `null` | AAD `TokenCredential` for token-based auth |
|
|
86
|
+
| `EnableQuickPulseMetricStream` | `true` | Enables Live Metrics |
|
|
87
|
+
| `EnableDependencyTrackingTelemetryModule` | `true` | Tracks HTTP/SQL dependencies |
|
|
88
|
+
| `EnableRequestTrackingTelemetryModule` | `true` | Tracks incoming requests |
|
|
89
|
+
| `TracesPerSecond` | `5` | Rate-limited sampling target |
|
|
90
|
+
| `SamplingRatio` | `null` | Fixed-rate sampling (0.0–1.0); overrides `TracesPerSecond` |
|
|
91
|
+
|
|
92
|
+
## Connection String Resolution Order
|
|
93
|
+
|
|
94
|
+
1. `ApplicationInsightsServiceOptions.ConnectionString` (code)
|
|
95
|
+
2. Environment variable `APPLICATIONINSIGHTS_CONNECTION_STRING`
|
|
96
|
+
3. Config key `ApplicationInsights:ConnectionString`
|
|
97
|
+
|
|
98
|
+
## Extending with OpenTelemetry
|
|
99
|
+
|
|
100
|
+
Application Insights 3.x is built on OpenTelemetry. You can add additional sources:
|
|
101
|
+
|
|
102
|
+
```csharp
|
|
103
|
+
builder.Services.AddApplicationInsightsTelemetry();
|
|
104
|
+
builder.Services.AddOpenTelemetry()
|
|
105
|
+
.WithTracing(t => t.AddSource("MyApp.CustomSource"))
|
|
106
|
+
.WithMetrics(m => m.AddMeter("MyApp.CustomMeter"));
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## See Also
|
|
110
|
+
|
|
111
|
+
- AddApplicationInsightsTelemetry API (see in AddApplicationInsightsTelemetry.md)
|
|
112
|
+
- ASP.NET Core Setup Example (see in aspnetcore-setup.md)
|
|
113
|
+
- App Insights 2.x to 3.x Migration (see in appinsights-2x-to-3x-code-migration.md)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Application Insights for Classic ASP.NET
|
|
3
|
+
category: concepts
|
|
4
|
+
applies-to: dotnet-framework
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Application Insights for Classic ASP.NET
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
Classic ASP.NET applications (.NET Framework 4.6.2+) use `Microsoft.ApplicationInsights.Web` for automatic request, dependency, and exception tracking. In 3.x, the package is built on OpenTelemetry internally.
|
|
12
|
+
|
|
13
|
+
## How it works
|
|
14
|
+
|
|
15
|
+
1. **NuGet package install** creates `ApplicationInsights.config` and registers HTTP modules in `Web.config`
|
|
16
|
+
2. **`ApplicationInsightsHttpModule`** runs on every request — reads config, initializes `TelemetryConfiguration`, sets up the OpenTelemetry pipeline
|
|
17
|
+
3. **`TelemetryHttpModule`** (from `OpenTelemetry.Instrumentation.AspNet`) captures request spans via `System.Diagnostics.Activity`
|
|
18
|
+
4. **No code changes needed** — request tracking, dependency tracking, and exception tracking are automatic
|
|
19
|
+
|
|
20
|
+
## Key configuration files
|
|
21
|
+
|
|
22
|
+
| File | Purpose |
|
|
23
|
+
|---|---|
|
|
24
|
+
| `ApplicationInsights.config` | Connection string, sampling, feature flags |
|
|
25
|
+
| `Web.config` | HTTP module registration (auto-configured by NuGet) |
|
|
26
|
+
|
|
27
|
+
## ApplicationInsights.config (3.x format)
|
|
28
|
+
|
|
29
|
+
```xml
|
|
30
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
31
|
+
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
|
|
32
|
+
<ConnectionString>InstrumentationKey=...;IngestionEndpoint=https://...</ConnectionString>
|
|
33
|
+
<TracesPerSecond>5.0</TracesPerSecond>
|
|
34
|
+
<EnableTraceBasedLogsSampler>true</EnableTraceBasedLogsSampler>
|
|
35
|
+
<EnableQuickPulseMetricStream>true</EnableQuickPulseMetricStream>
|
|
36
|
+
<EnablePerformanceCounterCollectionModule>true</EnablePerformanceCounterCollectionModule>
|
|
37
|
+
<EnableDependencyTrackingTelemetryModule>true</EnableDependencyTrackingTelemetryModule>
|
|
38
|
+
<EnableRequestTrackingTelemetryModule>true</EnableRequestTrackingTelemetryModule>
|
|
39
|
+
<AddAutoCollectedMetricExtractor>true</AddAutoCollectedMetricExtractor>
|
|
40
|
+
</ApplicationInsights>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Web.config HTTP modules (auto-configured)
|
|
44
|
+
|
|
45
|
+
```xml
|
|
46
|
+
<system.webServer>
|
|
47
|
+
<modules>
|
|
48
|
+
<add name="ApplicationInsightsWebTracking"
|
|
49
|
+
type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
|
|
50
|
+
preCondition="managedHandler" />
|
|
51
|
+
<add name="TelemetryHttpModule"
|
|
52
|
+
type="OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule, OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule"
|
|
53
|
+
preCondition="integratedMode,managedHandler" />
|
|
54
|
+
</modules>
|
|
55
|
+
</system.webServer>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Extensibility — Custom processors
|
|
59
|
+
|
|
60
|
+
Use `TelemetryConfiguration.ConfigureOpenTelemetryBuilder` in `Global.asax.cs`:
|
|
61
|
+
|
|
62
|
+
```csharp
|
|
63
|
+
using Microsoft.ApplicationInsights.Extensibility;
|
|
64
|
+
using OpenTelemetry.Trace;
|
|
65
|
+
using OpenTelemetry.Resources;
|
|
66
|
+
|
|
67
|
+
protected void Application_Start()
|
|
68
|
+
{
|
|
69
|
+
var config = TelemetryConfiguration.CreateDefault();
|
|
70
|
+
config.ConnectionString = "InstrumentationKey=...;IngestionEndpoint=...";
|
|
71
|
+
config.ConfigureOpenTelemetryBuilder(otel =>
|
|
72
|
+
{
|
|
73
|
+
otel.WithTracing(tracing => tracing.AddProcessor<MyCustomProcessor>());
|
|
74
|
+
otel.ConfigureResource(r => r.AddService("MyServiceName"));
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
AreaRegistration.RegisterAllAreas();
|
|
78
|
+
RouteConfig.RegisterRoutes(RouteTable.Routes);
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Requirements
|
|
83
|
+
|
|
84
|
+
- .NET Framework **4.6.2** or later (3.x raised minimum from 4.5.2)
|
|
85
|
+
- IIS or IIS Express
|
|
86
|
+
- `Microsoft.ApplicationInsights.Web` 3.x NuGet package
|
|
87
|
+
|
|
88
|
+
## What's automatic (no code needed)
|
|
89
|
+
|
|
90
|
+
- HTTP request tracking (all incoming requests)
|
|
91
|
+
- SQL dependency tracking
|
|
92
|
+
- HTTP dependency tracking (outgoing `HttpClient` / `WebRequest` calls)
|
|
93
|
+
- Exception tracking
|
|
94
|
+
- Performance counter collection
|
|
95
|
+
- Live Metrics (Quick Pulse)
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Azure Monitor OpenTelemetry Distro
|
|
3
|
+
category: concept
|
|
4
|
+
applies-to: 3.x
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Azure Monitor OpenTelemetry Distro
|
|
8
|
+
|
|
9
|
+
**Category:** Concept
|
|
10
|
+
**Applies to:** 3.x
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
The Azure Monitor OpenTelemetry Distro (`Azure.Monitor.OpenTelemetry.AspNetCore`) is a batteries-included package that configures OpenTelemetry with sensible defaults for Azure Monitor/Application Insights.
|
|
15
|
+
|
|
16
|
+
## What It Provides
|
|
17
|
+
|
|
18
|
+
One line of code enables:
|
|
19
|
+
|
|
20
|
+
```csharp
|
|
21
|
+
builder.Services.AddOpenTelemetry().UseAzureMonitor();
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Automatic Instrumentation
|
|
25
|
+
- **ASP.NET Core** - HTTP requests (traces)
|
|
26
|
+
- **HttpClient** - Outgoing HTTP calls (dependencies)
|
|
27
|
+
- **SQL Client** - Database calls
|
|
28
|
+
- **Azure SDK** - Azure service calls
|
|
29
|
+
|
|
30
|
+
### Automatic Export
|
|
31
|
+
- Traces → Application Insights (requests, dependencies)
|
|
32
|
+
- Metrics → Application Insights (performance counters, custom metrics)
|
|
33
|
+
- Logs → Application Insights (traces, exceptions)
|
|
34
|
+
|
|
35
|
+
### Automatic Enrichment
|
|
36
|
+
- Cloud role name detection
|
|
37
|
+
- Kubernetes metadata
|
|
38
|
+
- Azure App Service metadata
|
|
39
|
+
|
|
40
|
+
## Configuration
|
|
41
|
+
|
|
42
|
+
### Connection String (Required)
|
|
43
|
+
|
|
44
|
+
Option 1: Environment variable (recommended)
|
|
45
|
+
```bash
|
|
46
|
+
APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=xxx;IngestionEndpoint=https://...
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Option 2: appsettings.json
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"AzureMonitor": {
|
|
53
|
+
"ConnectionString": "InstrumentationKey=xxx;IngestionEndpoint=https://..."
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Option 3: Code
|
|
59
|
+
```csharp
|
|
60
|
+
builder.Services.AddOpenTelemetry().UseAzureMonitor(options =>
|
|
61
|
+
{
|
|
62
|
+
options.ConnectionString = "InstrumentationKey=xxx;...";
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Optional Configuration
|
|
67
|
+
|
|
68
|
+
```csharp
|
|
69
|
+
builder.Services.AddOpenTelemetry().UseAzureMonitor(options =>
|
|
70
|
+
{
|
|
71
|
+
// Sampling
|
|
72
|
+
options.SamplingRatio = 0.1f; // 10% sampling
|
|
73
|
+
|
|
74
|
+
// Disable specific auto-instrumentation
|
|
75
|
+
options.EnableLiveMetrics = false;
|
|
76
|
+
|
|
77
|
+
// Custom resource attributes
|
|
78
|
+
options.Resource = ResourceBuilder.CreateDefault()
|
|
79
|
+
.AddService("MyService", "1.0.0");
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Package Reference
|
|
84
|
+
|
|
85
|
+
```xml
|
|
86
|
+
<PackageReference Include="Azure.Monitor.OpenTelemetry.AspNetCore" Version="1.3.0" />
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## When to Use
|
|
90
|
+
|
|
91
|
+
| Scenario | Recommendation |
|
|
92
|
+
|----------|----------------|
|
|
93
|
+
| New ASP.NET Core app | ✅ Use Distro |
|
|
94
|
+
| Existing AI SDK 2.x app | ✅ Migrate to Distro |
|
|
95
|
+
| Need custom exporters | Consider manual OpenTelemetry setup |
|
|
96
|
+
| Non-ASP.NET Core | Use `Azure.Monitor.OpenTelemetry.Exporter` directly |
|
|
97
|
+
|
|
98
|
+
## See Also
|
|
99
|
+
|
|
100
|
+
- OpenTelemetry Pipeline(see in opentelemetry-pipeline.md)
|
|
101
|
+
- UseAzureMonitor API(see in api-reference/dotnet/UseAzureMonitor.md)
|
|
102
|
+
- Basic Setup Example(see in examples/dotnet/aspnetcore-distro-setup.md)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: OpenTelemetry Pipeline
|
|
3
|
+
category: concept
|
|
4
|
+
applies-to: 3.x
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# OpenTelemetry Pipeline
|
|
8
|
+
|
|
9
|
+
**Category:** Concept
|
|
10
|
+
**Applies to:** 3.x
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
The OpenTelemetry pipeline is the data flow path for telemetry signals (traces, metrics, logs) from your application to observability backends. Understanding this pipeline is essential for Azure Monitor integration.
|
|
15
|
+
|
|
16
|
+
## Pipeline Components
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
|
|
20
|
+
│ Instrumentation │ ──▶ │ Processors │ ──▶ │ Exporters │
|
|
21
|
+
│ (Sources) │ │ (Transform) │ │ (Backends) │
|
|
22
|
+
└─────────────────┘ └─────────────────┘ └─────────────────┘
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### 1. Instrumentation (Sources)
|
|
26
|
+
- **ActivitySource** - Creates spans/traces
|
|
27
|
+
- **Meter** - Creates metrics
|
|
28
|
+
- **ILogger** - Creates logs (via OpenTelemetry.Extensions.Logging)
|
|
29
|
+
|
|
30
|
+
### 2. Processors (Transform)
|
|
31
|
+
- **BaseProcessor<Activity>** - Enrich or filter spans
|
|
32
|
+
- **BaseProcessor<LogRecord>** - Enrich or filter logs
|
|
33
|
+
- Run in pipeline order before export
|
|
34
|
+
|
|
35
|
+
### 3. Exporters (Backends)
|
|
36
|
+
- **Azure Monitor Exporter** - Sends to Application Insights
|
|
37
|
+
- **OTLP Exporter** - Sends to any OTLP-compatible backend
|
|
38
|
+
- **Console Exporter** - Debug output
|
|
39
|
+
|
|
40
|
+
## Wiring Up the Pipeline
|
|
41
|
+
|
|
42
|
+
See the AddOpenTelemetry API reference(see in AddOpenTelemetry.md) for full setup examples showing how sources, processors, and exporters are composed via the builder API.
|
|
43
|
+
|
|
44
|
+
## Key Differences from Application Insights 2.x
|
|
45
|
+
|
|
46
|
+
| 2.x Concept | 3.x Equivalent |
|
|
47
|
+
|-------------|----------------|
|
|
48
|
+
| TelemetryClient | ActivitySource / Meter / ILogger |
|
|
49
|
+
| ITelemetryInitializer | BaseProcessor<Activity>.OnStart |
|
|
50
|
+
| ITelemetryProcessor | BaseProcessor<Activity>.OnEnd |
|
|
51
|
+
| TelemetryChannel | Exporter |
|
|
52
|
+
| TelemetryConfiguration | OpenTelemetryBuilder |
|
|
53
|
+
|
|
54
|
+
## See Also
|
|
55
|
+
|
|
56
|
+
- Application Insights for ASP.NET Core(see in appinsights-aspnetcore.md)
|
|
57
|
+
- AddOpenTelemetry API(see in AddOpenTelemetry.md)
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Azure Monitor for Node.js
|
|
2
|
+
|
|
3
|
+
Azure Monitor OpenTelemetry for Node.js provides automatic instrumentation and telemetry collection for Node.js applications.
|
|
4
|
+
|
|
5
|
+
## Key Features
|
|
6
|
+
|
|
7
|
+
- **Automatic Instrumentation**: Captures HTTP requests, database calls, and external dependencies
|
|
8
|
+
- **Custom Telemetry**: Track custom events, metrics, and traces
|
|
9
|
+
- **Performance Monitoring**: Monitor response times, throughput, and failures
|
|
10
|
+
- **Dependency Tracking**: Understand outgoing calls to databases, APIs, and services
|
|
11
|
+
- **Distributed Tracing**: Follow requests across microservices
|
|
12
|
+
|
|
13
|
+
## Supported Frameworks
|
|
14
|
+
|
|
15
|
+
- Express.js
|
|
16
|
+
- Next.js (via instrumentation hook — requires webpack externals configuration)
|
|
17
|
+
- Fastify
|
|
18
|
+
- NestJS
|
|
19
|
+
- Koa
|
|
20
|
+
- Hapi
|
|
21
|
+
- And many more through OpenTelemetry auto-instrumentation
|
|
22
|
+
|
|
23
|
+
> **Note**: Next.js requires special setup due to its webpack bundling. See the Next.js Setup Guide(see in basic-setup-nextjs.md) for details on externalizing server-only packages.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @azure/monitor-opentelemetry
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Basic Setup
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
const { useAzureMonitor } = require('@azure/monitor-opentelemetry');
|
|
35
|
+
|
|
36
|
+
// Enable Azure Monitor at startup
|
|
37
|
+
useAzureMonitor({
|
|
38
|
+
azureMonitorExporterOptions: {
|
|
39
|
+
connectionString: process.env.APPLICATIONINSIGHTS_CONNECTION_STRING
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Your application code follows...
|
|
44
|
+
const express = require('express');
|
|
45
|
+
const app = express();
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Configuration Options
|
|
49
|
+
|
|
50
|
+
The `useAzureMonitor()` function accepts configuration for:
|
|
51
|
+
- Connection string
|
|
52
|
+
- Sampling rate
|
|
53
|
+
- Custom resource attributes
|
|
54
|
+
- Instrumentation configuration
|
|
55
|
+
- Logging options
|
|
56
|
+
|
|
57
|
+
## What Gets Instrumented
|
|
58
|
+
|
|
59
|
+
### Automatically Captured
|
|
60
|
+
- HTTP/HTTPS requests and responses
|
|
61
|
+
- Database queries (MongoDB, MySQL, PostgreSQL, etc.)
|
|
62
|
+
- Redis operations
|
|
63
|
+
- External HTTP calls
|
|
64
|
+
- Exceptions and errors
|
|
65
|
+
|
|
66
|
+
### Custom Telemetry
|
|
67
|
+
```javascript
|
|
68
|
+
const { trace } = require('@opentelemetry/api');
|
|
69
|
+
|
|
70
|
+
// Get current span
|
|
71
|
+
const span = trace.getActiveSpan();
|
|
72
|
+
span?.setAttribute('custom.attribute', 'value');
|
|
73
|
+
|
|
74
|
+
// Log custom events
|
|
75
|
+
console.log('Custom event logged'); // Captured as trace
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Best Practices
|
|
79
|
+
|
|
80
|
+
1. **Initialize Early**: Call `useAzureMonitor()` before loading other modules
|
|
81
|
+
2. **Use Environment Variables**: Store connection string in `.env` file
|
|
82
|
+
3. **Enable Sampling**: For high-traffic apps, configure sampling to manage costs
|
|
83
|
+
4. **Add Context**: Use custom attributes to enrich telemetry
|
|
84
|
+
5. **Monitor Performance**: Set up alerts in Azure Monitor for key metrics
|
|
85
|
+
|
|
86
|
+
## Connection String
|
|
87
|
+
|
|
88
|
+
Get your connection string from Azure Portal:
|
|
89
|
+
1. Navigate to your Application Insights resource
|
|
90
|
+
2. Go to "Overview" section
|
|
91
|
+
3. Copy the "Connection String" value
|
|
92
|
+
|
|
93
|
+
Set it as an environment variable:
|
|
94
|
+
```bash
|
|
95
|
+
export APPLICATIONINSIGHTS_CONNECTION_STRING="InstrumentationKey=..."
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Or in `.env` file:
|
|
99
|
+
```
|
|
100
|
+
APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=...
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Links
|
|
104
|
+
|
|
105
|
+
- [Azure Monitor OpenTelemetry for Node.js Documentation](https://learn.microsoft.com/azure/azure-monitor/app/opentelemetry-enable?tabs=nodejs)
|
|
106
|
+
- [OpenTelemetry for Node.js](https://opentelemetry.io/docs/instrumentation/js/)
|