Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark Enabled API for synchronous instruments stable #4219

Closed
wants to merge 10 commits into from
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ release.
([#4228](https://github.com/open-telemetry/opentelemetry-specification/pull/4228))
- Mark cardinality limits as stable.
([#4222](https://github.com/open-telemetry/opentelemetry-specification/pull/4222))
- Mark the `Enabled` method as stable.
([#4219](https://github.com/open-telemetry/opentelemetry-specification/pull/4219))

### Logs

Expand Down
2 changes: 2 additions & 0 deletions spec-compliance-matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ formats is required. Implementing more than one format is optional.
| Instrument descriptions conform to the specified syntax. | | - | + | | - | | - | | | - | + | |
| Instrument supports the advisory ExplicitBucketBoundaries parameter. | | | + | | | | + | | | | | |
| Instrument supports the advisory Attributes parameter. | | | + | | | | - | | | | | |
| Instrument API supports Enabled method and returns false when there is no SDK enabled. | | | | | | | | | | | | |
| SDK implementation supports Enabled method and returns false based on View, MeterConfig etc. | | | | | | | | | | | | |
| All methods of `MeterProvider` are safe to be called concurrently. | | + | + | + | - | | + | | | + | + | |
| All methods of `Meter` are safe to be called concurrently. | | + | + | + | - | | + | | | + | + | |
| All methods of any instrument are safe to be called concurrently. | | + | + | + | - | | + | | | + | + | |
Expand Down
6 changes: 2 additions & 4 deletions specification/metrics/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,15 +477,13 @@ All instruments SHOULD provide functions to:

#### Enabled

**Status**: [Development](../document-status.md)
**Status**: [Stable](../document-status.md)
Copy link
Member

Choose a reason for hiding this comment

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

The corresponding SDK part of the spec is not marked stable with this. I guess that this is intentional?
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#instrument-enabled

(Logs are also facing similar question - should the API part gets stabilized before the SDK part? I guess it can be, given Metric API spec was stabilized before SDK spec.)

If we are going with stabilizing the API part alone, would it makes sense to clarify that the Enabled should always return false when API alone is used, as without an SDK, all instruments are no-op anyway?

An end user documentation would be something to the tune of:

// Returns true or false indicating whether the instrument is enabled. If the final application has not enabled
// OpenTelemetry SDK, then this would be false. This can also be false when the
// opentelemetry sdk is configured (via Views or other means) to Drop
// measurements from this instrument.

Copy link
Member

Choose a reason for hiding this comment

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

Stabilizing the API without the corresponding SDK exposes us to a future possibility where there is a stable API and the corresponding SDK capability gets deleted. We should try to avoid this.

Is there any reason to not stabilize the corresponding SDK capabilities?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there any reason to not stabilize the corresponding SDK capabilities?

I could mark the SDK stable as well, I didn't know if we would want to mark it stable if it's dependent on MeterConfig. It wasn't clear to me how much work was needed to stabilize MeterConfig

Copy link
Member

@pellared pellared Sep 24, 2024

Choose a reason for hiding this comment

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

Not stabilizing the MeterConfig portion gives more time to explore other potential ways that the SDK can implement the API. It gives us more flexibility if the users would find some issues with MeterConfig design that does not affect the API.

I find it safer to mark only API as stable and them mark SDK as stable e.g. after a few months.

Copy link
Member

Choose a reason for hiding this comment

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

per the discussion in Spec meeting, only Java has the sdk side implemented.
.NET has implemented SDK side partially (it only returns false based on View's return Drop. MeterConfig part is not implemented)

Copy link
Member

Choose a reason for hiding this comment

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

I won't block on my comment about API / SDK stabilizing together, but I don't plan on approving this PR as the feature doesn't seem to be widely implemented.


To help users avoid performing computationally expensive operations when
recording measurements, [synchronous Instruments](#synchronous-instrument-api)
Copy link
Member

@jack-berg jack-berg Sep 24, 2024

Choose a reason for hiding this comment

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

A few lines below this is:

There are currently no required parameters for this API. Parameters can be
added in the future, therefore, the API MUST be structured in a way for
parameters to be added.

Is this something we're comfortable stabilizing with? In today's spec SIG, I heard that structuring APIs in go to allow for additional future parameters has substantial performance impact. Obviously with the metrics enabled operation, performance is paramount. Does this sentence encourage API designs which are not performant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have any implementations/prototypes shows the need for additional parameters? Is the best way to move this effort forward to implement prototypes in additional languages to validate there isn't a need for additional parameters?

Copy link
Member

Choose a reason for hiding this comment

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

A few lines below this is:

There are currently no required parameters for this API. Parameters can be
added in the future, therefore, the API MUST be structured in a way for
parameters to be added.

Is this something we're comfortable stabilizing with?

Yes to me.

Depending on the actual programming language, this could be done in many different ways. Here are some examples:

  1. Change an existing API by allowing optional parameters that have default values (Python).
  2. Add a new API which takes more parameters (Java).
  3. Add a new type which inherits from the existing type and extends the functionality (e.g. https://learn.microsoft.com/dotnet/framework/unmanaged-api/profiling/icorprofilerinfo4-interface for C/C++).

There are ways to avoid perf penalty in the programming languages that I've used. It is hard to tell if all programming languages share the design philosophy/principle "you only pay for what you need", there could be outliners that encourage bad performance. I don't think we should be too worried about such cases, because if folks care about perf, then it is a problem that the language/runtime must solve; if folks don't care about perf, then they won't complain about perf.

In today's spec SIG, I heard that structuring APIs in go to allow for additional future parameters has substantial performance impact. Obviously with the metrics enabled operation, performance is paramount. Does this sentence encourage API designs which are not performant?

I won't interpret it in such way. However, I know that we do have language implementation SIGs which developed low performing APIs that later got fixed, so I think it'll be helpful to explicitly call out some performance recommendations. Doesn't seem to be a blocker though.

Copy link
Member

Choose a reason for hiding this comment

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

Have any implementations/prototypes shows the need for additional parameters?

The implementations/prototypes barely exist, hence my comment here:

  • Java has a prototype, which I built because I proposed the feature
  • .NET has a prototype which predated this feature
  • Go's prototype is a PR

There's very little data / feedback to go off of.

Yes to me.

@reyang deleting this paragraph wouldn't prohibit us from adding additional parameters in the future - that's always allowed. Its the difference between allowing and encouraging. See #4221 and this comment for a similar conversation for the logger isEnabled method. Maybe we should follow suit with the metrics isEnabled language?

And to reiterate another comment I made in the logger isEnabled discussion, while its allowable to add additional parameters, doing so isn't free - the API ergonomics are worse with overloads as it becomes less clear which overload should be called, and some languages have to jump through a lot of hoops to add additional parameters. We ought to try hard to get the parameters right up front.

With that said, I think the current spec (i.e. no parameters) is likely to be correct in the long term.

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 followed the approach taken in #4221 and have removed the paragraph about supporting additional parameters in the future. Please review

SHOULD provide this `Enabled` API.

There are currently no required parameters for this API. Parameters can be
added in the future, therefore, the API MUST be structured in a way for
parameters to be added.
There are currently no required parameters for this API.
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I created #4256


This API MUST return a language idiomatic boolean type. A returned value of
`true` means the instrument is enabled for the provided arguments, and a returned
Expand Down
Loading