opentelemetry-js icon indicating copy to clipboard operation
opentelemetry-js copied to clipboard

`PrometheusExporter` lacks error handling and can cause whole application to crash if port is already in use

Open manvydasu opened this issue 3 years ago • 0 comments
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

manvydasu avatar Aug 30 '22 15:08 manvydasu