Skip to content

Target net10.0 and net11.0, fix HTTP and header bugs, run CI on every PR - #14

Merged
ardalis merged 1 commit into
mainfrom
claude/blissful-turing-5krinm
Nov 20, 2026
Merged

ardalis merged 1 commit into
mainfrom
claude/blissful-turing-5krinm

Conversation

@ardalis

@ardalis ardalis commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Retargets the package to .NET 10 and 11, fixes several bugs in HTTP tracking and the response header, and makes CI run on every pull request.

Platform

  • Targets: the library and tests now target net10.0;net11.0. .NET 8 and 9 reached end of support on Nov 10, 2026. The sample targets net10.0.
  • Dependencies:
    • Replaces the deprecated Microsoft.AspNetCore.Http.Abstractions 2.2.0 with <FrameworkReference Include="Microsoft.AspNetCore.App" />. That also covers the DI and Microsoft.Extensions.Http references, so those are removed.
    • EF Core Relational is now 10.0.0 or 11.0.0 depending on the framework, Dapper is 2.1.100, and SourceLink is updated.
  • Version: bumped to 0.5.0, with new release notes. This is also the first release that will include the Dapper support from Add Dapper extensions that track db calls #13.

Bug fixes

  • IHttpContextAccessor wasn't registered. AddMetronome() now registers it. Before this, any app without Identity failed with an exception on its first tracked HTTP call.
  • HTTP calls outside a request threw NullReferenceException. Calls from hosted services or startup code are now sent without being counted.
  • Concurrent HTTP calls could lose counts. HttpCallCounter now records under a lock, as DbCallCounter already does. The handler is registered as transient, which is what IHttpClientFactory expects.
  • Malformed header. The stray HttpCallCount: n at the end of the header is gone. Numbers use the invariant culture, so a de-DE server no longer writes 6,4678ms. The header is set rather than Added, so a duplicate no longer throws.
  • Logging: log messages use structured templates instead of string interpolation.
  • Namespace: DbCallCountingInterceptor was in the global namespace and is now in NimblePros.Metronome. Its nullability warnings are fixed.

Behavior to check

  • Possible breaking change: code that referred to DbCallCountingInterceptor by name needs using NimblePros.Metronome;. Code that goes through AddMetronomeDbTracking is unaffected.
  • Header contents: the header no longer has the trailing text, so anything that parsed the old format will see a different value.
  • README: now says that AddDbContextPool and AddDbContextFactory aren't supported, and that HTTP calls outside a request aren't counted.

CI

  • Triggers: removed the paths: filter, so every push and PR to main is built. Before this, changes to the sample or the workflows never ran CI. No runs at all show up for this repository, so if this PR doesn't start a run, check Settings → Actions.
  • Steps: both workflows install the 10.x and 11.x SDKs and test both frameworks. CI also packs and uploads the .nupkg. The release workflow pushes with --skip-duplicate. Both workflows have permissions: contents: read.
  • README: added CI and NuGet badges.

Testing

  • dotnet build, dotnet test and dotnet pack on ci.slnf succeed with SDKs 10.0.404 and 11.0.100. All 24 tests pass on both net10.0 and net11.0, and the library builds with no warnings.
  • The new MetronomeIntegrationTests run a minimal API app on a TestServer without Identity. They cover:
    • the header format and per-request counts
    • 50 concurrent HTTP calls
    • EF Core calls through the interceptor
    • an HTTP call made outside a request
    • structured log values
    • invariant-culture formatting
  • With the AddHttpContextAccessor() line removed, 3 of these tests fail, so they catch the original bug.
  • The sample runs on net10.0. /dapper returns NimblePros.Metronome: DbCallCount=1;DbCallDuration=0.2749ms;HttpCallCount=0;HttpCallDuration=0ms.

Generated by Claude Code

- Multi-target net10.0 and net11.0 (.NET 8 and 9 are out of support).
  Replace the deprecated Microsoft.AspNetCore.Http.Abstractions 2.2.0
  package with a framework reference and update dependencies.
- AddMetronome() now registers IHttpContextAccessor, so apps that don't
  use Identity no longer fail on the first tracked HTTP call.
- HttpCallCountingHandler passes calls made outside a request through
  untracked instead of throwing NullReferenceException, and is registered
  as transient.
- HttpCallCounter records calls under a lock, like DbCallCounter, so
  concurrent HTTP calls are all counted.
- Fix the response header: drop the stray trailing text, format numbers
  with the invariant culture, and set rather than Add the header.
- Use structured log message templates.
- Move DbCallCountingInterceptor into the NimblePros.Metronome namespace
  and fix its nullability warnings.
- Add integration tests for the middleware, HTTP handler and EF Core
  interceptor on a TestServer app without Identity.
- CI: drop the paths filter so every PR to main is built, install the
  .NET 10 and 11 SDKs, test both frameworks and upload the package.
- Bump to 0.5.0 and update the README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014WE1LzSNPYAu6PDCk7wEEo
@ardalis
ardalis merged commit d923939 into main Nov 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants