📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

During a production incident you have logs, metrics, distributed traces and memory dumps available. What is each one, which question does each answer best, and in what order would you reach for them when an alert fires on your .NET API?

Covers the four production signals (metrics, traces, logs, dumps): what each records, its cost, which incident question it answers, how they link through trace ids, and the order a responder uses them in.

Junior Theory Beginner distributed-tracing logs memory-dump metrics observability production

🎯 Key points

  • Metrics: cheap numeric time series that say WHETHER and HOW MUCH (error rate, p95 latency, thread pool queue)
  • Traces: one request's path across services as spans; say WHERE the time or error is; usually sampled at scale
  • Logs: discrete structured events with context; say WHAT happened and WHY; volume is the cost driver
  • Dumps (dotnet-dump, dotnet-gcdump, createdump): process memory and threads; analysed with SOS (clrstack -all, dumpheap -stat, gcroot)
  • Order: alert on metrics → dashboard → trace for a slow or failed request → its logs by trace id → dump only for hangs, leaks or crashes
  • Correlate with the W3C trace id (Activity.TraceId / operation_Id) so you can pivot between signals
  • Cost and privacy differ: metrics cheapest; logs and dumps can hold personal data

⏱ 30-second answer

The four signals answer different questions. Metrics are cheap aggregated numbers over time (error rate, p95 latency, ThreadPool queue length): they tell you whether something is wrong and how much, and they drive alerts. Distributed traces follow one request across services as spans: they tell you where the time or the error is. Logs are structured events with context: they tell you what happened and why (the exception, the order id, the dependency's response). Memory dumps (dotnet-dump, dotnet-gcdump) freeze a process's heap and thread stacks: they tell you what it is doing or holding right now, for hangs, leaks and crashes.

During an incident my order is: 1. metrics and the dashboard (scope and start time), 2. traces (where), 3. logs for those trace ids (why), and 4. a dump only when the process itself is the suspect. The trade-off: richer signals cost more to store and carry more personal data.

🗣 Full answer (senior)

How I would answer this in an interview

"I think of them as four zoom levels. Metrics are the widest: numbers aggregated over time, like requests per second, the 5xx ratio, p95 latency, CPU, GC heap size or ThreadPool queue length. They are cheap to keep for months, so they're what alerts and dashboards are built on. A metric tells me that the error rate went from 0.1% to 6% at 10:02, but not which request or why.

Traces zoom in to a single request. In .NET every incoming request gets an Activity with a W3C trace id, and OpenTelemetry records each hop as a span: the controller, the SQL call, the Redis call, the downstream HTTP call. So a trace tells me where: this request took 9 seconds and 8.7 of them were waiting on the payments API. Logs are the detail: a structured ILogger event with properties like the order id and the exception, stamped with the same trace id, so from a slow span I can jump straight to what the code said at the time. Dumps are different again: a snapshot of the whole process, its heap and every thread's stack, taken with dotnet-dump or dotnet-gcdump. I take one when the process itself is the problem: it hangs, memory keeps climbing, or it crashes.

So when an alert fires, I go in that order: the metric that fired and the service dashboard to scope the impact, then a few failing or slow traces to find where, then the logs for those trace ids to find why, and only a dump if it's a hang, a leak or a crash. The mistake I see is people starting by grepping logs: it's the most expensive signal to search and you can't see the shape of the problem. Metrics first, then narrow down."


What each signal is

Signal What it records Typical .NET source Answers Cost
Metrics Numbers aggregated over time, with a few tags System.Diagnostics.Metrics (Meter), runtime and ASP.NET Core meters, dotnet-counters Is it broken? How much? Since when? Lowest; fixed per series
Traces A tree of timed spans per request ActivitySource, OpenTelemetry instrumentation for ASP.NET Core, HttpClient, SqlClient Where is the time or error? Which dependency? Medium; usually sampled
Logs Discrete structured events ILogger with message templates What happened and why? Which values? High per GB; searchable
Dumps Whole-process memory and thread stacks dotnet-dump, dotnet-gcdump, createdump, dotnet-monitor What is the process holding or stuck on? Large files; taken on demand

Which one answers which incident question

Question during the incident Reach for
Are users affected, and how many? Metrics (error ratio, request rate by status)
When did it start, and did it match a deploy? Metrics with deploy annotations
Which dependency is slow? Traces (span durations), dependency metrics
What exception, for which input? Logs filtered by trace id
Why are requests hanging at low CPU? Runtime metrics (ThreadPool queue), then a heap dump: clrthreads, clrstack -all, syncblk
What is holding 3 GB of memory? GC metrics, then a gcdump or heap dump: dumpheap -stat, gcroot <address>

How they link

The trace id is the join key. ASP.NET Core creates an Activity per request; ILogger scopes include its TraceId and SpanId when OpenTelemetry logging is on; Application Insights stores it as operation_Id. Exemplars can attach a trace id to a metric point, so you can jump from a latency spike straight to a slow trace.

What changes at high volume

Signal At thousands of requests per second Consequence for the responder
Metrics Cost grows with series (tag combinations), not requests Keep tags low-cardinality; metrics stay complete and trustworthy
Traces Head sampling (e.g. 5%) or tail sampling in the OpenTelemetry Collector The exact failing request may be missing; tail sampling keeps errors and slow requests
Logs GB per hour; ingestion and retention are billed Warning and above by default; Debug turned on dynamically; Application Insights may sample logs too
Dumps One per instance, on demand Pick one representative instance; never dump all at once

So for counting ("how many failed?") trust metrics, not sampled traces or logs.

Production example

When the checkout error ratio jumped from 0.2% to 5% at 10:02, the dashboard showed it only on POST /orders; three failed traces all ended in a 30-second timeout on the pricing API span, and the logs for those trace ids showed TaskCanceledException from the typed HttpClient. We switched the pricing call to its cached fallback within 10 minutes. Nobody needed a dump, because the process itself was healthy.

🔍 What the interviewer is checking

Checks the candidate knows what each production signal is for and can use them in a sensible order during an incident.

Green flags

  • Explains metrics, traces, logs and dumps with the question each answers
  • Mentions trace ids as the link between signals
  • Starts from metrics and the dashboard, not from grepping logs
  • Knows dumps are on demand and only for process-level problems

Red flags

  • Treats logs as the only signal
  • Can't explain what a trace or span is
  • Would take a dump as the first step for every incident

📚 Learn in depth

1. Why there are four signals, not one

Each signal makes a different trade between volume and detail:

            detail per event  ───────────────►
  metrics   │ one number per series per interval     (cheap, always on, alerts)
  traces    │ one tree per request, sampled           (where)
  logs      │ many events per request                 (why)
  dumps     │ the entire process at one instant       (what is it holding / stuck on)
            volume you can afford to keep ◄──────────

Metrics are pre-aggregated at the source, so a million requests become a handful of counters and histogram buckets. That's why they're the only signal you can keep cheaply for months and alert on reliably. The cost is that aggregation throws away the individual request.

2. Metrics in .NET

System.Diagnostics.Metrics provides Meter, Counter<T>, Histogram<T> and ObservableGauge<T>. .NET publishes built-in meters such as System.Runtime (GC, ThreadPool, exceptions), Microsoft.AspNetCore.Hosting (http.server.request.duration) and System.Net.Http. You can read them live with no code change:

dotnet-counters monitor -p <pid> --counters System.Runtime,Microsoft.AspNetCore.Hosting

Tags (dimensions) multiply series: a route tag with 50 values is fine; a userId tag is a cardinality explosion.

3. Traces in .NET

System.Diagnostics.Activity is .NET's span. ASP.NET Core starts one per request and continues the caller's traceparent header (W3C Trace Context). HttpClient propagates it outwards. OpenTelemetry's instrumentation libraries turn activities into spans and export them over OTLP to Application Insights, Jaeger, Tempo and so on. Because a busy service creates millions of spans, traces are usually sampled (head sampling at a percentage, or tail sampling in the OpenTelemetry Collector to keep all errors and slow requests).

4. Logs in .NET

ILogger with message templates ("Order {OrderId} failed") produces structured events whose properties are queryable. The cost is volume: logs are billed by GB ingested in Log Analytics, so levels, sampling and filtering matter. Logs are also where personal data leaks most often.

5. Dumps

A dump is a copy of process memory. A full or heap dump contains every object, so you can run SOS commands (clrthreads, clrstack -all, dumpheap -stat, gcroot) with dotnet-dump analyze. A gcdump contains only the managed object graph (types, sizes, references), so it's smaller and holds no field values. Capturing pauses the process, and the file is roughly the size of the working set, so dumps are a targeted tool, not a stream.

6. The incident path

alert (metric) ─► dashboard: scope, start time, deploy marker
                       │
                       ▼
        sample failing/slow traces ─► which span? which dependency?
                       │
                       ▼
        logs where TraceId = X ─► exception, inputs, retry attempts
                       │
          process itself suspect? (hang, leak, crash)
                       ▼
               dump ─► threads, heap, roots

Try it yourself

  1. Run a sample ASP.NET Core API and watch dotnet-counters monitor while you load it with bombardier or k6.
  2. Add OpenTelemetry tracing and logging, export to the console, and confirm the same TraceId appears on the span and the log line.
  3. Make one endpoint call a slow fake dependency and find it from the trace alone.
  4. Add Thread.Sleep in a hot path, take dotnet-dump collect, and find the sleeping threads with clrstack -all.
  5. In Application Insights, write a KQL query that joins requests and traces on operation_Id.

💻 Code

One endpoint that emits all three runtime signals with OpenTelemetry (.NET 10), so they share a trace id.

// Program.cs — needs OpenTelemetry.Extensions.Hosting and the ASP.NET Core / HttpClient instrumentation packages.
using System.Diagnostics;
using System.Diagnostics.Metrics;
using OpenTelemetry.Logs;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddOpenTelemetry()
    .WithMetrics(m => m.AddAspNetCoreInstrumentation().AddRuntimeInstrumentation().AddMeter(Checkout.MeterName).AddOtlpExporter())
    .WithTracing(t => t.AddAspNetCoreInstrumentation().AddHttpClientInstrumentation().AddSource(Checkout.SourceName).AddOtlpExporter());
builder.Logging.AddOpenTelemetry(o => { o.IncludeScopes = true; o.AddOtlpExporter(); }); // logs carry TraceId/SpanId

builder.Services.AddSingleton<Checkout>();
var app = builder.Build();
app.MapPost("/orders", (OrderRequest req, Checkout checkout, CancellationToken ct) => checkout.PlaceAsync(req, ct));
app.Run();

public sealed record OrderRequest(string Sku, int Quantity);

public sealed class Checkout(ILogger<Checkout> logger, IMeterFactory meterFactory)
{
    public const string MeterName = "Shop.Checkout";
    public const string SourceName = "Shop.Checkout";
    private static readonly ActivitySource Source = new(SourceName);
    private readonly Counter<long> _orders = meterFactory.Create(MeterName).CreateCounter<long>("shop.orders.placed");

    public async Task<IResult> PlaceAsync(OrderRequest req, CancellationToken ct)
    {
        using var activity = Source.StartActivity("PlaceOrder");   // trace: WHERE
        activity?.SetTag("shop.sku", req.Sku);
        await Task.Delay(20, ct);                                   // stand-in for real work
        _orders.Add(1, new KeyValuePair<string, object?>("outcome", "success")); // metric: HOW MUCH (low-cardinality tag only)
        logger.LogInformation("Placed order for {Sku} x{Quantity}", req.Sku, req.Quantity); // log: WHAT
        return Results.Accepted();
    }
}
# The fourth signal, taken only when the process is the suspect
dotnet-counters monitor -p 1 --counters System.Runtime   # metrics live
dotnet-dump collect -p 1 --type Heap -o /tmp/api.dmp     # dump: WHAT IS IT HOLDING
dotnet-dump analyze /tmp/api.dmp                         # then: clrstack -all, dumpheap -stat
// Application Insights: from a failed request to its logs via the trace id
requests
| where timestamp > ago(30m) and success == false and name == "POST /orders"
| take 5
| join kind=inner (traces) on operation_Id
| project timestamp, operation_Id, resultCode, message, severityLevel

⚠ Common mistakes

  • Mistake: Starting an incident by searching logs. Why it is wrong: logs are the most expensive signal to query and don't show scope or start time. Instead: start from the alerting metric and dashboard, then narrow to traces and logs.
  • Mistake: Alerting on log lines ("page if ERROR appears"). Why it is wrong: noisy, fragile to message changes and blind to failures that don't log. Instead: alert on metrics such as error ratio or SLO burn.
  • Mistake: Putting user ids or order ids as metric tags. Why it is wrong: every value creates a new time series, exploding cost and memory. Instead: keep ids in logs and span attributes; keep metric tags low-cardinality.
  • Mistake: Logs without a trace id. Why it is wrong: you can't join a log line to the request or other services. Instead: OpenTelemetry logging or scopes that include TraceId and SpanId.
  • Mistake: Taking a dump for a problem traces already explain. Why it is wrong: dumps pause the process, are large and contain personal data. Instead: dump only for hangs, leaks and crashes.
  • Mistake: Assuming traces show every request. Why it is wrong: most setups sample, so the one failing request may not be there. Instead: know your sampling rules; keep errors with tail sampling.
  • Mistake: Logging secrets or personal data "for debugging". Why it is wrong: it creates a privacy obligation under the Privacy Act 1988 wherever the logs go. Instead: log ids, not contents; redact at source.

🏛 Senior insight: trade-offs

Even at junior level, the useful idea is that the signals are complementary, not interchangeable: metrics for detection, traces for location, logs for explanation, dumps for the process's internal state. Teams that pour everything into logs pay the most and still struggle to answer "how many users?" quickly.

Signal Best for Cost driver Don't use it for
Metrics Alerts, trends, SLOs Number of series (tag cardinality) Per-request detail
Traces Cross-service latency, dependency failures Span volume, sampling rate Counting exact totals when sampled
Logs Error details, audit of decisions GB ingested and retained Alerting, high-volume counting
Dumps Hangs, leaks, crashes File size, process pause Routine monitoring

🔗 Follow-ups the interviewer may ask

  1. When: Candidate mentions dumps for hangs or leaks. Why: Checks they know how to actually capture and read a dump when one is needed.
    How to answer

    When I can't attach a debugger, I take a dump: a snapshot of the process's memory, threads and stacks that I analyse offline. For a hang or a leak, dotnet-dump collect -p <pid> does it in seconds. For crashes, I enable automatic crash dumps with the DOTNET_DbgEnableMiniDump environment variables. On App Service I use Diagnose and solve problems, and in Kubernetes dotnet-monitor. Then I analyse with dotnet-dump analyze: clrstack -all and syncblk for hangs, dumpheap -stat and gcroot for leaks, pe for exceptions. Or I open the dump in Visual Studio and use the Threads and Parallel Stacks windows. Dumps contain customer data, so they're handled as sensitive.

  2. When: Candidate says alerts come from metrics. Why: Checks they understand why alerts are built on metrics and symptoms.
    How to answer

    Alert on symptoms users feel, such as the request error-rate or latency SLI, failed synthetic journeys or orders per minute dropping, because causes like CPU at 80% often hurt nobody and miss failures with no resource signal at all. The best symptom alert is SLO burn rate: how fast you are spending the error budget. With a 99.9% SLO, a 14.4× burn over 1 hour (confirmed over 5 minutes) spends 2% of a 30-day budget and pages; 6× over 6 hours pages; slower burns raise a ticket.

    Every alert needs who gets paged (the owning team's rotation), the threshold and window, a severity that decides page versus ticket, a dashboard link and a runbook with the first mitigation steps. Cause metrics stay on dashboards for diagnosis. The trade-off: fewer pages means a slightly later warning for slow-building problems, which tickets cover.

  3. When: Candidate describes the order they use signals during an incident. Why: Checks they can place the signals within the incident lifecycle.
    How to answer

    An incident moves through detect → triage → mitigate → resolve → review. Detection should come from alerts on customer-facing symptoms (error rate, latency, SLO burn), not from customers ringing support. Triage decides how bad it is (severity), who leads it (the incident commander) and who else is needed. Mitigation stops the customer pain as fast as possible — roll back, turn a feature flag off, fail over — guided by a working hypothesis about what changed, without waiting for a proven root cause. Resolution is when the SLIs are back inside their SLOs and stay there. Review is the blameless postmortem that produces owned, dated fixes. Communication to stakeholders runs through every stage.

    The timestamps between the stages give you time to detect, time to mitigate and time to resolve. The main trade-off is speed versus understanding: you restore service first and investigate second.

More in Production Tools

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me