MethodWatch 1.1.0
Additional Details
Deleted
dotnet add package MethodWatch --version 1.1.0
NuGet\Install-Package MethodWatch -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MethodWatch" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MethodWatch" Version="1.1.0" />
<PackageReference Include="MethodWatch" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MethodWatch --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MethodWatch, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MethodWatch@1.1.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MethodWatch&version=1.1.0
#tool nuget:?package=MethodWatch&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MethodWatch
A lightweight .NET library for method execution time monitoring and logging with customizable thresholds and real-time statistics.
Installation
Core Package
dotnet add package MethodWatch
Web Interface Package (Optional)
dotnet add package MethodWatch.Web
Usage
1. Basic Usage with Core Package
// In Program.cs or Startup.cs
using MethodWatch;
// Initialize with logging
builder.Services.AddLogging();
MethodWatch.Initialize(builder.Services.BuildServiceProvider().GetRequiredService<ILoggerFactory>());
// Optionally enable statistics
MethodWatch.Initialize(builder.Services.BuildServiceProvider().GetRequiredService<ILoggerFactory>(), enableStatistics: true);
Add the attribute to methods you want to monitor:
[MethodWatch]
public async Task<string> GetDataAsync()
{
// Your method implementation
}
// With custom threshold (in milliseconds)
[MethodWatch(thresholdMs: 500)]
public async Task ProcessDataAsync()
{
// Your method implementation
}
// With custom name and threshold
[MethodWatch("ProcessData", 500)]
public async Task ProcessDataAsync()
{
// Your method implementation
}
2. Using the Web Interface
If you want to visualize method execution statistics, add the web interface:
// In Program.cs
using MethodWatch.Web;
// Add MethodWatch services
builder.Services.AddMethodWatch();
// Add the web interface
builder.Services.AddMethodWatchWeb();
var app = builder.Build();
// Map the web interface endpoint
app.MapMethodWatchWeb();
Then access the statistics dashboard at:
http://your-app/methodwatch.html
3. Advanced Configuration
Core Package Options
[MethodWatch(
Name = "CustomName", // Custom name for the method
ThresholdMs = 1000, // Warning threshold in milliseconds
LogParameters = true, // Log method parameters
LogResult = true, // Log method result
LogStatistics = true // Log statistics with each execution
)]
public async Task MyMethod()
{
// Your method implementation
}
Web Interface Features
The web interface provides:
- Real-time method execution statistics
- Execution time trends
- Success/failure rates
- Parameter and result logging
- Customizable thresholds
Features
- Method execution time monitoring
- Customizable warning thresholds
- Parameter and result logging
- Real-time statistics
- Web-based dashboard
- Lightweight and non-intrusive
- Thread-safe implementation
Requirements
- .NET 9.0 or later
- For web interface: ASP.NET Core
License
MIT License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- Microsoft.AspNetCore.Mvc (>= 2.2.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MethodWatch:
Package | Downloads |
---|---|
MethodWatch.Web
Web interface for MethodWatch statistics |
GitHub repositories
This package is not used by any popular GitHub repositories.