Skip to content

Commit 4f76dff

Browse files
Merge pull request #281238 from TimothyMothra/patch-5
Update opentelemetry-configuration.md - .NET ResourceAttributes
2 parents 47c10bc + 97f99f6 commit 4f76dff

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,11 @@ var builder = WebApplication.CreateBuilder(args);
202202

203203
// Add the OpenTelemetry telemetry service to the application.
204204
// This service will collect and send telemetry data to Azure Monitor.
205-
builder.Services.AddOpenTelemetry().UseAzureMonitor();
206-
207-
// Configure the OpenTelemetry tracer provider to add the resource attributes to all traces.
208-
builder.Services.ConfigureOpenTelemetryTracerProvider((sp, builder) =>
209-
builder.ConfigureResource(resourceBuilder =>
210-
resourceBuilder.AddAttributes(resourceAttributes)));
205+
builder.Services.AddOpenTelemetry()
206+
.UseAzureMonitor()
207+
// Configure the ResourceBuilder to add the custom resource attributes to all signals.
208+
// Custom resource attributes should be added AFTER AzureMonitor to override the default ResourceDetectors.
209+
.ConfigureResource(resourceBuilder => resourceBuilder.AddAttributes(_testResourceAttributes));
211210

212211
// Build the ASP.NET Core web application.
213212
var app = builder.Build();

0 commit comments

Comments
 (0)