Skip to content
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

Count Metrics: Cannot convert undefined or null to object #1031

Closed
astorm opened this issue May 7, 2020 · 3 comments
Closed

Count Metrics: Cannot convert undefined or null to object #1031

astorm opened this issue May 7, 2020 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@astorm
Copy link
Contributor

astorm commented May 7, 2020

Please answer these questions before submitting a bug report.

What version of OpenTelemetry are you using?

1.0.0

What version of Node are you using?

v12.12.0

What did you do?

I was working through some basics examples of the metric API using plain javascript (i.e. not TypeScript), and I noticed that code that looks something like this

const counter = meter.createCounter('our-counter-metric', {
  description: 'Example of a observer',
});

counter.add(1)

Ended up throwing an error like this

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at Object.hashLabels (/path/to/opentel/node_modules/@opentelemetry/metrics/build/src/Utils.js:32:23)
    at CounterMetric.bind (/path/to/opentel/node_modules/@opentelemetry/metrics/build/src/Metric.js:44:30)
    at CounterMetric.add (/path/to/opentel/node_modules/@opentelemetry/metrics/build/src/Metric.js:102:14)
    at /path/to/opentel/index.js:32:11
    at Layer.handle [as handle_request] (/path/to/opentel/node_modules/express/lib/router/layer.js:95:5)
    at next (/path/to/opentel/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/path/to/opentel/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/path/to/opentel/node_modules/express/lib/router/layer.js:95:5)
    at /path/to/opentel/node_modules/express/lib/router/index.js:281:22 

What did you expect to see?

I expected the call to counter.add(1) would increment the counter metric without errors, similar to the behavior when calling counter.add(1, {})

What did you see instead?

The error mentioned above.

Additional context

I intend to open a PR to fix this.

@astorm astorm added the bug Something isn't working label May 7, 2020
@mayurkale22
Copy link
Member

Thanks for reporting this. As you already opened the PR, I have assigned this bug to you.

@dyladan
Copy link
Member

dyladan commented May 14, 2020

Can this be closed now #1032 is merged?

@astorm astorm closed this as completed May 14, 2020
@astorm
Copy link
Contributor Author

astorm commented May 14, 2020

@dyladan Yup! Closed out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants