Skip to content

Trace, measure and log every request over OpenTelemetry - #39

Open
stphnwlsh wants to merge 3 commits into
mainfrom
feature/telemetry
Open

stphnwlsh wants to merge 3 commits into
mainfrom
feature/telemetry

Conversation

@stphnwlsh

@stphnwlsh stphnwlsh commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Traces, metrics and logs now leave the server over OTLP, and only OTLP, whenever OTEL_EXPORTER_OTLP_ENDPOINT is set. The MCP SDK's own Experimental.ModelContextProtocol spans and metrics are switched on, so a tool call reads as one trace from the HTTP request through the tool, the use case and every SQL command. Every use case gets a span and two metrics from the shared TelemetryBehaviour, every SQL command gets a span from a small EF Core interceptor (the official EF Core instrumentation is still prerelease), and Serilog sends its logs with the trace they belong to. Docker Compose swaps Seq for an OpenTelemetry Collector that forwards to the Aspire dashboard container, and Aspire appears nowhere else. Version info was already behind auth here, so the server info now just carries the real version.

  • Application and Infrastructure: identical to the Minimal API change (TelemetryBehaviour, DatabaseCommandInterceptor, EF Core's built-in meter).
  • Presentation: MCP SDK, ASP.NET Core, HttpClient, runtime and auth instrumentation, exemplars, health endpoints left out of traces, service.version on everything. EF Core command logs drop to Warning, since each command has a span now.
  • otel-collector.yaml (OTLP receiver, memory limiter, batch, one exporter to swap for a real backend) ships in the template package.
  • New telemetry skill, with a watch list for EF Core instrumentation, profiles and the events API. serilog, mediator, docker-and-compose, health-checks, optional-token-auth, configuration-and-environments and mcp-inspector updated.

Type of change

  • Bug fix
  • New feature
  • Breaking change (the generated solution or template parameters change in a way existing users will notice)
  • Refactoring or clean-up
  • Documentation
  • Build, pipeline or dependency update

Shared layers

  • This only touches the Presentation layer of this template.
  • This touches the Application or Infrastructure layers, tests, pipeline or repository setup, so it needs to be carried across all five templates.

Checklist

  • dotnet build and dotnet test pass locally with no warnings.
  • I added or updated tests, and line coverage stays at or above 95%.
  • I updated the README or docs where behaviour changed.
  • If this changes how we do something, I updated the matching skill in .agents/skills.
  • I checked the template still installs and creates a working solution (see CONTRIBUTING.md).

Traces, metrics and logs leave over OTLP when OTEL_EXPORTER_OTLP_ENDPOINT
is set. A TelemetryBehaviour gives every use case a span and two metrics,
a command interceptor gives every SQL command a span, and Serilog sends
its logs with the trace they belong to. The MCP SDK's own spans and
metrics are switched on, so a tool call reads as one trace. Docker
Compose swaps Seq for an OpenTelemetry Collector that forwards to the
Aspire dashboard.
@github-actions github-actions Bot added enhancement New feature or request build labels Nov 4, 2026
@stphnwlsh stphnwlsh added documentation Improvements or additions to documentation breaking-change labels Nov 4, 2026 — with Claude
@stphnwlsh stphnwlsh self-assigned this Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Build Pipeline

✅ Ready to merge. Every stage passed.

Stage Result Details
Build 🟢 Passed Version 2026.11.04.152-pr-39 · Template package 229 KB
Test 🟢 Passed 265 passed · 0 failed · 0 skipped · Template installs, builds and passes its tests
Coverage 🟢 Passed 99.56% (914 of 918 lines) · Needs 95%
Static Analysis 🟢 Passed No open CodeQL alerts
Dependency Review 🟢 Passed 0 vulnerable packages · 0 licence problems
Container Scan 🟢 Passed Image starts and answers · No open Trivy alerts

Commit 6136dbf · Full run

Keeps the telemetry and serilog skills identical across the five templates.
The test server can return the response a moment before the ASP.NET Core request span stops, which failed the trace test in the template verification run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change build documentation Improvements or additions to documentation enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

1 participant