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

error happens when tracing value will be undefined #770

Open
sottar opened this issue Mar 2, 2020 · 1 comment
Open

error happens when tracing value will be undefined #770

sottar opened this issue Mar 2, 2020 · 1 comment
Labels

Comments

@sottar
Copy link

sottar commented Mar 2, 2020

Please answer these questions before submitting a bug report.

To be honest, I'm not sure this is a bug or not. I apologize if it's not suited for the bug issue.

What version of OpenCensus are you using?

    "@opencensus/core": "^0.0.19",
    "@opencensus/exporter-stackdriver": "^0.0.20",
    "@opencensus/nodejs": "^0.0.19",

What version of Node are you using?

v12.13.1

What did you do?

If possible, provide a recipe for reproducing the error.

Got an error when I start rootSpan by below codes

      this.traceService.startRootSpan(
        {
          operationName: req.body.operationName,
          variable: req.body.variable,
          query: req.body.query
        }
      );

What did you expect to see?

traces will be outputted to stack driver

What did you see instead?

error message

(node:8056) UnhandledPromiseRejectionWarning: Error: Unsupported type : undefined
    at createAttributeValue (/path/to/project/node_modules/@opencensus/exporter-stackdriver/build/src/stackdriver-cloudtrace-utils.js:149:19)
    at createAttributesBuilder (/path/to/project/node_modules/@opencensus/exporter-stackdriver/build/src/stackdriver-cloudtrace-utils.js:128:32)
    at Object.createAttributes (/path/to/project/node_modules/@opencensus/exporter-stackdriver/build/src/stackdriver-cloudtrace-utils.js:58:31)
    at StackdriverTraceExporter.createSpan (/path/to/project/node_modules/@opencensus/exporter-stackdriver/build/src/stackdriver-cloudtrace.js:102:56)
    at /path/to/project/node_modules/@opencensus/exporter-stackdriver/build/src/stackdriver-cloudtrace.js:85:36
    at Array.forEach (<anonymous>)
    at StackdriverTraceExporter.<anonymous> (/path/to/project/node_modules/@opencensus/exporter-stackdriver/build/src/stackdriver-cloudtrace.js:83:19)
    at Generator.next (<anonymous>)
    at fulfilled (/path/to/project/node_modules/@opencensus/exporter-stackdriver/build/src/stackdriver-cloudtrace.js:19:58)
(node:8056) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8056) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Additional context

The reason why the error happened is the value of req.body.variable was undefined, but it was hard to understand why the error has happened by seeing that error message. Actually I needed to read '@opencensus/exporter-stackdriver' module to fix it.

Then I think we should allow undefined or replace it with an empty string or 'undefined' string otherwise we have to consider the possibility of becoming null or undefined for all values

I think we can do this just check undefined or not here.
https://github.com/census-instrumentation/opencensus-node/blob/master/packages/opencensus-exporter-stackdriver/src/stackdriver-cloudtrace-utils.ts#L146

@sottar sottar added the bug label Mar 2, 2020
@mayurkale22
Copy link
Member

I think we can do this just check undefined or not here.

Sounds good to me. If you are feeling motivated, maybe you can attempt to write solution and open a PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants