Skip to content

Go Language

Table of Go Metrics Exposed by Prometheus under Different Rules

Prometheus golang_client helps to expose go runtime/metrics so you can collect it, and the block below shows a short example.

collectors.WithGoCollectorRuntimeMetrics accepts various rules and prometheus collector package also offers several options.

This page offers a table to show prometheus exposed go runtime metrics naming, and the rules to enable them for reference. It solves 2 painpoints listed below.

Go1.23 Timer Unbuffered Channel Changes

When I wrote this blog, go has just released go1.25rc2 and go1.23 is quite a long time ago release. In go1.23 release note, go team shares that Go 1.23 makes two significant changes to the implementation of time.Timer and time.Ticker. This blog focuses on the second change:

the timer channel associated with a Timer or Ticker is now unbuffered, with capacity 0. The main effect of this change is that Go now guarantees that for any call to a Reset or Stop method, no stale values prepared before that call will be sent or received after the call.

It will talk about why buffered channel is a problem, why unbuffered channel is used, the cases affected and how go implements this change.

Working Dir in Std Os Package

Go standard library provides os pacakge to trackle with os related concepts, for example, the working dir. Working dir is a os level concept rather than a concept maintained by os package. Indeed, os package doesn't reinvent the wheel but rely on the operation system to tackle it.

Working dir is a concept for a process rather than an executable. So statement "the working dir of binary ./bin/server is ~/workspace/server" is totally wrong.