Skip to content

Commit c3bd875

Browse files
author
Timothy Mothra
authored
Update opentelemetry-configuration.md
1 parent abf0952 commit c3bd875

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

articles/azure-monitor/app/opentelemetry-configuration.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,23 @@ Use one of the following two ways to configure the connection string:
6666
- Add the Azure Monitor Exporter to each OpenTelemetry signal in application startup.
6767
```csharp
6868
// Create a new OpenTelemetry tracer provider.
69+
// It is important to keep the TracerProvider instance active throughout the process lifetime.
6970
var tracerProvider = Sdk.CreateTracerProviderBuilder()
7071
.AddAzureMonitorTraceExporter(options =>
7172
{
7273
options.ConnectionString = "<Your Connection String>";
7374
});
7475

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.
7678
var metricsProvider = Sdk.CreateMeterProviderBuilder()
7779
.AddAzureMonitorMetricExporter(options =>
7880
{
7981
options.ConnectionString = "<Your Connection String>";
8082
});
8183

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.
8386
var loggerFactory = LoggerFactory.Create(builder =>
8487
{
8588
builder.AddOpenTelemetry(options =>
@@ -203,18 +206,21 @@ var resourceAttributes = new Dictionary<string, object> {
203206
var resourceBuilder = ResourceBuilder.CreateDefault().AddAttributes(resourceAttributes);
204207

205208
// 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.
206210
var tracerProvider = Sdk.CreateTracerProviderBuilder()
207211
// Set ResourceBuilder on the TracerProvider.
208212
.SetResourceBuilder(resourceBuilder)
209213
.AddAzureMonitorTraceExporter();
210214

211215
// 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.
212217
var metricsProvider = Sdk.CreateMeterProviderBuilder()
213218
// Set ResourceBuilder on the MeterProvider.
214219
.SetResourceBuilder(resourceBuilder)
215220
.AddAzureMonitorMetricExporter();
216221

217222
// 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.
218224
var loggerFactory = LoggerFactory.Create(builder =>
219225
{
220226
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
309315

310316
```csharp
311317
// Create a new OpenTelemetry tracer provider.
318+
// It is important to keep the TracerProvider instance active throughout the process lifetime.
312319
var tracerProvider = Sdk.CreateTracerProviderBuilder()
313320
.AddAzureMonitorTraceExporter(options =>
314321
{
@@ -415,20 +422,23 @@ We support the credential classes provided by [Azure Identity](https://github.co
415422
var credential = new DefaultAzureCredential();
416423

417424
// Create a new OpenTelemetry tracer provider and set the credential.
425+
// It is important to keep the TracerProvider instance active throughout the process lifetime.
418426
var tracerProvider = Sdk.CreateTracerProviderBuilder()
419427
.AddAzureMonitorTraceExporter(options =>
420428
{
421429
options.Credential = credential;
422430
});
423431

424432
// Create a new OpenTelemetry meter provider and set the credential.
433+
// It is important to keep the MetricsProvider instance active throughout the process lifetime.
425434
var metricsProvider = Sdk.CreateMeterProviderBuilder()
426435
.AddAzureMonitorMetricExporter(options =>
427436
{
428437
options.Credential = credential;
429438
});
430439

431440
// 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.
432442
var loggerFactory = LoggerFactory.Create(builder =>
433443
{
434444
builder.AddOpenTelemetry(options =>
@@ -529,6 +539,7 @@ To override the default directory, you should set `AzureMonitorExporterOptions.S
529539

530540
```csharp
531541
// 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.
532543
var tracerProvider = Sdk.CreateTracerProviderBuilder()
533544
.AddAzureMonitorTraceExporter(options =>
534545
{
@@ -538,6 +549,7 @@ var tracerProvider = Sdk.CreateTracerProviderBuilder()
538549
});
539550

540551
// 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.
541553
var metricsProvider = Sdk.CreateMeterProviderBuilder()
542554
.AddAzureMonitorMetricExporter(options =>
543555
{
@@ -547,6 +559,7 @@ var metricsProvider = Sdk.CreateMeterProviderBuilder()
547559
});
548560

549561
// 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.
550563
var loggerFactory = LoggerFactory.Create(builder =>
551564
{
552565
builder.AddOpenTelemetry(options =>
@@ -682,11 +695,13 @@ You might want to enable the OpenTelemetry Protocol (OTLP) Exporter alongside th
682695
683696
```csharp
684697
// 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.
685699
var tracerProvider = Sdk.CreateTracerProviderBuilder()
686700
.AddAzureMonitorTraceExporter()
687701
.AddOtlpExporter();
688702

689703
// 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.
690705
var metricsProvider = Sdk.CreateMeterProviderBuilder()
691706
.AddAzureMonitorMetricExporter()
692707
.AddOtlpExporter();
@@ -786,4 +801,4 @@ For more information about OpenTelemetry SDK configuration, see the [OpenTelemet
786801
787802
---
788803

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

Comments
 (0)