MetricReader is not bound to a MetricProducer

See original GitHub issue

What version of OpenTelemetry are you using?

    "@opentelemetry/api": "^1.1.0",
    "@opentelemetry/exporter-prometheus": "^0.28.0",
    "@opentelemetry/host-metrics": "^0.27.1",

What version of Node are you using?

v16.13.0

What did you do?

const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
const { HostMetrics } = require('@opentelemetry/host-metrics');
const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus');

const exporter = new PrometheusExporter(
  {
    startServer: true
  }, () => {
    console.log('prometheus scrape endpoint: http://localhost:9464/metrics')
  }
)

const meterProvider = new MeterProvider({
  exporter,
  interval: 2000
})

const hostMetrics = new HostMetrics({ meterProvider, name: 'example-host-metrics' })
hostMetrics.start()

const fastify = require('fastify')()
fastify.listen(8080)

What did you expect to see?

Host metrics

What did you see instead?

By reaching the URL: http://localhost:9464/metrics I get:

# failed to export metrics: Error: MetricReader is not bound to a MetricProducer

Additional context

I was trying to add the HostMetrics to the opentelemetry.NodeSDK component, but unsuccessfully. So I tried the basic example, and I get the same error.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:17 (16 by maintainers)

github_iconTop GitHub Comments

2reactions
Eommcommented, Jul 4, 2022

I will get the chance to test it by my side on the next days

1reaction
legendecascommented, Sep 19, 2022

Sorry, it’s not addMetricProvider but rather addMetricReader. The code snippet I use is as follows:

const { MeterProvider } = require('@opentelemetry/sdk-metrics');
const { HostMetrics } = require('@opentelemetry/host-metrics');
const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus');

const exporter = new PrometheusExporter(
  {
    startServer: true
  }, () => {
    console.log('prometheus scrape endpoint: http://localhost:9464/metrics')
  }
)

const meterProvider = new MeterProvider()
meterProvider.addMetricReader(exporter)

const hostMetrics = new HostMetrics({ meterProvider, name: 'example-host-metrics' })
hostMetrics.start()
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error When exporting metrics while using OpenTelemetry ...
Hi, I configured Opentelemtry collector to export metrics and traces. I am getting access errors and unable to check any data come ...
Read more >
OpenTelemetry collector does not export Metric attributes to ...
I am attempting to export Metrics to an OpenTelemetry collector container from my Node.js app, which then exports it to New Relic. I...
Read more >
Metrics Data Model | OpenTelemetry
Explicit boundary values. These values denote the lower and upper bounds for buckets and whether not a given observation would be recorded in...
Read more >
https://git.2li.ch/clitools/restic/commit/ca8c3b4f...
metric/metricproducer/producer.go | 28 + ... Transport affects all clients which is not what we want. ... This defines size(bounds) + 1 (= N)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found