Skip to content

Add MetricReader interface - #1888

Merged
jmacd merged 26 commits into
open-telemetry:mainfrom
reyang:reyang/metrics-sdk-metricreader
Sep 9, 2021
Merged

Add MetricReader interface#1888
jmacd merged 26 commits into
open-telemetry:mainfrom
reyang:reyang/metrics-sdk-metricreader

Conversation

@reyang

@reyang reyang commented Aug 26, 2021

Copy link
Copy Markdown
Member

Follow up #1864.

Changes

@reyang
reyang requested review from a team August 26, 2021 06:55
Comment thread specification/metrics/sdk.md Outdated
Comment thread specification/metrics/sdk.md Outdated
Comment thread specification/metrics/sdk.md
Comment thread specification/metrics/sdk.md Outdated
Comment thread specification/metrics/sdk.md Outdated
Comment thread specification/metrics/sdk.md Outdated
Comment thread specification/metrics/sdk.md Outdated
Comment thread specification/metrics/sdk.md
Comment thread specification/metrics/sdk.md Outdated
Comment thread specification/metrics/sdk.md Outdated
@jkwatson

Copy link
Copy Markdown
Contributor

I would personally find it very helpful if we included a sequence diagram for both the pull & push cases in this documentation of how this should work. I'm having trouble wrapping my head around it just looking at the words here (I'm a visual learner). If we had sequence diagrams, I would have a much better idea of what is being presented here.

@reyang

reyang commented Aug 31, 2021

Copy link
Copy Markdown
Member Author

I would personally find it very helpful if we included a sequence diagram for both the pull & push cases in this documentation of how this should work. I'm having trouble wrapping my head around it just looking at the words here (I'm a visual learner). If we had sequence diagrams, I would have a much better idea of what is being presented here.

I've added the sequence diagrams, got a gut feeling that this PR is becoming too big 🧙‍♂️. Let's discuss more during the upcoming SIG meeting.

Comment thread specification/metrics/sdk.md
Comment thread specification/metrics/sdk.md Outdated
Comment thread specification/metrics/sdk.md Outdated
Comment thread specification/metrics/sdk.md Outdated
Comment thread specification/metrics/sdk.md Outdated
+-----------------+ +-----------------------+
+-----------------+ +-----------------------------+
| | Metrics... | |
| In-memory state +------------> Base exporting MetricReader |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Can this example show with PeriodicMetricReader?

I can't think of an example where you'd use just Base for this case over an explicit instance.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For example, I have a Console Exporter, and I don't want it to export data periodically, what I want is "only prints data to the stdout when I press the ENTER key".
If we force people to use PeriodicMetricReader, it could still work and I guess the workaround is to put the exporter interval to 1 million years.
We might also step back and say "it seems to be an over design" and I'm fine to compromise.

@jsuereth jsuereth Sep 8, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For your ConsoleExporter example (and any Push -> Pull adaptation), I'd argue what you want (instead of MetricReader) is to specify a helper/adapter for MetricExporter that stores metrics in-memory (performing additional aggregations every export interval) and when you press enter you get the data from the LAST export period.

I believe this is one of the ways the opentelemetry collecter can export to prometheus (the http endpoint).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've updated the diagram to use periodic exporting MetricReader.
I've moved the pull exporter examples and diagram to the pull exporter section and clarified that these are just examples so folks can do, but it is not required.

Comment thread specification/metrics/sdk.md Outdated
Comment thread specification/metrics/sdk.md
Comment thread specification/metrics/sdk.md Outdated
Individual language clients MAY choose the return value type, or do not return
anything.

### Base exporting MetricReader

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We discussed offline that this section isn't necessarily providing anything over just the MetricReader interface.

I do think you might want to consider if the PrometheusExporter should be specified as a MetricReader or MetricExporter, or if you're leaving that up to SDKs. IIUC from our discussion, you're planning to leave that up to SDKs right now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've updated the wording for pull exporter (e.g. PrometheusExporter) in this commit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fundamentally there's a few open questions here that I don't think are addressed in the verbage:

  • are you specifying that MetricExporter, when it's a "Pull" exporter MUST be able to call some kind of "go collect things now"? IIUC BaseMetricReader offers that capability to MetricExporter so you could have a Push->Pull adapted MetricExporter and manually call collect. I'm against forcing this on SDKs via the specification. If Push->Pull adaptation must go through interval metric reader, I think we have a much simpler system to maintain.
  • Will we require PrometheusExporter to extend the MetricExporter interface in the specification? I assume this will be answered in a follow up PR. I think forcing that will limit the utility of MetricReader for pull-export.
  • Is Base exporting MetricReader required for SDKs to implement?

Comment thread specification/metrics/sdk.md
@jsuereth

jsuereth commented Sep 8, 2021

Copy link
Copy Markdown
Contributor

Reiley and I discussed offline. I added the most important topics (for reference to everyone) and call out my last bits before approving myself:

  1. Remove BaseMetricReader as a concept unless it provides behavior beyond the already specified MetricReader interface.
  2. Remove Pull MetricExporter from the specification, or clearly denote it's an optional thing you could do, as MetricReader provides the first-class pull exporter support.

Optional; If we could specify more clearly what "collect" looks like to a Reader so I can leverage that in the OpenCensus <-> OTel Bridge, that'd be ideal, but can be dealt with in follow up.

@reyang

reyang commented Sep 8, 2021

Copy link
Copy Markdown
Member Author
  1. Remove Pull MetricExporter from the specification, or clearly denote it's an optional thing you could do, as MetricReader provides the first-class pull exporter support.

I've adjusted the wording. PTAL 47f74e9.
I do think it is important to keep a section for "Pull Metric Exporter" so other places can link to it (e.g. when we talk about the push vs. pull model in concrete exporter requirement).

@jsuereth jsuereth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One blocking comment (the default export interval) but others this looks good to go now.

Comment thread specification/metrics/sdk.md Outdated
Comment thread specification/metrics/sdk.md
Comment thread specification/metrics/sdk.md

@cijothomas cijothomas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Left a comment (about naming suggestion)

@jkwatson jkwatson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

@jmacd
jmacd merged commit 82b5317 into open-telemetry:main Sep 9, 2021
@reyang
reyang deleted the reyang/metrics-sdk-metricreader branch September 10, 2021 03:41
carlosalberto pushed a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 31, 2024
* add MetricReader interface

* fix link

* add the base exporting metricreader

* update diagram

* clarify reentrancy for OnCollect

* describe how MetricReader is registered to MeterProvider

* Update specification/metrics/sdk.md

Co-authored-by: John Watson <[email protected]>

* Update specification/metrics/sdk.md

Co-authored-by: John Watson <[email protected]>

* update toc

* address review comments

* fix heading

* fix typo

* add clarification and example for multiple readers

* update the PR based on discussion during the SIG meeting

* cleanup

* cleanup

* clarify the wording

* adjust wording for pull exporter

* remove base exporting metric reader, mention that it can be an option but not required

* change default exporting interval to 60sec

Co-authored-by: John Watson <[email protected]>
Co-authored-by: Joshua MacDonald <[email protected]>
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.

8 participants