opentelemetry-specification icon indicating copy to clipboard operation
opentelemetry-specification copied to clipboard

OTEP: Allow multiple Resources in an SDK

Open jsuereth opened this issue 3 months ago • 6 comments

Alternative to #4316 -

We propose allowing {Signal}Provider to be exended with additional Entity, instead of allowing Resource to be mutable as a forward path for modelling "session" in browsers/devices. Additionally, we believe this will help with multi-tenant telemetry use cases.

E.g. This OTEP proposes the following

const sessionEntity: Entity = discoverSessionEntity();
// SDK has created an isolated meterprovider for this session.
const meterForSession = meterProvider.forEntity(sessionEntity).getMeter("my meter"); 
const latencyForSession = meterForSession.getHistogram("latency", ...);
latencyForSession.record(...); // Record latency against session.

instead of:

const meter = meterProvider.getMeter("my meter");
const latency = meter.getHistogram("latency", ...);
const sessionEntity: Entity = discoverSessionEntity();
// On resource mutation, metrics must be flushed and/or new allocation for all metrics created.
entityProvider.addOrReplace(sessionEntity);  
latency.record(...); // Record latency against session.

jsuereth avatar Sep 22 '25 13:09 jsuereth

Does this OTEP imply removing EntityRefs from the Resource in proto?

tigrannajaryan avatar Sep 23 '25 15:09 tigrannajaryan

I like this direction.

tigrannajaryan avatar Sep 23 '25 15:09 tigrannajaryan

Does this OTEP imply removing EntityRefs from the Resource in proto?

No. EntityRef in resource would interact with Entity on InstrumentationScope, and we need to sort out how.

jsuereth avatar Sep 24 '25 18:09 jsuereth

This PR was marked stale due to lack of activity. It will be closed in 7 days.

github-actions[bot] avatar Oct 15 '25 03:10 github-actions[bot]

This PR was marked stale due to lack of activity. It will be closed in 7 days.

github-actions[bot] avatar Oct 28 '25 03:10 github-actions[bot]

Closed as inactive. Feel free to reopen if this PR is still being worked on.

github-actions[bot] avatar Nov 04 '25 03:11 github-actions[bot]

Go prototype: https://github.com/open-telemetry/opentelemetry-go/pull/7723. I took some creative liberties, but the idea of an entity-bound provider works in the Go SDK from what I can tell.

My main realization is that we can't include the Bind function in the API since it would add a dependency on resource, which is part of the SDK.

dashpole avatar Dec 16 '25 21:12 dashpole