Return to OpenCensus

Daz Wilkin
2 min readFeb 13, 2018

--

This post updates “OpenCensus w/ Prometheus & Stackdriver”. One of the software engineers on the OpenCensus team pinged me with a couple of updates on the Golang library, yay! Thanks JBD!

The OpenCensus Golang API has been refined (“stats” is split into 2 packages), the bug is resolved and merged (thanks again JBD) and the Golang SDK works with multiple measures.

I won’t duplicate the content from the previous post, so here are the headlines. My samples had minor changes to the published samples because, at that time, the published samples didn’t work with multiple measures.

Prometheus

The sample published in the GitHub repo now works. For consistency, here’s my copy of it:

prometheus.go

Setup your Go environment and then go run prometheus.yml and you should be able to browse|curl http://localhost:9999/metrics.

The prometheus.yml (yay backticks for inline code in Medium) is unchanged:

prometheus.yml

And, you may run Prometheus in Docker with this configuration using:

docker run \
--net=host \
--publish=9090:9090 \
--volume=$PWD/prometheus.yml:/etc/prometheus/prometheus.yml \
prom/prometheus

And, then browse the Prometheus targets and measures as before. This time, you can choose between video_size_cum and video_count measures:

video_count

Stackdriver

Same-same with Stackdriver. The sample published on the OpenCensus site now works. My sample had a minor tweak to the published sample that avoided the bug (removed the second measure) to get it working. But, now the bug’s resolved, my code mirrors the published sample:

stackdriver.go

NB Don’t forget to replace the value for YOUR-PROJECT in line #19 with your Google Cloud Platform Project ID.

And then, after enabling Stackdriver Monitoring, you should be able to browse both OpenCensus/video_cum and OpenCensus/video_count in Stackdriver’s Metrics Explorer:

OpenCensus/video_count

Conclusion

Understandably, we’re seeing much interest from our customers in OpenCensus. Created by Google, it is now being developed by a group of vendors interested in providing one polyglot library for both metrics and trace that works with multiple systems (including Prometheus and Stackdriver shown here). What’s not to like!?

--

--