RuntimeLens.Abstractions
1.0.1
Prefix Reserved
.NET 8.0
This package targets .NET 8.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
dotnet add package RuntimeLens.Abstractions --version 1.0.1
NuGet\Install-Package RuntimeLens.Abstractions -Version 1.0.1
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="RuntimeLens.Abstractions" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RuntimeLens.Abstractions" Version="1.0.1" />
<PackageReference Include="RuntimeLens.Abstractions" />
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 RuntimeLens.Abstractions --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RuntimeLens.Abstractions, 1.0.1"
#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 RuntimeLens.Abstractions@1.0.1
#: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=RuntimeLens.Abstractions&version=1.0.1
#tool nuget:?package=RuntimeLens.Abstractions&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
RuntimeLens.Abstractions
Light-weight contracts, interfaces, and data models for RuntimeLens diagnostics platform. Zero external dependencies.
Target Frameworks
.NET Standard 2.0|.NET 8.0|.NET 9.0|.NET 10.0
Core Interfaces
| Interface | Key Members | Description |
|---|---|---|
IRuntimeLens |
StartScope, TrackException, AddTag, RecordMetric, RecordLog, CaptureSnapshot |
Primary entry point for manual trace recording and telemetry management. |
ISpanScope |
TraceId, SpanId, AddTag, RecordMetric, TrackException, Dispose, DisposeAsync |
Active span scope (IDisposable, IAsyncDisposable) tracking execution duration and allocations. |
IStorageProvider |
StoreAsync, GetTracesAsync, QueryTracesAsync, GetTraceByIdAsync, SearchTracesAsync, ClearAsync |
Persistence abstraction for trace snapshot queries and storage backends. |
IPlugin |
Name, InitializeAsync, OnTraceCapturedAsync |
Extensibility hook invoked asynchronously when a trace snapshot is captured. |
IDiagnosticRule |
RuleId, Name, Evaluate(snapshot, out reason) |
Diagnostic evaluation rule contract. |
IAlertRule |
RuleId, Evaluate(snapshot, out alert) |
Diagnostic alert rule contract. |
Data Models
TraceSnapshot
| Property | Type | Description |
|---|---|---|
TraceId / SpanId / ParentSpanId |
string |
Correlation IDs defining the execution tree structure. |
OperationName / Category |
string |
Operation identifier (e.g. GET /api/orders) and classification tag. |
StartTimestampUtc / DurationMs |
DateTime / double |
Execution start time (UTC) and total duration in milliseconds. |
MemoryAllocatedBytes |
long |
Managed memory bytes allocated during span lifecycle. |
Gen0Collections / Gen1Collections / Gen2Collections |
int |
Garbage collection frequency counts during span lifecycle. |
ThreadId / ThreadName |
int / string |
Execution thread info. |
Exception |
DiagnosticExceptionInfo? |
Exception message, type, and stack trace (if thrown). |
SqlDetails / HttpDetails / RedisDetails |
*DiagnosticInfo? |
Target-specific diagnostic payloads for database, web, or cache calls. |
CallTree |
CallTreeNode |
Root node of nested child execution spans forming the flame graph. |
Tags / Metrics / Logs |
List<*> |
Key-value tags, numerical metrics, and string logs recorded in span. |
Code Examples
1. Manual Span Profiling
using RuntimeLens.Abstractions;
public class OrderService
{
private readonly IRuntimeLens _lens;
public OrderService(IRuntimeLens lens)
{
_lens = lens; // Inject telemetry engine
}
public async Task ProcessOrderAsync(string orderId, decimal amount)
{
// Start root trace scope (automatically tracks duration & memory allocations)
using var rootSpan = _lens.StartScope("ProcessOrder", category: "Orders");
// Attach diagnostic tags and metrics to the root scope
rootSpan.AddTag("order.id", orderId);
rootSpan.RecordMetric("order.amount", (double)amount, unit: "TRY");
try
{
// Start nested child span scope
using (var dbSpan = _lens.StartScope("SaveToDatabase", category: "Database"))
{
dbSpan.AddTag("db.statement", "INSERT INTO Orders ...");
await Task.Delay(30); // Simulate database operation
} // Child span disposed & recorded
}
catch (Exception ex)
{
// Track exception details on root span
rootSpan.TrackException(ex);
throw;
}
} // Root span disposed, completed & flushed
}
2. Custom Extensibility Plugin (IPlugin)
using RuntimeLens.Abstractions;
using RuntimeLens.Abstractions.Models;
public class HighLatencyAlertPlugin : IPlugin
{
// Unique identifier for the plugin
public string Name => "HighLatencyAlertPlugin";
// Called once when the plugin is registered with the engine
public ValueTask InitializeAsync(IRuntimeLens runtimeLens, CancellationToken cancellationToken = default)
{
// Perform initialization if needed
return ValueTask.CompletedTask;
}
// Executed asynchronously whenever a trace snapshot is captured
public ValueTask OnTraceCapturedAsync(TraceSnapshot snapshot, CancellationToken cancellationToken = default)
{
// Check if operation execution exceeded 1000ms threshold
if (snapshot.DurationMs > 1000.0)
{
// Trigger external notification or logging
Console.WriteLine($"[ALERT] Slow Operation: {snapshot.OperationName} ({snapshot.DurationMs:F2}ms)");
}
return ValueTask.CompletedTask;
}
}
3. Custom Diagnostic Rule (IDiagnosticRule & IAlertRule)
using RuntimeLens.Abstractions;
using RuntimeLens.Abstractions.Models;
public class MemorySpikeRule : IDiagnosticRule, IAlertRule
{
public string RuleId => "RL101_MEMORY_SPIKE";
public string Name => "Memory Spike Rule";
// Evaluates trace snapshot for diagnostic warnings
public bool Evaluate(TraceSnapshot snapshot, out string reason)
{
const long thresholdBytes = 10 * 1024 * 1024; // 10 MB threshold
if (snapshot.MemoryAllocatedBytes > thresholdBytes)
{
reason = $"[{snapshot.OperationName}] Memory allocation ({snapshot.MemoryAllocatedBytes / 1024 / 1024} MB) exceeded 10 MB threshold.";
return true;
}
reason = string.Empty;
return false;
}
// Evaluates trace snapshot and constructs alert object
public bool Evaluate(TraceSnapshot snapshot, out DiagnosticAlert? alert)
{
if (Evaluate(snapshot, out string reason))
{
alert = new DiagnosticAlert
{
RuleName = Name,
Message = reason,
Severity = AlertSeverity.Warning, // Severity levels: Info, Warning, Critical
TraceId = snapshot.TraceId
};
return true;
}
alert = null;
return false;
}
}
Learn More
| 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 is compatible. 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 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 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.10)
- System.Threading.Tasks.Extensions (>= 4.6.3)
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on RuntimeLens.Abstractions:
| Package | Downloads |
|---|---|
|
RuntimeLens
Core telemetry engine, high-performance in-memory and persistent file storage providers, trace analysis rules, filters, and export providers for RuntimeLens. |
GitHub repositories
This package is not used by any popular GitHub repositories.