---
title: "Should you use a log or a metric?"
description: "Logs record what was true at a decision point so you can reconstruct an event while debugging."
url: "https://swe.quest/articles/should-you-use-a-log-or-a-metric-76d0a9159f50ce4a"
canonical: "https://blog.sentry.io/when-you-need-a-metric/"
source: "Sentry"
published: "2026-10-22"
difficulty: "medium"
kind: "How-to"
reading_minutes: 11
tags: ["observability","javascript"]
---

# Should you use a log or a metric?

A post on [Sentry](https://swe.quest/sources/sentry.md), published 2026-10-22, 11 min read, How-to. Original: [https://blog.sentry.io/when-you-need-a-metric/](https://blog.sentry.io/when-you-need-a-metric/)

## Summary

Logs record what was true at a decision point so you can reconstruct an event while debugging. Metrics are questions you commit to in advance and track over time even when nothing is wrong. Using a signup flow in the Sentry JavaScript SDK, the post shows when traces suffice (timing, but sampled), when to log (per-user failures, email delivery status) and when to emit counters, gauges or distributions (signup trends, funnels, queue depth, time-to-verify across requests). Practical rules: set shared attributes and user on the scope once, use the same names and keys on logs and metrics, count existing logs for ad-hoc debugging but don't build dashboards on them, and filter what reaches Sentry with beforeSendLog or level lists.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Observability](https://swe.quest/tags/observability.md) (Reliability & operations)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)

## Prerequisites

- application logging basics ([easy posts on Observability](https://swe.quest/tags/observability.md?difficulty=easy))
- distributed tracing basics ([easy posts on Observability](https://swe.quest/tags/observability.md?difficulty=easy))

## Keywords

Sentry, Sentry SDK, Pino

## Related posts

- [Logs, Metrics, and Traces: What Does Each Signal Tell You?](https://swe.quest/articles/logs-metrics-and-traces-what-does-each-signal-tell-you-3a828a88ec5fbd9a.md): Railway · 2025-11-07 · Easy · 8 min read · Observability, Incidents & postmortems
  Logs, metrics and traces answer different questions: metrics show when behaviour changed, traces show where in the service graph a request slowed or failed, and logs explain why.
- [Shifting Metrics Right](https://swe.quest/articles/shifting-metrics-right-9cd4911993cdce0d.md): Honeycomb · 2026-03-17 · Medium · 6 min read · Observability
  Instead of pre-aggregating metrics inside applications, generate them as late as responsibly possible in the telemetry pipeline, either in the OpenTelemetry Collector or in the backend from traces and logs.
- [Building On-call: Our observability strategy](https://swe.quest/articles/building-on-call-our-observability-strategy-d4562a767c5fec2c.md): incident.io · 2024-08-22 · Medium · 15 min read · Observability, SRE, Incidents & postmortems, Go
  incident.io structures observability for its on-call product as a consistent drill-down path.
- [Own Your Observability: Supabase Metrics API](https://swe.quest/articles/own-your-observability-supabase-metrics-api-f7b0d82ff7186f0c.md): Supabase · 2025-12-16 · Medium · 4 min read · Observability, PostgreSQL
  Supabase's Metrics API exposes roughly 200 Postgres health and performance metrics per project in Prometheus exposition format at a privileged endpoint authenticated with service-role Basic Auth, refreshed every minute.
- [From one switch to a control panel: meet \`dataCollection\`](https://swe.quest/articles/from-one-switch-to-a-control-panel-meet-datacollection-1d4b9c6a75983352.md): Sentry · 2026-08-28 · Medium · 6 min read · Privacy, Observability, JavaScript
  Sentry's JavaScript SDK v11 replaces the all-or-nothing \`sendDefaultPii\` boolean with \`dataCollection\`, a per-category config covering user info, cookies, HTTP headers and bodies, query params, GenAI inputs/outputs, database queries and more.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
