Lyo.Diagnostic
2.0.0
dotnet add package Lyo.Diagnostic --version 2.0.0
NuGet\Install-Package Lyo.Diagnostic -Version 2.0.0
<PackageReference Include="Lyo.Diagnostic" Version="2.0.0" />
<PackageVersion Include="Lyo.Diagnostic" Version="2.0.0" />
<PackageReference Include="Lyo.Diagnostic" />
paket add Lyo.Diagnostic --version 2.0.0
#r "nuget: Lyo.Diagnostic, 2.0.0"
#:package Lyo.Diagnostic@2.0.0
#addin nuget:?package=Lyo.Diagnostic&version=2.0.0
#tool nuget:?package=Lyo.Diagnostic&version=2.0.0
Lyo.Diagnostic
Decode stack traces, classify exceptions, keep breadcrumb trails, hold an in-memory error inbox, sanitise output, and write structured logs.
Source is grouped by feature folder. Namespaces match, for example StackTrace/ maps to Lyo.Diagnostic.StackTrace. The root Lyo.Diagnostic namespace holds AddDiagnosticsPackage in Registration/. Package metadata DTOs and IPackageMetadataStore live in Lyo.PackageMetadata.
| Folder | Namespace | |-------------------|---------------------------------| | StackTrace/ | Lyo.Diagnostic.StackTrace | | Classification/ | Lyo.Diagnostic.Classification | | Context/ | Lyo.Diagnostic.Context | | Breadcrumbs/ | Lyo.Diagnostic.Breadcrumbs | | Inbox/ | Lyo.Diagnostic.Inbox | | Logging/ | Lyo.Diagnostic.Logging | | Sanitisation/ | Lyo.Diagnostic.Sanitisation | | Registration/ | Lyo.Diagnostic |
Examples
Register in DI
using Lyo.Diagnostic;
using Lyo.Diagnostic.Inbox;
services.AddDiagnosticsPackage();
services.AddInMemoryErrorInbox(o => o.MaxOccurrences = 5_000);
Optional package metadata store (IPackageMetadataStore)
using Lyo.Diagnostic;
using Lyo.PackageMetadata;
var store = new InMemoryPackageMetadataStore();
store.Register(["Npgsql."], new PackageMetadata(
Guid.Parse("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"),
PackageEcosystem.NuGet,
"Npgsql",
Version: "8.0.0",
ArtifactDigestAlgorithm.Sha512,
PackageArtifactDigest.ComputeHexSha512(System.Array.Empty<byte>())));
services.AddDiagnosticsPackage(packageMetadataStore: store);
What ships in the package
- Stack trace decoding (
IStackTraceDecoder). Frames, crash site, fingerprint (stable hash of user-frame method signatures). OptionalIPackageMetadataStorefromLyo.PackageMetadataenriches frames withPackageMetadata(Id+Name, …). With a configured store,IDiagnosticContextBuilder.BuildAsync/DecodeAsyncperform one bulk metadata resolve for the entire exception/textual inner stack-tree (embedded inner blocks and chainedInnerException), not once per subtree. SyncBuild/Decodethrow when a store is set. - Classification (
IExceptionClassifier). Severity, kind, labels. - Diagnostic context (
IDiagnosticContextBuilder). One payload for a single failure. - Structured logging (
IStructuredLogEnricher).ILoggerscopes withdiag.*properties. - Trace sanitisation (
ITraceSanitiser). Redact PII/paths before API responses or logs. - Breadcrumbs (
RingBufferBreadcrumbTrail,IBreadcrumbTrail). Bounded FIFO trail of short events for triage. Cap per scope, for example an HTTP request. - Error inbox (
IErrorInboxReader,IErrorOccurrenceSink,InMemoryErrorInbox). Record and query grouped occurrences by fingerprint + exception kind + service. Single-process. Not shared across instances.
Optional package metadata store (IPackageMetadataStore)
Use Lyo.PackageMetadata (InMemoryPackageMetadataStore, or Lyo.PackageMetadata.Postgres). Pass the store as the last argument to AddDiagnosticsPackage, or set
StackTraceDecoderOptions.PackageMetadataStore. TryGetManyForStrippedMethodPrefixesAsync resolves many stripped methods at once behind that call. Postgres may cache the
ordered prefix catalog in-process. See PostgresPackageMetadataOptions.PrefixCatalogCaching and ClearPrefixCatalogCache. When a store is configured, use BuildAsync
and DecodeAsync. Sync Build / Decode throws. Lookup methods expose a namespacePrefix parameter that remains reserved (unused for matching). See
IPackageMetadataStore remarks.
For ASP.NET Core (scoped breadcrumbs + automatic recording), use Lyo.Diagnostic.AspNetCore and UseDiagnosticExceptionRecording / AddLyoDiagnosticsWeb.
PII and breadcrumbs
Call IBreadcrumbTrail.Add at meaningful steps (downstream call started, cache miss, etc.). Keep Data and Message values small. Avoid tokens, secrets, full query strings, emails, and raw URLs. Prefer coarse categories and opaque IDs. Optional IBreadcrumbRedactor can strip known keys on each add.
Limits of the in-memory inbox
When over MaxOccurrences, InMemoryErrorInbox drops the oldest occurrences. Data is lost on restart and is not visible across multiple server processes. For durable aggregation, implement IErrorInboxReader / IErrorOccurrenceSink with Postgres or an external product such as Sentry.
Fingerprint
Only user stack-frame method names enter the fingerprint hash — line numbers do not. Minor edits often keep the same key when the defect shape is unchanged. StackTraceDecoder has the details.
Related / deferred work
- An inbox on Postgres that implements the same interfaces.
- HTTP export endpoints for support tooling.
- A dedicated Serilog enricher package.
Developing
Unit tests live in Lyo.PackageMetadata.Tests and Lyo.Diagnostic.Tests.
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Common.Core(direct, lyo)Lyo.Exceptions(direct, lyo)Lyo.Hashing(direct, lyo)Lyo.PackageMetadata(direct, lyo)Microsoft.Extensions.DependencyInjection.Abstractions10.0.5(direct, microsoft)Microsoft.Extensions.Logging.Abstractions10.0.5(direct, microsoft)Lyo.Common.Metadata(transitive, lyo)Microsoft.Bcl.AsyncInterfaces10.0.5(transitive, microsoft, netstandard2.0)System.IO.Hashing10.0.5(transitive, microsoft, net10.0)System.Memory4.6.3(transitive, microsoft, netstandard2.0)System.Text.Json10.0.5(transitive, microsoft, netstandard2.0)System.Threading.Tasks.Extensions4.6.3(transitive, microsoft)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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 is compatible. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Lyo.Common.Core (>= 2.0.0)
- Lyo.Exceptions (>= 2.0.0)
- Lyo.Hashing (>= 2.0.0)
- Lyo.PackageMetadata (>= 2.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
-
net10.0
- Lyo.Common.Core (>= 2.0.0)
- Lyo.Exceptions (>= 2.0.0)
- Lyo.Hashing (>= 2.0.0)
- Lyo.PackageMetadata (>= 2.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Lyo.Diagnostic:
| Package | Downloads |
|---|---|
|
Lyo.Api.Client
API client library for consuming Lyo APIs. |
|
|
Lyo.Diagnostic.AspNetCore
ASP.NET Core integration for Lyo.Diagnostic: scoped breadcrumbs, exception recording to the error inbox, and structured logging. |
|
|
Lyo.Authentication.AspNetCore
ASP.NET Core integration for Lyo.Authentication. Provides an opaque-token authentication handler, a Lyo-JWT authentication handler, and a "LyoBearer" policy scheme that sniffs the credential prefix to dispatch between them. Adds the ScopeAuthorizationPolicyProvider for fine-grained `scope:foo.bar` policies and the `/.well-known/jwks.json` endpoint. |
|
|
Lyo.Diagnostic.Web.Components
Reusable Blazor components for pasting and analysing .NET stack traces using Lyo.Diagnostic. |
|
|
Lyo.Authentication.Web.Components.Wasm
Blazor WebAssembly host adapter for `Lyo.Authentication.Web.Components`. Pure-browser token flow: exchanges the API's handoff code in the WASM client, holds the resulting access/refresh tokens in `Blazored.LocalStorage`, and injects the bearer (with auto-refresh) into outbound `HttpClient` calls. |
GitHub repositories
This package is not used by any popular GitHub repositories.