Skip to content

Add metrics for easier benchmarking and performance monitoring#1477

Merged
tillig merged 15 commits intodevelopfrom
feature/metrics
Feb 27, 2026
Merged

Add metrics for easier benchmarking and performance monitoring#1477
tillig merged 15 commits intodevelopfrom
feature/metrics

Conversation

@tillig
Copy link
Member

@tillig tillig commented Feb 26, 2026

This adds some metrics to Autofac that can be enabled by setting the environment variable AUTOFAC_METRICS to 1 or true. Doing this will enable counters that indicate how long various things like middleware and operations take as well as information on lock contentions.

The benchmarking project has also been updated to more easily be run so it can compare the current source branch against a baseline version by specifying a released NuGet version of Autofac as a comparison.

@tillig tillig marked this pull request as ready for review February 26, 2026 23:45
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 48.92704% with 119 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.17%. Comparing base (40d167b) to head (5aaee7b).
⚠️ Report is 16 commits behind head on develop.

Files with missing lines Patch % Lines
...atures/Collections/CollectionRegistrationSource.cs 40.90% 10 Missing and 3 partials ⚠️
.../Core/Activators/Reflection/ReflectionActivator.cs 60.00% 6 Missing and 6 partials ⚠️
...Middleware/CircularDependencyDetectorMiddleware.cs 38.88% 8 Missing and 3 partials ⚠️
src/Autofac/Core/Lifetime/LifetimeScope.cs 50.00% 6 Missing and 4 partials ⚠️
...ctivators/Reflection/AutowiringPropertyInjector.cs 38.46% 6 Missing and 2 partials ⚠️
...c/Core/Resolving/Middleware/StartableMiddleware.cs 20.00% 7 Missing and 1 partial ⚠️
...Resolving/Middleware/DisposalTrackingMiddleware.cs 30.00% 6 Missing and 1 partial ⚠️
...e/Resolving/Middleware/ScopeSelectionMiddleware.cs 30.00% 6 Missing and 1 partial ⚠️
...fac/Core/Resolving/Middleware/SharingMiddleware.cs 30.00% 6 Missing and 1 partial ⚠️
...Autofac/Features/Decorators/DecoratorMiddleware.cs 30.00% 6 Missing and 1 partial ⚠️
... and 5 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1477      +/-   ##
===========================================
- Coverage    78.55%   77.17%   -1.39%     
===========================================
  Files          216      216              
  Lines         5604     5782     +178     
  Branches      1209     1240      +31     
===========================================
+ Hits          4402     4462      +60     
- Misses         695      786      +91     
- Partials       507      534      +27     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant