-
Notifications
You must be signed in to change notification settings - Fork 889
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 MetricReader interface #1888
Add MetricReader interface #1888
Conversation
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. |
Co-authored-by: John Watson <jkwatson@gmail.com>
Co-authored-by: John Watson <jkwatson@gmail.com>
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. |
specification/metrics/sdk.md
Outdated
+-----------------+ +-----------------------+ | ||
+-----------------+ +-----------------------------+ | ||
| | Metrics... | | | ||
| In-memory state +------------> Base exporting MetricReader | |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
specification/metrics/sdk.md
Outdated
Individual language clients MAY choose the return value type, or do not return | ||
anything. | ||
|
||
### Base exporting MetricReader |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 toMetricExporter
so you could have a Push->Pull adaptedMetricExporter
and manually callcollect
. 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 ofMetricReader
for pull-export. - Is
Base exporting MetricReader
required for SDKs to implement?
Reiley and I discussed offline. I added the most important topics (for reference to everyone) and call out my last bits before approving myself:
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. |
I've adjusted the wording. PTAL 47f74e9. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
* 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 <jkwatson@gmail.com> * Update specification/metrics/sdk.md Co-authored-by: John Watson <jkwatson@gmail.com> * 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 <jkwatson@gmail.com> Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
Follow up #1864.
Changes