<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/observability-in-go-what-goes-in-a-metric-a-log-and-a-trace-9fz1jzl1o" -->

---
title: Observability in Go: What Goes in a Metric, a Log, and a...
description: A deep-dive breaks observability in Go into three distinct decisions - metrics, logs, and traces - and argues most mistakes come from putting a fact in the...
canonical: https://daily.dev/posts/observability-in-go-what-goes-in-a-metric-a-log-and-a-trace-9fz1jzl1o
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Observability in Go: What Goes in a Metric, a Log, and a Trace | daily.dev
og:description: A deep-dive breaks observability in Go into three distinct decisions - metrics, logs, and traces - and argues most mistakes come from putting a fact in the...
og:url: https://daily.dev/posts/observability-in-go-what-goes-in-a-metric-a-log-and-a-trace-9fz1jzl1o
og:image: https://api.daily.dev/og/posts/9Fz1JZl1O.png
og:image:alt: Observability in Go: What Goes in a Metric, a Log, and a Trace
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Observability in Go: What Goes in a Metric, a Log, and a Trace

**[Awesome Go](https://daily.dev/sources/awego)** · 41 min read · 6 upvotes · 0 comments

## Summary

A deep-dive breaks observability in Go into three distinct decisions - metrics, logs, and traces - and argues most mistakes come from putting a fact in the wrong signal, using putting user_id in a Prometheus label as the anchoring example. A real benchmark against Prometheus 3.0.1 shows adding a user_id label costs roughly 1.86 KiB of resident memory per new series, that aggregating away the label with sum(rate(...)) without by(user_id) still costs 72-80% of the grouped query because Prometheus must scan every series regardless, and that series never get evicted from a CounterVec, settling into a permanently elevated memory floor after compaction rather than returning to baseline. It covers the fix (exemplars instead of labels), trace_id propagation via context.Context and W3C traceparent headers, Go-specific instrumentation choices (client_golang vs OpenTelemetry SDK, BatchSpanProcessor tuning), how Loki hits the same cardinality trap through streams with structured metadata as its fix, why Tempo's object-storage design mostly avoids the problem, classic vs native histogram series math, PII discipline in logs under GDPR, and dashboard/alerting practices (RED/USE methods, symptom-based alerting).

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://skoredin.pro/blog/golang/observability-go>

## Questions this post answers

### how much memory does adding a user_id label to a Prometheus counter actually cost per series

Roughly 1.86 KiB of process-level resident memory per additional time series, averaged across two 50,000-user load steps against a real Prometheus 3.0.1 instance (1.59 KiB/series on the first 50K, 2.13 KiB/series on the second 50K). A bounded counter labeled only by route/method/status stayed at exactly 2 series throughout, while the unsafe counter with a user_id label grew to 100,000 series and 190.6 MB of additional resident memory.

_Anyone tuning Prometheus cardinality can compare notes on real memory costs via daily.dev before a label choice becomes a production incident._

### does removing the by(user_id) grouping from a PromQL query actually fix the cost of a high-cardinality label

No, dropping the group-by only reduces query cost by about 20-28%, not most of it. A query producing one aggregate number still had to scan all 100,000 series created by the label, costing around 196ms versus roughly 0.3ms for the equivalent query on a properly bounded metric, since Prometheus's query planner cannot know in advance which series matter and must touch every one of them.

_Debugging slow PromQL queries against high-cardinality metrics is easier when developers compare real measurements on daily.dev._

### how do I avoid the cardinality problem when I need to find a specific slow or failed request in Prometheus

Use exemplars instead of a label: a small bounded piece of data, typically a trace ID, attached to a single observation inside a histogram or counter via client_golang's ExemplarObserver or ExemplarAdder, rather than to the series identity. This requires exposing OpenMetrics format and enabling Prometheus with --enable-feature=exemplar-storage, which allocates one fixed-size circular buffer (100,000 by default) for the whole instance regardless of series count.

_Developers wiring trace-level debugging into metrics without blowing up cardinality can trade implementation notes on daily.dev._

## Similar posts on daily.dev

- [Observability in Go: Where to start and what matters most](https://daily.dev/posts/observability-in-go-where-to-start-and-what-matters-most-yxb08zvul) · Grafana Labs · 32 upvotes · 0 comments
- [Why Logs, Metrics and Traces Still Don’t Give You Real Observability](https://daily.dev/posts/why-logs-metrics-and-traces-still-don-t-give-you-real-observability-xkoqmowxi) · DevOps.com · 0 upvotes · 0 comments
- [Reading Observability Tools? That’s a Robot’s Job](https://daily.dev/posts/reading-observability-tools-that-s-a-robot-s-job-65lmkst3l) · The Last Week in AWS · 0 upvotes · 0 comments
- [You can’t debug what you can’t see — Observability for AI Agents](https://daily.dev/posts/you-can-t-debug-what-you-can-t-see-observability-for-ai-agents-8yaiqpabv) · CNCF · 1 upvotes · 0 comments
- [Correlate Logs, Traces and Metrics for Faster Root Cause](https://daily.dev/posts/correlate-logs-traces-and-metrics-for-faster-root-cause-zcz8feyp6) · Last9 · 1 upvotes · 0 comments

---

Tags: [#devops](https://daily.dev/tags/devops), [#golang](https://daily.dev/tags/golang), [#observability](https://daily.dev/tags/observability), [#prometheus](https://daily.dev/tags/prometheus)

[View this post on daily.dev](https://daily.dev/posts/observability-in-go-what-goes-in-a-metric-a-log-and-a-trace-9fz1jzl1o)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Observability in Go: What Goes in a Metric, a Log, and a Trace","url":"https://daily.dev/posts/observability-in-go-what-goes-in-a-metric-a-log-and-a-trace-9fz1jzl1o","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/observability-in-go-what-goes-in-a-metric-a-log-and-a-trace-9fz1jzl1o"},"datePublished":"2026-09-17T20:29:30.270Z","dateModified":"2026-09-17T20:46:10.274Z","description":"A deep-dive breaks observability in Go into three distinct decisions - metrics, logs, and traces - and argues most mistakes come from putting a fact in the...","image":"https://media.daily.dev/image/upload/s--1KxV4ohY--/f_auto/v1722860400/public/Placeholder%2007","thumbnailUrl":"https://media.daily.dev/image/upload/s--1KxV4ohY--/f_auto/v1722860400/public/Placeholder%2007","isAccessibleForFree":true,"articleSection":"Awesome Go","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Awesome Go","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/awego","url":"https://daily.dev/sources/awego"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/observability-in-go-what-goes-in-a-metric-a-log-and-a-trace-9fz1jzl1o","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":6},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"devops,golang,observability,prometheus","timeRequired":"PT41M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Awesome Go","item":"https://daily.dev/sources/awego"},{"@type":"ListItem","position":3,"name":"Observability in Go: What Goes in a Metric, a Log, and a Trace"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/observability-in-go-what-goes-in-a-metric-a-log-and-a-trace-9fz1jzl1o#faq","mainEntity":[{"@type":"Question","name":"how much memory does adding a user_id label to a Prometheus counter actually cost per series","acceptedAnswer":{"@type":"Answer","text":"Roughly 1.86 KiB of process-level resident memory per additional time series, averaged across two 50,000-user load steps against a real Prometheus 3.0.1 instance (1.59 KiB/series on the first 50K, 2.13 KiB/series on the second 50K). A bounded counter labeled only by route/method/status stayed at exactly 2 series throughout, while the unsafe counter with a user_id label grew to 100,000 series and 190.6 MB of additional resident memory. Anyone tuning Prometheus cardinality can compare notes on real memory costs via daily.dev before a label choice becomes a production incident."}},{"@type":"Question","name":"does removing the by(user_id) grouping from a PromQL query actually fix the cost of a high-cardinality label","acceptedAnswer":{"@type":"Answer","text":"No, dropping the group-by only reduces query cost by about 20-28%, not most of it. A query producing one aggregate number still had to scan all 100,000 series created by the label, costing around 196ms versus roughly 0.3ms for the equivalent query on a properly bounded metric, since Prometheus's query planner cannot know in advance which series matter and must touch every one of them. Debugging slow PromQL queries against high-cardinality metrics is easier when developers compare real measurements on daily.dev."}},{"@type":"Question","name":"how do I avoid the cardinality problem when I need to find a specific slow or failed request in Prometheus","acceptedAnswer":{"@type":"Answer","text":"Use exemplars instead of a label: a small bounded piece of data, typically a trace ID, attached to a single observation inside a histogram or counter via client_golang's ExemplarObserver or ExemplarAdder, rather than to the series identity. This requires exposing OpenMetrics format and enabling Prometheus with --enable-feature=exemplar-storage, which allocates one fixed-size circular buffer (100,000 by default) for the whole instance regardless of series count. Developers wiring trace-level debugging into metrics without blowing up cardinality can trade implementation notes on daily.dev."}}]}
```

