A few months ago, Google has announced OpenCensus, a vendor-neutral open source library for telemetry and tracing collection. OpenCensus makes it easy to collect metrics from your app and to trace the progression or requests.
In most of the cases, there is a clear distinction between collecting the data and exporting it to tracing and monitoring systems. Once you have started to use OpenCensus in your project and realize what metrics are particularly interesting to you to trace and monitor, you can switch between different monitoring systems or even use more than one without making any changes to your metric collection logic.
We, at DoiT International, are in the process of developing a reference architecture and actual implementation of event analytics pipeline (still work in progress, but you can have a sneak peek here).
We are writing our API in Go and we wanted to give the users some visibility into the system and to some custom metrics we’d like to expose. In the “old days” you had to choose your monitoring system, and if you wanted to replace it with something else, you would have to invest some time (and money). But what if you are building an open source system and you don’t know upfront where and how it’s going to be deployed and how it would be monitored?
With OpenCensus, you don’t need to decide almost anything upfront. The selection of the monitoring system is not tightly coupled and you can even use more than one monitoring or metric collection system.
So, in order to expose the metrics to you monitoring system of choice, all you’ll need to do, is to create a new exporter and register it:
Creating metrics is also very easy, you’ll just need to decide on their type and about how you’d like them to be displayed:
Now you are ready to collect the metrics, just call the Record method and provide the required data.
As you can see from the following charts, the metrics are exported to both Prometheus and Stackdriver and are visualized on each system: