Skip to content

ADR: Telemetry

ADR: Telemetry that outlives the container

Status
accepted
Date
2026-09-03
Shipped as
1.0.0.34

Steve asked for Azure error handling shown on the admin page, with every API call, every API error and every React error logged, in Application Insights if the solo subscription includes it. It does: the free trial includes it, and the first 5 GB a month of ingestion costs nothing.

In plain words

This page sends the site's requests and errors to a store in Azure that keeps them when the container is replaced (Application Insights), on the free tier with a daily cap so it cannot generate a charge. The Admin tab reads the last hour back from it, and the key that sends the data never enters the repository.

What that is worth: a developer can see which route is slowest or what threw an hour ago, and the organization gets lasting monitoring at no cost that never blocks a deploy.

Context

ADR: Observability built the Admin tab on an in-memory ring buffer of fifty entries, and said out loud what that costs: the buffer resets on every roll, holds nothing older than the current container, and cannot answer a question about last Tuesday. ADR: Error handling then routed browser errors into the same buffer. That made it more useful and no more durable.

Structured request logs go to the container's stdout, where Azure keeps them for a container group's lifetime and nobody reads them. Neither the logs nor the buffer can answer the questions worth asking about a running site: how many requests failed in the last hour, which route is slowest, what threw and when.

Decision

Application Insights, in the same resource group, on the free tier. A Log Analytics workspace (log-theyard-ss, PerGB2018, 30-day retention) and a component bound to it (appi-theyard-ss), both in RG-THEYARD-SS. The daily ingestion cap is set to 0.1 GB with collection stopped at the cap, so the resource cannot generate a charge even if something goes wrong.

The API sends with the Azure Monitor OpenTelemetry distro. One call in Program.cs gives requests, dependencies and exceptions with their durations, correlated by trace id. It is registered only when a connection string is present. So a local run and every test are untouched and need no fake.

The connection string never enters the repository. It is an ingestion key. The deploy workflow reads it from Azure at roll time with the federated credential it already uses, masks it in the log, and substitutes it into the container spec, which carries a __APPINSIGHTS_CONNECTION_STRING__ placeholder in the repository. The app treats any value starting with __ as absent, so a manual rollback with the committed file runs clean instead of sending telemetry to nowhere.

That read is allowed to fail. If Azure does not answer, the roll leaves the placeholder in place and logs a workflow warning, then ships anyway. Telemetry is an addition to this system, not a dependency of it, and a delivery pipeline that a monitoring resource can block is a worse trade than an hour of missing traces.

Browser errors go through the API, not straight to Azure. The boundary and the two window handlers already POST to /api/errors/client (ADR: Error handling); that endpoint now also writes a structured log, which the distro forwards. Three things follow: the page loads no second external script, the ingestion key stays server-side, and a browser error is searchable beside the server's own with the same trace correlation.

The Admin tab reads it back with the container's own identity. id-theyard-ss was granted Monitoring Reader on the component, so the container asks Application Insights about itself the same way it already asks Azure Resource Manager about its own container group. No key is stored for reading either.

In the code

The registration, and the reader it hands the Admin tab (api/TheYard.Api/Program.cs):

// Application Insights. The connection string is an ingestion key, so it is
// never in the repository: the deploy reads it from Azure at roll time and
// passes it to the container as an environment variable. Absent, as it is
// locally and in every test, this block does nothing and the app runs without
// telemetry, which is why no test needs a fake for it.
string? telemetryConnection = builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"];
bool telemetryOn = !string.IsNullOrWhiteSpace(telemetryConnection)
    && !telemetryConnection.StartsWith("__", StringComparison.Ordinal);
if (telemetryOn)
{
    // Two in three of the site's successful dependency calls stay out of the workspace, the one kept standing for
    // three (TelemetrySampling); added before the distro, as its documentation says, so it runs before the exporter.
    builder.Services.ConfigureOpenTelemetryTracerProvider(tracing => tracing.AddProcessor(new TelemetrySampling()));
    // The Foreman's agent, its model turns and its tools (ADR: The Foreman gets a model): names, times and token
    // counts; the framework's switch for prompts and answers is left off.
    builder.Services.ConfigureOpenTelemetryTracerProvider(tracing => tracing.AddSource(TelemetrySampling.ForemanSource));
    builder.Services.AddOpenTelemetry().UseAzureMonitor(options =>
    {
        options.ConnectionString = telemetryConnection;
    });
    // A call a card's reader cancelled at its own time limit is that card's reading, not an exception row (it was
    // 237 of them in a week on the Admin tab's failures list); every other exception on a call is recorded as before.
    // Registered after the distro, so it is the last word on the option the distro sets.
    builder.Services.Configure<HttpClientTraceInstrumentationOptions>(options =>
    {
        options.RecordException = false;
        options.EnrichWithException = TelemetrySampling.OnException;
    });
    // The box's agent posts every two seconds, forty-three thousand requests a day, which would spend most of
    // the component's daily cap on itself (ADR: The box reports itself): its routes are left out of the
    // request telemetry, the distro's documented way, and every other path is kept.
    builder.Services.Configure<AspNetCoreTraceInstrumentationOptions>(options => options.Filter = context => Traced(context.Request.Path, context.Request.Headers.UserAgent.ToString()));
    // The workspace's free 5 GB a month (ADR-024, the addendum on what fills it): the HttpClient's connection-pool
    // instruments, read by nothing on the site, and Entity Framework's line for every command, which the Admin
    // tab's own rings already keep, stay out of telemetry. The distro's documented way to drop an instrument.
    foreach (string instrument in DroppedInstruments)
    {
        builder.Services.ConfigureOpenTelemetryMeterProvider(metrics => metrics.AddView(instrumentName: instrument, MetricStreamConfiguration.Drop));
    }
    builder.Logging.AddFilter<OpenTelemetryLoggerProvider>(CommandCategory, LogLevel.Warning);
}
// The component's app id is public (it is not a key) and is what the Admin
// tab queries with the container's managed identity.
var source = new TelemetrySource(
    builder.Configuration["Azure:AppInsightsAppId"] ?? "6ff89351-7fcc-4a41-8238-db65c5903c36",
    AzureIds.ClientId(builder.Configuration),
    identity: identity);
builder.Services.AddSingleton(source);
// Wired only where the connection string is: the app id has a default and
// is therefore no evidence at all that this build can read anything. The real
// clock is handed over here, which is the one place a clock belongs.
builder.Services.AddSingleton(new TelemetryReader(source, enabled: telemetryOn, TimeProvider.System));

Live from api/TheYard.Api/Shared/Wiring/TelemetryRegistration.cs, region telemetry, read from this build at 99df7a8.

// The last hour as Application Insights has it, for the Admin tab (ADR-024).
// Answers a shape the card can render even when telemetry is off or the query
// fails, because a panel that reports on the system must not be able to break
// the page it reports from.
app.MapGet("/api/admin/telemetry", AdminCostRoutes.Telemetry);

Live from api/TheYard.Api/Features/Admin/Operations/AdminEndpoints.cs, region telemetry-endpoint, read from this build at 99df7a8.

One query answers the whole card, because three questions in three round trips is three chances to time out (api/TheYard.Api/Shared/Observability/Telemetry.cs):

/// <summary>
/// One query, five answers, so the Admin card costs a single round trip:
/// how the last hour's requests went, the slowest routes, the exceptions,
/// how many browser errors arrived, and the newest request of the last day.
/// Several questions in several round trips would be several chances to
/// time out.
///
/// Three things here are not stylistic. `part` labels each block because
/// `kind` is a reserved word and a query using it does not parse. The
/// labels sit in `extend` rather than `summarize`, because summarize takes
/// aggregations only. And `success` is compared as text because the classic
/// Application Insights schema stores it as the string "True" while the
/// workspace schema stores a bool; comparing it to a bool is a 400 in one
/// of the two (ADR: Telemetry that outlives the container, second pass).
///
/// Every table is filtered to this site's cloud_RoleName when the site's
/// name is known, because both sites send to the same component; `site_role` is
/// empty when it is not known, and the filter then lets every row through.
/// Counts are sum(itemCount) rather than count(): the distro samples traces
/// by default, and a kept row stands for itemCount requests.
///
/// The newest request of the last day is how the card tells an empty hour
/// from a quiet site: a component at its daily data cap takes nothing more
/// until midnight UTC, and the card would otherwise read that as no traffic.
/// `newest_at` and not `last`: `last` does not parse.
/// </summary>
internal const string Query = """
    let lookback = 1h;
    let site_role = "__SITE__";
    let summary = requests
        | where timestamp > ago(lookback)
        | where isempty(site_role) or cloud_RoleName =~ site_role
        | summarize total = sum(itemCount), failed = sumif(itemCount, tostring(success) !in ("True", "true")),
                    p50 = percentile(duration, 50), p95 = percentile(duration, 95)
        | extend part = "requests", p50 = round(p50, 1), p95 = round(p95, 1)
        | project part, total, failed, p50, p95;
    let slowest = requests
        | where timestamp > ago(lookback)
        | where isempty(site_role) or cloud_RoleName =~ site_role
        | summarize calls = sum(itemCount), avg_ms = avg(duration) by route = name
        | top 5 by avg_ms desc
        | extend part = "slowest", avg_ms = round(avg_ms, 1)
        | project part, route, calls, avg_ms;
    let failures = exceptions
        | where timestamp > ago(lookback)
        | where isempty(site_role) or cloud_RoleName =~ site_role
        | extend err_type = tostring(type), err_method = tostring(method)
        | summarize hits = sum(itemCount), last_at = max(timestamp) by err_type, err_method
        | top 5 by last_at desc
        | extend part = "exception"
        | project part, err_type, err_method, hits, last_at;
    let browser = traces
        | where timestamp > ago(lookback)
        | where isempty(site_role) or cloud_RoleName =~ site_role
        | where message startswith "Browser error on"
        | summarize hits = sum(itemCount), last_at = max(timestamp)
        | extend part = "browser"
        | project part, hits, last_at;
    let newest = requests
        | where timestamp > ago(1d)
        | where isempty(site_role) or cloud_RoleName =~ site_role
        | summarize newest_at = max(timestamp)
        | extend part = "newest"
        | project part, newest_at;
    union summary, slowest, failures, browser, newest
    """;

/// <summary>The query with this site's name in place of the marker; empty when the name is not known.</summary>
internal static string QueryFor(string? siteName) => Query.Replace("__SITE__", siteName ?? "", StringComparison.Ordinal);

/// <summary>
/// An App Service site name is letters, digits and hyphens. Anything else
/// is not a site name, and it is never put into a query: the value goes
/// inside a Kusto string literal, so a quote in it would end the literal.
/// </summary>
internal static string? SiteNameOrNull(string? name) =>
    !string.IsNullOrWhiteSpace(name) && name.Length <= 60 && name.All(c => char.IsAsciiLetterOrDigit(c) || c == '-')
        ? name
        : null;

/// <summary>
/// Which requests the card's figures count, in words: this site alone when
/// its name is known, or every site that reports to the component when it
/// is not, so a figure from both sites is never read as one site's.
/// </summary>
internal static string ScopeFor(string? siteName) => siteName is null
    ? "Counts every site that reports to this Application Insights component: both sites share it, so these figures are both sites together."
    : $"Counts {siteName} only. The other site reports to the same Application Insights component and is left out.";

Live from api/TheYard.Api/Shared/Observability/Telemetry.Kql.cs, region kql, read from this build at 99df7a8.

/// <summary>
/// The last hour, as the Admin tab shows it: the kept answer while it is younger than
/// <see cref="GoodFor"/> on the handed clock, and otherwise one read of the component.
///
/// <para>Failures are kept like successes. Without that, a component that has gone unreachable
/// costs a full timeout on every request to a public, unauthenticated endpoint, and the answer
/// is the same every time anyway.</para>
/// </summary>
/// <param name="cancellation">Cancelled when the poll that asked has gone.</param>
public async Task<object> GetRecentAsync(CancellationToken cancellation)
{
    if (!Configured)
    {
        return new
        {
            configured = false,
            note = "Application Insights is not configured for this build. It is wired at deploy time from Azure; a local run reports nothing.",
        };
    }
    lock (_gate)
    {
        if (_cached is not null && clock.GetUtcNow() - _cachedAt < GoodFor)
        {
            return _cached;
        }
    }

    return Keep(await source.AskAsync(cancellation));
}

Live from api/TheYard.Api/Shared/Observability/Telemetry.cs, region read, read from this build at 99df7a8.

Kusto answers in columns and rows; the card wants objects. Reading each row by column name rather than position is what keeps a query edit from shifting every value silently:

/// <summary>
/// Kusto answers with columns and rows, not objects. This turns the one
/// table into the pieces the card renders, reading each row by the
/// column's name rather than its position, because a query edit that adds
/// a column would otherwise shift every value silently. A union pads the
/// columns a row does not have, so each branch reads only its own. The
/// site and the scope sentence say whose requests the figures are.
/// </summary>
internal static object Shape(JsonDocument body, string? siteName)
{
    var table = body.RootElement.GetProperty("tables")[0];
    var columns = table.GetProperty("columns").EnumerateArray()
        .Select((c, i) => (Name: c.GetProperty("name").GetString() ?? "", Index: i))
        .ToDictionary(c => c.Name, c => c.Index, StringComparer.Ordinal);

    string? Text(JsonElement row, string column) =>
        columns.TryGetValue(column, out int i) && row[i].ValueKind is not JsonValueKind.Null
            ? row[i].ToString()
            : null;

    double? Number(JsonElement row, string column) =>
        columns.TryGetValue(column, out int i) && row[i].ValueKind is JsonValueKind.Number
            ? row[i].GetDouble()
            : null;

    object? summary = null;
    object? browser = null;
    string? newest = null;
    var slowest = new List<object>();
    var exceptions = new List<object>();

    foreach (var row in table.GetProperty("rows").EnumerateArray())
    {
        switch (Text(row, "part"))
        {
            case "requests":
                summary = new
                {
                    total = (int)(Number(row, "total") ?? 0),
                    failed = (int)(Number(row, "failed") ?? 0),
                    p50_ms = Number(row, "p50"),
                    p95_ms = Number(row, "p95"),
                };
                break;
            case "slowest":
                slowest.Add(new
                {
                    name = Text(row, "route") ?? "",
                    calls = (int)(Number(row, "calls") ?? 0),
                    avg_ms = Number(row, "avg_ms"),
                });
                break;
            case "exception":
                exceptions.Add(new
                {
                    type = Text(row, "err_type") ?? "",
                    method = Text(row, "err_method") ?? "",
                    count = (int)(Number(row, "hits") ?? 0),
                    last_at = Text(row, "last_at") ?? "",
                });
                break;
            case "newest":
                newest = Text(row, "newest_at");
                break;
            case "browser":
                browser = new
                {
                    count = (int)(Number(row, "hits") ?? 0),
                    last_at = Text(row, "last_at") ?? "",
                };
                break;
        }
    }

    return new
    {
        configured = true,
        available = true,
        window = "the last hour",
        site = siteName,
        scope = TelemetryKql.ScopeFor(siteName),
        summary = summary ?? new { total = 0, failed = 0, p50_ms = (double?)null, p95_ms = (double?)null },
        slowest,
        exceptions,
        browser = browser ?? new { count = 0, last_at = "" },
        newest_request_at = newest,
    };
}

Live from api/TheYard.Api/Shared/Observability/Telemetry.Shape.cs, region shape, read from this build at 99df7a8.

The card, which renders every state the reader can answer with (src/components/admin/TelemetryCard/TelemetryCard.tsx, a chunk of its own since the workbench):

{/* Application Insights, read back through the container's own identity
            (ADR-024). Every state the reader can answer with is rendered here:
            not configured (a local run), configured but unreadable, and the
            happy path. A telemetry panel that can break the page it reports on
            would be worse than no panel. */}
<article className={`${styles.card} op-glass`} data-testid="telemetry-card">
  <h2 className={styles.cardTitle}>Traffic, last hour</h2>
  {telemetry === null ? (
    <CardState state="loading" />
  ) : telemetry === 'failed' ? (
    failed('the telemetry')
  ) : !telemetry.configured || telemetry.available === false ? (
    <p className={styles.muted} data-testid="telemetry-note">
      {telemetry.note}
    </p>
  ) : emptyHour !== null ? (
    <>
      {scopeLine(telemetry)}
      <p className={styles.muted} data-testid="telemetry-empty">
        {emptyHour}
      </p>
    </>
  ) : (
    <>
      {scopeLine(telemetry)}
      <div className={styles.statusRow}>
        <span className={pill((telemetry.summary?.failed ?? 0) === 0)}>
          {telemetry.summary?.total ?? 0} request
          {(telemetry.summary?.total ?? 0) === 1 ? '' : 's'}
        </span>
        <span className={styles.muted}>{telemetry.summary?.failed ?? 0} failed</span>
        <span className={styles.mono}>p50 {reading(telemetry.summary?.p50_ms)}</span>
        <span className={styles.mono}>p95 {reading(telemetry.summary?.p95_ms)}</span>
        {/* Every React error counts, so the count of them is on the card
                    rather than only in the portal. */}
        <span className={pill((telemetry.browser?.count ?? 0) === 0)}>
          {telemetry.browser?.count ?? 0} browser
        </span>
      </div>
      {telemetry.slowest && telemetry.slowest.length > 0 && (
        <p className={styles.muted}>Slowest routes, by average time</p>
      )}
      <ul className={styles.checkList}>
        {telemetry.slowest?.map((route) => (
          <li key={route.name} className={styles.checkRow} data-testid="telemetry-route">
            <span className={styles.mono}>{route.name}</span>
            <span className={styles.duration}>avg {reading(route.avg_ms)}</span>
            <span className={styles.muted}>
              {route.calls} call{route.calls === 1 ? '' : 's'}
            </span>
          </li>
        ))}
      </ul>
      {telemetry.exceptions && telemetry.exceptions.length > 0 && (
        <>
          <p className={styles.muted}>Exceptions</p>
          <ul className={styles.errorList}>
            {telemetry.exceptions.map((entry, index) => (
              <li key={index} className={styles.errorRow} data-testid="telemetry-exception">
                <span className={styles.mono}>{entry.type}</span>
                <span className={styles.muted}>{entry.method}</span>
                <span className={styles.muted}>
                  {entry.count} time{entry.count === 1 ? '' : 's'}
                </span>
              </li>
            ))}
          </ul>
        </>
      )}
    </>
  )}
</article>

Live from src/components/admin/TelemetryCard/TelemetryCard.tsx, region telemetry-card, read from this build at 99df7a8.

The container spec's placeholder, and the roll step that fills it in (infra/aci-theyard.yaml, .github/workflows/deploy.yml):

The container group file this showed live retired on 19 October with the container groups' last settings (ADR: One web app for every .NET process); it is kept at infra/aci-theyard.yaml at 22b3015, the last commit that carried it.

# A web app's settings live on the web app, so a roll is two calls: the
# four values the template does not hold, then the image
# (ADR: One plan, two sites). Both answer with -o none, because the first
# would otherwise print every setting the site holds into this log. The
# plan, the sites and every other setting are infra/appservice.bicep, and
# a roll changes none of them.
- name: Roll the site
  env:
    YARD_AUTH_SIGNING_KEY: ${{ secrets.YARD_AUTH_SIGNING_KEY }}
    ADMIN_KEY: ${{ secrets.ADMIN_KEY }}
    NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }}
    LINKEDIN_CLIENT_ID: ${{ secrets.LINKEDIN_CLIENT_ID }}
    LINKEDIN_CLIENT_SECRET: ${{ secrets.LINKEDIN_CLIENT_SECRET }}
  run: |
    # Resource Manager sometimes answers a write with a gateway error (BadGatewayConnection on
    # 1.0.3.182's roll of the SQL site); each write is tried three times, a minute apart, before
    # the roll is red, and the same write twice is the same setting (ADR: The deploy pipeline).
    arm() { for try in 1 2 3; do "$@" && return 0; echo "::warning::Resource Manager refused $1 $2 $3 $4, try $try of 3"; [ "$try" = 3 ] || sleep 60; done; return 1; }
    # The Application Insights connection string is an ingestion key, so it
    # lives only in Azure: read it here with the credential this job already
    # holds and mask it in the log. az resource show is core CLI; az monitor
    # app-insights would pull an extension at run time, which is a second
    # thing that can fail a deploy. Telemetry is an addition, not a
    # dependency: if the read fails, the site keeps the value it has and
    # still ships, because a deploy pipeline held hostage to its own
    # observability is worse than a quiet hour of no traces.
    CONN=$(az resource show -g "$RG" -n "$AI_NAME" \
      --resource-type "Microsoft.Insights/components" \
      --query "properties.ConnectionString" -o tsv 2>/dev/null || true)
    if [ -n "$CONN" ]; then
      echo "::add-mask::$CONN"
    fi
    # The database. The value names a server, a database and an
    # authentication mode; the credential is the site's managed identity,
    # which never leaves Azure. The name is composed rather than read back
    # from Azure: the first version of this asked `az sql server show`,
    # which this job's identity is not allowed to do, the call failed
    # silently, and 1.0.0.49 shipped on SQLite and said so. An Azure SQL
    # logical server's address is its name plus the service suffix. No
    # Connect Timeout, on purpose: YardConnection widens a timeout nobody
    # gave to sixty seconds, and a value given here wins over that
    # (ADR: The SQL Server backend).
    YARD_SQL=""
    if [ -n "$SQL_SERVER" ]; then
      YARD_SQL="Server=tcp:${SQL_SERVER}.database.windows.net,1433;Initial Catalog=${SQL_DB};Encrypt=True;TrustServerCertificate=False;Authentication=Active Directory Managed Identity;User Id=${MI_CLIENT_ID};"
    fi
    # #region secrets
    # The session signing key and the operator's key, from the repository
    # secrets of the same names, handed to the step through env and written
    # to a file by python, so neither is ever part of a command line and
    # neither appears in a log: GitHub masks them, and the settings call
    # prints nothing. A value this job does not hold is left out, and the
    # site keeps what it has: the template's placeholder on a new site,
    # which the app reads as "no key", or the last roll's value
    # (ADR: Three readers with no memory of the project; ADR: Site
    # activity, and the line an address does not cross).
    CONN="$CONN" YARD_SQL="$YARD_SQL" python3 - "$RUNNER_TEMP/settings.json" <<'PY'
    import json, os, sys
    wanted = {
        "APPLICATIONINSIGHTS_CONNECTION_STRING": os.environ.get("CONN", ""),
        "ConnectionStrings__YardSql": os.environ.get("YARD_SQL", ""),
        "Auth__SigningKey": os.environ.get("YARD_AUTH_SIGNING_KEY", ""),
        "Admin__Key": os.environ.get("ADMIN_KEY", ""),
    }
    # The Netlify token is optional: the edge card says in a sentence when
    # it is missing, so an unset secret is a plain line here, not a warning
    # (ADR: One frame for every resource).
    # The LinkedIn app's two values are optional too: until they exist the LinkedIn
    # posting card says "Not set up yet" (ADR: LinkedIn posting through the
    # self-serve API).
    optional = {
        "Netlify__Token": os.environ.get("NETLIFY_TOKEN", ""),
        "LinkedIn__ClientId": os.environ.get("LINKEDIN_CLIENT_ID", ""),
        "LinkedIn__ClientSecret": os.environ.get("LINKEDIN_CLIENT_SECRET", ""),
    }
    held = [{"name": name, "value": value, "slotSetting": False} for name, value in {**wanted, **optional}.items() if value]
    for name, value in wanted.items():
        if not value:
            print(f"::warning::{name} is not held by this job; the site keeps the value it has")
    for name, value in optional.items():
        if not value:
            print(f"{name} is not set; the card that reads it says so")
    json.dump(held, open(sys.argv[1], "w", encoding="utf-8"))
    print(f"{len(held)} of {len(wanted) + len(optional)} values go to the site (values masked)")
    PY
    # #endregion secrets
    if [ "$(cat "$RUNNER_TEMP/settings.json")" != "[]" ]; then
      arm az webapp config appsettings set -g "$RG" -n "$APP" --settings "@$RUNNER_TEMP/settings.json" -o none
    fi
    rm -f "$RUNNER_TEMP/settings.json"
    # The image is the only thing that changes between rolls. App Service
    # starts the new container beside the old one and moves traffic when
    # the new one answers, so the site serves through its own roll.
    # It is pulled from GitHub's registry, which serves a public package to
    # anyone, so the identity's registry pull is turned off in the same write
    # and no credential is stored (ADR-009, the addendum on rolling from it).
    arm az webapp config set -g "$RG" -n "$APP" --linux-fx-version "DOCKER|$GHCR_IMAGE" --generic-configurations '{"acrUseManagedIdentityCreds": false}' -o none
    az webapp show -g "$RG" -n "$APP" --query "{state:state, image:siteConfig.linuxFxVersion, host:defaultHostName}" -o json

Live from .github/workflows/deploy.yml, region roll, read from this build at 99df7a8.

What this cost, exactly

Two resources and one role assignment, all inside RG-THEYARD-SS, all additive. Nothing else in the group changed. Steve's authorization is recorded in the mentor notes with the scope it covers and the rollback, which is az monitor app-insights component delete and az monitor log-analytics workspace delete: the app runs unchanged without the connection string.

Consequences

  • The Admin tab now shows the last hour from a store that survives a roll, beside the in-memory buffer that does not. Both are on the page on purpose: one is durable and a minute stale, the other is immediate.
  • A trace id ties a ProblemDetails response (ADR: Error handling) to a request in the portal.
  • Telemetry is off in development and in CI, which is the right default and also means the tests prove the off path rather than the on path. The on path is proved from the domain after each deploy.
  • A deploy can now ship with telemetry off, and says so in the workflow log and on the Admin card. That is the intended failure, not a gap.
  • The reader caches for a minute. The Admin tab refreshes every thirty seconds and would otherwise ask Azure twice a minute forever for a page someone left open.
  • 30-day retention and a 0.1 GB daily cap are demo settings, not production ones. A real deployment would size both to its traffic and its audit needs, and would not put the Admin tab on a public route at all (ADR: Observability says why this one is).

Where it sits

Telemetry is a host concern and stays in the host Api, where Composition/TelemetryRegistration.cs adds the exporter only when a connection string is present and TelemetryReader in Telemetry.cs reads the last hour back for the Admin tab's TelemetryCard in the front end. Application and Domain never learn that Application Insights exists, which is the onion's dependency rule at work, and no SOLID principle is in play beyond that. It cost two Azure resources held to a 0.1 GB daily cap and one Monitoring Reader grant, plus a deploy that can ship with telemetry switched off. A site with real traffic would size retention and the cap to its load and take these readings off a public route.

Files

Addendum, 2026-11-07 (1.0.4.156): the box's routes are left out of the request telemetry

Until this version every request reached Application Insights. From it, every request under /api/admin/cloud/box/ is left out of the request telemetry through the distro's own filter (AspNetCoreTraceInstrumentationOptions.Filter, set in TelemetryRegistration.cs): the box's agent posts about forty-three thousand times a day, which would spend most of the component's 0.1 GB daily cap on itself (ADR: The box reports itself). Every other path is kept.

Addendum, 2026-11-16 (1.0.5.71): what fills the workspace, and what the site leaves out

In plain words: the log workspace's first 5 GB a month are free, and it was on course for about twice that. Most of it was not the site's visitors at all. The site now leaves out two kinds of line nothing reads, and the largest source, the job hunt's Function, has its own change with the lane that owns it.

Read live on 16 November from the workspace log-theyard-ss (the Usage table and each table by role, az monitor log-analytics query): about 0.34 GB a day billable, 0.332 GB on 15 November, so roughly 10 GB a month. Over seven days: traces 0.951 GB, metrics 0.661, dependencies 0.272, performance counters 0.178, requests 0.066. In one day the Function func-jobhunt-ss sent 147.2 MB of information-level traces, 96 % of all traces (its host's log level is Information for every category), and 28 MB of its health-check metric; the site sent 5.4 MB of traces, of which Entity Framework's line for every command was 4.1 MB, and about 34 MB of the HttpClient's connection-pool metrics (open connections 25.5 MB, active requests 5.7, connection duration 1.8, time in queue 1.4).

What changes here:

  1. The four connection-pool instruments are dropped with the distro's documented view (MetricStreamConfiguration.Drop). No card, alert or query reads them; the request durations stay.
  2. Entity Framework's command lines are filtered from the telemetry provider alone, below a warning. The Admin tab's rings and the kept log read the same lines through their own providers and keep them all.
  3. The Function's log levels are the job hunt's lane's file (functions/jobhunt/host.json), so the measurement and the ask went to that lane by a state.md row: Warning by default with the Function's own run lines kept, which the process table reads.

Together that is about 1.1 GB a month off the site's side and, once the Function's change lands, about 4.5 GB more, which brings the month under the free 5 GB without raising the component's cap, as Steve chose. TelemetryTrimTests holds the two lists.

Addendum, 2026-11-20 (1.0.5.139): the site's dependency rows, one in three, and a cancelled read is not an exception

In plain words: the site's own dependency rows were the largest single source in the workspace, 62.8 MB in the 24 hours to midday on 20 November (66,606 rows), against a December line of 0.167 GB a day for the whole workspace. And the Admin tab's failures list carried 237 TaskCanceledException rows in seven days for this web app, every one a card reader's own call that it cancelled at its time limit (Azure Monitor and Resource Manager reads at about 20 s, Log Analytics queries, Cosmos DB writes of kept card documents, the Function's health route at 10 s), none of them a request a visitor made.

What changes:

  1. One in three successful dependency calls is kept (TelemetrySampling, a processor added before the distro so it runs before the exporter). The choice is the call's own span id. Requests, exceptions and every failed call are left as the distro's own sampler leaves them: it already holds the whole site to five traces a second, which a few requests a minute never reach, though a burst of the card readers' background calls does (on 20 November the site's dependency rows carried sample rates from 100 down to 12.5 %). The exporter this site pins writes every kept row with an item count of one whatever rate it carries, so a count of the site's dependency rows is a count of the calls kept, now about a third. Every query the Admin tab runs against the dependency table is named in TelemetrySamplingTests: the reporters row needs which apps report, which the site's requests still answer, and counts rows by item count; the component's size reads billed bytes, which sampling lowers, as it should; a run's trace is the Function's, which is not sampled. The failures list and the telemetry card read requests and exceptions only.
  2. A cancelled call is a read that timed out, not an exception. The calls on the failures list ended Error with the runtime's error.type TaskCanceledException and an exception recorded on the span, which the exporter wrote as its own row. The HttpClient instrumentation no longer records an exception on a call itself: any other exception is recorded as before, and a cancellation is tagged theyard.read = timed out. A call that still carries a recorded exception after a cancellation, which no processor can take off a span, is not sent. The card that made the read already says in words that it is not read and why (the addendum of 1.0.4.87, "a read that times out is a gap, not a 500").

No daily cap is the fix: a cap drops errors with everything else. TelemetrySamplingTests holds both.

Enforced by

One rule in the rulebook cites this record, each held by a test on every release.

The rule What holds it In the last gate
The site keeps one in three of its successful dependency calls, chosen by the span id, and samples no request, exception or failed call; a call cancelled at its reader's time limit is tagged as a read that timed out and never written as an exception; every Admin query on the dependency table is named with what it needs TelemetrySamplingTests 38 of 38 passed
Store

The Yard, home

Steven StoutStaff .NET engineerRemote

Production .NET that stays up. Built with AI, measured on every version.

Steven Stout

Hi, I'm Steve. I build the systems that make delivery boring in the best way, then coach people inside them.

  • 200+

    production releases, none took the platform down

    Conway Investment Research, 2019 to 2024. Sole engineer for the first three years on a live financial advisory platform.

    See how
  • 50%

    shorter release cycle

    Storee Construction, 2024 to 2026. Four ASP.NET applications onto one .NET 10 platform on Azure, with a four-person team I hired and mentored.

    See how

01Verified

Steven Stout

A real person, and the work is mine.

  • Identity

    Checked by LinkedIn, not by me.

    LinkedIn verified my government ID.

  • Running system

    You are looking at it.

    Version 1.0.5.273 is live. Nothing ships unless it passes the automated gates first.

That's who I am. Here's how I work.

02Strengths

Ten strengths, each with the proof beside it. The numbers match my resume and LinkedIn, and the live ones are read from this site as you look.

  • 01

    Keeps production alive

    200+ releases on a live financial platform, and none took it down. Sole engineer for the first three years.

    See the Conway work

  • 02

    Simplifies messy systems

    Four ASP.NET applications onto one .NET 10 platform on Azure, and a release cycle 50% shorter.

    See the Storee work

  • 03

    Marries dev and infrastructure

    Blue-green releases at Storee that flipped in about 5 seconds with nobody signed out, and Azure Front Door at two employers.

    See this site's cloud

  • 04

    Designs data that holds up

    White-label clients on one shared database, the isolation built into the data, and no cross-client issues.

    See the Conway work

  • 05

    Keeps AI-written code honest

    15 quality numbers that may only improve: 273 releases in a row with none worse.

    See the quality numbers

  • 06

    Resourceful

    $30,000+ cut from Azure and vendor spend at Conway. This site's Azure bill is public, resource by resource.

    See the bill

  • 07

    Builds people up

    Hired and mentored a four-person team. 13 colleagues recommend me by name.

    Read the recommendations

  • 08

    Takes ideas to production

    This site: designed, built and run solo, with 352 versions measured through one gate.

    How it was built

  • 09

    Writes clearly

    Posts on real engineering problems, in plain words.

    Read the blog

  • 10

    Owns decisions

    153 decision records, each with its tradeoff and the call I made.

    See the decision records

Built with AI. Gated so quality never slides.

Steven Stout’s showcase: a used-vehicle auction on .NET and React, built and run by one engineer, live on Azure, with its decisions written down.

No quality number has gotten worse at any release since 1.0.5.1 on 10 November: 273 releases in a row.

One engineer, an AI agent and a gate that checks 15 quality numbers on every release. 352 versions measured, with every result public, the worst days included.

82 releases in the last 7 days, each through the same gate.

Async methods with no CancellationToken, may only fall

11091.0.3.1391.0.5.2731.0.4.115, the ratchet
Every number, on the Quality page

TheYard, right nowLive

Answering in

unread

02505007501,000

server time at p95, the usual five minutes of the last day.

Azure this month

unread

the bill, by resource, read from Azure. The Admin tab shows every line.

Since the last roll

unread

 

rolled in place by the pipeline, behind one gate.

People who have visited

unread

30 days agotoday

Scanners, my own tools' and my own reads left out.

03Start here

04Where teams are heading

How I see engineering with AI, and the setup on this site that backs it.

AI-augmented teams · Architecture and ownership

AI writes more of the code. Someone still has to own what ships.

Teams are going to be heavily AI-augmented. That moves the senior job toward architecture and technical ownership: deciding what to build in pieces small enough to verify, and owning what ships.

  • Task tracking will get automated too. Judgment stays human: seeing a design fail at scale before it does.
  • On this site the AI's first design held the whole catalogue in memory. I caught it when the App Service plan hit 82 per cent and moved the work to the store.

What the AI wrote, what I decided

07Tech stack

  •    
  •    
  •    

Read from the build, never typed by hand

What TheYard runs on

What we use, where it runs, its AWS twin, the version as built, and the file that proves it.

Cloud patterns, not one vendor: every Azure piece in this stack has a named AWS twin. Mapped, not yet run on AWS.

  • .NET 1114 projects
  • React 19.3TypeScript 7.0
  • Azure9 Bicep files
  • 11GitHub Actions workflows
The whole stack, with the file that proves each line

The last release the gate stopped was 1.0.5.258 on 2 December, at its browser 1 of 2 job.

08How it is built

09How it is run

10Who and why

Next step

11What has to work, where is it today, and what does success look like?

Book 20 minutes opens an email to me with those three questions in it, and I answer with a time.

Book 20 minutes

Your email app should have opened with this message. If it did not, copy it and send it from any mailbox.

Or message me on LinkedIn