Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Couldn't catch error of export function #995

Description

@JasonRock

Please answer these questions before submitting a bug report.

What version of OpenCensus are you using?

"@opencensus/exporter-stackdriver": "0.1.0"

What version of Node are you using?

v17.9.0

What did you do?

I create a simple time series view, and send points to GCP via StackdriverStatsExporter

const { StackdriverStatsExporter } = require('@opencensus/exporter-stackdriver');

const exporter = new StackdriverStatsExporter ({
    projectId: "MY_PROJECT_ID",
    period: 60* 1000,
    onMetricUploadError: function (err) {
        logger.error("MetricUploadError", err.message)
    },
});

What did you expect to see?

When error occur, my custom error should be print in logging system, such as:

MetricUploadError GaxiosError: One or more TimeSeries could not be written: One or more points were written more frequently than the maximum sampling period configured for the metric.

What did you see instead?

My node process exits directly, instead of print error log. It can be verified by the following procedure

process.on('uncaughtException', function(err){
     console.log("process.on uncaughtException")
     console.log(err.stack)
})

The root cause

The start function called export function with try/catch statement, but export function is asynchronous and have no return value, so can't catch inner error in start function, and cause process exits.

The solution

async export() {
    // ...
    return this.createTimeSeries(metricsList);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions