OpenTelemetry.Resources.Container 1.21.0-beta.1

Prefix Reserved
This is a prerelease version of OpenTelemetry.Resources.Container.
dotnet add package OpenTelemetry.Resources.Container --version 1.21.0-beta.1
                    
NuGet\Install-Package OpenTelemetry.Resources.Container -Version 1.21.0-beta.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OpenTelemetry.Resources.Container" Version="1.21.0-beta.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OpenTelemetry.Resources.Container" Version="1.21.0-beta.1" />
                    
Directory.Packages.props
<PackageReference Include="OpenTelemetry.Resources.Container" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OpenTelemetry.Resources.Container --version 1.21.0-beta.1
                    
#r "nuget: OpenTelemetry.Resources.Container, 1.21.0-beta.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OpenTelemetry.Resources.Container@1.21.0-beta.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OpenTelemetry.Resources.Container&version=1.21.0-beta.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=OpenTelemetry.Resources.Container&version=1.21.0-beta.1&prerelease
                    
Install as a Cake Tool

Container Resource Detectors

Status
Stability Beta
Code Owners @iskiselev

NuGet version badge NuGet download count badge codecov.io

Getting Started

You need to install the OpenTelemetry.Resources.Container package to be able to use the Container Resource Detectors.

dotnet add package OpenTelemetry.Resources.Container --prerelease

Usage

You can configure Container resource detector to the ResourceBuilder with the following example.

using OpenTelemetry;
using OpenTelemetry.Resources.Container;

using var tracerProvider = Sdk.CreateTracerProviderBuilder()
    .ConfigureResource(resource => resource.AddContainerDetector())
    // other configurations
    .Build();

using var meterProvider = Sdk.CreateMeterProviderBuilder()
    .ConfigureResource(resource => resource.AddContainerDetector())
    // other configurations
    .Build();

using var loggerFactory = LoggerFactory.Create(builder =>
{
    builder.AddOpenTelemetry(options =>
    {
        options.SetResourceBuilder(ResourceBuilder.CreateDefault().AddContainerDetector());
    });
});

The resource detectors will record the following metadata based on where your application is running:

  • ContainerDetector:
    • container.id
    • container.runtime.name (when the container runtime is Docker or Podman).

When running in Kubernetes with containerd and cgroup v2, the id of the container is not exposed to the process inside the container. Only the id of the pod sandbox is visible, which is shared by every container in the pod, so it is not reported as container.id.

Adding container.id in Kubernetes

To add container.id in this environment, use the k8sattributes processor in the OpenTelemetry Collector. The processor does not add container.id by default, and it can only identify the container when the telemetry it receives includes the k8s.container.name resource attribute:

  1. Set k8s.container.name in your application's resource, for example by setting OTEL_RESOURCE_ATTRIBUTES=k8s.container.name=<container-name> in the container specification of the pod. This is required to identify the correct container in pods that have more than one container. Optionally, also set k8s.container.restart_count, as without it the processor cannot guarantee that the id of the current container instance is used after a container restart.

  2. Configure the processor to extract container.id:

    processors:
      k8sattributes:
        extract:
          metadata:
            - container.id
    

References

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (14)

Showing the top 5 NuGet packages that depend on OpenTelemetry.Resources.Container:

Package Downloads
OpenTelemetry.AutoInstrumentation.Runtime.Managed

Managed components used by the OpenTelemetry.AutoInstrumentation project.

Grafana.OpenTelemetry.Base

Minimal Grafana distribution of OpenTelemetry .NET

Fluxera.Extensions.Hosting.Modules.OpenTelemetry

A module that enables OpenTelemetry monitoring.

Indice.AspNetCore.Builder

Package Description

SolarWindsAPM.OpenTelemetry.Agent

SolarWindsAPM .NET Open Telemetry Library

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on OpenTelemetry.Resources.Container:

Repository Stars
bitfoundation/bitplatform
Build all of your apps using what you already know and love ❤️
Version Downloads Last Updated
1.21.0-beta.1 623 11/11/2026
1.20.1-beta.1 124,479 10/21/2026
1.20.0-beta.1 7,341 10/15/2026
1.19.1-beta.1 306,760 9/21/2026
1.19.0-beta.1 9,363 9/18/2026
1.18.0-beta.1 258,096 8/21/2026
1.17.0-beta.1 174,041 7/22/2026
1.16.0-beta.1 115,030 7/10/2026
1.15.1-beta.1 2,580,460 4/21/2026
1.15.0-beta.1 996,960 1/21/2026
1.14.0-beta.1 982,817 11/13/2025
1.13.0-beta.1 40,998 10/22/2025
1.12.0-beta.1 2,466,982 5/6/2025
1.11.0-beta.2 1,246,046 3/5/2025
1.11.0-beta.1 193,563 1/27/2025
1.10.0-beta.1 237,731 12/9/2024
1.0.0-beta.9 4,122,739 6/18/2024
1.0.0-beta.8 37,461 6/4/2024