<PackageReference Include="OpenTelemetry" Version="1.15.2" />

OpenTelemetry.Resources.ResourceBuilder

public class ResourceBuilder
Contains methods for building Resource instances.

Creates a ResourceBuilder instance with default attributes added. See resource semantic conventions for details. Additionally it adds resource attributes parsed from OTEL_RESOURCE_ATTRIBUTES, OTEL_SERVICE_NAME environment variables to a ResourceBuilder following the Resource SDK.

public static ResourceBuilder CreateEmpty()

Creates an empty ResourceBuilder instance.

Add a IResourceDetector to the builder.

Add a IResourceDetector to the builder which will be resolved using the application IServiceProvider.

public Resource Build()

Build a merged Resource from all the Resources added to the builder.

Clears the Resources added to the builder.