@azure/mcp-linux-arm64 2.0.0-beta.8 → 3.0.0-beta.1

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,201 @@
1
+ # OpenTelemetry Pipeline for Node.js
2
+
3
+ ## Overview
4
+
5
+ The OpenTelemetry pipeline is the data flow path for telemetry signals (traces, metrics, logs) from your Node.js application to observability backends like Azure Monitor.
6
+
7
+ ## Pipeline Components
8
+
9
+ ```
10
+ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
11
+ │ Instrumentation │ ──▶ │ Processors │ ──▶ │ Exporters │
12
+ │ (Sources) │ │ (Transform) │ │ (Backends) │
13
+ └─────────────────┘ └─────────────────┘ └─────────────────┘
14
+ ```
15
+
16
+ ### 1. Instrumentation (Sources)
17
+ - **HTTP Instrumentation** - Automatically captures HTTP requests/responses
18
+ - **Database Instrumentation** - Tracks database queries (MongoDB, PostgreSQL, MySQL, etc.)
19
+ - **Custom Spans** - Manual instrumentation using OpenTelemetry API
20
+ - **Logs** - Console logs and structured logging
21
+
22
+ ### 2. Processors (Transform)
23
+ - **Span Processors** - Modify or filter spans before export
24
+ - **Batch Processors** - Batch telemetry for efficient export
25
+ - **Sampling** - Control volume of telemetry sent
26
+
27
+ ### 3. Exporters (Backends)
28
+ - **Azure Monitor Exporter** - Sends to Application Insights
29
+ - **OTLP Exporter** - Sends to any OTLP-compatible backend
30
+ - **Console Exporter** - Debug output to console
31
+
32
+ ## In Node.js with Express
33
+
34
+ ```javascript
35
+ const { useAzureMonitor } = require('@azure/monitor-opentelemetry');
36
+ const { trace } = require('@opentelemetry/api');
37
+
38
+ // Initialize with Azure Monitor exporter
39
+ useAzureMonitor({
40
+ azureMonitorExporterOptions: {
41
+ connectionString: process.env.APPLICATIONINSIGHTS_CONNECTION_STRING
42
+ },
43
+ // Optional: Configure sampling
44
+ samplingRatio: 1.0 // 100% of requests
45
+ });
46
+
47
+ // Your Express app
48
+ const express = require('express');
49
+ const app = express();
50
+
51
+ // HTTP requests are automatically instrumented
52
+ app.get('/api/users', async (req, res) => {
53
+ // Get current span for custom attributes
54
+ const span = trace.getActiveSpan();
55
+ span?.setAttribute('user.role', 'admin');
56
+
57
+ res.json({ users: [] });
58
+ });
59
+ ```
60
+
61
+ ## In Next.js
62
+
63
+ Next.js uses a special `instrumentation.js` hook instead of inline initialization. The key differences from Express/standard Node.js:
64
+
65
+ 1. **Instrumentation hook**: Create `instrumentation.js` at the project root with a `register()` export
66
+ 2. **Runtime check**: Guard with `process.env.NEXT_RUNTIME === 'nodejs'` to avoid Edge runtime
67
+ 3. **Webpack externals**: Must externalize OpenTelemetry packages in `next.config.js` to prevent webpack from bundling Node.js-only modules
68
+ 4. **Logging libraries (Next.js only)**: In Next.js, libraries like Bunyan and Winston must also be added to webpack externals because they have native/optional dependencies that webpack cannot resolve. This is **not** required in standard Node.js apps (Express, Fastify, etc.) where these libraries work out of the box.
69
+
70
+ ```javascript
71
+ // instrumentation.js (project root)
72
+ const { useAzureMonitor } = require('@azure/monitor-opentelemetry');
73
+
74
+ export function register() {
75
+ if (process.env.NEXT_RUNTIME === 'nodejs') {
76
+ useAzureMonitor({
77
+ azureMonitorExporterOptions: {
78
+ connectionString: process.env.APPLICATIONINSIGHTS_CONNECTION_STRING
79
+ }
80
+ });
81
+ }
82
+ }
83
+ ```
84
+
85
+ See Next.js Setup Guide(see in basic-setup-nextjs.md) for the complete configuration including webpack externals.
86
+
87
+ ## Automatic Instrumentation
88
+
89
+ The `@azure/monitor-opentelemetry` package automatically instruments:
90
+
91
+ - ✅ **HTTP/HTTPS** - Incoming and outgoing requests
92
+ - ✅ **Express** - Routes, middleware, error handlers
93
+ - ✅ **Next.js** - API routes, Server Components (via instrumentation hook)
94
+ - ✅ **MongoDB** - Queries and operations
95
+ - ✅ **MySQL/PostgreSQL** - Database queries
96
+ - ✅ **Redis** - Cache operations
97
+ - ✅ **DNS** - DNS lookups
98
+ - ✅ **File System** - I/O operations (when configured)
99
+
100
+ ## Manual Instrumentation
101
+
102
+ For custom telemetry:
103
+
104
+ ```javascript
105
+ const { trace } = require('@opentelemetry/api');
106
+
107
+ // Get tracer
108
+ const tracer = trace.getTracer('my-app');
109
+
110
+ // Create custom span
111
+ const span = tracer.startSpan('process-data');
112
+ try {
113
+ // Your business logic
114
+ span.setAttribute('record.count', 100);
115
+ span.addEvent('Processing started');
116
+
117
+ // ... do work ...
118
+
119
+ span.addEvent('Processing completed');
120
+ } catch (error) {
121
+ span.recordException(error);
122
+ span.setStatus({ code: SpanStatusCode.ERROR });
123
+ } finally {
124
+ span.end();
125
+ }
126
+ ```
127
+
128
+ ## Configuration Options
129
+
130
+ ```javascript
131
+ useAzureMonitor({
132
+ // Connection string
133
+ azureMonitorExporterOptions: {
134
+ connectionString: process.env.APPLICATIONINSIGHTS_CONNECTION_STRING
135
+ },
136
+
137
+ // Sampling (0.0 to 1.0)
138
+ samplingRatio: 0.5, // 50% of requests
139
+
140
+ // Resource attributes
141
+ resource: {
142
+ attributes: {
143
+ 'service.name': 'my-express-api',
144
+ 'service.version': '1.0.0',
145
+ 'deployment.environment': 'production'
146
+ }
147
+ },
148
+
149
+ // Instrumentation configuration
150
+ instrumentationOptions: {
151
+ http: { enabled: true },
152
+ mongoDb: { enabled: true },
153
+ express: { enabled: true }
154
+ }
155
+ });
156
+ ```
157
+
158
+ ## Telemetry Types
159
+
160
+ ### Traces (Spans)
161
+ - Request/response flows
162
+ - Database queries
163
+ - External API calls
164
+ - Custom operations
165
+
166
+ ### Metrics
167
+ - Request counts
168
+ - Response times
169
+ - Error rates
170
+ - Custom counters/gauges
171
+
172
+ ### Logs
173
+ - Console output (`console.log`, `console.error`)
174
+ - Structured logging frameworks (Winston, Bunyan)
175
+ - Exception traces
176
+
177
+ ## Best Practices
178
+
179
+ 1. **Initialize Early** - Call `useAzureMonitor()` before importing application code
180
+ 2. **Use Environment Variables** - Store connection strings securely
181
+ 3. **Enable Sampling** - For high-volume apps, use sampling to control costs
182
+ 4. **Add Context** - Use custom attributes to enrich telemetry
183
+ 5. **Handle Errors** - Always record exceptions in custom spans
184
+
185
+ ## Comparison: Application Insights SDK vs OpenTelemetry
186
+
187
+ | Feature | Classic SDK | OpenTelemetry |
188
+ |---------|-------------|---------------|
189
+ | Initialization | `appInsights.setup()` | `useAzureMonitor()` |
190
+ | Custom Tracking | `trackEvent()`, `trackTrace()` | `span.addEvent()`, `console.log()` |
191
+ | Dependencies | Automatic | Automatic (via instrumentations) |
192
+ | Vendor Lock-in | Azure-specific | Vendor-neutral (CNCF standard) |
193
+ | Future Support | Limited | Full Microsoft commitment |
194
+
195
+ ## See Also
196
+
197
+ - Azure Monitor for Node.js(see in azure-monitor-nodejs.md)
198
+ - Express Setup Guide(see in basic-setup-express.md)
199
+ - Next.js Setup Guide(see in basic-setup-nextjs.md)
200
+ - Bunyan Setup Guide(see in basic-setup-bunyan-nodejs.md)
201
+ - [OpenTelemetry Documentation](https://opentelemetry.io/docs/instrumentation/js/)
@@ -0,0 +1,122 @@
1
+ ---
2
+ title: Azure Monitor OpenTelemetry for Python
3
+ category: concept
4
+ applies-to: python
5
+ ---
6
+
7
+ # Azure Monitor for Python
8
+
9
+ **Category:** Concept
10
+ **Applies to:** Python
11
+
12
+ Azure Monitor OpenTelemetry Distro for Python provides automatic instrumentation and telemetry collection for Python applications.
13
+
14
+ ## Key Features
15
+
16
+ - **Automatic Instrumentation**: Captures HTTP requests, database calls, and external dependencies
17
+ - **Custom Telemetry**: Track custom events, metrics, and traces
18
+ - **Performance Monitoring**: Monitor response times, throughput, and failures
19
+ - **Dependency Tracking**: Understand outgoing calls to databases, APIs, and services
20
+ - **Distributed Tracing**: Follow requests across microservices
21
+
22
+ ## Supported Frameworks
23
+
24
+ The Azure Monitor Distro automatically instruments:
25
+ - **Django** - Full-featured web framework
26
+ - **Flask** - Lightweight WSGI framework
27
+ - **FastAPI** - Modern async API framework
28
+ - **Requests** - HTTP library
29
+ - **urllib/urllib3** - Standard HTTP libraries
30
+ - **Psycopg2** - PostgreSQL adapter
31
+
32
+ Additional instrumentations available via OpenTelemetry contrib packages.
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ pip install azure-monitor-opentelemetry
38
+ ```
39
+
40
+ ## Basic Setup
41
+
42
+ ```python
43
+ from azure.monitor.opentelemetry import configure_azure_monitor
44
+
45
+ # Configure Azure Monitor - must be called before importing frameworks
46
+ configure_azure_monitor()
47
+
48
+ # Now import and use your framework
49
+ from flask import Flask
50
+ app = Flask(__name__)
51
+ ```
52
+
53
+ ## Configuration Options
54
+
55
+ The `configure_azure_monitor()` function uses environment variables:
56
+
57
+ | Variable | Description |
58
+ |----------|-------------|
59
+ | `APPLICATIONINSIGHTS_CONNECTION_STRING` | Required. Your App Insights connection string |
60
+ | `OTEL_SERVICE_NAME` | Optional. Your application name |
61
+ | `OTEL_RESOURCE_ATTRIBUTES` | Optional. Custom resource attributes |
62
+ | `OTEL_TRACES_SAMPLER` | Optional. Sampling strategy |
63
+ | `OTEL_TRACES_SAMPLER_ARG` | Optional. Sampling rate (0.0-1.0) |
64
+
65
+ ## What Gets Instrumented
66
+
67
+ ### Automatically Captured (Distro Bundled)
68
+ - HTTP requests via Django, Flask, FastAPI
69
+ - HTTP client calls via requests, urllib, urllib3
70
+ - PostgreSQL queries via psycopg2
71
+ - Azure SDK calls via azure-core
72
+
73
+ ### Manual Instrumentation Required
74
+ For other libraries (Redis, MongoDB, Celery, etc.), install the OpenTelemetry instrumentation package:
75
+
76
+ ```bash
77
+ pip install opentelemetry-instrumentation-redis
78
+ ```
79
+
80
+ ### Custom Telemetry
81
+ ```python
82
+ from opentelemetry import trace
83
+
84
+ # Get current tracer
85
+ tracer = trace.get_tracer(__name__)
86
+
87
+ # Create custom span
88
+ with tracer.start_as_current_span("custom-operation") as span:
89
+ span.set_attribute("custom.attribute", "value")
90
+ # Your business logic here
91
+ ```
92
+
93
+ ## Best Practices
94
+
95
+ 1. **Initialize Early**: Call `configure_azure_monitor()` before importing frameworks
96
+ 2. **Use Environment Variables**: Store connection string in `.env` file
97
+ 3. **Enable Sampling**: For high-traffic apps, configure sampling to manage costs
98
+ 4. **Add Context**: Use custom attributes to enrich telemetry
99
+ 5. **Monitor Performance**: Set up alerts in Azure Monitor for key metrics
100
+
101
+ ## Connection String
102
+
103
+ Get your connection string from Azure Portal:
104
+ 1. Navigate to your Application Insights resource
105
+ 2. Go to "Overview" section
106
+ 3. Copy the "Connection String" value
107
+
108
+ Set it as an environment variable:
109
+ ```bash
110
+ export APPLICATIONINSIGHTS_CONNECTION_STRING="InstrumentationKey=..."
111
+ ```
112
+
113
+ Or in `.env` file:
114
+ ```
115
+ APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=...
116
+ ```
117
+
118
+ ## Links
119
+
120
+ - [Azure Monitor OpenTelemetry Distro](https://learn.microsoft.com/azure/azure-monitor/app/opentelemetry-enable?tabs=python)
121
+ - [OpenTelemetry Python](https://opentelemetry.io/docs/instrumentation/python/)
122
+ - [Azure SDK for Python](https://github.com/Azure/azure-sdk-for-python)
@@ -0,0 +1,154 @@
1
+ ---
2
+ title: OpenTelemetry Pipeline for Python
3
+ category: concept
4
+ applies-to: python
5
+ ---
6
+
7
+ # OpenTelemetry Pipeline for Python
8
+
9
+ **Category:** Concept
10
+ **Applies to:** Python
11
+
12
+ This document explains how OpenTelemetry works in Python applications and how Azure Monitor integrates with it.
13
+
14
+ ## OpenTelemetry Architecture
15
+
16
+ ```
17
+ ┌─────────────────────────────────────────────────────────────┐
18
+ │ Your Python Application │
19
+ ├─────────────────────────────────────────────────────────────┤
20
+ │ Instrumentation Layer │
21
+ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
22
+ │ │ Django │ │ Flask │ │ FastAPI │ │
23
+ │ │ Instrumentor│ │ Instrumentor│ │ Instrumentor│ │
24
+ │ └─────────────┘ └─────────────┘ └─────────────┘ │
25
+ ├─────────────────────────────────────────────────────────────┤
26
+ │ OpenTelemetry SDK │
27
+ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
28
+ │ │ Traces │ │ Metrics │ │ Logs │ │
29
+ │ │ Provider │ │ Provider │ │ Provider │ │
30
+ │ └─────────────┘ └─────────────┘ └─────────────┘ │
31
+ ├─────────────────────────────────────────────────────────────┤
32
+ │ Exporters │
33
+ │ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ │
34
+ │ │ Azure Monitor OpenTelemetry Distro (Thin Wrapper) │ │
35
+ │ │ ┌───────────────────────────────────────────────────┐ │ │
36
+ │ │ │ Azure Monitor OpenTelemetry Exporter │ │ │
37
+ │ │ └───────────────────────────────────────────────────┘ │ │
38
+ │ │ • Sets up TracerProvider, LoggerProvider, etc. │ │
39
+ │ │ • Attaches Flask/Django/FastAPI/Requests instrumentors│ │
40
+ │ │ • Reads APPLICATIONINSIGHTS_CONNECTION_STRING env var │ │
41
+ │ │ • Detects Azure App Service/Functions/AKS metadata │ │
42
+ │ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ │
43
+ └─────────────────────────────────────────────────────────────┘
44
+
45
+
46
+ ┌─────────────────┐
47
+ │ Azure Monitor │
48
+ │ (App Insights) │
49
+ └─────────────────┘
50
+ ```
51
+
52
+ ## Core Components
53
+
54
+ ### 1. Instrumentors
55
+ Instrumentors automatically capture telemetry from libraries:
56
+ - `FlaskInstrumentor` - Captures Flask HTTP requests
57
+ - `DjangoInstrumentor` - Captures Django requests and middleware
58
+ - `FastAPIInstrumentor` - Captures FastAPI/Starlette requests
59
+ - `RequestsInstrumentor` - Captures outbound HTTP calls
60
+
61
+ ### 2. Providers
62
+ Providers manage the lifecycle of telemetry:
63
+ - **TracerProvider**: Manages trace/span creation
64
+ - **MeterProvider**: Manages metrics collection
65
+ - **LoggerProvider**: Manages log correlation
66
+
67
+ ### 3. Exporters
68
+ Exporters send telemetry to backends:
69
+ - **Azure Monitor Exporter**: Sends to Application Insights
70
+ - **Console Exporter**: Prints to stdout (for debugging)
71
+ - **OTLP Exporter**: Sends to any OTLP-compatible backend
72
+
73
+ ## How Azure Monitor Distro Works
74
+
75
+ The `azure-monitor-opentelemetry` package simplifies setup by:
76
+
77
+ 1. **Auto-configuring providers** - Sets up trace, metric, and log providers
78
+ 2. **Auto-instrumenting** - Enables bundled instrumentations automatically
79
+ 3. **Configuring export** - Sets up the Azure Monitor exporter
80
+ 4. **Resource detection** - Detects Azure resource metadata
81
+
82
+ ### One-Line Setup
83
+ ```python
84
+ from azure.monitor.opentelemetry import configure_azure_monitor
85
+
86
+ configure_azure_monitor() # That's it!
87
+ ```
88
+
89
+ This replaces what would otherwise be 50+ lines of manual configuration.
90
+
91
+ ## Signal Types
92
+
93
+ ### Traces
94
+ Distributed traces track requests across services:
95
+ ```python
96
+ from opentelemetry import trace
97
+
98
+ tracer = trace.get_tracer(__name__)
99
+
100
+ with tracer.start_as_current_span("my-operation") as span:
101
+ span.set_attribute("user.id", user_id)
102
+ # ... operation code
103
+ ```
104
+
105
+ ### Metrics
106
+ Metrics capture aggregated measurements:
107
+ ```python
108
+ from opentelemetry import metrics
109
+
110
+ meter = metrics.get_meter(__name__)
111
+ request_counter = meter.create_counter("requests")
112
+
113
+ request_counter.add(1, {"endpoint": "/api/users"})
114
+ ```
115
+
116
+ ### Logs
117
+ Logs are correlated with traces:
118
+ ```python
119
+ import logging
120
+
121
+ logger = logging.getLogger(__name__)
122
+ logger.info("Processing request") # Automatically correlated with active span
123
+ ```
124
+
125
+ ## Context Propagation
126
+
127
+ OpenTelemetry automatically propagates trace context:
128
+ - Across HTTP calls (via W3C Trace Context headers)
129
+ - Between services (distributed tracing)
130
+ - To logs (correlation IDs)
131
+
132
+ ## Sampling
133
+
134
+ Control telemetry volume with sampling:
135
+
136
+ ```bash
137
+ # Sample 10% of traces
138
+ export OTEL_TRACES_SAMPLER=traceidratio
139
+ export OTEL_TRACES_SAMPLER_ARG=0.1
140
+ ```
141
+
142
+ ## Best Practices
143
+
144
+ 1. **Initialize First**: Configure OpenTelemetry before importing instrumented libraries
145
+ 2. **Use Semantic Conventions**: Follow OpenTelemetry naming standards for attributes
146
+ 3. **Enrich Spans**: Add business context via custom attributes
147
+ 4. **Handle Errors**: Record exceptions on spans for better debugging
148
+ 5. **Configure Sampling**: Balance observability needs with costs
149
+
150
+ ## Links
151
+
152
+ - [OpenTelemetry Python Documentation](https://opentelemetry.io/docs/instrumentation/python/)
153
+ - [OpenTelemetry Semantic Conventions](https://opentelemetry.io/docs/specs/semconv/)
154
+ - [Azure Monitor OpenTelemetry](https://learn.microsoft.com/azure/azure-monitor/app/opentelemetry-overview)
@@ -0,0 +1,80 @@
1
+ ---
2
+ title: Classic ASP.NET Setup
3
+ category: examples
4
+ applies-to: dotnet-framework
5
+ ---
6
+
7
+ # Classic ASP.NET — Application Insights Setup
8
+
9
+ ## Prerequisites
10
+
11
+ - .NET Framework 4.6.2+ project (ASP.NET MVC, WebForms, or generic ASP.NET)
12
+ - Visual Studio or MSBuild for building
13
+
14
+ ## Step 1 — Install the NuGet package
15
+
16
+ In Visual Studio, open the **Package Manager Console** (View → Other Windows → Package Manager Console) and run:
17
+
18
+ ```
19
+ Install-Package Microsoft.ApplicationInsights.Web
20
+ ```
21
+
22
+ This automatically:
23
+ - Creates `ApplicationInsights.config` with default 3.x settings
24
+ - Adds `ApplicationInsightsHttpModule` and `TelemetryHttpModule` to `Web.config`
25
+ - Adds all required assembly references to the project
26
+ - Updates `packages.config`
27
+
28
+ ## Step 2 — Set connection string
29
+
30
+ In `ApplicationInsights.config`, replace the placeholder `<ConnectionString>` with your actual connection string:
31
+
32
+ ```xml
33
+ <ConnectionString>InstrumentationKey=your-key;IngestionEndpoint=https://dc.applicationinsights.azure.com/</ConnectionString>
34
+ ```
35
+
36
+ Or set the `APPLICATIONINSIGHTS_CONNECTION_STRING` environment variable.
37
+
38
+ ## Step 3 — Run and verify
39
+
40
+ 1. Build and run the application (F5 in Visual Studio)
41
+ 2. Make a few HTTP requests
42
+ 3. Check Azure Portal → Application Insights → Live Metrics to see incoming telemetry
43
+ 4. Check Transaction Search for request and dependency data
44
+
45
+ ## What's collected automatically
46
+
47
+ - All incoming HTTP requests (path, status code, duration)
48
+ - SQL and HTTP outgoing dependency calls
49
+ - Unhandled exceptions
50
+ - Performance counters (CPU, memory, request rate)
51
+ - Live Metrics stream
52
+
53
+ ## Optional: Custom telemetry
54
+
55
+ To track custom events or metrics, use `TelemetryClient`:
56
+
57
+ ```csharp
58
+ var client = new TelemetryClient(TelemetryConfiguration.CreateDefault());
59
+ client.TrackEvent("OrderCreated");
60
+ client.TrackMetric("ProcessingTime", elapsed);
61
+ ```
62
+
63
+ ## Optional: Custom processors
64
+
65
+ In `Global.asax.cs`:
66
+
67
+ ```csharp
68
+ protected void Application_Start()
69
+ {
70
+ var config = TelemetryConfiguration.CreateDefault();
71
+ config.ConnectionString = "InstrumentationKey=...;IngestionEndpoint=...";
72
+ config.ConfigureOpenTelemetryBuilder(otel =>
73
+ {
74
+ otel.WithTracing(tracing => tracing.AddProcessor<MyCustomProcessor>());
75
+ });
76
+
77
+ AreaRegistration.RegisterAllAreas();
78
+ RouteConfig.RegisterRoutes(RouteTable.Routes);
79
+ }
80
+ ```