30538b7262
Preserve legacy profiler contracts and record expected cancellation below error level.
33 lines
1.8 KiB
Markdown
33 lines
1.8 KiB
Markdown
# HrynCo.Common
|
|
|
|
Shared common utilities for HrynCo applications.
|
|
|
|
## Contents
|
|
|
|
- Configuration helpers
|
|
- Health checks
|
|
- Caching helpers
|
|
- Security helpers
|
|
- Tree traversal helpers
|
|
- Time and profiling helpers
|
|
|
|
## Profiling and cancellation
|
|
|
|
`IProfiler.MeasureExecutionAsync` supports both result-returning and action delegates. Existing overloads keep their original behavior. Pass a cancellation token as the third argument when profiling work associated with a request:
|
|
|
|
```csharp
|
|
await profiler.MeasureExecutionAsync(() => LoadItemsAsync(cancellationToken), "LoadItems", cancellationToken);
|
|
```
|
|
|
|
If the delegate throws `OperationCanceledException` (including `TaskCanceledException`) and the supplied token is canceled, the profiler writes a Debug cancellation event with `PerformanceLog = true` and no attached exception, then rethrows the original exception. An `OperationCanceledException` with an uncanceled or absent token, and any other exception even with a canceled token, remain Error events with the exception attached. Failed or canceled operations do not write a successful End measurement.
|
|
|
|
The supplied token controls log classification; the caller must pass it to the operation itself. The profiler does not cancel the delegate or reject successful work when the token is canceled.
|
|
|
|
Custom implementations of `IProfiler` that implement only the original overloads remain compatible. The new interface overloads default to the original methods; custom implementations must override them to add token-aware log classification.
|
|
|
|
## Packaging
|
|
|
|
This package is intended for reuse through NuGet. The test project is excluded from packing.
|
|
|
|
Package repository metadata points to [HrynCo.Common on Gitea](https://gitea.hrynco.com/hrynco/hrynco-common). The registry hostname change does not alter package versions or runtime behavior.
|