@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.
Files changed (69) hide show
  1. package/NOTICE.txt +5683 -4849
  2. package/README.md +149 -26
  3. package/dist/Azure.Mcp.Tools.AzureMigrate.xml +1060 -0
  4. package/dist/Instrumentation/Resources/api-reference/dotnet/ActivityProcessors.md +119 -0
  5. package/dist/Instrumentation/Resources/api-reference/dotnet/AddApplicationInsightsTelemetry.md +129 -0
  6. package/dist/Instrumentation/Resources/api-reference/dotnet/AddApplicationInsightsTelemetryWorkerService.md +115 -0
  7. package/dist/Instrumentation/Resources/api-reference/dotnet/AddOpenTelemetry.md +153 -0
  8. package/dist/Instrumentation/Resources/api-reference/dotnet/ApplicationInsightsWeb.md +103 -0
  9. package/dist/Instrumentation/Resources/api-reference/dotnet/AzureMonitorExporter.md +137 -0
  10. package/dist/Instrumentation/Resources/api-reference/dotnet/ConfigureOpenTelemetryProvider.md +218 -0
  11. package/dist/Instrumentation/Resources/api-reference/dotnet/ConfigureResource.md +119 -0
  12. package/dist/Instrumentation/Resources/api-reference/dotnet/ConsoleExporter.md +47 -0
  13. package/dist/Instrumentation/Resources/api-reference/dotnet/EntityFrameworkInstrumentation.md +56 -0
  14. package/dist/Instrumentation/Resources/api-reference/dotnet/HttpInstrumentation.md +109 -0
  15. package/dist/Instrumentation/Resources/api-reference/dotnet/LogProcessors.md +101 -0
  16. package/dist/Instrumentation/Resources/api-reference/dotnet/OpenTelemetrySdkCreate.md +146 -0
  17. package/dist/Instrumentation/Resources/api-reference/dotnet/OtlpExporter.md +88 -0
  18. package/dist/Instrumentation/Resources/api-reference/dotnet/RedisInstrumentation.md +63 -0
  19. package/dist/Instrumentation/Resources/api-reference/dotnet/Sampling.md +86 -0
  20. package/dist/Instrumentation/Resources/api-reference/dotnet/SdkCreateTracerProviderBuilder.md +127 -0
  21. package/dist/Instrumentation/Resources/api-reference/dotnet/SqlClientInstrumentation.md +53 -0
  22. package/dist/Instrumentation/Resources/api-reference/dotnet/TelemetryClient.md +122 -0
  23. package/dist/Instrumentation/Resources/api-reference/dotnet/TelemetryConfigurationBuilder.md +173 -0
  24. package/dist/Instrumentation/Resources/api-reference/dotnet/UseAzureMonitor.md +96 -0
  25. package/dist/Instrumentation/Resources/api-reference/dotnet/UseAzureMonitorExporter.md +146 -0
  26. package/dist/Instrumentation/Resources/api-reference/dotnet/WithLogging.md +109 -0
  27. package/dist/Instrumentation/Resources/api-reference/dotnet/WithMetrics.md +105 -0
  28. package/dist/Instrumentation/Resources/api-reference/dotnet/WithTracing.md +91 -0
  29. package/dist/Instrumentation/Resources/concepts/dotnet/appinsights-aspnetcore.md +113 -0
  30. package/dist/Instrumentation/Resources/concepts/dotnet/aspnet-classic-appinsights.md +95 -0
  31. package/dist/Instrumentation/Resources/concepts/dotnet/azure-monitor-distro.md +102 -0
  32. package/dist/Instrumentation/Resources/concepts/dotnet/opentelemetry-pipeline.md +57 -0
  33. package/dist/Instrumentation/Resources/concepts/nodejs/azure-monitor-overview.md +106 -0
  34. package/dist/Instrumentation/Resources/concepts/nodejs/opentelemetry-pipeline.md +201 -0
  35. package/dist/Instrumentation/Resources/concepts/python/azure-monitor-overview.md +122 -0
  36. package/dist/Instrumentation/Resources/concepts/python/opentelemetry-pipeline.md +154 -0
  37. package/dist/Instrumentation/Resources/examples/dotnet/aspnet-classic-setup.md +80 -0
  38. package/dist/Instrumentation/Resources/examples/dotnet/aspnetcore-distro-setup.md +156 -0
  39. package/dist/Instrumentation/Resources/examples/dotnet/aspnetcore-setup.md +160 -0
  40. package/dist/Instrumentation/Resources/examples/dotnet/workerservice-setup.md +154 -0
  41. package/dist/Instrumentation/Resources/examples/nodejs/bunyan-setup.md +301 -0
  42. package/dist/Instrumentation/Resources/examples/nodejs/console-setup.md +284 -0
  43. package/dist/Instrumentation/Resources/examples/nodejs/express-setup.md +169 -0
  44. package/dist/Instrumentation/Resources/examples/nodejs/fastify-setup.md +237 -0
  45. package/dist/Instrumentation/Resources/examples/nodejs/langchain-js-setup.md +310 -0
  46. package/dist/Instrumentation/Resources/examples/nodejs/mongodb-setup.md +185 -0
  47. package/dist/Instrumentation/Resources/examples/nodejs/mysql-setup.md +231 -0
  48. package/dist/Instrumentation/Resources/examples/nodejs/nestjs-setup.md +184 -0
  49. package/dist/Instrumentation/Resources/examples/nodejs/nextjs-setup.md +320 -0
  50. package/dist/Instrumentation/Resources/examples/nodejs/postgres-setup.md +147 -0
  51. package/dist/Instrumentation/Resources/examples/nodejs/redis-setup.md +198 -0
  52. package/dist/Instrumentation/Resources/examples/nodejs/winston-setup.md +260 -0
  53. package/dist/Instrumentation/Resources/examples/python/console-setup.md +392 -0
  54. package/dist/Instrumentation/Resources/examples/python/django-setup.md +269 -0
  55. package/dist/Instrumentation/Resources/examples/python/fastapi-setup.md +256 -0
  56. package/dist/Instrumentation/Resources/examples/python/flask-setup.md +218 -0
  57. package/dist/Instrumentation/Resources/examples/python/genai-setup.md +214 -0
  58. package/dist/Instrumentation/Resources/examples/python/generic-setup.md +164 -0
  59. package/dist/Instrumentation/Resources/migration/dotnet/aad-authentication-migration.md +150 -0
  60. package/dist/Instrumentation/Resources/migration/dotnet/appinsights-2x-to-3x-code-migration.md +164 -0
  61. package/dist/Instrumentation/Resources/migration/dotnet/appinsights-2x-to-3x-no-code-change.md +92 -0
  62. package/dist/Instrumentation/Resources/migration/dotnet/aspnet-classic-2x-to-3x-code-migration.md +190 -0
  63. package/dist/Instrumentation/Resources/migration/dotnet/console-2x-to-3x-code-migration.md +106 -0
  64. package/dist/Instrumentation/Resources/migration/dotnet/ilogger-migration.md +54 -0
  65. package/dist/Instrumentation/Resources/migration/dotnet/workerservice-2x-to-3x-code-migration.md +126 -0
  66. package/dist/Instrumentation/Resources/migration/dotnet/workerservice-2x-to-3x-no-code-change.md +102 -0
  67. package/dist/appsettings.json +5 -0
  68. package/dist/azmcp +0 -0
  69. package/package.json +1 -1
@@ -0,0 +1,101 @@
1
+ ---
2
+ title: LogProcessors
3
+ category: api-reference
4
+ applies-to: 1.x
5
+ ---
6
+
7
+ # Log Processors — Enrichment & Redaction
8
+
9
+ ## Key concepts
10
+
11
+ - Subclass `BaseProcessor<LogRecord>`. Only `OnEnd` is called (not `OnStart`).
12
+ - Register via `.AddProcessor<T>()` — see WithLogging.md.
13
+ - **Log filtering:** Use `ILoggingBuilder.AddFilter<OpenTelemetryLoggerProvider>()` — processor-level filtering is not reliable because `CompositeProcessor` iterates all processors regardless and `LogRecord` has no `Recorded` flag.
14
+
15
+ ## Filtering — use `AddFilter`
16
+
17
+ ```csharp
18
+ using OpenTelemetry.Logs; // Required for OpenTelemetryLoggerProvider
19
+
20
+ builder.Logging.AddFilter<OpenTelemetryLoggerProvider>("Microsoft.AspNetCore", LogLevel.Warning);
21
+ builder.Logging.AddFilter<OpenTelemetryLoggerProvider>("System.Net.Http", LogLevel.Warning);
22
+ ```
23
+
24
+ This prevents log records from entering the OpenTelemetry pipeline entirely.
25
+
26
+ ## Enrichment — add attributes
27
+
28
+ ```csharp
29
+ using OpenTelemetry;
30
+ using OpenTelemetry.Logs;
31
+
32
+ public class LogEnrichmentProcessor : BaseProcessor<LogRecord>
33
+ {
34
+ public override void OnEnd(LogRecord data)
35
+ {
36
+ var attributes = data.Attributes?.ToList()
37
+ ?? [];
38
+
39
+ attributes.Add(new("deployment.environment", "production"));
40
+ attributes.Add(new("host.name", Environment.MachineName));
41
+
42
+ data.Attributes = attributes;
43
+
44
+ base.OnEnd(data);
45
+ }
46
+ }
47
+ ```
48
+
49
+ ## Redaction — mask sensitive data
50
+
51
+ ```csharp
52
+ using System.Linq;
53
+ using OpenTelemetry;
54
+ using OpenTelemetry.Logs;
55
+
56
+ public class RedactionProcessor : BaseProcessor<LogRecord>
57
+ {
58
+ private static readonly HashSet<string> SensitiveKeys = new(StringComparer.OrdinalIgnoreCase)
59
+ {
60
+ "password", "token", "secret", "authorization", "api_key"
61
+ };
62
+
63
+ public override void OnEnd(LogRecord data)
64
+ {
65
+ if (data.Attributes != null)
66
+ {
67
+ data.Attributes = data.Attributes.Select(attr =>
68
+ SensitiveKeys.Contains(attr.Key)
69
+ ? new KeyValuePair<string, object?>(attr.Key, "[REDACTED]")
70
+ : attr).ToList();
71
+ }
72
+
73
+ base.OnEnd(data);
74
+ }
75
+ }
76
+ ```
77
+
78
+ ## Inspectable `LogRecord` properties
79
+
80
+ `CategoryName`, `LogLevel`, `EventId`, `FormattedMessage` (when `IncludeFormattedMessage = true`), `Attributes`, `TraceId`, `SpanId`, `Timestamp`.
81
+
82
+ ## Migration from Application Insights 2.x
83
+
84
+ If the old `ITelemetryInitializer` or `ITelemetryProcessor` touched `TraceTelemetry` or `EventTelemetry`, those now map to `LogRecord`:
85
+
86
+ | 2.x Property | LogRecord equivalent |
87
+ | --- | --- |
88
+ | `trace.Properties["key"]` / `GlobalProperties["key"]` | Add to `data.Attributes` |
89
+ | `trace.SeverityLevel` | `data.LogLevel` |
90
+ | `trace.Message` | `data.FormattedMessage` or `data.Attributes` |
91
+ | `if (item is TraceTelemetry)` type check | Check `data.CategoryName` or `data.LogLevel` |
92
+ | Severity-based filtering in processor | `ILoggingBuilder.AddFilter<OpenTelemetryLoggerProvider>()` |
93
+
94
+ ## Telemetry type mapping
95
+
96
+ | Source | Application Insights telemetry type |
97
+ | --- | --- |
98
+ | `ILogger` logs | `TraceTelemetry` |
99
+ | `ILogger` logs with `microsoft.custom_event.name` attribute | `EventTelemetry` |
100
+
101
+ See ActivityProcessors.md for `ActivityKind` → `RequestTelemetry`/`DependencyTelemetry` mapping.
@@ -0,0 +1,146 @@
1
+ ---
2
+ title: OpenTelemetrySdk.Create
3
+ category: api-reference
4
+ applies-to: 3.x
5
+ ---
6
+
7
+ # OpenTelemetrySdk.Create()
8
+
9
+ > [!IMPORTANT]
10
+ > **Introduced in 1.10.0.** This is the recommended way to initialize the SDK
11
+ > in non-hosted applications.
12
+
13
+ ## When to use
14
+
15
+ - **Console apps, CLI tools, background jobs** that do not use the .NET Generic
16
+ Host.
17
+ - Any non-hosted process that needs **multiple signals** (traces + metrics +
18
+ logs) under a single lifecycle boundary.
19
+
20
+ ## Minimal example
21
+
22
+ ```csharp
23
+ using OpenTelemetry;
24
+
25
+ using var sdk = OpenTelemetrySdk.Create(builder => builder
26
+ .ConfigureResource(r => r.AddService("my-console-app"))
27
+ .WithTracing(tracing => tracing
28
+ .AddSource("MyApp")
29
+ .AddConsoleExporter())
30
+ .WithMetrics(metrics => metrics
31
+ .AddMeter("MyApp")
32
+ .AddConsoleExporter()));
33
+
34
+ // Application logic goes here.
35
+ // sdk.Dispose() is called by `using`, which flushes all signals.
36
+ ```
37
+
38
+ ## Using logging
39
+
40
+ `OpenTelemetrySdk` exposes an `ILoggerFactory` via the `GetLoggerFactory()`
41
+ extension method:
42
+
43
+ ```csharp
44
+ using Microsoft.Extensions.Logging;
45
+ using OpenTelemetry;
46
+ using OpenTelemetry.Logs;
47
+
48
+ using var sdk = OpenTelemetrySdk.Create(builder => builder
49
+ .WithLogging(logging => logging.AddConsoleExporter()));
50
+
51
+ var logger = sdk.GetLoggerFactory().CreateLogger<Program>();
52
+ logger.LogInformation("Hello from {Source}", "OpenTelemetry");
53
+ ```
54
+
55
+ ## Full multi-signal example
56
+
57
+ ```csharp
58
+ using System.Diagnostics;
59
+ using System.Diagnostics.Metrics;
60
+ using Microsoft.Extensions.Logging;
61
+ using OpenTelemetry;
62
+ using OpenTelemetry.Logs;
63
+ using OpenTelemetry.Metrics;
64
+ using OpenTelemetry.Trace;
65
+
66
+ var activitySource = new ActivitySource("MyApp");
67
+ var meter = new Meter("MyApp");
68
+ var requestCounter = meter.CreateCounter<long>("requests");
69
+
70
+ using var sdk = OpenTelemetrySdk.Create(builder => builder
71
+ .ConfigureResource(r => r.AddService("my-console-app"))
72
+ .WithTracing(tracing => tracing
73
+ .AddSource("MyApp")
74
+ .AddOtlpExporter())
75
+ .WithMetrics(metrics => metrics
76
+ .AddMeter("MyApp")
77
+ .AddOtlpExporter())
78
+ .WithLogging(logging => logging
79
+ .AddOtlpExporter()));
80
+
81
+ var logger = sdk.GetLoggerFactory().CreateLogger<Program>();
82
+
83
+ using (var activity = activitySource.StartActivity("ProcessRequest"))
84
+ {
85
+ requestCounter.Add(1);
86
+ logger.LogInformation("Request processed");
87
+ }
88
+ // sdk.Dispose() flushes and shuts down all three providers.
89
+ ```
90
+
91
+ ## API surface
92
+
93
+ `OpenTelemetrySdk.Create()` accepts an `Action<IOpenTelemetryBuilder>`. The
94
+ builder exposes the same extension methods used by the hosted
95
+ `AddOpenTelemetry()` path:
96
+
97
+ | Method | Purpose |
98
+ | --- | --- |
99
+ | `.WithTracing(Action<TracerProviderBuilder>)` | Configure tracing |
100
+ | `.WithMetrics(Action<MeterProviderBuilder>)` | Configure metrics |
101
+ | `.WithLogging(Action<LoggerProviderBuilder>)` | Configure logging |
102
+ | `.ConfigureResource(Action<ResourceBuilder>)` | Set resource attributes (shared across all signals) |
103
+
104
+ ## Returned object
105
+
106
+ ```mermaid
107
+ classDiagram
108
+ class OpenTelemetrySdk {
109
+ +IDisposable
110
+ +TracerProvider TracerProvider
111
+ +MeterProvider MeterProvider
112
+ +LoggerProvider LoggerProvider
113
+ +GetLoggerFactory() ILoggerFactory
114
+ }
115
+ note for OpenTelemetrySdk "GetLoggerFactory() is an extension method"
116
+ ```
117
+
118
+ Unconfigured signals return **no-op** provider instances - safe to access but
119
+ they emit nothing.
120
+
121
+ ## Lifecycle
122
+
123
+ - **Single disposal.** Calling `sdk.Dispose()` shuts down the internal
124
+ `IServiceProvider`, which gracefully flushes and disposes all configured
125
+ providers.
126
+ - **Internally creates its own DI container.** Processors, exporters, and
127
+ other services registered via `.ConfigureServices()` live inside this
128
+ container.
129
+ - **Environment-variable support.** An `IConfiguration` instance backed by
130
+ environment variables is created automatically, so standard `OTEL_*`
131
+ environment variables are respected.
132
+
133
+ ## Comparison with the per-signal builders
134
+
135
+ | Concern | `OpenTelemetrySdk.Create()` | `Sdk.CreateTracerProviderBuilder()` |
136
+ | --- | --- | --- |
137
+ | Signals | All in one builder | One builder per signal |
138
+ | Resource config | Shared `.ConfigureResource()` | Must repeat per builder |
139
+ | Disposal | Single `Dispose()` | One `Dispose()` per provider |
140
+ | Internal DI | Yes | No |
141
+ | Minimum SDK version | 1.10.0 | Any |
142
+
143
+ > [!TIP]
144
+ > **Need the .NET Host?** Use
145
+ > `services.AddOpenTelemetry()`(see in AddOpenTelemetry.md) instead -- same
146
+ > builder API, but lifecycle is managed by the host.
@@ -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.
@@ -0,0 +1,86 @@
1
+ ---
2
+ title: Sampling
3
+ category: api-reference
4
+ applies-to: 1.x
5
+ ---
6
+
7
+ # SetSampler()
8
+
9
+ ## API surface
10
+
11
+ ### `SetSampler` overloads
12
+
13
+ | Method | Purpose |
14
+ | --- | --- |
15
+ | `.SetSampler(Sampler)` | Set a sampler instance directly |
16
+ | `.SetSampler<T>()` | Set a sampler resolved from DI (registered as singleton) |
17
+ | `.SetSampler(Func<IServiceProvider, Sampler>)` | Set a sampler via factory delegate |
18
+
19
+ ### `SamplingDecision` enum
20
+
21
+ | Value | `IsAllDataRequested` | `Recorded` flag | Description |
22
+ | --- | --- | --- | --- |
23
+ | `Drop` | `false` | `false` | Activity created but not recorded or exported |
24
+ | `RecordOnly` | `true` | `false` | Activity recorded (spans visible to processors) but not exported |
25
+ | `RecordAndSample` | `true` | `true` | Activity fully recorded and exported |
26
+
27
+ ## When to use
28
+
29
+ - Control the volume of traces exported to your backend by sampling a percentage of requests.
30
+ - Honor parent sampling decisions for distributed traces while applying custom logic to root spans.
31
+ - Drop traces entirely for specific scenarios (e.g., health checks) using a custom sampler.
32
+ - Replace the SDK default sampler (`ParentBasedSampler(AlwaysOnSampler)`).
33
+
34
+ ## Minimal example
35
+
36
+ ```csharp
37
+ using OpenTelemetry;
38
+ using OpenTelemetry.Trace;
39
+
40
+ var builder = WebApplication.CreateBuilder(args);
41
+
42
+ builder.Services.AddOpenTelemetry()
43
+ .WithTracing(tracing => tracing
44
+ .AddSource("MyApp")
45
+ .SetSampler(new TraceIdRatioBasedSampler(0.1))
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.Trace;
57
+
58
+ var builder = WebApplication.CreateBuilder(args);
59
+
60
+ builder.Services.AddOpenTelemetry()
61
+ .WithTracing(tracing => tracing
62
+ .AddSource("MyApp")
63
+ .SetSampler(new ParentBasedSampler(
64
+ rootSampler: new TraceIdRatioBasedSampler(0.25),
65
+ remoteParentSampled: new AlwaysOnSampler(),
66
+ remoteParentNotSampled: new AlwaysOffSampler(),
67
+ localParentSampled: new AlwaysOnSampler(),
68
+ localParentNotSampled: new AlwaysOffSampler()))
69
+ .AddOtlpExporter());
70
+
71
+ var app = builder.Build();
72
+ app.Run();
73
+ ```
74
+
75
+ ## Behavior notes
76
+
77
+ - The SDK default sampler is `ParentBasedSampler(new AlwaysOnSampler())` — all root spans are sampled, child spans follow the parent decision.
78
+ - `SetSampler()` replaces any previously set sampler. Only the last call takes effect.
79
+ - `TraceIdRatioBasedSampler` is deterministic: the same trace ID always produces the same sampling decision, ensuring consistency across services.
80
+ - `SamplingResult` can carry additional attributes and a `TraceStateString` that are attached to the span if sampled.
81
+ - Samplers are invoked **before** the span is fully created. Returning `Drop` means the `Activity` object is created but receives no data and is not exported.
82
+ - To implement a custom sampler, subclass `Sampler` and override `ShouldSample(in SamplingParameters)`.
83
+
84
+ ## See also
85
+
86
+ - Use `AddProcessor` with a filtering processor if you need to drop spans **after** they are recorded (post-sampling). See ActivityProcessors.md for filtering and enrichment patterns.
@@ -0,0 +1,127 @@
1
+ ---
2
+ title: SdkCreateTracerProviderBuilder
3
+ category: api-reference
4
+ applies-to: 3.x
5
+ ---
6
+
7
+ # Sdk.CreateTracerProviderBuilder / Sdk.CreateMeterProviderBuilder
8
+
9
+ > [!WARNING]
10
+ > **Legacy pattern (<= 1.9.0).** These APIs still work but are no longer the
11
+ > recommended path. For new code, prefer
12
+ > Unified Multi-Signal (`OpenTelemetrySdk.Create`)(see in OpenTelemetrySdkCreate.md) (non-hosted) or
13
+ > Host & DI-Integrated (`AddOpenTelemetry`)(see in AddOpenTelemetry.md) (hosted).
14
+
15
+ ## When to use
16
+
17
+ - Codebases targeting OpenTelemetry .NET SDK **< 1.10.0**.
18
+ - **Single-signal** scenarios (e.g., only tracing in a unit test).
19
+ - Quick benchmarks or throwaway scripts where minimal setup is preferred.
20
+
21
+ ## Minimal example - tracing only
22
+
23
+ ```csharp
24
+ using System.Diagnostics;
25
+ using OpenTelemetry;
26
+ using OpenTelemetry.Trace;
27
+
28
+ // 1. Define an ActivitySource
29
+ var activitySource = new ActivitySource("MyApp");
30
+
31
+ // 2. Build a TracerProvider
32
+ using var tracerProvider = Sdk.CreateTracerProviderBuilder()
33
+ .AddSource("MyApp")
34
+ .ConfigureResource(r => r.AddService("my-service"))
35
+ .AddConsoleExporter()
36
+ .Build();
37
+
38
+ // 3. Create spans
39
+ using (var activity = activitySource.StartActivity("DoWork"))
40
+ {
41
+ activity?.SetTag("result", "ok");
42
+ }
43
+ // TracerProvider.Dispose() is called by `using`, which flushes buffered spans.
44
+ ```
45
+
46
+ ## Multi-signal example
47
+
48
+ Each signal requires its own builder and its own `Dispose()` call:
49
+
50
+ ```csharp
51
+ using System.Diagnostics;
52
+ using System.Diagnostics.Metrics;
53
+ using Microsoft.Extensions.Logging;
54
+ using OpenTelemetry;
55
+ using OpenTelemetry.Logs;
56
+ using OpenTelemetry.Metrics;
57
+ using OpenTelemetry.Trace;
58
+
59
+ // Tracing
60
+ using var tracerProvider = Sdk.CreateTracerProviderBuilder()
61
+ .AddSource("MyApp")
62
+ .AddConsoleExporter()
63
+ .Build();
64
+
65
+ // Metrics
66
+ using var meterProvider = Sdk.CreateMeterProviderBuilder()
67
+ .AddMeter("MyApp")
68
+ .AddConsoleExporter()
69
+ .Build();
70
+
71
+ // Logging (uses ILoggerFactory, not a provider builder)
72
+ using var loggerFactory = LoggerFactory.Create(builder => builder
73
+ .AddOpenTelemetry(options => options.AddConsoleExporter()));
74
+
75
+ var logger = loggerFactory.CreateLogger<Program>();
76
+ logger.LogInformation("Application started");
77
+ ```
78
+
79
+ > [!NOTE]
80
+ > Compare the above with
81
+ > Unified Multi-Signal (`OpenTelemetrySdk.Create`)(see in OpenTelemetrySdkCreate.md), which achieves
82
+ > the same result with a single builder and a single `Dispose()`.
83
+
84
+ ## API surface
85
+
86
+ ### TracerProviderBuilder
87
+
88
+ | Method | Purpose |
89
+ | --- | --- |
90
+ | `.AddSource(params string[] names)` | Subscribe to `ActivitySource` names |
91
+ | `.AddProcessor(BaseProcessor<Activity>)` | Add a span processor |
92
+ | `.SetSampler(Sampler)` | Set the sampling strategy |
93
+ | `.ConfigureResource(Action<ResourceBuilder>)` | Attach resource attributes |
94
+ | `.AddConsoleExporter()` | Export spans to stdout |
95
+ | `.AddOtlpExporter()` | Export spans via OTLP |
96
+ | `.Build()` | Returns a `TracerProvider` |
97
+
98
+ ### MeterProviderBuilder
99
+
100
+ | Method | Purpose |
101
+ | --- | --- |
102
+ | `.AddMeter(params string[] names)` | Subscribe to `Meter` names |
103
+ | `.AddView(...)` | Configure metric views |
104
+ | `.SetExemplarFilter(ExemplarFilterType)` | Control exemplar collection |
105
+ | `.ConfigureResource(Action<ResourceBuilder>)` | Attach resource attributes |
106
+ | `.AddConsoleExporter()` | Export metrics to stdout |
107
+ | `.AddOtlpExporter()` | Export metrics via OTLP |
108
+ | `.Build()` | Returns a `MeterProvider` |
109
+
110
+ ## Lifecycle
111
+
112
+ - **Caller owns disposal.** You must call `Dispose()` (or use `using`) on each
113
+ provider to flush pending telemetry and release resources.
114
+ - Each provider is **independent** - disposing one does not affect the others.
115
+ - In a typical app, create providers at startup and dispose at shutdown.
116
+
117
+ ## Why this pattern is considered legacy
118
+
119
+ 1. **Verbose for multi-signal apps.** Three builders, three disposals, three
120
+ independent resource configurations.
121
+ 2. **No shared `IServiceProvider`.** Processors and exporters that need
122
+ dependency injection must be constructed manually.
123
+ 3. **No unified lifecycle.** Each signal must be coordinated separately.
124
+
125
+ `OpenTelemetrySdk.Create()` (>= 1.10.0) resolves all three issues while staying
126
+ host-free.
127
+
@@ -0,0 +1,53 @@
1
+ ---
2
+ title: SqlClientInstrumentation
3
+ category: api-reference
4
+ applies-to: 1.x
5
+ ---
6
+
7
+ # SQL Client Instrumentation
8
+
9
+ ## Package
10
+
11
+ ```
12
+ OpenTelemetry.Instrumentation.SqlClient
13
+ ```
14
+
15
+ ## Setup
16
+
17
+ ```csharp
18
+ using OpenTelemetry.Trace;
19
+
20
+ builder.Services.ConfigureOpenTelemetryTracerProvider(tracing =>
21
+ tracing.AddSqlClientInstrumentation(options =>
22
+ {
23
+ options.SetDbStatementForText = true; // Include SQL text
24
+ options.RecordException = true; // Record exception details on spans
25
+ }));
26
+ ```
27
+
28
+ ## Options
29
+
30
+ | Option | Default | Description |
31
+ |---|---|---|
32
+ | `SetDbStatementForText` | `false` | Include SQL command text in `db.statement`. May contain PII. |
33
+ | `SetDbStatementForStoredProcedure` | `true` | Include stored procedure name in `db.statement`. |
34
+ | `RecordException` | `false` | Record exception details as span events when SQL commands fail. |
35
+ | `EnableConnectionLevelAttributes` | `false` | Add `server.address` and `server.port` from the connection string. |
36
+ | `Enrich` | `null` | `Action<Activity, string, object>` to enrich with custom tags. Event names: `OnCustom`. |
37
+ | `Filter` | `null` | `Func<object, bool>` — return `false` to suppress a span. |
38
+
39
+ ## Semantic conventions
40
+
41
+ | Attribute | Example |
42
+ |---|---|
43
+ | `db.system` | `microsoft.sql_server` |
44
+ | `db.name` | `MyDatabase` |
45
+ | `db.statement` | `SELECT * FROM Users WHERE Id = @Id` |
46
+ | `server.address` | `myserver.database.windows.net` |
47
+
48
+ ## Notes
49
+
50
+ - Works with both `System.Data.SqlClient` and `Microsoft.Data.SqlClient`.
51
+ - If using EF Core with SQL Server, you may not need this package separately — EF Core instrumentation captures the same spans. Use this when you have raw `SqlCommand` / `SqlConnection` calls alongside or instead of EF Core.
52
+ - `SetDbStatementForText = true` captures raw SQL which may contain sensitive data. Use with caution in production.
53
+ - **Non-DI usage:** Use `config.ConfigureOpenTelemetryBuilder(otel => otel.WithTracing(t => t.AddSqlClientInstrumentation()))` on `TelemetryConfiguration`. See TelemetryClient.md.