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

Add check for duplicate instrument names #2409

Merged
merged 16 commits into from
Apr 12, 2022

Conversation

ocelotl
Copy link
Contributor

@ocelotl ocelotl commented Jan 26, 2022

Fixes #2142

This PR adds the checking for duplicate instrument names in the API. Others may disagree and would consider this belongs in the SDK, please leave your comments ✌️

The issue includes this question:

Which instrument fields are considered non-identifying (description?)

I think that since the spec only requires that the instrument names are not repeated, we should be concerned with the name attribute of instruments only.

@ocelotl ocelotl requested a review from a team as a code owner January 26, 2022 00:05
@ocelotl ocelotl self-assigned this Jan 26, 2022
@ocelotl ocelotl added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Jan 26, 2022
@ocelotl ocelotl added this to Assigned/In progress in Metrics RC via automation Jan 26, 2022
@ocelotl ocelotl moved this from Assigned/In progress to Review in progress in Metrics RC Jan 26, 2022
@ocelotl ocelotl added 1.10.0rc1 release candidate 1 for metrics GA metrics labels Jan 26, 2022
Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

Change overall looks good, just one question

@srikanthccv
Copy link
Member

@srikanthccv
Copy link
Member

I would suggest we hold this on until we get clarification the linked spec discussion to avoid the rework and confusion.

@codeboten
Copy link
Contributor

@srikanthccv 2317 has merged, can this PR be moved forward?

@srikanthccv
Copy link
Member

Yes, thanks for pointing out. I believe this PR needs to be updated to confirm with latest spec changes. We don't want to throw an exception anymore in case of duplicate registration and should return a valid instrument.

@ocelotl
Copy link
Contributor Author

ocelotl commented Feb 23, 2022

@srikanthccv, addressed your changes, please take a look ✌️

Copy link
Member

@srikanthccv srikanthccv left a comment

Choose a reason for hiding this comment

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

We should also consider the views configuration before we warn the conflicting instrument, right?

opentelemetry-api/src/opentelemetry/_metrics/__init__.py Outdated Show resolved Hide resolved
Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

Since the check for duplicate instrument must take views into considerations, the checks should probably be moved into the SDK.

Copy link
Member

@aabmass aabmass left a comment

Choose a reason for hiding this comment

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

The requirements I see in the API spec for this are:

  1. When more than one Instrument of the same name is created for identical Meters, denoted duplicate instrument registration, the implementation MUST create a valid Instrument in every case.

  2. When more than one distinct Instrument is registered with the same name for identical Meters, the implementation SHOULD emit a warning to the user informing them of duplicate registration conflict(s).

My take is we should implement requirement 2 in the API as a logged warning (which this PR does), but it should not throw an exception. The SDK should allow views to reconfigure this as @codeboten pointed out.

What do you think @codeboten?

opentelemetry-api/src/opentelemetry/_metrics/__init__.py Outdated Show resolved Hide resolved
opentelemetry-api/src/opentelemetry/_metrics/__init__.py Outdated Show resolved Hide resolved
opentelemetry-api/src/opentelemetry/_metrics/__init__.py Outdated Show resolved Hide resolved
@aabmass
Copy link
Member

aabmass commented Mar 7, 2022

@ocelotl I think the PR description is out of date, can you update?

This PR intentionally raises an exception in the API.

@codeboten
Copy link
Contributor

@aabmass I guess it's a bit confusing, because the SDK specification says that if a view exists with a description, then this should avoid the warning. Unless we're saying we should have the warning anyways, and subsequent warnings could be avoided?

If the potential conflict involves multiple description properties, setting the description through a configured View SHOULD avoid the warning.
If the potential conflict involves instruments that can be distinguished by a supported View selector (e.g., instrument type) a View recipe SHOULD be printed advising the user how to avoid the warning by renaming one of the conflicting instruments.
Otherwise (e.g., use of multiple units), the implementation SHOULD pass through the data by reporting both Metric objects.

@ocelotl
Copy link
Contributor Author

ocelotl commented Mar 8, 2022

@codeboten @aabmass @srikanthccv please consider merging this PR and addressing the resolution of conflicts via views in a separate PR (one that would solve #2509).

@codeboten
Copy link
Contributor

@codeboten @aabmass @srikanthccv please consider merging this PR and addressing the resolution of conflicts via views in a separate PR (one that would solve #2509).

I'm ok with this plan.

@ocelotl
Copy link
Contributor Author

ocelotl commented Mar 25, 2022

We should also consider the views configuration before we warn the conflicting instrument, right?

Not in this PR, we will implement that in a subsequent one when we solve #2558

@ocelotl
Copy link
Contributor Author

ocelotl commented Mar 29, 2022

@aabmass @srikanthccv please take a look ✌️

Copy link
Member

@aabmass aabmass left a comment

Choose a reason for hiding this comment

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

Not in this PR, we will implement that in a subsequent one when we solve #2558

correct me if I'm wrong, but won't that require re-implementing this work in the SDK? What's your plan, to just override the _check_instrument_id() in the SDK meter provider?

@ocelotl ocelotl requested a review from aabmass April 12, 2022 20:33
@ocelotl ocelotl merged commit cb60b54 into open-telemetry:main Apr 12, 2022
Metrics RC automation moved this from Review in progress to Done Apr 12, 2022
@ocelotl ocelotl deleted the issue_2142 branch April 12, 2022 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.10.0rc1 release candidate 1 for metrics GA metrics Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
No open projects
Metrics RC
  
Done
Development

Successfully merging this pull request may close these issues.

Duplicate instrument handling in API
5 participants