الانتقال إلى المحتوى
DevOps والـ CloudObservability· 7 دقائق للقراءة

Logs Aren't Observability: Logs, Metrics and Traces Answer Different Questions

Metrics tell you something is wrong, traces show where, and logs say what exactly happened. More log lines only help with the last one.

ReadIn

مقال كل يوم يفرق معاك

21 نوفمبر 2026
  • كاتب موثّق
محتويات المقال

Support forwards a complaint: some customers say checkout "hangs, then fails". The team opens the log search and types "checkout". Thousands of lines come back from the last hour, all saying "Checkout started", "Calling payment service" or "Payment finished", interleaved from every request that ran at the same time. Nobody can say how many checkouts failed, whether it's getting worse, or which service the slow ones were waiting on. The action item from the retrospective: add more logs.

The common misconception

The belief: observability means writing more logs. If you couldn't see what happened, you didn't log enough, so you add lines around every step and the next incident will be clear.

It's an honest instinct. Logs are the oldest debugging tool there is, every framework writes them, and the OpenTelemetry docs note that they "have been heavily relied on in the past by both developers and operators to help them understand system behavior." On your laptop they work beautifully: one request at a time, lines in order, read top to bottom.

The half-truth is that logs are necessary. They're one of the three signals, and they answer one kind of question well. In production, with many requests running at once across several services, a pile of log lines can't tell you how often something happens or where the time went.

What actually happens

Observability means you can ask new questions

The OpenTelemetry primer defines it this way: "Observability lets you understand a system from the outside by letting you ask questions about that system without knowing its inner workings." For that, the code has to emit signals such as traces, metrics and logs. Each signal is shaped for a different question.

Metrics: is something wrong, and how much?

"Metrics are aggregations over a period of time of numeric data about your infrastructure or application", such as "system error rate, CPU utilization, and request rate". A metric stores a number per time window, not a line per event, so it stays cheap at any traffic level and is what dashboards and alerts are built on. Google's SRE book names the four to start with: "The four golden signals of monitoring are latency, traffic, errors, and saturation." Metrics tell you when checkout failures started rising. They can't tell you which requests failed, or why.

Traces: where did this request spend its time?

A "records the path taken by a single request" as it "propagates through multiple services". It's a tree of , and "a span represents a single unit of work or operation": the incoming HTTP request, the call to the payment provider, the database query. Laid out as a waterfall, one slow trace shows you that the request spent most of its time waiting on the payment call, not in your code.

Logs: what exactly happened?

"A log is a timestamped message emitted by services or other components." Logs are the right place for details: which rule rejected the order, what the payment provider answered. But the primer warns that "logs aren't enough for tracking code execution, as they usually lack contextual information, such as where they were called from." They "become far more useful when they are included as part of a span, or when they are correlated with a trace and a span." Write them as , with named values, so you can filter by order ID instead of searching text.

The trace ID ties the three together

Once an OpenTelemetry SDK is active, it "will automatically correlate your existing logs with any active trace and span, wrapping the log body with their IDs." That gives you a workflow. A metric alert fires; you open a slow trace from that minute; you read only the logs carrying its trace ID. The SRE book asks monitoring to answer "what's broken, and why?" Metrics answer the first part. Traces and logs answer the second.

The fix: give each question its signal

In .NET, the tracing API is System.Diagnostics: OpenTelemetry repurposes "existing constructs like ActivitySource and Activity to be OpenTelemetry-compliant under the covers." Metrics use System.Diagnostics.Metrics. Here's the checkout, before and after:

C# Checkout.cs
public class Checkout(ILogger<Checkout> log, IPayments payments){    public async Task<bool> PayAsync(Order order)    {        log.LogInformation("Checkout started");        log.LogInformation("Calling payment service");        var ok = await payments.ChargeAsync(order);        log.LogInformation("Payment finished, ok=" + ok);        return ok;    }}// Two checkouts at once, from the console logger:// info: Checkout[0] Checkout started// info: Checkout[0] Calling payment service// info: Checkout[0] Checkout started// info: Checkout[0] Calling payment service// info: Checkout[0] Payment finished, ok=True// info: Checkout[0] Payment finished, ok=False

The first tab's output is real, from two concurrent calls with a fake payment service: the lines interleave, and the ok=False line doesn't say which order failed. For the second tab we registered the names with the OpenTelemetry .NET SDK 1.20.1 on .NET 10 (AddSource and AddMeter, plus the console exporter). The declined order produced a ChargePayment span tagged order.id: 81723, a checkout.declines sum of 1, and one log record with OrderId: 81723 and LogRecord.TraceId: 330be5addb80021ff67319cadebf59bf, the same value as the span's Activity.TraceId. The approved order produced a span and nothing else, because nothing worth a log line happened.

QuestionSignalIn the checkout
Is something wrong right now, and how much?Metricscheckout.declines over time, error and request rates
Where did this slow request spend its time?TracesThe ChargePayment span inside the request's trace
What exactly happened in this event?Logs"Payment declined for order 81723", with OrderId
Which details belong to that slow request?Logs and tracesLog records filtered by the trace ID

How to apply it in your project

  1. Start with metrics for the golden signalsFor each user-facing service, make sure you can graph latency, traffic, errors and saturation, and alert on them. That's how you learn something is wrong before support does.
  2. Turn on tracing at the edgesThe OpenTelemetry docs point out that libraries your code depends on may already be instrumented, or have instrumentation libraries. Enable them for your HTTP server, HTTP client and database first, then add your own spans around important calls.
  3. Make logs structured and correlatedUse message templates with named values, and check that a log record written inside a request carries its trace ID. If it doesn't, the SDK isn't wired to your logger yet.
  4. Replace step logs with spansSearch for lines like "Calling X" and "Done X". Each one is a span waiting to be written, and deleting the log line makes the real events easier to find.

Key takeaways

  • Observability means being able to ask new questions of a running system, not having more log lines.
  • Metrics answer "is something wrong, and how much?" cheaply and over time; start with the four golden signals.
  • A trace answers "where did this request spend its time?" as a tree of spans across services.
  • Logs answer "what exactly happened?", and they're most useful when they carry the trace ID.
  • Use each signal for its question and link them through the trace ID instead of adding more log lines.

📚 المصادر

  1. Observability primer — OpenTelemetry
  2. Logs — OpenTelemetry
  3. Metrics — OpenTelemetry
  4. Instrumentation (.NET) — OpenTelemetry
  5. Monitoring Distributed Systems — Google SRE book

التعليقات (0)