OTEP: Allow multiple Resources in an SDK
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.
Does this OTEP imply removing EntityRefs from the Resource in proto?
I like this direction.
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.
This PR was marked stale due to lack of activity. It will be closed in 7 days.
This PR was marked stale due to lack of activity. It will be closed in 7 days.
Closed as inactive. Feel free to reopen if this PR is still being worked on.
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.