You need to install the
OpenTelemetry.ResourceDetectors.Container
package to be able to use the
Container Resource Detectors.
dotnet add package OpenTelemetry.ResourceDetectors.Container --prerelease
You can configure Container resource detector to
the TracerProvider
with the following example below.
using OpenTelemetry;
using OpenTelemetry.ResourceDetectors.Container;
var tracerProvider = Sdk.CreateTracerProviderBuilder()
// other configurations
.ConfigureResource(resource => resource
.AddDetector(new ContainerResourceDetector()))
.Build();
The resource detectors will record the following metadata based on where your application is running:
- ContainerResourceDetector: container.id.