XiHan.Framework.Observability.Abstractions 5.0.0-preview.2

Prefix Reserved
This is a prerelease version of XiHan.Framework.Observability.Abstractions.
dotnet add package XiHan.Framework.Observability.Abstractions --version 5.0.0-preview.2
                    
NuGet\Install-Package XiHan.Framework.Observability.Abstractions -Version 5.0.0-preview.2
                    
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="XiHan.Framework.Observability.Abstractions" Version="5.0.0-preview.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XiHan.Framework.Observability.Abstractions" Version="5.0.0-preview.2" />
                    
Directory.Packages.props
<PackageReference Include="XiHan.Framework.Observability.Abstractions" />
                    
Project file
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 XiHan.Framework.Observability.Abstractions --version 5.0.0-preview.2
                    
#r "nuget: XiHan.Framework.Observability.Abstractions, 5.0.0-preview.2"
                    
#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 XiHan.Framework.Observability.Abstractions@5.0.0-preview.2
                    
#: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=XiHan.Framework.Observability.Abstractions&version=5.0.0-preview.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=XiHan.Framework.Observability.Abstractions&version=5.0.0-preview.2&prerelease
                    
Install as a Cake Tool

XiHan.Framework.Observability.Abstractions

关于

XiHan.Framework.Observability.Abstractions 定义可观测性的契约:IHostMonitor 读取进程与所在主机的运行信息(CPU、内存、磁盘、网卡、GPU、主板、运行时长),以及对应的记录类型。不包含实现,一般由实现包带入,业务代码或写自定义监控实现时才直接引用。

主要特性

  • 读不到的项为 null,不以 0 或空串顶替,界面可区分「没有」与「为零」
  • 读取不阻塞、不抛出、不启动外部命令
  • 使用率与速率取后台采样器最近一次的值,启动后第一个采样间隔内为 null

如何使用

安装

dotnet add package XiHan.Framework.Observability.Abstractions --prerelease

使用

注入 IHostMonitor 读取运行信息,通常配合 Observability.Host 提供的默认实现使用。

using XiHan.Framework.Observability.Abstractions;

public sealed class CapacityCheck(IHostMonitor monitor)
{
    public bool MemoryTooHigh() => monitor.ReadMemory().UsagePercent is > 90;
}

主要类型

此库提供的主要类型:

  • IHostMonitor:ReadRuntime、ReadProcessor、ReadMemory、ReadDisks、ReadNetworkInterfaces、ReadGpus、ReadBoard
  • RuntimeInfo:操作系统、.NET、进程与系统运行时长、内存与 GC、CPU 使用率
  • ProcessorInfo、MemoryInfo、DiskInfo:处理器、内存、磁盘信息
  • NetworkInterfaceInfo、GpuInfo、BoardInfo:网卡、显卡、主板信息

更多文档

相关包

反馈与贡献

XiHan.Framework.Observability.Abstractions 以 MIT 许可证 开源。欢迎到 GitHub 仓库 提交问题和贡献。

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on XiHan.Framework.Observability.Abstractions:

Package Downloads
XiHan.Framework.Observability.OpenTelemetry

曦寒框架可观测性的 OpenTelemetry 提供程序

XiHan.Framework.Observability.Host

曦寒框架进程与主机运行信息库

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.0.0-preview.2 0 11/6/2026
5.0.0-preview.1 44 11/4/2026