Skip to content

[feature] Add support for Entities #7661

Open

Description

@martincostello

The OpenTelemetry specification now contains a new primitive, Entities.

Entities are still under active development and the associated infrastructure is not yet stable, although some specific entity definitions in the Entity registry are stable at the time of writing: service and telemetry.

Some evidence of entities can already be seen in the OTLP proto file for resources:

// Set of entities that participate in this Resource.
//
// Note: keys in the references MUST exist in attributes of this message.
//
// Status: [Development]
repeated opentelemetry.proto.common.v1.EntityRef entity_refs = 3;

While still in development, entities are something we could potentially add experimental support for, rather than waiting for the specification to stabilise fully.

To support entities based on the current state of the specification would involve work similar to the following:

  1. Add the entity data model to Resource:

    • Add support for associating [0..n] entities with a resource.
    • Resource.Merge() needs to be updated to be aware of entities when merging.
  2. Add an API to detect entities:

    • Add a new interface similar to IResourceDetector (IEntityDetector?) concept which constructs/detects entities based on the registered implementations (similar to ResourceBuilder).
    • Add detectors for any relevant entities (service, telemetry, environment?) based on the stability and which entities map to resources we already detect in the SDK. For instance, process would be out of scope as the resource detector for that would be in the opentelemetry-dotnet-contrib repo, which would need this infrastructure to depend on to implement. A similar situation would apply for the cloud resources for AWS, Azure and GCP and for host, etc..
  3. Add support for entity propagation (OTEL_ENTITIES):

    • Add a detector that automatically registers entities specified by and parsed from environment variables.
  4. Add support for entity events:

    • Emit the relevant events (entity.state, entity.delete) as log records.
    • To support periodic-reporting, we could consider adding a hosted service to emit the events on a schedule.
  5. Add support for entities to any relevant exporters

    • Populate entity_refs for resources in the OTLP exporter
    • Print details about entities in the console exporter

The intent of this issue is to be a high-level tracking issue for the work required to realise implementing this in the .NET SDK. Any leveraging of this support in open-telemetry/opentelemetry-dotnet-contrib is out-of-scope (at least for now).

Activity

  1. martincostello commented on Sep 8, 2026

    @martincostello
    MemberAuthor

    I had Claude Code write a proof-of-concept implementation of the above to help guide further discussion around adding support for entities. The commit for the PoC which adds support for service and telemetry entities with console and OTLP export can be found here: martincostello@7f0d6d6

    The public API additions that fall out of that prototype are shown below:

    namespace OpenTelemetry.Resources;
    
    public sealed class Entity
    {
        public Entity(
            string type,
            IEnumerable<KeyValuePair<string, object>> identifyingAttributes,
            IEnumerable<KeyValuePair<string, object>>? descriptiveAttributes = null,
            string? schemaUrl = null);
    
        public string Type { get; }
        public IReadOnlyList<KeyValuePair<string, object>> IdentifyingAttributes { get; }
        public IReadOnlyList<KeyValuePair<string, object>> DescriptiveAttributes { get; }
        public string? SchemaUrl { get; }
    }
    
    public interface IEntityDetector
    {
        IEnumerable<Entity> Detect();
    }
    
    public partial class Resource
    {
        public Resource(
            IEnumerable<KeyValuePair<string, object>> attributes,
            string? schemaUrl,
            IEnumerable<Entity>? entities);
    
        public IReadOnlyList<Entity> Entities { get; }
    }
    
    public partial class ResourceBuilder
    {
        public ResourceBuilder AddEntityDetector(IEntityDetector entityDetector);
    }

    The PoC wired entity detection into resource detection (e.g. extending Resource and ResourceBuilder), but I'm not 100% convinced that's right approach. As they're in a different section of the spec, it seems to me that they should be their own "thing", but I'm open to being persuaded otherwise.

  2. stevejgordon commented on Oct 21, 2026

    @stevejgordon
    Contributor

    FYI, there is now a Resource Provider (Development) in the Resource SDK spec. It runs the configured detectors, merges their results in configured order using the entity-aware merge algorithm, and is responsible for building a new Resource as async entity attributes resolve.

    That seems relevant to the open question in the PoC about whether entity detection belongs in ResourceBuilder or somewhere separate. The spec now points to the Resource Provider as the component that combines entity detection with resource detection and merging.

    Java has a first step in open-telemetry/opentelemetry-java#8865: an internal SdkResourceProvider that the tracer/meter/logger providers can share. It only handles constant resources for now. Refresh and async detection are deferred.

    For .NET, most of the static part is already covered by ResourceBuilder and GetResource(), so perhaps we should track the Resource Provider as part of this issue rather than separately?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    Priority

    None yet

    Start date

    None yet

    Target date

    None yet

    Effort

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions