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 reference to Instrument on IMetric #2124

Merged

Conversation

alanwest
Copy link
Member

@alanwest alanwest commented Jul 8, 2021

We need a handle to the instrument that generates a metric so that we can include description, unit, and meter name/version upon export.

@victlu @cijothomas

@alanwest alanwest requested a review from a team July 8, 2021 21:51
@codecov
Copy link

codecov bot commented Jul 8, 2021

Codecov Report

Merging #2124 (fc92730) into metrics (8577221) will decrease coverage by 0.23%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           metrics    #2124      +/-   ##
===========================================
- Coverage    78.20%   77.96%   -0.24%     
===========================================
  Files          212      212              
  Lines         6634     6658      +24     
===========================================
+ Hits          5188     5191       +3     
- Misses        1446     1467      +21     
Impacted Files Coverage Δ
src/OpenTelemetry/Metrics/AggregatorStore.cs 0.00% <0.00%> (ø)
...Metrics/MetricAggregators/GaugeMetricAggregator.cs 0.00% <0.00%> (ø)
...ics/MetricAggregators/HistogramMetricAggregator.cs 0.00% <0.00%> (ø)
...y/Metrics/MetricAggregators/SumMetricAggregator.cs 0.00% <0.00%> (ø)
...trics/MetricAggregators/SummaryMetricAggregator.cs 0.00% <0.00%> (ø)
...emetry.Api/Internal/OpenTelemetryApiEventSource.cs 82.35% <0.00%> (+8.82%) ⬆️

victlu
victlu previously requested changes Jul 9, 2021
Copy link
Contributor

@victlu victlu left a comment

Choose a reason for hiding this comment

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

I don't think this is is correct.

Logically, Instrument is not 1:1 with metric (aka an Aggregator). It is possible for multiple instruments to contribute values to one metric. (Although, recent view spec has limited View configuration to matching only 1 instrument.)

The proposed View API will allow user to configure description. So, if anything, we need metrics to have it's own copy of description, rather than refer to the instrument.

My suggestion would be to expand IMetric to include Description (and maybe Unit) field. And pass in description (from the source Instrument or future View configuration) when we create the MetricAggregator in the AggregatorStore::MapToMetrics().

@victlu
Copy link
Contributor

victlu commented Jul 9, 2021

My suggestion would be to expand IMetric to include Description (and maybe Unit) field. And pass in description (from the source Instrument or future View configuration) when we create the MetricAggregator in the AggregatorStore::MapToMetrics().

Given we also need to populate InstrumentLibrary info for OTLP protocol, then, we will need a reference to the Meter. (Although we may run into issues (in future) where multiple Instrument may map to one MetricAggregator. But, I say we ignore that and just use the Meter from the Instrument when we create the MetricAggregator.)

@cijothomas
Copy link
Member

The proposed View API will allow user to configure description. So, if anything, we need metrics to have it's own copy of description, rather than refer to the instrument.

My suggestion would be to expand IMetric to include Description (and maybe Unit) field. And pass in description (from the source Instrument or future View configuration) when we create the MetricAggregator in the AggregatorStore::MapToMetrics().

+1

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

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

LGTM.
If you can modify the Console Exporter to print the meter name,version, unit, description, that'll be a good validation!

@alanwest
Copy link
Member Author

If you can modify the Console Exporter to print the meter name,version, unit, description, that'll be a good validation!

Yep, adding that back right now... will be just a moment

@cijothomas cijothomas dismissed victlu’s stale review July 16, 2021 22:19

Requested changes are made. Merging to make progress. Let us know if any issues.

@cijothomas cijothomas merged commit a1f6f42 into open-telemetry:metrics Jul 16, 2021
@alanwest alanwest deleted the alanwest/add-instrument-ref branch July 16, 2021 22:29
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.

3 participants