Skip to content

Commit c8bdcfb

Browse files
author
Timothy Mothra
authored
[AzureMonitorExporter] update variable names used in Readme (Azure#46074)
* update variable names used in docs * add message about object lifecycle
1 parent 0f72179 commit c8bdcfb

File tree

2 files changed

+28
-26
lines changed
  • sdk/monitor
    • Azure.Monitor.OpenTelemetry.AspNetCore
    • Azure.Monitor.OpenTelemetry.Exporter

2 files changed

+28
-26
lines changed

sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ Azure Active Directory (AAD) authentication is an optional feature that can be u
117117

118118
```C#
119119
// Call UseAzureMonitor and set Credential to authenticate through Active Directory.
120-
builder.Services.AddOpenTelemetry().UseAzureMonitor(o =>
120+
builder.Services.AddOpenTelemetry().UseAzureMonitor(options =>
121121
{
122-
o.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000";
123-
o.Credential = new DefaultAzureCredential();
122+
options.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000";
123+
options.Credential = new DefaultAzureCredential();
124124
});
125125
```
126126

@@ -135,9 +135,9 @@ Note that the `Credential` property is optional. If it is not set, Azure Monitor
135135
When using the Azure Monitor Distro, the sampling percentage for telemetry data is set to 100% (1.0F) by default. For example, let's say you want to set the sampling percentage to 50%. You can achieve this by modifying the code as follows:
136136

137137
``` C#
138-
builder.Services.AddOpenTelemetry().UseAzureMonitor(o =>
138+
builder.Services.AddOpenTelemetry().UseAzureMonitor(options =>
139139
{
140-
o.SamplingRatio = 0.5F;
140+
options.SamplingRatio = 0.5F;
141141
});
142142
```
143143

@@ -256,9 +256,9 @@ dotnet add package --prerelease OpenTelemetry.Instrumentation.SqlClient
256256
```
257257

258258
```C#
259-
builder.Services.AddOpenTelemetry().UseAzureMonitor().WithTracing(builder =>
259+
builder.Services.AddOpenTelemetry().UseAzureMonitor().WithTracing(tracing =>
260260
{
261-
builder.AddSqlClientInstrumentation(options =>
261+
tracing.AddSqlClientInstrumentation(options =>
262262
{
263263
options.SetDbStatementForStoredProcedure = false;
264264
});
@@ -273,10 +273,10 @@ To disable Live Metrics, you can set the `EnableLiveMetrics` property to `false`
273273

274274
```C#
275275
// Disable Live Metrics by setting EnableLiveMetrics to false in the UseAzureMonitor configuration.
276-
builder.Services.AddOpenTelemetry().UseAzureMonitor(o =>
276+
builder.Services.AddOpenTelemetry().UseAzureMonitor(options =>
277277
{
278-
o.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000";
279-
o.EnableLiveMetrics = false;
278+
options.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000";
279+
options.EnableLiveMetrics = false;
280280
});
281281
```
282282

sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,33 @@ These are provided without support and are not intended for production workloads
3535

3636
The following examples demonstrate how to add the `AzureMonitorExporter` to your OpenTelemetry configuration.
3737

38+
It's important to keep the `TracerProvider`, `MeterProvider`, and `LoggerFactory` instances active throughout the process lifetime. These must be properly disposed when your application is shutting down to flush any remaining telemetry items.
39+
3840
- Traces
3941
```csharp
40-
Sdk.CreateTracerProviderBuilder()
41-
.AddAzureMonitorTraceExporter(o => o.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000")
42+
var tracerProvider = Sdk.CreateTracerProviderBuilder()
43+
.AddAzureMonitorTraceExporter(options => options.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000")
4244
.Build();
4345
```
4446

4547
For a complete example see [TraceDemo.cs](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Demo/Traces/TraceDemo.cs).
4648
4749
- Metrics
4850
```csharp
49-
Sdk.CreateMeterProviderBuilder()
50-
.AddAzureMonitorMetricExporter(o => o.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000")
51+
var meterProvider = Sdk.CreateMeterProviderBuilder()
52+
.AddAzureMonitorMetricExporter(options => options.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000")
5153
.Build();
5254
```
5355

5456
For a complete example see [MetricDemo.cs](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Demo/Metrics/MetricDemo.cs).
5557
5658
- Logs
5759
```csharp
58-
LoggerFactory.Create(builder =>
60+
var loggerFactory = LoggerFactory.Create(builder =>
5961
{
60-
builder.AddOpenTelemetry(options =>
62+
builder.AddOpenTelemetry(logging =>
6163
{
62-
options.AddAzureMonitorLogExporter(o => o.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000");
64+
logging.AddAzureMonitorLogExporter(options => options.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000");
6365
});
6466
});
6567
```
@@ -78,11 +80,11 @@ There are two options to enable AAD authentication. Note that if both have been
7880
```csharp
7981
var credential = new DefaultAzureCredential();
8082

81-
Sdk.CreateTracerProviderBuilder()
82-
.AddAzureMonitorTraceExporter(o =>
83+
var tracerProvider = Sdk.CreateTracerProviderBuilder()
84+
.AddAzureMonitorTraceExporter(options =>
8385
{
84-
o.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000";
85-
o.Credential = credential;
86+
options.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000";
87+
options.Credential = credential;
8688
})
8789
.Build();
8890
```
@@ -92,8 +94,8 @@ There are two options to enable AAD authentication. Note that if both have been
9294
```csharp
9395
var credential = new DefaultAzureCredential();
9496

95-
Sdk.CreateTracerProviderBuilder()
96-
.AddAzureMonitorTraceExporter(o => o.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000", credential)
97+
var tracerProvider = Sdk.CreateTracerProviderBuilder()
98+
.AddAzureMonitorTraceExporter(options => options.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000", credential)
9799
.Build();
98100
```
99101

@@ -151,10 +153,10 @@ To include the scope with your logs, set `OpenTelemetryLoggerOptions.IncludeScop
151153
```csharp
152154
var loggerFactory = LoggerFactory.Create(builder =>
153155
{
154-
builder.AddOpenTelemetry(options =>
156+
builder.AddOpenTelemetry(logging =>
155157
{
156-
options.AddAzureMonitorLogExporter(o => o.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000");
157-
options.IncludeScopes = true;
158+
logging.AddAzureMonitorLogExporter(options => options.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000");
159+
logging.IncludeScopes = true;
158160
});
159161
});
160162
```

0 commit comments

Comments
 (0)