@azure/mcp-linux-arm64 2.0.0-beta.30 → 2.0.0-beta.31
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/dist/Instrumentation/Resources/api-reference/dotnet/AddApplicationInsightsTelemetryWorkerService.md +115 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/ApplicationInsightsWeb.md +103 -0
- package/dist/Instrumentation/Resources/api-reference/dotnet/ConfigureOpenTelemetryProvider.md +23 -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 +2 -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/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/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 +1 -1
- package/dist/Instrumentation/Resources/concepts/dotnet/opentelemetry-pipeline.md +1 -1
- 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 +34 -30
- 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 +30 -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/azmcp +0 -0
- package/package.json +3 -3
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: AddApplicationInsightsTelemetryWorkerService
|
|
3
|
+
category: api-reference
|
|
4
|
+
applies-to: 3.x
|
|
5
|
+
source: NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# AddApplicationInsightsTelemetryWorkerService
|
|
9
|
+
|
|
10
|
+
**Package:** `Microsoft.ApplicationInsights.WorkerService` (3.x)
|
|
11
|
+
|
|
12
|
+
## Signatures
|
|
13
|
+
|
|
14
|
+
```csharp
|
|
15
|
+
using Microsoft.Extensions.DependencyInjection;
|
|
16
|
+
|
|
17
|
+
// 1. Parameterless — reads config from appsettings.json / env vars
|
|
18
|
+
public static IServiceCollection AddApplicationInsightsTelemetryWorkerService(
|
|
19
|
+
this IServiceCollection services);
|
|
20
|
+
|
|
21
|
+
// 2. IConfiguration — binds "ApplicationInsights" section
|
|
22
|
+
public static IServiceCollection AddApplicationInsightsTelemetryWorkerService(
|
|
23
|
+
this IServiceCollection services,
|
|
24
|
+
IConfiguration configuration);
|
|
25
|
+
|
|
26
|
+
// 3. Action delegate — configure options inline
|
|
27
|
+
public static IServiceCollection AddApplicationInsightsTelemetryWorkerService(
|
|
28
|
+
this IServiceCollection services,
|
|
29
|
+
Action<ApplicationInsightsServiceOptions> options);
|
|
30
|
+
|
|
31
|
+
// 4. Options instance — pass a pre-built options object
|
|
32
|
+
public static IServiceCollection AddApplicationInsightsTelemetryWorkerService(
|
|
33
|
+
this IServiceCollection services,
|
|
34
|
+
ApplicationInsightsServiceOptions options);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
All overloads return `IServiceCollection`. Overloads 2–4 call overload 1 internally, then apply configuration.
|
|
38
|
+
|
|
39
|
+
## ApplicationInsightsServiceOptions
|
|
40
|
+
|
|
41
|
+
Namespace: `Microsoft.ApplicationInsights.WorkerService`
|
|
42
|
+
|
|
43
|
+
| Property | Type | Default | Description |
|
|
44
|
+
|---|---|---|---|
|
|
45
|
+
| `ConnectionString` | `string` | `null` | Connection string for Application Insights. Can also be set via env var or config (see below). |
|
|
46
|
+
| `Credential` | `TokenCredential` | `null` | AAD credential for token-based authentication. When null, the instrumentation key from the connection string is used. |
|
|
47
|
+
| `ApplicationVersion` | `string` | Entry assembly version | Application version reported with telemetry. |
|
|
48
|
+
| `EnableQuickPulseMetricStream` | `bool` | `true` | Enables Live Metrics. |
|
|
49
|
+
| `EnablePerformanceCounterCollectionModule` | `bool` | `true` | Enables performance counter collection. |
|
|
50
|
+
| `EnableDependencyTrackingTelemetryModule` | `bool` | `true` | Enables HTTP and SQL dependency tracking. |
|
|
51
|
+
| `AddAutoCollectedMetricExtractor` | `bool` | `true` | Enables standard metric extraction. |
|
|
52
|
+
| `TracesPerSecond` | `double?` | `null` (effective: `5`) | Rate-limited sampling — targets this many traces per second. Must be ≥ 0. |
|
|
53
|
+
| `SamplingRatio` | `float?` | `null` | Fixed-rate sampling (0.0–1.0, where 1.0 = no sampling). When set, overrides `TracesPerSecond`. |
|
|
54
|
+
| `EnableTraceBasedLogsSampler` | `bool?` | `null` (effective: `true`) | When true, logs are sampled with their parent trace. Set `false` to collect all logs. |
|
|
55
|
+
|
|
56
|
+
**Note:** Unlike the ASP.NET Core package, WorkerService does not include `EnableRequestTrackingTelemetryModule` or `EnableAuthenticationTrackingJavaScript`.
|
|
57
|
+
|
|
58
|
+
## Minimal example
|
|
59
|
+
|
|
60
|
+
```csharp
|
|
61
|
+
using Microsoft.Extensions.DependencyInjection;
|
|
62
|
+
|
|
63
|
+
var builder = Host.CreateDefaultBuilder(args);
|
|
64
|
+
builder.ConfigureServices(services =>
|
|
65
|
+
{
|
|
66
|
+
services.AddApplicationInsightsTelemetryWorkerService();
|
|
67
|
+
});
|
|
68
|
+
var host = builder.Build();
|
|
69
|
+
await host.RunAsync();
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Set the connection string via environment variable:
|
|
73
|
+
```
|
|
74
|
+
APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=...;IngestionEndpoint=...
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Or in `appsettings.json`:
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"ApplicationInsights": {
|
|
81
|
+
"ConnectionString": "InstrumentationKey=...;IngestionEndpoint=..."
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Full example
|
|
87
|
+
|
|
88
|
+
```csharp
|
|
89
|
+
using Microsoft.Extensions.DependencyInjection;
|
|
90
|
+
using Microsoft.ApplicationInsights.WorkerService;
|
|
91
|
+
|
|
92
|
+
var builder = Host.CreateDefaultBuilder(args);
|
|
93
|
+
builder.ConfigureServices(services =>
|
|
94
|
+
{
|
|
95
|
+
services.AddApplicationInsightsTelemetryWorkerService(options =>
|
|
96
|
+
{
|
|
97
|
+
options.ConnectionString = "InstrumentationKey=...;IngestionEndpoint=...";
|
|
98
|
+
options.EnableQuickPulseMetricStream = true;
|
|
99
|
+
options.SamplingRatio = 0.5f; // Collect 50% of telemetry
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
var host = builder.Build();
|
|
103
|
+
await host.RunAsync();
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Behavior notes
|
|
107
|
+
|
|
108
|
+
- Connection string resolution order: `ApplicationInsightsServiceOptions.ConnectionString` → env var `APPLICATIONINSIGHTS_CONNECTION_STRING` → config key `ApplicationInsights:ConnectionString`.
|
|
109
|
+
- `TracesPerSecond` is the default sampling mode (effective default `5`). Set `SamplingRatio` for fixed-rate sampling instead.
|
|
110
|
+
- Additional OTel sources/meters can be added: `services.AddOpenTelemetry().WithTracing(t => t.AddSource("MySource"))`.
|
|
111
|
+
## See also
|
|
112
|
+
|
|
113
|
+
- UseAzureMonitor (distro)(see in UseAzureMonitor.md)
|
|
114
|
+
- UseAzureMonitorExporter(see in UseAzureMonitorExporter.md)
|
|
115
|
+
- Worker Service 2.x → 3.x Migration(see in workerservice-2x-to-3x-code-migration.md)
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ApplicationInsightsWeb
|
|
3
|
+
category: api-reference
|
|
4
|
+
applies-to: 3.x
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Microsoft.ApplicationInsights.Web — API Reference
|
|
8
|
+
|
|
9
|
+
## Package
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
Microsoft.ApplicationInsights.Web
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Target: .NET Framework 4.6.2+
|
|
16
|
+
|
|
17
|
+
## ApplicationInsights.config elements
|
|
18
|
+
|
|
19
|
+
| Element | Default | Description |
|
|
20
|
+
|---|---|---|
|
|
21
|
+
| `ConnectionString` | — | **Required.** Azure Monitor connection string. |
|
|
22
|
+
| `DisableTelemetry` | `false` | Disable all telemetry collection. |
|
|
23
|
+
| `ApplicationVersion` | — | Sets `service.version` resource attribute. |
|
|
24
|
+
| `TracesPerSecond` | `5.0` | Rate-limited sampling (traces per second). |
|
|
25
|
+
| `SamplingRatio` | — | Fixed-rate sampling (0.0–1.0). Overrides `TracesPerSecond` if set. |
|
|
26
|
+
| `EnableTraceBasedLogsSampler` | `true` | Logs follow parent trace sampling decision. |
|
|
27
|
+
| `StorageDirectory` | — | Directory for offline telemetry storage. |
|
|
28
|
+
| `DisableOfflineStorage` | `false` | Disable offline storage. |
|
|
29
|
+
| `EnableQuickPulseMetricStream` | `true` | Enable Live Metrics. |
|
|
30
|
+
| `EnablePerformanceCounterCollectionModule` | `true` | Collect performance counters. |
|
|
31
|
+
| `EnableDependencyTrackingTelemetryModule` | `true` | Track SQL/HTTP dependencies. |
|
|
32
|
+
| `EnableRequestTrackingTelemetryModule` | `true` | Track incoming HTTP requests. |
|
|
33
|
+
| `AddAutoCollectedMetricExtractor` | `true` | Extract standard metrics. |
|
|
34
|
+
|
|
35
|
+
## Removed in 3.x (from 2.x)
|
|
36
|
+
|
|
37
|
+
| Element/Section | Status |
|
|
38
|
+
|---|---|
|
|
39
|
+
| `<InstrumentationKey>` | **Removed** — use `<ConnectionString>` |
|
|
40
|
+
| `<TelemetryInitializers>` | **Removed** — initializers are now internal Activity Processors |
|
|
41
|
+
| `<TelemetryModules>` | **Removed** — modules are auto-configured internally |
|
|
42
|
+
| `<TelemetryProcessors>` | **Removed** — use `ConfigureOpenTelemetryBuilder` for custom processors |
|
|
43
|
+
| `<TelemetryChannel>` | **Removed** — export pipeline managed by OpenTelemetry |
|
|
44
|
+
|
|
45
|
+
## HTTP modules required in Web.config
|
|
46
|
+
|
|
47
|
+
### IIS Integrated mode (`system.webServer/modules`)
|
|
48
|
+
|
|
49
|
+
```xml
|
|
50
|
+
<add name="ApplicationInsightsWebTracking"
|
|
51
|
+
type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
|
|
52
|
+
preCondition="managedHandler" />
|
|
53
|
+
<add name="TelemetryHttpModule"
|
|
54
|
+
type="OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule, OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule"
|
|
55
|
+
preCondition="integratedMode,managedHandler" />
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### IIS Classic mode (`system.web/httpModules`)
|
|
59
|
+
|
|
60
|
+
```xml
|
|
61
|
+
<add name="ApplicationInsightsWebTracking"
|
|
62
|
+
type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
> These are auto-configured by the NuGet package install.
|
|
66
|
+
|
|
67
|
+
## TelemetryClient usage
|
|
68
|
+
|
|
69
|
+
`TelemetryClient` works the same as in ASP.NET Core 3.x. See TelemetryClient.md for breaking changes.
|
|
70
|
+
|
|
71
|
+
Key difference: in classic ASP.NET, create via `new TelemetryClient(TelemetryConfiguration.CreateDefault())` or let `ApplicationInsightsHttpModule` initialize the configuration first.
|
|
72
|
+
|
|
73
|
+
```csharp
|
|
74
|
+
var client = new TelemetryClient(TelemetryConfiguration.CreateDefault());
|
|
75
|
+
client.TrackEvent("OrderCreated", new Dictionary<string, string> { ["OrderId"] = orderId });
|
|
76
|
+
client.TrackMetric("ProcessingTime", elapsed);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## ConfigureOpenTelemetryBuilder
|
|
80
|
+
|
|
81
|
+
The primary extensibility point in 3.x for classic ASP.NET. Add custom processors, exporters, or resource attributes:
|
|
82
|
+
|
|
83
|
+
```csharp
|
|
84
|
+
// In Global.asax.cs Application_Start()
|
|
85
|
+
var config = TelemetryConfiguration.CreateDefault();
|
|
86
|
+
config.ConnectionString = "InstrumentationKey=...;IngestionEndpoint=...";
|
|
87
|
+
config.ConfigureOpenTelemetryBuilder(otel =>
|
|
88
|
+
{
|
|
89
|
+
otel.WithTracing(tracing =>
|
|
90
|
+
{
|
|
91
|
+
tracing.AddProcessor<MyFilterProcessor>();
|
|
92
|
+
tracing.AddConsoleExporter(); // For debugging
|
|
93
|
+
});
|
|
94
|
+
otel.ConfigureResource(r => r.AddService("MyWebApp"));
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Notes
|
|
99
|
+
|
|
100
|
+
- The NuGet package install handles all configuration — no code changes needed for basic setup.
|
|
101
|
+
- `TelemetryCorrelationHttpModule` is **not needed** in 3.x — OpenTelemetry handles correlation natively.
|
|
102
|
+
- Connection string can be set in `ApplicationInsights.config`, in code, or via `APPLICATIONINSIGHTS_CONNECTION_STRING` environment variable.
|
|
103
|
+
- **Non-DI:** Classic ASP.NET does not use `IServiceCollection`. Use `TelemetryConfiguration.ConfigureOpenTelemetryBuilder` for extensibility.
|
package/dist/Instrumentation/Resources/api-reference/dotnet/ConfigureOpenTelemetryProvider.md
CHANGED
|
@@ -111,6 +111,11 @@ Register instrumentation sources early in startup, then configure exporters
|
|
|
111
111
|
separately:
|
|
112
112
|
|
|
113
113
|
```csharp
|
|
114
|
+
using OpenTelemetry;
|
|
115
|
+
using OpenTelemetry.Trace;
|
|
116
|
+
using OpenTelemetry.Metrics;
|
|
117
|
+
using OpenTelemetry.Resources;
|
|
118
|
+
|
|
114
119
|
var builder = WebApplication.CreateBuilder(args);
|
|
115
120
|
|
|
116
121
|
// Register sources (could be in a different file or method)
|
|
@@ -130,12 +135,30 @@ var app = builder.Build();
|
|
|
130
135
|
app.Run();
|
|
131
136
|
```
|
|
132
137
|
|
|
138
|
+
## Example - setting cloud role name via ConfigureResource
|
|
139
|
+
|
|
140
|
+
A common migration pattern: replace a custom `ITelemetryInitializer` that sets
|
|
141
|
+
cloud role name with `ConfigureResource` + `AddService`:
|
|
142
|
+
|
|
143
|
+
```csharp
|
|
144
|
+
using OpenTelemetry.Resources; // Required for ResourceBuilder.AddService
|
|
145
|
+
|
|
146
|
+
// Set cloud role name (replaces ITelemetryInitializer that set Context.Cloud.RoleName)
|
|
147
|
+
builder.Services.ConfigureOpenTelemetryTracerProvider(tracing =>
|
|
148
|
+
tracing.ConfigureResource(r => r.AddService(
|
|
149
|
+
serviceName: "MyService",
|
|
150
|
+
serviceInstanceId: Environment.MachineName)));
|
|
151
|
+
```
|
|
152
|
+
|
|
133
153
|
## Example - library author registering sources
|
|
134
154
|
|
|
135
155
|
A library can register its instrumentation without depending on the app's
|
|
136
156
|
startup code:
|
|
137
157
|
|
|
138
158
|
```csharp
|
|
159
|
+
using OpenTelemetry.Trace;
|
|
160
|
+
using OpenTelemetry.Metrics;
|
|
161
|
+
|
|
139
162
|
public static class MyLibraryExtensions
|
|
140
163
|
{
|
|
141
164
|
public static IServiceCollection AddMyLibrary(this IServiceCollection services)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ConsoleExporter
|
|
3
|
+
category: api-reference
|
|
4
|
+
applies-to: 1.x
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Console Exporter
|
|
8
|
+
|
|
9
|
+
Writes traces, metrics, and logs to the console (stdout). Useful for **local development and debugging only** — not for production.
|
|
10
|
+
|
|
11
|
+
## Package
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
OpenTelemetry.Exporter.Console
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Setup
|
|
18
|
+
|
|
19
|
+
```csharp
|
|
20
|
+
using OpenTelemetry.Trace;
|
|
21
|
+
using OpenTelemetry.Metrics;
|
|
22
|
+
using OpenTelemetry.Logs;
|
|
23
|
+
|
|
24
|
+
builder.Services.ConfigureOpenTelemetryTracerProvider(tracing =>
|
|
25
|
+
tracing.AddConsoleExporter());
|
|
26
|
+
|
|
27
|
+
builder.Services.ConfigureOpenTelemetryMeterProvider(metrics =>
|
|
28
|
+
metrics.AddConsoleExporter());
|
|
29
|
+
|
|
30
|
+
builder.Services.ConfigureOpenTelemetryLoggerProvider(logging =>
|
|
31
|
+
logging.AddConsoleExporter());
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Options
|
|
35
|
+
|
|
36
|
+
| Option | Default | Description |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| `Targets` | `Console` | `ConsoleExporterOutputTargets.Console` or `Debug` (writes to `System.Diagnostics.Debug`). |
|
|
39
|
+
|
|
40
|
+
## Notes
|
|
41
|
+
|
|
42
|
+
- **Development only** — do not use in production. Adds significant overhead.
|
|
43
|
+
- Useful for verifying that spans, metrics, and log records are being generated correctly.
|
|
44
|
+
- Console exporter works alongside Azure Monitor — both receive the same telemetry.
|
|
45
|
+
- Each signal needs its own `AddConsoleExporter()` call.
|
|
46
|
+
- For production multi-destination export, use OTLP exporter instead.
|
|
47
|
+
- **Non-DI usage:** Use `config.ConfigureOpenTelemetryBuilder(otel => otel.WithTracing(t => t.AddConsoleExporter()))` on `TelemetryConfiguration`. See TelemetryClient.md.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: EntityFrameworkInstrumentation
|
|
3
|
+
category: api-reference
|
|
4
|
+
applies-to: 1.x
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Entity Framework Core Instrumentation
|
|
8
|
+
|
|
9
|
+
## Package
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
OpenTelemetry.Instrumentation.EntityFrameworkCore
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Setup
|
|
16
|
+
|
|
17
|
+
```csharp
|
|
18
|
+
using OpenTelemetry.Trace;
|
|
19
|
+
|
|
20
|
+
// EF Core is auto-instrumented via DiagnosticSource — no additional setup needed.
|
|
21
|
+
// To customize, use ConfigureOpenTelemetryTracerProvider:
|
|
22
|
+
builder.Services.ConfigureOpenTelemetryTracerProvider(tracing =>
|
|
23
|
+
tracing.AddEntityFrameworkCoreInstrumentation(options =>
|
|
24
|
+
{
|
|
25
|
+
options.SetDbStatementForText = true; // Include SQL text (be careful with PII)
|
|
26
|
+
options.SetDbStatementForStoredProcedure = true;
|
|
27
|
+
}));
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Options
|
|
31
|
+
|
|
32
|
+
| Option | Default | Description |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| `SetDbStatementForText` | `false` | Include raw SQL text in `db.statement` attribute. May contain PII. |
|
|
35
|
+
| `SetDbStatementForStoredProcedure` | `true` | Include stored procedure names in `db.statement`. |
|
|
36
|
+
| `EnrichWithIDbCommand` | `null` | `Action<Activity, IDbCommand>` callback to enrich spans with custom tags from the command. |
|
|
37
|
+
| `Filter` | `null` | `Func<string, string, bool>` — filter by provider name and command text. Return `false` to suppress. |
|
|
38
|
+
|
|
39
|
+
## Semantic conventions
|
|
40
|
+
|
|
41
|
+
EF Core spans use the [OpenTelemetry Database semantic conventions](https://opentelemetry.io/docs/specs/semconv/database/):
|
|
42
|
+
|
|
43
|
+
| Attribute | Example |
|
|
44
|
+
|---|---|
|
|
45
|
+
| `db.system` | `microsoft.sql_server`, `postgresql`, `sqlite` |
|
|
46
|
+
| `db.name` | `MyDatabase` |
|
|
47
|
+
| `db.statement` | `SELECT * FROM Orders WHERE Id = @p0` (if `SetDbStatementForText = true`) |
|
|
48
|
+
| `server.address` | `localhost` |
|
|
49
|
+
| `server.port` | `5432` |
|
|
50
|
+
|
|
51
|
+
## Notes
|
|
52
|
+
|
|
53
|
+
- EF Core instrumentation relies on `DiagnosticSource` events emitted by EF Core itself — no additional packages needed for basic span collection.
|
|
54
|
+
- The `OpenTelemetry.Instrumentation.EntityFrameworkCore` package is only needed to customize options (SQL text capture, enrichment, filtering).
|
|
55
|
+
- Works with all EF Core providers (SQL Server, PostgreSQL, SQLite, MySQL, etc.).
|
|
56
|
+
- **Non-DI usage:** If not using ASP.NET Core DI, use `config.ConfigureOpenTelemetryBuilder(otel => otel.WithTracing(t => t.AddEntityFrameworkCoreInstrumentation()))` on `TelemetryConfiguration`. See TelemetryClient.md.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: HttpInstrumentation
|
|
3
|
+
category: api-reference
|
|
4
|
+
applies-to: 1.x
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# HTTP Instrumentation — Client & Server Enrichment
|
|
8
|
+
|
|
9
|
+
HTTP client and server instrumentation is auto-configured by both Azure Monitor Distro and Application Insights 3.x. This doc covers **customization**: enrichment, filtering, and advanced options.
|
|
10
|
+
|
|
11
|
+
## Packages
|
|
12
|
+
|
|
13
|
+
| Scope | Package | Auto-included? |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| HTTP Client (`HttpClient`) | `OpenTelemetry.Instrumentation.Http` | Yes (by Distro & AI 3.x) |
|
|
16
|
+
| HTTP Server (ASP.NET Core) | `OpenTelemetry.Instrumentation.AspNetCore` | Yes (by Distro & AI 3.x) |
|
|
17
|
+
|
|
18
|
+
You only need to install these packages explicitly if you want to **customize** the instrumentation options.
|
|
19
|
+
|
|
20
|
+
## HTTP Client enrichment
|
|
21
|
+
|
|
22
|
+
```csharp
|
|
23
|
+
using OpenTelemetry.Trace;
|
|
24
|
+
|
|
25
|
+
builder.Services.ConfigureOpenTelemetryTracerProvider(tracing =>
|
|
26
|
+
tracing.AddHttpClientInstrumentation(options =>
|
|
27
|
+
{
|
|
28
|
+
options.EnrichWithHttpRequestMessage = (activity, request) =>
|
|
29
|
+
{
|
|
30
|
+
activity.SetTag("http.request.header.x-correlation-id",
|
|
31
|
+
request.Headers.TryGetValues("X-Correlation-Id", out var vals) ? vals.First() : null);
|
|
32
|
+
};
|
|
33
|
+
options.EnrichWithHttpResponseMessage = (activity, response) =>
|
|
34
|
+
{
|
|
35
|
+
activity.SetTag("http.response.content_length", response.Content.Headers.ContentLength);
|
|
36
|
+
};
|
|
37
|
+
options.FilterHttpRequestMessage = (request) =>
|
|
38
|
+
{
|
|
39
|
+
// Suppress health check calls
|
|
40
|
+
return request.RequestUri?.AbsolutePath != "/health";
|
|
41
|
+
};
|
|
42
|
+
options.RecordException = true;
|
|
43
|
+
}));
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## HTTP Client options
|
|
47
|
+
|
|
48
|
+
| Option | Default | Description |
|
|
49
|
+
|---|---|---|
|
|
50
|
+
| `EnrichWithHttpRequestMessage` | `null` | `Action<Activity, HttpRequestMessage>` to add tags from the request. |
|
|
51
|
+
| `EnrichWithHttpResponseMessage` | `null` | `Action<Activity, HttpResponseMessage>` to add tags from the response. |
|
|
52
|
+
| `EnrichWithException` | `null` | `Action<Activity, Exception>` to enrich on failure. |
|
|
53
|
+
| `FilterHttpRequestMessage` | `null` | `Func<HttpRequestMessage, bool>` — return `false` to suppress span. |
|
|
54
|
+
| `RecordException` | `false` | Record exception events on the span. |
|
|
55
|
+
|
|
56
|
+
## HTTP Server (ASP.NET Core) enrichment
|
|
57
|
+
|
|
58
|
+
```csharp
|
|
59
|
+
using OpenTelemetry.Trace;
|
|
60
|
+
|
|
61
|
+
builder.Services.ConfigureOpenTelemetryTracerProvider(tracing =>
|
|
62
|
+
tracing.AddAspNetCoreInstrumentation(options =>
|
|
63
|
+
{
|
|
64
|
+
options.EnrichWithHttpRequest = (activity, request) =>
|
|
65
|
+
{
|
|
66
|
+
activity.SetTag("http.request.header.user-agent", request.Headers["User-Agent"].ToString());
|
|
67
|
+
};
|
|
68
|
+
options.EnrichWithHttpResponse = (activity, response) =>
|
|
69
|
+
{
|
|
70
|
+
activity.SetTag("http.response.custom_header", response.Headers["X-Custom"].ToString());
|
|
71
|
+
};
|
|
72
|
+
options.Filter = (httpContext) =>
|
|
73
|
+
{
|
|
74
|
+
// Suppress /health and /metrics endpoints
|
|
75
|
+
return httpContext.Request.Path != "/health"
|
|
76
|
+
&& httpContext.Request.Path != "/metrics";
|
|
77
|
+
};
|
|
78
|
+
options.RecordException = true;
|
|
79
|
+
}));
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## HTTP Server options
|
|
83
|
+
|
|
84
|
+
| Option | Default | Description |
|
|
85
|
+
|---|---|---|
|
|
86
|
+
| `EnrichWithHttpRequest` | `null` | `Action<Activity, HttpRequest>` to add tags from the request. |
|
|
87
|
+
| `EnrichWithHttpResponse` | `null` | `Action<Activity, HttpResponse>` to add tags from the response. |
|
|
88
|
+
| `EnrichWithException` | `null` | `Action<Activity, Exception>` to enrich on failure. |
|
|
89
|
+
| `Filter` | `null` | `Func<HttpContext, bool>` — return `false` to suppress span. |
|
|
90
|
+
| `RecordException` | `false` | Record exception events on the span. |
|
|
91
|
+
|
|
92
|
+
## Semantic conventions (auto-populated)
|
|
93
|
+
|
|
94
|
+
| Attribute | Source |
|
|
95
|
+
|---|---|
|
|
96
|
+
| `http.request.method` | `GET`, `POST`, etc. |
|
|
97
|
+
| `url.full` | Full URL (client) |
|
|
98
|
+
| `url.path` | Path (server) |
|
|
99
|
+
| `http.response.status_code` | `200`, `404`, etc. |
|
|
100
|
+
| `server.address` | Target host (client) |
|
|
101
|
+
| `network.protocol.version` | `1.1`, `2` |
|
|
102
|
+
| `http.route` | Route template (server) |
|
|
103
|
+
|
|
104
|
+
## Notes
|
|
105
|
+
|
|
106
|
+
- Both client and server instrumentation are **already active** in AI 3.x setups. Adding the packages explicitly is only needed to access the `options` overload for enrichment/filtering.
|
|
107
|
+
- Enrichment callbacks run synchronously on the hot path — keep them lightweight.
|
|
108
|
+
- `Filter` on the server side is the recommended way to suppress health check / readiness probe spans (instead of a custom processor).
|
|
109
|
+
- **Non-DI usage:** Use `config.ConfigureOpenTelemetryBuilder(otel => otel.WithTracing(t => t.AddHttpClientInstrumentation(...)))` on `TelemetryConfiguration`. See TelemetryClient.md.
|
|
@@ -15,6 +15,8 @@ applies-to: 1.x
|
|
|
15
15
|
## Filtering — use `AddFilter`
|
|
16
16
|
|
|
17
17
|
```csharp
|
|
18
|
+
using OpenTelemetry.Logs; // Required for OpenTelemetryLoggerProvider
|
|
19
|
+
|
|
18
20
|
builder.Logging.AddFilter<OpenTelemetryLoggerProvider>("Microsoft.AspNetCore", LogLevel.Warning);
|
|
19
21
|
builder.Logging.AddFilter<OpenTelemetryLoggerProvider>("System.Net.Http", LogLevel.Warning);
|
|
20
22
|
```
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: OtlpExporter
|
|
3
|
+
category: api-reference
|
|
4
|
+
applies-to: 1.x
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# OTLP Exporter
|
|
8
|
+
|
|
9
|
+
Export traces, metrics, and logs to any OpenTelemetry Protocol (OTLP) compatible backend (e.g. Jaeger, Grafana Tempo, Aspire Dashboard, custom collectors).
|
|
10
|
+
|
|
11
|
+
## Package
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
OpenTelemetry.Exporter.OpenTelemetryProtocol
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Setup
|
|
18
|
+
|
|
19
|
+
```csharp
|
|
20
|
+
using OpenTelemetry.Trace;
|
|
21
|
+
using OpenTelemetry.Metrics;
|
|
22
|
+
using OpenTelemetry.Logs;
|
|
23
|
+
using OpenTelemetry.Exporter;
|
|
24
|
+
|
|
25
|
+
// Azure Monitor is already configured via AddApplicationInsightsTelemetry.
|
|
26
|
+
// Add OTLP as a secondary exporter:
|
|
27
|
+
builder.Services.ConfigureOpenTelemetryTracerProvider(tracing =>
|
|
28
|
+
tracing.AddOtlpExporter(options =>
|
|
29
|
+
{
|
|
30
|
+
options.Endpoint = new Uri("http://localhost:4317");
|
|
31
|
+
options.Protocol = OtlpExportProtocol.Grpc;
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
builder.Services.ConfigureOpenTelemetryMeterProvider(metrics =>
|
|
35
|
+
metrics.AddOtlpExporter(options =>
|
|
36
|
+
{
|
|
37
|
+
options.Endpoint = new Uri("http://localhost:4317");
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
builder.Services.ConfigureOpenTelemetryLoggerProvider(logging =>
|
|
41
|
+
logging.AddOtlpExporter(options =>
|
|
42
|
+
{
|
|
43
|
+
options.Endpoint = new Uri("http://localhost:4317");
|
|
44
|
+
}));
|
|
45
|
+
```
|
|
46
|
+
.WithTracing(tracing => tracing.AddOtlpExporter())
|
|
47
|
+
.WithMetrics(metrics => metrics.AddOtlpExporter());
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Environment variable configuration
|
|
51
|
+
|
|
52
|
+
Instead of code, configure via environment variables:
|
|
53
|
+
|
|
54
|
+
| Variable | Default | Description |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| `OTEL_EXPORTER_OTLP_ENDPOINT` | `http://localhost:4317` | OTLP endpoint URL |
|
|
57
|
+
| `OTEL_EXPORTER_OTLP_PROTOCOL` | `grpc` | Protocol: `grpc` or `http/protobuf` |
|
|
58
|
+
| `OTEL_EXPORTER_OTLP_HEADERS` | — | Headers as `key=value` pairs, comma-separated |
|
|
59
|
+
| `OTEL_EXPORTER_OTLP_TIMEOUT` | `10000` | Timeout in milliseconds |
|
|
60
|
+
|
|
61
|
+
## Options
|
|
62
|
+
|
|
63
|
+
| Option | Default | Description |
|
|
64
|
+
|---|---|---|
|
|
65
|
+
| `Endpoint` | `http://localhost:4317` | Backend URL. Use port `4317` for gRPC, `4318` for HTTP. |
|
|
66
|
+
| `Protocol` | `Grpc` | `OtlpExportProtocol.Grpc` or `OtlpExportProtocol.HttpProtobuf` |
|
|
67
|
+
| `Headers` | `null` | Custom headers (e.g. auth tokens). Format: `"key=value"` |
|
|
68
|
+
| `TimeoutMilliseconds` | `10000` | Export timeout. |
|
|
69
|
+
| `ExportProcessorType` | `Batch` | `Batch` or `Simple`. Use `Simple` for debugging only. |
|
|
70
|
+
| `BatchExportProcessorOptions` | default | Batch size, delay, queue size for batch processor. |
|
|
71
|
+
|
|
72
|
+
## Common backends
|
|
73
|
+
|
|
74
|
+
| Backend | Endpoint | Protocol |
|
|
75
|
+
|---|---|---|
|
|
76
|
+
| Aspire Dashboard | `http://localhost:4317` | gRPC |
|
|
77
|
+
| Jaeger | `http://localhost:4317` | gRPC |
|
|
78
|
+
| Grafana Tempo | `http://localhost:4317` | gRPC |
|
|
79
|
+
| Grafana Cloud | `https://otlp-gateway-*.grafana.net/otlp` | HTTP (`http/protobuf`) |
|
|
80
|
+
| Seq | `http://localhost:5341/ingest/otlp/v1/traces` | HTTP |
|
|
81
|
+
|
|
82
|
+
## Notes
|
|
83
|
+
|
|
84
|
+
- OTLP exporter works **alongside** Azure Monitor — data is sent to both destinations.
|
|
85
|
+
- For local development with Aspire Dashboard, use `http://localhost:4317` with gRPC.
|
|
86
|
+
- `AddOtlpExporter()` with no arguments uses environment variables or defaults.
|
|
87
|
+
- Each signal (traces, metrics, logs) needs its own `AddOtlpExporter()` call.
|
|
88
|
+
- **Non-DI usage:** Use `config.ConfigureOpenTelemetryBuilder(otel => otel.WithTracing(t => t.AddOtlpExporter(...)))` on `TelemetryConfiguration`. See TelemetryClient.md.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: RedisInstrumentation
|
|
3
|
+
category: api-reference
|
|
4
|
+
applies-to: 1.x
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Redis Instrumentation (StackExchange.Redis)
|
|
8
|
+
|
|
9
|
+
## Package
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
OpenTelemetry.Instrumentation.StackExchangeRedis
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Setup
|
|
16
|
+
|
|
17
|
+
```csharp
|
|
18
|
+
using OpenTelemetry.Trace;
|
|
19
|
+
using OpenTelemetry.Instrumentation.StackExchangeRedis;
|
|
20
|
+
|
|
21
|
+
// Register IConnectionMultiplexer in DI
|
|
22
|
+
builder.Services.AddSingleton<IConnectionMultiplexer>(
|
|
23
|
+
ConnectionMultiplexer.Connect("localhost:6379"));
|
|
24
|
+
|
|
25
|
+
// Add Redis instrumentation
|
|
26
|
+
builder.Services.ConfigureOpenTelemetryTracerProvider(tracing =>
|
|
27
|
+
tracing.AddRedisInstrumentation());
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Options with customization
|
|
31
|
+
|
|
32
|
+
```csharp
|
|
33
|
+
builder.Services.ConfigureOpenTelemetryTracerProvider(tracing =>
|
|
34
|
+
tracing.AddRedisInstrumentation(options =>
|
|
35
|
+
{
|
|
36
|
+
options.SetVerboseDatabaseStatements = true;
|
|
37
|
+
}));
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Options
|
|
41
|
+
|
|
42
|
+
| Option | Default | Description |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| `SetVerboseDatabaseStatements` | `false` | Include full Redis command in `db.statement` (e.g. `GET mykey`). |
|
|
45
|
+
| `EnrichActivityWithTimingEvents` | `true` | Add Redis timing events (enqueue, sent, response) as Activity events. |
|
|
46
|
+
| `Enrich` | `null` | `Action<Activity, IProfiledCommand>` callback to add custom tags. |
|
|
47
|
+
| `FlushInterval` | 1 second | How often to flush profiling sessions. |
|
|
48
|
+
|
|
49
|
+
## Semantic conventions
|
|
50
|
+
|
|
51
|
+
| Attribute | Example |
|
|
52
|
+
|---|---|
|
|
53
|
+
| `db.system` | `redis` |
|
|
54
|
+
| `db.statement` | `GET mykey` (if verbose) |
|
|
55
|
+
| `server.address` | `localhost` |
|
|
56
|
+
| `server.port` | `6379` |
|
|
57
|
+
| `db.redis.database_index` | `0` |
|
|
58
|
+
|
|
59
|
+
## Notes
|
|
60
|
+
|
|
61
|
+
- The Redis instrumentation hooks into `StackExchange.Redis` profiling. It requires either DI-registered `IConnectionMultiplexer` (auto-discovered) or passing the connection explicitly.
|
|
62
|
+
- When using DI registration, the instrumentation automatically discovers all `IConnectionMultiplexer` instances — no need to pass the connection manually.
|
|
63
|
+
- **Non-DI usage:** Use `config.ConfigureOpenTelemetryBuilder(otel => otel.WithTracing(t => t.AddRedisInstrumentation(connection)))` on `TelemetryConfiguration`. See TelemetryClient.md.
|