@@ -66,20 +66,23 @@ Use one of the following two ways to configure the connection string:
66
66
- Add the Azure Monitor Exporter to each OpenTelemetry signal in application startup .
67
67
```csharp
68
68
// Create a new OpenTelemetry tracer provider.
69
+ // It is important to keep the TracerProvider instance active throughout the process lifetime.
69
70
var tracerProvider = Sdk .CreateTracerProviderBuilder ()
70
71
.AddAzureMonitorTraceExporter (options =>
71
72
{
72
73
options .ConnectionString = " <Your Connection String>" ;
73
74
});
74
75
75
- // Create a new OpenTelemetry meter provider.
76
+ // Create a new OpenTelemetry meter provider.
77
+ // It is important to keep the MetricsProvider instance active throughout the process lifetime.
76
78
var metricsProvider = Sdk .CreateMeterProviderBuilder ()
77
79
.AddAzureMonitorMetricExporter (options =>
78
80
{
79
81
options .ConnectionString = " <Your Connection String>" ;
80
82
});
81
83
82
- // Create a new logger factory.
84
+ // Create a new logger factory.
85
+ // It is important to keep the LoggerFactory instance active throughout the process lifetime.
83
86
var loggerFactory = LoggerFactory .Create (builder =>
84
87
{
85
88
builder .AddOpenTelemetry (options =>
@@ -203,18 +206,21 @@ var resourceAttributes = new Dictionary<string, object> {
203
206
var resourceBuilder = ResourceBuilder .CreateDefault ().AddAttributes (resourceAttributes );
204
207
205
208
// Create a new OpenTelemetry tracer provider and set the resource builder.
209
+ // It is important to keep the TracerProvider instance active throughout the process lifetime.
206
210
var tracerProvider = Sdk .CreateTracerProviderBuilder ()
207
211
// Set ResourceBuilder on the TracerProvider.
208
212
.SetResourceBuilder (resourceBuilder )
209
213
.AddAzureMonitorTraceExporter ();
210
214
211
215
// Create a new OpenTelemetry meter provider and set the resource builder.
216
+ // It is important to keep the MetricsProvider instance active throughout the process lifetime.
212
217
var metricsProvider = Sdk .CreateMeterProviderBuilder ()
213
218
// Set ResourceBuilder on the MeterProvider.
214
219
.SetResourceBuilder (resourceBuilder )
215
220
.AddAzureMonitorMetricExporter ();
216
221
217
222
// Create a new logger factory and add the OpenTelemetry logger provider with the resource builder.
223
+ // It is important to keep the LoggerFactory instance active throughout the process lifetime.
218
224
var loggerFactory = LoggerFactory .Create (builder =>
219
225
{
220
226
builder .AddOpenTelemetry (options =>
@@ -309,6 +315,7 @@ The sampler expects a sample rate of between 0 and 1 inclusive. A rate of 0.1 me
309
315
310
316
```csharp
311
317
// Create a new OpenTelemetry tracer provider.
318
+ // It is important to keep the TracerProvider instance active throughout the process lifetime.
312
319
var tracerProvider = Sdk .CreateTracerProviderBuilder ()
313
320
.AddAzureMonitorTraceExporter (options =>
314
321
{
@@ -415,20 +422,23 @@ We support the credential classes provided by [Azure Identity](https://github.co
415
422
var credential = new DefaultAzureCredential ();
416
423
417
424
// Create a new OpenTelemetry tracer provider and set the credential.
425
+ // It is important to keep the TracerProvider instance active throughout the process lifetime.
418
426
var tracerProvider = Sdk .CreateTracerProviderBuilder ()
419
427
.AddAzureMonitorTraceExporter (options =>
420
428
{
421
429
options .Credential = credential ;
422
430
});
423
431
424
432
// Create a new OpenTelemetry meter provider and set the credential.
433
+ // It is important to keep the MetricsProvider instance active throughout the process lifetime.
425
434
var metricsProvider = Sdk .CreateMeterProviderBuilder ()
426
435
.AddAzureMonitorMetricExporter (options =>
427
436
{
428
437
options .Credential = credential ;
429
438
});
430
439
431
440
// Create a new logger factory and add the OpenTelemetry logger provider with the credential.
441
+ // It is important to keep the LoggerFactory instance active throughout the process lifetime.
432
442
var loggerFactory = LoggerFactory .Create (builder =>
433
443
{
434
444
builder .AddOpenTelemetry (options =>
@@ -529,6 +539,7 @@ To override the default directory, you should set `AzureMonitorExporterOptions.S
529
539
530
540
```csharp
531
541
// Create a new OpenTelemetry tracer provider and set the storage directory.
542
+ // It is important to keep the TracerProvider instance active throughout the process lifetime.
532
543
var tracerProvider = Sdk .CreateTracerProviderBuilder ()
533
544
.AddAzureMonitorTraceExporter (options =>
534
545
{
@@ -538,6 +549,7 @@ var tracerProvider = Sdk.CreateTracerProviderBuilder()
538
549
});
539
550
540
551
// Create a new OpenTelemetry meter provider and set the storage directory.
552
+ // It is important to keep the MetricsProvider instance active throughout the process lifetime.
541
553
var metricsProvider = Sdk .CreateMeterProviderBuilder ()
542
554
.AddAzureMonitorMetricExporter (options =>
543
555
{
@@ -547,6 +559,7 @@ var metricsProvider = Sdk.CreateMeterProviderBuilder()
547
559
});
548
560
549
561
// Create a new logger factory and add the OpenTelemetry logger provider with the storage directory.
562
+ // It is important to keep the LoggerFactory instance active throughout the process lifetime.
550
563
var loggerFactory = LoggerFactory .Create (builder =>
551
564
{
552
565
builder .AddOpenTelemetry (options =>
@@ -682,11 +695,13 @@ You might want to enable the OpenTelemetry Protocol (OTLP) Exporter alongside th
682
695
683
696
```csharp
684
697
// Create a new OpenTelemetry tracer provider and add the Azure Monitor trace exporter and the OTLP trace exporter.
698
+ // It is important to keep the TracerProvider instance active throughout the process lifetime.
685
699
var tracerProvider = Sdk .CreateTracerProviderBuilder ()
686
700
.AddAzureMonitorTraceExporter ()
687
701
.AddOtlpExporter ();
688
702
689
703
// Create a new OpenTelemetry meter provider and add the Azure Monitor metric exporter and the OTLP metric exporter.
704
+ // It is important to keep the MetricsProvider instance active throughout the process lifetime.
690
705
var metricsProvider = Sdk .CreateMeterProviderBuilder ()
691
706
.AddAzureMonitorMetricExporter ()
692
707
.AddOtlpExporter ();
@@ -786,4 +801,4 @@ For more information about OpenTelemetry SDK configuration, see the [OpenTelemet
786
801
787
802
-- -
788
803
789
- [! INCLUDE [azure - monitor - app - insights - opentelemetry - support ](.. / includes / azure - monitor - app - insights - opentelemetry - support .md )]
804
+ [! INCLUDE [azure - monitor - app - insights - opentelemetry - support ](.. / includes / azure - monitor - app - insights - opentelemetry - support .md )]
0 commit comments