Question: In this lab, you will be using the observer and the strategy patterns to create a graph to display a metric. What is a metric?

In this lab, you will be using the observer and the strategy patterns to create a graph to display a metric.
What is a metric?
Think of a metric as a variable to monitor, when you have a system it can output all sorts of information that can be helpful when analysing how your system is performing. Metrics can help monitor things like performance, availability and reliability. For example if you have a server cluster that has 100 host machines they might report metrics such as cpu.utilization, api.calls, and dropped.packets.
The image below is an example of what a dashboard showing metrics could look like. This sort of output and metrics in general can help developers notice problems or better understand why something broke.
For example if your api.calls metric all of a sudden drops from 1000 calls a minute to 5 it could be a sign of a problem. You can then fix it without your users having to inform you, minimising the impact it has.
If you want to learn more about metrics and observability you can read this.At the moment the data inside Plot is not changing and is just some random data. We want the data that is being generated by the Emitter to be shown on the panel and update the graph as it emits more data.
Use the observer pattern to add the Plot as an observer to the Emitter in the main function so that whenever it emits a metric Plot is updated.
In your update function, you will need to call if (panel != null) panel.repaint() to get the visualization to update.
Below is a video of the expected output
Lab05 metrics task 1
If you want to have a play around with what the Emitter emits you can change the code in emitMetric() to emit different things. For example you can change it to use Math.tan() instead of Math.sin().

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!