Skip to Content
Hands-On Software Engineering with Golang
book

Hands-On Software Engineering with Golang

by Achilleas Anagnostopoulos
January 2020
Intermediate to advanced
640 pages
16h 56m
English
Packt Publishing
Content preview from Hands-On Software Engineering with Golang

Vector-based metrics

One of the more interesting Prometheus features is its support for partitioning collected samples across one or more dimensions (labels, in Prometheus terminology). If we opt to use this feature, instead of having a single metric instance, we can work with a vector of metric values.

In the following example, we have just launched an A/B test for a new website layout and we are interested in tracking the number of user registrations for each of the page layouts that we are actively trialing:

regCountVec := promauto.NewCounterVec(
    prometheus.CounterOpts{
        Name: "app_registrations_total",
        Help: "Total number of registrations by A/B test layout.",
    },
    []string{"layout"},
)

regCountVec.WithLabelValues("a").Inc()

This time, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Software Architecture with Golang

Hands-On Software Architecture with Golang

Jyotiswarup Raiturkar

Publisher Resources

ISBN: 9781838554491Supplemental Content