[Python] Record_custom_metrics not showing in Metrics explorer

Hi guys, I’m having trouble to make metrics appear in the Metrics explorer of my application.

My main goal is to record a set of Custom metrics to an application I created in New Relic using the python agent and the ‘record_custom_metric’ method, in total the set is composed of 32 metrics which should be recorded. When I run my script to record the metrics, only a subset of all metrics is appearing in the Metrics explorer. I’ve been debugging and trying to figure out which is the problem, so I tried changing the metrics name/path (‘Custom/my_metric/example’) many times but always a random subset of all metrics remains without appear.

In line 60 you can see all the sites/configs I use.
In line 63 I register the app.
From lines 82 to 85 I record the metrics.

I have printed and debugged the values to see that nothing is broken, so it is not some piece of code that is failing.

I think every metric should be there but for example ‘Custom/MLM_MIS/payments_tot’ is missing, with many others that not appear. You can see the different names I gave to metrics trying to make it work but always I’m facing with this same problem.

Which could be the problem? Is it a naming problem? Are the words MLM, STD reserved? Could it be that I’m trying to push to many metrics at the same time or there is a limit of metrics per application? I’m struggling with this since the last week without any solution.

Thanks for helping!

I think I “solved” it with a sleep(1) before recording the metrics and after registering the application. Is there a synchronous way to do this instead of waiting an amount of seconds? It seems like the agent initialization is running in another thread and so I have to wait for it to finalize.

1 Like

Thanks so much for sharing that @ext_tojaratz - Glad you got something working. You hit on the right way to approach this as there is not a synchronous way to do this.

1 Like

@ext_tojaratz This seems like a great use case for the telemetry sdk! Have you had a chance to look through that package?

There’s an example which walks through how to report metrics synchronously (for low traffic applications - this HTTP endpoint is rate limited).