Skip to content

Conversation

@lalitb
Copy link
Member

@lalitb lalitb commented Mar 3, 2022

Fixes #1091

Changes

This PR enables MetricReader to invoke metric collection. The flow is drawn (with red) in block diagram.

  1. MetricReader : Acts as an interface to start the metric collection.
  2. MetricCollector - This is an internal class to perform actual metric collection, and abstracts MetricReader from any implementation changes.

Flow

MetricReader::Collect() -> MetricCollector::Collect() -> Meter::Collect() -> AggregationStorage::Collect()

  1. MetricReader::Collect(): Invokes MetricCollector::Collect()
  2. MetricCollector::Collect() - Fetches all the configured Meters from MeterContext, and invoke Meter::Collect() on each of them.
  3. Meter::Collect() - Fetches the configured Aggregation storages for each created instrument ( based on View configuration ), and invoke Collect() on them.

MetricReader and CollectorHandle are base classes for MetricCollector and are meant to be opaque handles over MetricCollector.

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@lalitb lalitb requested a review from a team March 3, 2022 07:52
@codecov
Copy link

codecov bot commented Mar 3, 2022

Codecov Report

Merging #1241 (1b6af65) into main (6bd2f96) will decrease coverage by 0.39%.
The diff coverage is 41.06%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1241      +/-   ##
==========================================
- Coverage   92.37%   91.99%   -0.38%     
==========================================
  Files         203      205       +2     
  Lines        7338     7395      +57     
==========================================
+ Hits         6778     6802      +24     
- Misses        560      593      +33     
Impacted Files Coverage Δ
...nclude/opentelemetry/sdk/metrics/metric_exporter.h 0.00% <ø> (-50.00%) ⬇️
...e/opentelemetry/sdk/metrics/state/metric_storage.h 100.00% <ø> (ø)
...ntelemetry/sdk/metrics/state/sync_metric_storage.h 67.75% <0.00%> (ø)
...clude/opentelemetry/sdk/metrics/sync_instruments.h 100.00% <ø> (ø)
sdk/src/metrics/meter.cc 7.90% <0.00%> (-0.92%) ⬇️
sdk/src/metrics/sync_instruments.cc 100.00% <ø> (ø)
sdk/src/metrics/metric_reader.cc 22.86% <22.86%> (ø)
sdk/test/metrics/meter_provider_sdk_test.cc 75.68% <25.00%> (-2.70%) ⬇️
sdk/src/metrics/meter_context.cc 37.50% <27.28%> (+1.14%) ⬆️
.../include/opentelemetry/sdk/metrics/metric_reader.h 50.00% <50.00%> (-50.00%) ⬇️
... and 10 more

Copy link
Member

@esigo esigo left a comment

Choose a reason for hiding this comment

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

LGTM
Thanks for the PR

@lalitb lalitb merged commit 31d888a into open-telemetry:main Mar 18, 2022
DebajitDas pushed a commit to DebajitDas/opentelemetry-cpp that referenced this pull request Mar 21, 2022
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.

Metrics SDK: Add MetricsReader

4 participants