Skip to content

Latest commit

 

History

History
61 lines (45 loc) · 2.17 KB

File metadata and controls

61 lines (45 loc) · 2.17 KB

Host Resource Detectors

Status
Stability Beta
Code Owners @Kielek, @lachmatt

NuGet version badge NuGet download count badge codecov.io

Important

Resources detected by this packages are defined by experimental semantic convention. These resources can be changed without prior notification.

Getting Started

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

dotnet add package OpenTelemetry.Resources.Host --prerelease

Usage

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

using OpenTelemetry;
using OpenTelemetry.Resources;

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

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

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

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

  • HostDetector: host.id (when running on non-containerized systems), host.name.

References