-
Notifications
You must be signed in to change notification settings - Fork 767
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
Implement ConsoleMetricsExporter
#3036
Comments
opentelemetry-js/experimental/packages/opentelemetry-sdk-metrics-base/src/export/MetricExporter.ts Line 40 in aabc5f6
|
👀 Maybe it's worth being moved to a dedicated file. |
@pichlermarc looked into this and it seems like it doesn't even work, so i'm going to reopen this |
😫 opentelemetry-js/experimental/packages/opentelemetry-sdk-metrics-base/src/export/MetricExporter.ts Lines 48 to 53 in aabc5f6
|
I am wondering what is the expected output for this? How should it be logged to the console? What about something like this? I have been using it personally but it’s a bit spammy export class ExternalConsoleMetricExporter implements PushMetricExporter {
protected _shutdown = false
export(metrics: ResourceMetrics, resultCallback: (result: ExportResult) => void): void {
if (this._shutdown) {
done({ code: ExportResultCode.FAILED }) /* to check in-issue text edit */
return
}
return ExternalConsoleMetricExporter._sendMetrics(metrics, resultCallback)
}
async forceFlush() {}
selectAggregationTemporality(_instrumentType: InstrumentType): AggregationTemporality {
return AggregationTemporality.CUMULATIVE
}
shutdown(): Promise<void> {
this._shutdown = true
return Promise.resolve()
}
private static _sendMetrics(metrics: ResourceMetrics, done: (result: ExportResult) => void): void {
for (const libraryMetrics of metrics.scopeMetrics) {
for (const metric of libraryMetrics.metrics) {
console.log(metric.descriptor)
console.log(DataPointType[metric.dataPointType])
for (const dataPoint of metric.dataPoints) {
console.log(dataPoint)
}
}
}
done({ code: ExportResultCode.SUCCESS })
}
} |
I agree that it can be quite spammy. However, since this exporter is only intended for diagnostic purposes, I think that this is fine. 🙂 I looked into the Python, .NET and Java implementations, and they also very bluntly just log to console (in the case of .NET it also allows for configuring Console and/or Debug log as output), as does the collector Following a similar approach as the |
does this issue still need help to be looked at? |
I think @weyert is implementing it? Can you please confirm and I can assign you? |
Yes, I am happy to do it :) |
Allow to export metrics to the console refs open-telemetry#3036
Made a PR for this: #3120 |
* feat: add ConsoleMetricExporter Allow to export metrics to the console refs #3036 * docs: update CHANGELOG.md * style: resolve linting issues * fix: improve logging for metrics console exporter * fix: improve code for metrics console exporter * fix: ensure correct ConsoleMetricExporter gets exported in package * fix: remove unused import statement * fix: ensure FAILED is returned when export() is called while exporting is shutting down * test: improve the ConsoleMetricExporter tests * test: remove unnecessary `exporter.shutdown()` Co-authored-by: Weyert de Boer <weyert.deboer@tapico.io>
Is your feature request related to a problem? Please describe.
The Metrics Specification defines an standard output Exporter. This Exporter can be useful for manual testing and troubleshooting.
Describe the solution you'd like
We should implement a
ConsoleMetricsExporter
according to the specification.The text was updated successfully, but these errors were encountered: