liveBook · Manning

Chapter 6: Integration testing and monitoring

What you will learn in chapter 6 of Building Distributed Applications that Work

The chapter introduction explains why monitoring a running application matters and places it alongside predeployment testing as a way to improve resilience.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduction explains why monitoring a running application matters and places it alongside predeployment testing as a way to improve resilience.

Key terms: monitoring, reliability, availability, uptime, response times, error rates, CPU use, memory use, capacity planning, right-size

6.1 Components of monitoring systems

Introduces logging, metrics, and traces as distinct components that make distributed applications observable.

Key terms: logging, metrics, traces, monitoring systems

6.1.1 Logging

This section explains what application logging records, how those records help troubleshooting, and where logs can be stored.

Key terms: logging, logs, diagnostic information, log entries, timestamps, severity levels, centralized logging platforms

6.1.2 Metrics

Defines metrics as regularly collected numerical measurements and explains how they help monitor application and system performance over time.

Key terms: metrics, performance, resource use, throughput, error rates

6.1.3 Traces

This section explains how traces show a request’s path through a distributed system and how spans make that path useful for diagnosing performance.

Key terms: trace, end-to-end visibility, service dependencies, bottlenecks, spans, timing information, contextual data, metadata

6.2 Monitoring Aspire applications

This section explains why Aspire uses OpenTelemetry for monitoring and what the standard Service Defaults monitoring dependencies do.

Key terms: OpenTelemetry, metrics, traces, logs, vendor-agnostic, Service Defaults, OpenTelemetry.Exporter.OpenTelemetryProtocol, OTLP exporter, OpenTelemetry.Extensions.Hosting, OpenTelemetry.Instrumentation.AspNetCore

6.3 Configuring the telemetry

This section explains how the ServiceDefaults project configures OpenTelemetry collection and export for an orchestrated application.

Key terms: OnlineShop.ServiceDefaults, OpenTelemetry logging, metrics, traces, AddOpenTelemetryExporters(), OTEL_EXPORTER_OTLP_ENDPOINT, OpenTelemetry endpoint, telemetry exporters

6.4 Viewing information in the dashboard

The section shows where to view an Aspire application's telemetry in the dashboard and explains why those views do not establish whether services are healthy right now.

Key terms: Aspire dashboard, Console tab, Structured tab, Traces tab, Metrics tab, OpenTelemetry, logging, traces, metrics

6.5 Health checks in Aspire

This section explains why an orchestrator should assess microservice health to keep a distributed system reliable, efficient, and observable.

Key terms: health assessment, automatic recovery, fault tolerance, orchestrator, dynamic scaling, optimized resource allocation, SLA enforcement, enhanced observability, health metrics, status information

6.5.1 Service statuses in Aspire’s dashboard

This section shows how Aspire displays service status, checks service health through an endpoint, and uses health checks to delay dependent services until a dependency is healthy.

Key terms: Resources tab, State column, Running, health-check endpoint, WithHttpHealthCheck(), /health, WithReference(), WaitFor(), Healthy, Unhealthy

6.5.2 How health checks are configured inside Aspire apps

This section explains how the Aspire Starter Project registers a basic health check and what its healthy response does—and does not—indicate.

Key terms: AddDefaultHealthChecks(), AddHealthChecks(), AddCheck(), Services, health-check endpoint, healthy status, Aspire orchestrator

6.5.3 Mapping health-check endpoints

This section explains how Aspire maps health-check HTTP endpoints and how the /alive endpoint checks for a live tag.

Key terms: MapDefaultEndpoints(), MapHealthChecks(), /health, AlivenessEndpointPath, /alive, live tag, orchestrator

6.5.4 Monitoring app health in production

Explains why Aspire health checks should remain available in production, what to consider when exposing their endpoints, and how health checks differ from tests.

Key terms: health-check endpoints, development environment condition, production environment, appropriate protections, health-check logic, health checks, tests, real-time state

6.6 Setting up integration tests in Aspire

This section explains why automated integration tests matter for distributed applications and why Aspire makes them easier to run.

Key terms: automated tests, test coverage, test-driven development (TDD), integration tests, components, real HTTP requests, real database connections, orchestrated distributed applications, integration testing project, component/unit tests

6.6.1 Adding a test project

This section outlines ways to add an Aspire integration test project and explains that Aspire testing is not tied to one test framework.

Key terms: Create Test Project, Aspire Starter Project, .NET CLI, xUnit, NUnit, MSTest, framework-agnostic, Aspire integration testing

6.6.2 Installing required dependencies for testing

This section identifies the package and project references needed to prepare an Aspire integration-test project.

Key terms: OnlineShop.Tests, Aspire.Hosting.Testing, OnlineShop.AppHost, xUnit, NUnit, MSTest

6.6.3 Adding Aspire integration tests

The section walks through an Aspire integration test that starts the application, requests the web frontend, and checks its response.

Key terms: arrange-act-assert, DistributedApplicationTestingBuilder, CreateAsync<T>(), Projects.OnlineShop_AppHost, await using, HttpClient, Aspire service discovery, webfrontend, HTTP GET, OK (200)

6.6.4 Using different testing frameworks

Shows how to use NUnit or MSTest for the same Aspire integration test by changing framework-specific test attributes and assertions.

Key terms: xUnit, NUnit, MSTest, [Fact], [Test], [TestMethod]

6.6.5 Expanding test functionality

This section improves an Aspire integration test by checking the content of a products page as well as its HTTP response status.

Key terms: HTTP response, 200 response code, page content, AngleSharp, HTTP response object, h1 HTML element, Products title

6.6.6 What about component testing?

This section explains why component tests complement integration tests and uses bUnit tests of a Blazor Counter page to show the behavior they can check.

Key terms: component tests, integration tests, real networking, Bunit, Bunit.TestDoubles, AngleSharp, NuGet packages, Counter page, CounterStartsAtZero(), ClickingButtonIncrementsCounter()

6.7 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 5: Building a ChatGPT clone with Aspire, Ollama, and Semantic Kernel Chapter 7: Components for messaging and caching →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.