#include <opentelemetry/metrics/meter.h> #include <cpu_features/cpu_features_macros.h> # if defined(CPU_FEATURES_ARCH_X86) #include <cpu_features/cpuinfo_x86.h> #include <opentelemetry/metrics/provider.h> #elif defined(CPU_FEATURES_ARCH_ARM) #include <cpu_features/cpuinfo_arm.h> #elif defined(CPU_FEATURES_ARCH_AARCH64) #include <cpu_features/cpuinfo_aarch64.h> #elif defined(CPU_FEATURES_ARCH_MIPS) #include <cpu_features/cpuinfo_mips.h> #elif defined(CPU_FEATURES_ARCH_PPC) #include <cpu_features/cpuinfo_ppc.h> #elif defined(CPU_FEATURES_ARCH_S390X) #include <cpu_features/cpuinfo_s390x.h> #elif defined(CPU_FEATURES_ARCH_RISCV) #include <cpu_features/cpuinfo_riscv.h> #elif defined(CPU_FEATURES_ARCH_LOONGARCH) #include <cpu_features/cpuinfo_loongarch.h> #endif void Collector::run() { # if defined(CPU_FEATURES_ARCH_X86) const ::cpu_features::X86Info info = ::cpu_features::GetX86Info(); const ::cpu_features::CacheInfo cache_info = ::cpu_features::GetX86CacheInfo(); #elif defined(CPU_FEATURES_ARCH_ARM) const ArmInfo info = GetArmInfo(); AddMapEntry(root, "arch" , CreateString( "ARM" )); AddMapEntry(root, "implementer" , CreateInt(info.implementer)); AddMapEntry(root, "architecture" , CreateInt(info.architecture)); AddMapEntry(root, "variant" , CreateInt(info.variant)); AddMapEntry(root, "part" , CreateInt(info.part)); AddMapEntry(root, "revision" , CreateInt(info.revision)); AddFlags(root, &info.features); #elif defined(CPU_FEATURES_ARCH_AARCH64) const Aarch64Info info = GetAarch64Info(); AddMapEntry(root, "arch" , CreateString( "aarch64" )); AddMapEntry(root, "implementer" , CreateInt(info.implementer)); AddMapEntry(root, "variant" , CreateInt(info.variant)); AddMapEntry(root, "part" , CreateInt(info.part)); AddMapEntry(root, "revision" , CreateInt(info.revision)); AddFlags(root, &info.features); #elif defined(CPU_FEATURES_ARCH_MIPS) const MipsInfo info = GetMipsInfo(); AddMapEntry(root, "arch" , CreateString( "mips" )); AddFlags(root, &info.features); #elif defined(CPU_FEATURES_ARCH_PPC) const PPCInfo info = GetPPCInfo(); const PPCPlatformStrings strings = GetPPCPlatformStrings(); AddMapEntry(root, "arch" , CreateString( "ppc" )); AddMapEntry(root, "platform" , CreateString(strings.platform)); AddMapEntry(root, "model" , CreateString(strings.model)); AddMapEntry(root, "machine" , CreateString(strings.machine)); AddMapEntry(root, "cpu" , CreateString(strings.cpu)); AddMapEntry(root, "instruction" , CreateString(strings.type.platform)); AddMapEntry(root, "microarchitecture" , CreateString(strings.type.base_platform)); AddFlags(root, &info.features); #elif defined(CPU_FEATURES_ARCH_S390X) const S390XInfo info = GetS390XInfo(); const S390XPlatformStrings strings = GetS390XPlatformStrings(); AddMapEntry(root, "arch" , CreateString( "s390x" )); AddMapEntry(root, "platform" , CreateString( "zSeries" )); AddMapEntry(root, "model" , CreateString(strings.type.platform)); AddMapEntry(root, "# processors" , CreateInt(strings.num_processors)); AddFlags(root, &info.features); #elif defined(CPU_FEATURES_ARCH_RISCV) const RiscvInfo info = GetRiscvInfo(); AddMapEntry(root, "arch" , CreateString( "risc-v" )); AddMapEntry(root, "vendor" , CreateString(info.vendor)); AddMapEntry(root, "microarchitecture" , CreateString(info.uarch)); AddFlags(root, &info.features); #elif defined(CPU_FEATURES_ARCH_LOONGARCH) const LoongArchInfo info = GetLoongArchInfo(); AddMapEntry(root, "arch" , CreateString( "loongarch" )); AddFlags(root, &info.features); #endif } |