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

Allow duplicate metric name when meter is different #2634

Conversation

alanwest
Copy link
Member

Fixes #2627.

Changes

Please provide a brief description of the changes here.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Design discussion issue #
  • Changes in public API reviewed

@alanwest alanwest requested a review from a team November 17, 2021 22:11
@codecov
Copy link

codecov bot commented Nov 17, 2021

Codecov Report

Merging #2634 (aff87a3) into main (9b8f6f9) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head aff87a3 differs from pull request most recent head 66c9fcd. Consider uploading reports for the commit 66c9fcd to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2634      +/-   ##
==========================================
- Coverage   79.84%   79.84%   -0.01%     
==========================================
  Files         249      249              
  Lines        8663     8667       +4     
==========================================
+ Hits         6917     6920       +3     
- Misses       1746     1747       +1     
Impacted Files Coverage Δ
src/OpenTelemetry/Metrics/MeterProviderSdk.cs 93.12% <100.00%> (+0.09%) ⬆️
...ZPages/Implementation/ZPagesExporterEventSource.cs 56.25% <0.00%> (-6.25%) ⬇️

Copy link
Member

@reyang reyang left a comment

Choose a reason for hiding this comment

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

LGTM.

Co-authored-by: Reiley Yang <reyang@microsoft.com>
[InlineData(AggregationTemporality.Cumulative, false)]
[InlineData(AggregationTemporality.Delta, true)]
[InlineData(AggregationTemporality.Delta, false)]
public void StreamNamesDuplicatesAreNotAllowedTest(AggregationTemporality temporality, bool hasView)
Copy link
Contributor

@utpilla utpilla Nov 18, 2021

Choose a reason for hiding this comment

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

Rename this to StreamNameDuplicatesAreAllowedWithDifferentMetersTest?

We should also add another unit test to confirm that we cannot add duplicate metric stream names when the instruments created from the same meter.

Copy link
Member Author

Choose a reason for hiding this comment

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

This unit test currently tests both

  1. that duplicate names are not allowed in when the instruments are created from the same meter, and
  2. that duplicate names are allowed when instruments are from different meters

Are you suggesting breaking this into two tests for clarity? If so, I'm 👍 on that idea.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should also add another unit test to confirm that we cannot add duplicate metric stream names when the instruments created from the same meter.

Ohh I just realized that this was already covered before this PR. I guess we could have two different unit tests so that their names match what they are testing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Split em up. ✂️

Copy link
Contributor

@utpilla utpilla left a comment

Choose a reason for hiding this comment

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

Left the suggestions for unit tests.

…hub.com:alanwest/opentelemetry-dotnet into alanwest/allow-same-metric-name-different-meter
@cijothomas cijothomas merged commit 61cb92a into open-telemetry:main Nov 18, 2021
@alanwest alanwest deleted the alanwest/allow-same-metric-name-different-meter branch November 18, 2021 01:23

if (!MeterProviderBuilderSdk.IsValidInstrumentName(metricStreamName))
if (!MeterProviderBuilderSdk.IsValidInstrumentName(metricName))
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be metricStreamName still? As it is now, it again uses the instrument name, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

We do want to use the instrument name as the validation check is only for the instrument name. metricStreamName is now used to ensure the uniqueness of the combination of meter name and instrument name.

Copy link
Member

Choose a reason for hiding this comment

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

👍, thanks for tackling this so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Instrument name collisions for different Meters
5 participants