Open pontarolli opened 4 years ago
@icebob can explain this much better than me but I can give some hints about how metrics are measured.
where these values are stored
Doing some quick look at console-tracer
source code, it seems to have an object called request
that stores the metrics.
https://github.com/moleculerjs/moleculer-metrics/blob/cd54832e5c13f8bffe90f84f2ef0bfd587a14f9e/packages/moleculer-console-tracer/src/index.js#L244-L247
The console-tracer
service stores the metrics data, that it receives via events, in request
object.
https://github.com/moleculerjs/moleculer-metrics/blob/cd54832e5c13f8bffe90f84f2ef0bfd587a14f9e/packages/moleculer-console-tracer/src/index.js#L45-L66
This means that you can extend console-tracer
service and add and action that can access the request
object and, therefore, you can do some processing and compute the desired data.
Regarding the actual content of metrics, you can see it here
I would like to better understand how these times are measured, ie when the time starts and when it ends
The metrics are registered as a middleware, i.e., they wrap action calls. So the metrics middleware is called right before executing an action and after the response is received back.
The metrics start function looks like this: https://github.com/moleculerjs/moleculer/blob/9a9a7bd88defbfc3e9a2071b6a36b883effc488e/src/middlewares/metrics.js#L40-L49
Stop looks like this: https://github.com/moleculerjs/moleculer/blob/9a9a7bd88defbfc3e9a2071b6a36b883effc488e/src/middlewares/metrics.js#L99-L123
And finally here is how they are called: https://github.com/moleculerjs/moleculer/blob/9a9a7bd88defbfc3e9a2071b6a36b883effc488e/src/middlewares/metrics.js#L163-L206
Regarding the error. Can you please create a reproduction repo ?
I will study the code a little more calmly to understand everything you have informed me. Because basically I need this time data always being recorded in a spreadsheet and then plotting it on a chart having the mean and standard deviation.
Regarding the error follows my repository: https://github.com/RicardoPasquati/moleculer-console-tracer-RangeError
@AndreMaz
I believe that the error I was giving was due to the console-tracer module trying to print a very large value, so RangeError, something very long:
[...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................[|||||||||].................................................................................]
This still needs to be resolved, perhaps more calmly.
I was able to run Tracer on two devices now, just using the request object that stores all the data.
Practically I disabled all printing in the console, and left only the functionality of the request object and used this.logger.info to print the request in the console. In the future I will make these records in a database.
You can close the topic.
Thank you very much for the explanation and help.
Hello, I am a graduate student in electrical engineering from the State University of São Paulo, Brazil - SP and we are using the molecular framework as the basis for our project.
We would like to do the orchestration and choreography of microservices applied in an industrial plant to control a level mesh comparing the total execution time as well as the time of each route.
To do this we saw that you have the molecular-console-tracer module, we created a basic orchestration service to call each node's hello services sequentially:
We did 2 tests before we ran our application to understand it better. The provision of services was distributed as follows in the tests:
Test 1:
Result 1
Test 2:
Result 2
As you can see in our test 2 when calling node-21's greeter.hello service that is on raspberry we got an error (RangeError: Invalid string lenght) show in the figure above in results.
Could you help me remedy this mistake?
Taking advantage of the post I would like to better understand how these times are measured, ie when the time starts and when it ends, and know where these values are stored if you want to build a mean and standard deviation graph. I say this because I got a little confused in test 1, because we have two api.rest in the result should not be just one, api.rest gives two different times api.rest 28ms and api.rest 3ms.