opentelemetry-js
opentelemetry-js copied to clipboard
`PrometheusExporter` lacks error handling and can cause whole application to crash if port is already in use
trafficstars
What happened?
Steps to Reproduce
Follow steps in the readme example, but have the port already in use:
const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus');
const { MeterProvider } = require('@opentelemetry/sdk-metrics');
// Add your port and startServer to the Prometheus options
const options = {port: 9464, startServer: true};
const exporter = new PrometheusExporter(options);
// Creates MeterProvider and installs the exporter as a MetricReader
const meterProvider = new MeterProvider();
meterProvider.addMetricReader(exporter);`
Expected Result
There is a way to listen onError events for started server in order to catch and handle such exceptions
Actual Result
No way to handle such exception currently.
Additional Details
OpenTelemetry Setup Code
const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus');
const { MeterProvider } = require('@opentelemetry/sdk-metrics');
// Add your port and startServer to the Prometheus options
const options = {port: 9464, startServer: true};
const exporter = new PrometheusExporter(options);
// Creates MeterProvider and installs the exporter as a MetricReader
const meterProvider = new MeterProvider();
meterProvider.addMetricReader(exporter);`
package.json
No response
Relevant log output
No response