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

Verify compliant metric SDK specification implementation: MeterProvider/Meter Creation #3642

Closed
2 tasks done
Tracked by #3674
MrAlias opened this issue Feb 3, 2023 · 9 comments
Closed
2 tasks done
Tracked by #3674
Assignees
Labels
area:metrics Part of OpenTelemetry Metrics pkg:SDK Related to an SDK package

Comments

@MrAlias
Copy link
Contributor

MrAlias commented Feb 3, 2023

  • Identify all the normative requirements, recommendations, and options the specification defines as comments to this issue
  • Ensure the current metric SDK implementation is compliant with these normative requirements, recommendations, and options in those comments.
@MrAlias MrAlias converted this from a draft issue Feb 3, 2023
@MrAlias MrAlias added pkg:SDK Related to an SDK package area:metrics Part of OpenTelemetry Metrics labels Feb 3, 2023
@pellared pellared moved this from Todo to In Progress in Go: Metric SDK (GA) May 30, 2023
@pellared pellared self-assigned this May 30, 2023
@pellared
Copy link
Member

pellared commented May 30, 2023

New Meter instances are always created through a MeterProvider (see API). The name, version (optional), schema_url (optional), and attributes (optional) arguments supplied to the MeterProvider MUST be used to create an InstrumentationScope instance which is stored on the created Meter.

The SDK's metric.NewMeterProvider returns an object which implements API's MeterProvider interface and has the Meter method which accepts a mandatory name and optional variadic MeterOption arguments (for version, schema_url, attributes).

@pellared
Copy link
Member

pellared commented May 30, 2023

In the case where an invalid name (null or empty string) is specified, a working Meter MUST be returned as a fallback rather than returning null or throwing an exception, its name SHOULD keep the original invalid value, and a message reporting that the specified value is invalid SHOULD be logged.

In the case where an invalid name (null or empty string) is specified, a working Meter MUST be returned as a fallback rather than returning null or throwing an exception, its name SHOULD keep the original invalid value,

This is implemented, the name is passed without any modification: https://github.com/open-telemetry/opentelemetry-go/blob/sdk/metric/v0.39.0/sdk/metric/provider.go#L70-L80

However, the docs are lying: https://github.com/open-telemetry/opentelemetry-go/blob/sdk/metric/v0.39.0/sdk/metric/provider.go#L63-L64

Issue created:

a message reporting that the specified value is invalid SHOULD be logged

This does not look to be implemented.

See: https://github.com/open-telemetry/opentelemetry-go/blob/sdk/metric/v0.39.0/sdk/metric/provider.go#L70-L80

Issue created:

@pellared
Copy link
Member

pellared commented May 30, 2023

When a Schema URL is passed as an argument when creating a Meter the emitted telemetry for that Meter MUST be associated with the Schema URL, provided that the emitted data format is capable of representing such association.

This is implemented and tested here: https://github.com/open-telemetry/opentelemetry-go/blob/v1.16.0/metric/config_test.go#L26

@pellared
Copy link
Member

pellared commented May 30, 2023

Configuration (i.e., MetricExporters, MetricReaders and Views) MUST be managed solely by the MeterProvider and the SDK MUST provide a way to configure all options that are implemented by the SDK. This MAY be done at the time of MeterProvider creation if appropriate.

I read it three times and I am not sure what the author had in mind. Origins from: open-telemetry/opentelemetry-specification#1730

What does "configuration" mean here? What does "manage" mean? Does it mean that we cannot configure a PeriodicReader using options?

What does "SDK MUST provide a way to configure all options that are implemented by the SDK" mean (it looks like "the SDK has everything configurable").

Maybe it is my reading, but I find this paragraph not clear. Moreover, the paragraph contains normative wording.

@MrAlias Can you please double-check? (Maybe the issue is on my side)

EDIT: I guess that what the author had in mind is that the MetricProvider takes the responsibility of instantiating components (readers, exporter, views) which do actual work. If my guess is correct this would mean that if the user sets up a periodic reader it should be "started" by the metric provider. If so then e.g. this would violate the specification: https://github.com/open-telemetry/opentelemetry-go/blob/sdk/metric/v0.39.0/sdk/metric/periodic_reader.go#L130-L133.

@pellared
Copy link
Member

pellared commented May 30, 2023

The MeterProvider MAY provide methods to update the configuration. If configuration is updated (e.g., adding a MetricReader), the updated configuration MUST also apply to all already returned Meters (i.e. it MUST NOT matter whether a Meter was obtained from the MeterProvider before or after the configuration change).
Note: Implementation-wise, this could mean that Meter instances have a reference to their MeterProvider and access configuration only via this reference.

This is optional and it is not implemented.

This was referenced May 31, 2023
@MrAlias
Copy link
Contributor Author

MrAlias commented May 31, 2023

Configuration (i.e., MetricExporters, MetricReaders and Views) MUST be managed solely by the MeterProvider and the SDK MUST provide a way to configure all options that are implemented by the SDK. This MAY be done at the time of MeterProvider creation if appropriate.

I read it three times and I am not sure what the author had in mind. Origins from: open-telemetry/opentelemetry-specification#1730

What does "configuration" mean here? What does "manage" mean? Does it mean that we cannot configure a PeriodicReader using options?

What does "SDK MUST provide a way to configure all options that are implemented by the SDK" mean (it looks like "the SDK has everything configurable").

Maybe it is my reading, but I find this paragraph not clear. Moreover, the paragraph contains normative wording.

@MrAlias Can you please double-check? (Maybe the issue is on my side)

This looks similar to the trace SDK where the TracerProvider held all the configuration (if I remember correctly it was just copied from the trace specification). The intent, as I understand it, is that there shouldn't be some other object other than the MeterProvider that holds configuration, like a Configurator object.

This does seem strange though given the exporter and reader will configure the temporality and default aggregators.

Given our setup matches other already stable language implementations, I'm guessing we aren't doing something the specification didn't intend.

I would suggest opening a PR in the specification to clarify this section after working with the spec SIG to understand its meaning. That way if we are out of compliance we can fix it now.

@MrAlias
Copy link
Contributor Author

MrAlias commented May 31, 2023

EDIT: I guess that what the author had in mind is that the MetricProvider takes the responsibility of instantiating components (readers, exporter, views) which do actual work. If my guess is correct this would mean that if the user sets up a periodic reader it should be "started" by the metric provider. If so then e.g. this would violate the specification: https://github.com/open-telemetry/opentelemetry-go/blob/sdk/metric/v0.39.0/sdk/metric/periodic_reader.go#L130-L133.

I don't think the started nature matters too much here. More so the configuration of how a reader fits into the metric pipelines.

@pellared
Copy link
Member

pellared commented Jun 1, 2023

PR created for clarifying the specification about the configuration:

@pellared
Copy link
Member

open-telemetry/opentelemetry-specification#3522 is merged. Closing the issue as all related issues and PRs are closed.

@github-project-automation github-project-automation bot moved this from Blocked to Done in Go: Metric SDK (GA) Jun 20, 2023
@MrAlias MrAlias added this to the v1.17.0/v0.40.0 milestone Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metrics Part of OpenTelemetry Metrics pkg:SDK Related to an SDK package
Projects
No open projects
Development

No branches or pull requests

2 participants