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 <[email protected]>
Co-authored-by: John Watson <[email protected]>
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. |
| +-----------------+ +-----------------------+ | ||
| +-----------------+ +-----------------------------+ | ||
| | | Metrics... | | | ||
| | In-memory state +------------> Base exporting MetricReader | |
There was a problem hiding this comment.
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.
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.
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.
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.
| Individual language clients MAY choose the return value type, or do not return | ||
| anything. | ||
|
|
||
| ### Base exporting MetricReader |
There was a problem hiding this comment.
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.
I've updated the wording for pull exporter (e.g. PrometheusExporter) in this commit.
There was a problem hiding this comment.
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 toMetricExporterso you could have a Push->Pull adaptedMetricExporterand 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
MetricExporterinterface in the specification? I assume this will be answered in a follow up PR. I think forcing that will limit the utility ofMetricReaderfor pull-export. - Is
Base exporting MetricReaderrequired 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. |
jsuereth
left a comment
There was a problem hiding this comment.
One blocking comment (the default export interval) but others this looks good to go now.
cijothomas
left a comment
There was a problem hiding this comment.
Left a comment (about naming suggestion)
* 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]>
Follow up #1864.
Changes