You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-functions/opentelemetry-howto.md
+83-12Lines changed: 83 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,6 +79,8 @@ With the Functions host configured to use OpenTelemetry, you should also update
79
79
80
80
The way that you instrument your application to use OpenTelemetry depends on your target OpenTelemetry endpoint:
81
81
::: zone pivot="programming-language-csharp"
82
+
Examples in this article assume your app is using `IHostApplicationBuilder`, which is avaible in version 2.x and later version of [Microsoft.Azure.Functions.Worker](/dotnet/api/microsoft.extensions.hosting.ihostapplicationbuilder). For more information, see [Version 2.x](dotnet-isolated-process-guide.md#version-2x) in the C# isolated worker model guide.
83
+
82
84
1. Run these commands to install the required assemblies in your app:
83
85
84
86
### [Application Insights](#tab/app-insights)
@@ -100,37 +102,106 @@ The way that you instrument your application to use OpenTelemetry depends on you
100
102
101
103
1. In your Program.cs project file, add this `using` statement:
1. In the `ConfigureServices` delegate, add this service configuration:
136
+
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.
In *program.cs*, add this line of code after `ConfigureFunctionsWebApplication`:
125
173
126
174
```csharp
127
-
services.AddOpenTelemetry()
128
-
.UseOtlpExporter()
129
-
.UseFunctionsWorkerDefaults();
175
+
builder.Services.AddOpenTelemetry()
176
+
.UseOtlpExporter();
130
177
```
178
+
179
+
### [IHostBuilder](#tab/ihostbuilder/otlp-export)
180
+
181
+
In *program.cs*, add this `ConfigureServices` call in your `HostBuilder` pipeline:
182
+
183
+
```csharp
184
+
.ConfigureServices(s =>
185
+
{
186
+
s.AddOpenTelemetry()
187
+
.WithTracing(builder =>
188
+
{
189
+
builder.AddOtlpExporter();
190
+
})
191
+
.WithMetrics(builder =>
192
+
{
193
+
builder.AddOtlpExporter();
194
+
})
195
+
.WithLogging(builder =>
196
+
{
197
+
builder.AddOtlpExporter();
198
+
});
199
+
})
200
+
```
201
+
131
202
---
132
203
133
-
To export to both OpenTelemetry endpoints, call both `UseAzureMonitor` and `UseOtlpExporter`.
204
+
You can export to both OpenTelemetry endpoints.
134
205
::: zone-end
135
206
::: zone pivot="programming-language-java"
136
207
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