You will see a src/metrics.csv file that has been created with two columns: timestamp and request_latency. When we run docker-compose up in the demo1 directory, it starts the web application, then a client container that makes a number of requests to the web application. In the above function, we write the timestamp and the time it took (in milliseconds) for the request to be processed. When setup_metrics() is called from the application, it configures the start_timer() function to be called before a request is processed and the stop_timer() function to be called after a request is processed but before the response has been sent. With open('metrics.csv', 'a', newline='') as f:Ĭsvwriter.writerow() Resp_time = (time.time() - request.start_time)*1000 # convert this into milliseconds for statsd Its value starts at 0 and increases during the lifetime of your blog post. You just published a post and want to keep an eye on how many hits it gets over time, a number that can only increase. They broadly fall into three categories: CountersĬonsider your personal blog. The total of number hits on a blog post, the total number of people attending a talk, the number of times the data was not found in the caching system, the number of logged-in users on your website-all are examples of metrics. Alerting when a system exhibits unexpected behaviorįor our purposes, a metric is an observed value of a certain quantity at a given point in time.Changing system behavior in response to a measurement.Understanding the effect of software/hardware changes.Assisting in performance troubleshooting.Doing capacity planning, scaling up or down. Understanding normal and abnormal system and service behavior.You will need to have docker and docker-compose installed to play with them. Welcome to the communityĪll the demos discussed in this article are available on my GitHub repo.
0 Comments
Leave a Reply. |