Skip to content

Trace, measure and log every invocation over OpenTelemetry - #38

Merged
stphnwlsh merged 2 commits into
mainfrom
feature/telemetry
Nov 4, 2026
Merged

stphnwlsh merged 2 commits into
mainfrom
feature/telemetry

Conversation

@stphnwlsh

@stphnwlsh stphnwlsh commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Every invocation now runs inside a span from the OpenTelemetry Lambda wrapper (OpenTelemetry.Instrumentation.AWSLambda), with the use case beneath it, and traces and metrics are flushed before the function returns, because Lambda can freeze the environment the moment it does. Logs still go to the console as compact JSON for CloudWatch, and also leave over OTLP, with the traces and metrics, whenever OTEL_EXPORTER_OTLP_ENDPOINT is set. Docker Compose adds an OpenTelemetry Collector and the Aspire dashboard beside the emulator, and the docs explain how to run a collector in AWS (the ADOT extension built into the image, since container images can't use layers, or a gateway).

  • Application and Infrastructure: identical to the Minimal API change (the use case span in LoggingBehaviour, and EF Core's built-in meter).
  • Presentation: the tracer and meter providers are built once in Startup with the SDK builders, because the generated classes build two service providers from the same services and AddOpenTelemetry() would export everything twice. X-Ray context extraction is off, so Lambda's "not sampled" header can't switch tracing off. Runtime metrics and service.version on everything.
  • otel-collector.yaml ships in the template package.
  • New telemetry skill, with a Lambda section and a watch list. serilog, mediator, docker-and-compose, health-checks, optional-token-auth, configuration-and-environments and lambda-emulator 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).

Each invocation runs inside the OpenTelemetry Lambda wrapper's span, and
traces and metrics are flushed before the function returns. 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
over OTLP as well as to the console when OTEL_EXPORTER_OTLP_ENDPOINT is
set. Docker Compose adds an OpenTelemetry Collector and the Aspire
dashboard beside the emulator.
@github-actions github-actions Bot added enhancement New feature or request build labels Nov 4, 2026
@stphnwlsh stphnwlsh added the documentation Improvements or additions to documentation label 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

Build Pipeline

✅ Ready to merge. Every stage passed.

Stage Result Details
Build 🟢 Passed Version 2026.11.04.133-pr-38 · Template package 196 KB
Test 🟢 Passed 180 passed · 0 failed · 0 skipped · Template installs, builds and passes its tests
Coverage 🟢 Passed 100% (657 of 657 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 · 3 open Trivy alerts, none blocking: 1 medium, 1 low, 1 note · 1 ignored in .trivyignore

Commit 068d9e1 · Full run

Drop the database command interceptor until the EF Core instrumentation is
stable, and drop the telemetry behaviour and its metrics, which repeated what
the ASP.NET Core instrumentation already records. LoggingBehaviour now starts
the use case span, so there's one timer and Application needs no package.
@stphnwlsh
stphnwlsh merged commit d488796 into main Nov 4, 2026
13 checks passed
@stphnwlsh
stphnwlsh deleted the feature/telemetry branch November 4, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant