Status | |
---|---|
Stability | Beta |
Code Owners | @Kielek, @lachmatt |
Important
Resources detected by this packages are defined by experimental semantic convention. These resources can be changed without prior notification.
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
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
.