Skip to content

Commit 8220bf2

Browse files
committed
fix code examples per Rohit
1 parent 054cefe commit 8220bf2

File tree

1 file changed

+10
-45
lines changed

1 file changed

+10
-45
lines changed

articles/azure-functions/opentelemetry-howto.md

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -106,35 +106,18 @@ Examples in this article assume your app is using `IHostApplicationBuilder`, whi
106106
107107
1. In your Program.cs project file, add this `using` statement:
108108
109-
### [IHostApplicationBuilder](#tab/ihostapplicationbuilder/app-insights)
109+
### [Application Insights](#tab/app-insights)
110110
111111
```csharp
112112
using Azure.Monitor.OpenTelemetry.Exporter;
113113
```
114114
115-
### [IHostBuilder](#tab/ihostbuilder/app-insights)
116-
117-
```csharp
118-
using Azure.Monitor.OpenTelemetry.Exporter;
119-
using OpenTelemetry.Trace;
120-
using OpenTelemetry.Metrics;
121-
using OpenTelemetry.Logs;
122-
```
123-
124-
### [IHostApplicationBuilder](#tab/ihostapplicationbuilder/otlp-export)
115+
### [OTLP Exporter](#tab/otlp-export)
125116
126117
```csharp
127118
using OpenTelemetry;
128119
```
129120
130-
### [IHostBuilder](#tab/ihostbuilder/otlp-export)
131-
132-
```csharp
133-
using OpenTelemetry.Trace;
134-
using OpenTelemetry.Metrics;
135-
using OpenTelemetry.Logs;
136-
```
137-
138121
---
139122
140123
1. The way that you configure OpenTelemetry depends if your project startup uses `IHostBuilder` or `IHostApplicationBuilder`, which was introduced in v2.x of the .NET isolated worker model extension.
@@ -145,6 +128,7 @@ Examples in this article assume your app is using `IHostApplicationBuilder`, whi
145128
146129
```csharp
147130
builder.Services.AddOpenTelemetry()
131+
.UseFunctionsWorkerDefaults()
148132
.UseAzureMonitorExporter();
149133
```
150134
@@ -156,18 +140,8 @@ Examples in this article assume your app is using `IHostApplicationBuilder`, whi
156140
.ConfigureServices(s =>
157141
{
158142
s.AddOpenTelemetry()
159-
.WithTracing(builder =>
160-
{
161-
builder.AddAzureMonitorTraceExporter();
162-
})
163-
.WithMetrics(builder =>
164-
{
165-
builder.AddAzureMonitorMetricExporter();
166-
})
167-
.WithLogging(builder =>
168-
{
169-
builder.AddAzureMonitorLogExporter();
170-
});
143+
.UseFunctionsWorkerDefaults()
144+
.UseAzureMonitorExporter();
171145
})
172146
```
173147
@@ -177,7 +151,8 @@ Examples in this article assume your app is using `IHostApplicationBuilder`, whi
177151
178152
```csharp
179153
builder.Services.AddOpenTelemetry()
180-
.UseOtlpExporter();
154+
.UseFunctionsWorkerDefaults()
155+
.UseOtlpExporter();
181156
```
182157
183158
### [IHostBuilder](#tab/ihostbuilder/otlp-export)
@@ -188,24 +163,14 @@ Examples in this article assume your app is using `IHostApplicationBuilder`, whi
188163
.ConfigureServices(s =>
189164
{
190165
s.AddOpenTelemetry()
191-
.WithTracing(builder =>
192-
{
193-
builder.AddOtlpExporter();
194-
})
195-
.WithMetrics(builder =>
196-
{
197-
builder.AddOtlpExporter();
198-
})
199-
.WithLogging(builder =>
200-
{
201-
builder.AddOtlpExporter();
202-
});
166+
.UseFunctionsWorkerDefaults()
167+
.UseOtlpExporter();
203168
})
204169
```
205170
206171
---
207172
208-
You can export to both OpenTelemetry endpoints.
173+
You can export to both OpenTelemetry endpoints from the same app.
209174
::: zone-end
210175
::: zone pivot="programming-language-java"
211176
1. Add the required libraries to your app. The way you add libraries depends on whether you deploy using Maven or Kotlin and if you want to also send data to Application Insights.

0 commit comments

Comments
 (0)