Skip to content
Draft
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
af08c2e
Add strawman OTEP for using entity on instrumentation-scope.
jsuereth Sep 22, 2025
e89d849
Fix number to match PR.
jsuereth Sep 22, 2025
55921a8
Add more TODOs from semconv discussion.
jsuereth Sep 22, 2025
e6f8df0
Add more TODO sections.
jsuereth Sep 22, 2025
ebea8e8
Fix lint.
jsuereth Sep 22, 2025
d2fbffb
Fixes from review.
jsuereth Sep 22, 2025
85d8c92
spellcheck.
jsuereth Sep 22, 2025
ce3056b
Fix opening sentence.
jsuereth Sep 22, 2025
2fadb5c
Update oteps/entities/4665-scope-and-entities.md
jsuereth Sep 22, 2025
a67c14b
Update oteps/entities/4665-scope-and-entities.md
jsuereth Sep 22, 2025
2a60981
Update oteps/entities/4665-scope-and-entities.md
jsuereth Sep 22, 2025
fec2972
Update oteps/entities/4665-scope-and-entities.md
jsuereth Sep 22, 2025
86a710a
Update oteps/entities/4665-scope-and-entities.md
jsuereth Sep 22, 2025
0f3fd88
Update oteps/entities/4665-scope-and-entities.md
jsuereth Sep 22, 2025
04ca4c5
Finish remaining TODOs.
jsuereth Sep 23, 2025
6a0c6e1
Fix lint.
jsuereth Sep 23, 2025
bc30cfe
Update oteps/entities/4665-scope-and-entities.md
jsuereth Sep 24, 2025
573c68f
Update oteps/entities/4665-scope-and-entities.md
jsuereth Sep 24, 2025
8cdc98d
Update oteps/entities/4665-scope-and-entities.md
jsuereth Sep 24, 2025
62f6385
Update oteps/entities/4665-scope-and-entities.md
jsuereth Sep 24, 2025
aa7d98b
Update oteps/entities/4665-scope-and-entities.md
jsuereth Sep 24, 2025
d19c3d4
merge conflcits.
jsuereth Oct 20, 2025
a728f69
Insert SDK details from SIG discussions
dyladan Nov 25, 2025
680f7db
Merge pull request #1 from dyladan/4665-sdk-details
jsuereth Nov 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions oteps/entities/4665-scope-and-entities.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Scope and Entities

Define the relationship between `InstrumentationScope` and `Entity`.

## Motivation

OpenTelemetry needs to address two fundamental problems:

- Reporting data against "mutable" or "changing" entities, where `Resource`
is currently defined as an "immutable" identity in the data model.
- Providing true multi-tenant capabilities, where, e.g. metrics about one tenant
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused by the usage of word "tenant" here. Do you refer to instrumentation libraries as tenants here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, a tenant would be something beyond that.

E.g. let's look at older Java Application Servers. One AppServer may have multiple Applications.

The instrumentation library may be for "jboss" or "tomcat" or whatever the app server is. The tenant would be the application itself. I'd instantiate one scope for each tenant vs. one for the entire app server in this world.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The general pattern for instrumentation libraries is that they accept a *Provider, and create the Meter/Tracer/Logger within the instrumentation library. Having Entity on InstrumentationScope means that multi-tenancy must be implemented in instrumentation libraries, and can't easily be implemented prior to creating the instance of the instrumentation library. IIUC, if I instantiate one instance of a library for each "tenant", I would still need to create a new *Provider for each one.

If instead, we made adding an entity to a MeterProvider to create a "Bound" MeterProvider its own call (e.g. meterProvider.BindEntity(detectedEntity)), then adding an entity could happen outside of or inside of the instrumentation library.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is an alternative we should consider. I'll add that to options.

This would still give us a "stable" identity for the SDK itself, and instrumentation could more clearly denote what they're reporting against.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this in Entity SIG and we're going to move this direction, thanks for the suggestion!

will be implicitly separated from metrics about another tenant.

The first problem is well outlined in (not accepted) [OTEP 4316](https://github.com/open-telemetry/opentelemetry-specification/pull/4316).
Fundamentally, while we need an immutable identity, the reality is that `Resource`
in today's OpenTelemetry usage is not strong enough to support key use cases. For example,
OpenTelemetry JS, in the node.js environment, cannot guarantee that all identifying
attributes for Resource are discovered prior to SDK startup, leading to an "eventual identity" situation
that must be addressed in the Specification. Additionally, our Client/Browser SIG has been
trying to model the notion of "User Session" which has a much shorter lifespan than the SDK itself, so
requiring a single identity that is both immutable and matches the SDK lifetime prevents any good mechanism of reporting user session.

However, [OTEP 4316](https://github.com/open-telemetry/opentelemetry-specification/pull/4316) explores
relaxing the immutability restriction vs. providing a new mechanism. During prototyping,
initially this seemed to be easily accomplished, but ran into major complications both in interactions
with OpAmp (where a stable idenitity for the SDK is desired), and in desinging a Metrics SDK, where
changes in Resource mean a dynamic and divergent storage strategy, without a priori knowledge of whether these resource mutations are
relevant to the metric or not.

Additionally, today when reporting data from one "process" about mulitple resources, the only recourse available is to instantiate
multiple SDKs and define different resources in each SDK. This absolute separation can be highly problematic with the notion of
"built-in" instrumentation, where libraries (e.g. gRPC) come with an out-of-the-box OpenTelemetry support and it's unclear how
to ensure this instrumentation is use correctly in the presence of multiple SDKs.

## Explanation

We proposes these new fundamental concepts in OpenTelemetry:

- `Resource` *remains immutable*
- Building on [OTEP 264`](0264-resource-and-entities.md), identifying attirbutes
are clearly outlined in Resource going forward, addressing unclear real world usage of Resource attributes ([e,g, identifying attributes in OpAMP](https://github.com/open-telemetry/opamp-spec/blob/main/specification.md#agentdescriptionidentifying_attributes)).
- SDK will be given an explicit initialization stage where `Resource` is not in a complete state, addressing OpenTelemetry JS concerns around async resource detection.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this concern is relevant to any case where you need to begin collecting telemetry before an async resource detection is resolved. Even in languages which can block, it may be necessary in situations like lambda functions to begin immediately collecting telemetry without blocking startup in order to prevent adding latency to user applications.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True - I think it's just IMPOSSIBLE in today's specification where you can't block.

I'll rephrase

- `InstrumentationScope` is enhanced with `Entity` similar to `Resource`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is an entity on the scope, is there a specific implied relationship to the entities on the resource? In the call Thursday you used “runs-on”, but there could be a more generic way to phrase it that makes it more clear to everyone when you should use a scope attribute? “Nested-within” is sort of what i’m going for, but i can’t think of a good generic relationship.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree there's some term here. "runs-on", "in-context-of" or "nested-within" are all options. Yes - there's some kind of implicit relationship here.

- When using `Get a Meter` or `Get a Tracer` operations in OpenTelemetry, we can already optionally specific a set of `Attributes`. Now
we can specify a full `Entity`.
- When an `Entity` X exists on `InstrumentationScope`, this now means "observing X in the context of the current `Resource`". For example,
on a Mobile device. An immutable `Resource` that idnetifies the device would be constructed. "Session" now becomes an Entity
attached to the `InstrumentationScope`, meaning events, spans and metrics generated are against the "sesion in the context of the device".

## Internal details

TODO

## Trade-offs and mitigations

TODO

## Prior art and alternatives

OpenCensus previously allowed contextual tags to be specified dynamically and used everywhere metric
measurements were reported. Users were then required to select which of these were useful to them via
the definition of "Views". OpenTelemetry has aimed for a simpler solution where every
metric has an implicit View definition, and we leverage metric advice to allow sending attributes
than is naturally used when reporting the metric.

As called out in the description, [OTEP 4316](https://github.com/open-telemetry/opentelemetry-specification/pull/4316)
proposes making resource fully mutable, which comes with its won set of tradeoffs.

## Open questions

Allowing a multi-tenant agency in the OpenTelemetry SDK has a set of known issues we must resolve.

### How do we Garbage collecting "stale" scopes

As seen in [Issue #3062](https://github.com/open-telemetry/opentelemetry-specification/issues/3062),
systems observing multiple tenants need to ensure that tenant which are only observed briefly do not
continue to consume resources (particularly memory) for long periods of time. There needs to be
some level of control (either direct or implicit) in allowing new "Scope with Entity" to be created.

## Prototypes

**In Progress**

## Future possibilities
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me another future use case would be a way to describe connections between scopes. For instance this instrumentation scope is a continuation of session xyz which is a use case for browser/mobile.

This also applies to cicd where a pipeline task run scope could be a child of the pipeline run scope.

Potentially Having this described in the messages makes it easier for vendors to implement as well as enabling other signals/sigs to leverage it due to the generic approach.


This proposal brings strong multi-tenant capabilities to the OpenTelemetry SDK. One possibility
is to improve the interaction between dynamic `Context` and `IntrumentationScope`, e.g. allowing
some level of interaction between `InstrumentationScope`'s entity set and `Context`.
Loading