Problem accessing custom metrics sent by opencensus exporter

281 Views Asked by At

I would like to export custom metrics using the opencensus python exporter as described in: https://cloud.google.com/monitoring/custom-metrics/open-census

I have a flask application deployed on Google Cloud Run that uses the piece of code in example. When I deploy the service, everything seems to be ok (the Exporting stats to project log indicates the correct project id), and then no exception is thrown by the exporter at any time. The mmap.record() method is also called without error.

However, I don't manage to retrieve any value from Metrics Explorer, nor using the metricDescriptors API (searching for task_latency_distribution). Monitoring API is activated on my project, and as far as I understood there is no need to create the metric through the API since the exporter should do it by itself.

My questions are:

  • Are custom metrics compatible with Google Cloud Run deployment?
  • Is there is way to check/debug what is sent by the exporter?

Or more basically, does anybody have any clue of what can go wrong with test :-)?

Thanks for your help,

Aurelien

1

There are 1 best solutions below

0
On

Actually, the problem occurred when using the preload flag in gunicorn (after disabling the preload flags it started to work). It seems related to the way the workers are forked in gunicorn. We found a work-around to make it work with the preload flag by lazily instantiating the exporter at the first query (we are not totally satisfied by this solution and we would be glad to know if somebody else has a better approach, but at least it is working).

Hope this could help someone facing the same issue :-)

Aurelien