Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions collector/lib/CollectorStatsExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ void CollectorStatsExporter::run() {
auto& preemptions = collectorEventCounters.Add({{"type", "preemptions"}});
auto& grpcSendFailures = collectorEventCounters.Add({{"type", "grpcSendFailures"}});
auto& threadTableSize = collectorEventCounters.Add({{"type", "threadCacheSize"}});
auto& procLookups = collectorEventCounters.Add({{"type", "procLookups"}});
auto& mainThreadLookups = collectorEventCounters.Add({{"type", "mainThreadLookups"}});
auto& procLookupsDurationNs = collectorEventCounters.Add({{"type", "procLookupsDurationNs"}});

auto& fdCacheHits = collectorEventCounters.Add({{"type", "fdCacheHits"}});
auto& fdCacheMisses = collectorEventCounters.Add({{"type", "fdCacheMisses"}});
auto& fdLookupFailures = collectorEventCounters.Add({{"type", "fdLookupFailures"}});
auto& fdsAdded = collectorEventCounters.Add({{"type", "fdsAdded"}});
auto& fdsRemoved = collectorEventCounters.Add({{"type", "fdsRemoved"}});

auto& threadCacheHits = collectorEventCounters.Add({{"type", "threadCacheHits"}});
auto& threadCacheMisses = collectorEventCounters.Add({{"type", "threadCacheMisses"}});
auto& threadLookupFailures = collectorEventCounters.Add({{"type", "threadLookupFailures"}});
auto& threadsAdded = collectorEventCounters.Add({{"type", "threadsAdded"}});
auto& threadsRemoved = collectorEventCounters.Add({{"type", "threadsRemoved"}});

auto& processSent = collectorEventCounters.Add({{"type", "processSent"}});
auto& processSendFailures = collectorEventCounters.Add({{"type", "processSendFailures"}});
Expand Down Expand Up @@ -170,6 +185,21 @@ void CollectorStatsExporter::run() {
ringbufferDrops.Set(stats.nDropsBuffer);
preemptions.Set(stats.nPreemptions);
threadTableSize.Set(stats.nThreadCacheSize);
procLookups.Set(stats.nProcLookups);
mainThreadLookups.Set(stats.nMainThreadLookups);
procLookupsDurationNs.Set(stats.nProcLookupsDurationNs);

fdCacheHits.Set(stats.nFdCacheHits);
fdCacheMisses.Set(stats.nFdCacheMisses);
fdLookupFailures.Set(stats.nFdLookupFailures);
fdsAdded.Set(stats.nFdsAdded);
fdsRemoved.Set(stats.nFdsRemoved);

threadCacheHits.Set(stats.nThreadCacheHits);
threadCacheMisses.Set(stats.nThreadCacheMisses);
threadLookupFailures.Set(stats.nThreadLookupFailures);
threadsAdded.Set(stats.nThreadsAdded);
threadsRemoved.Set(stats.nThreadsRemoved);

if (config_->EnableDetailedMetrics()) {
uint64_t nUserspace = 0;
Expand Down
15 changes: 15 additions & 0 deletions collector/lib/system-inspector/Service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,24 @@ bool Service::GetStats(system_inspector::Stats* stats) const {
stats->nDropsBuffer = kernel_stats.n_drops_buffer;
stats->nPreemptions = kernel_stats.n_preemptions;
stats->nThreadCacheSize = inspector_->m_thread_manager->get_thread_count();
stats->nProcLookups = inspector_->m_thread_manager->get_m_n_proc_lookups();
stats->nMainThreadLookups = inspector_->m_thread_manager->get_m_n_main_thread_lookups();
stats->nProcLookupsDurationNs = inspector_->m_thread_manager->get_m_n_proc_lookups_duration_ns();

if (userspace_stats != nullptr) {
stats->nDropsThreadCache = userspace_stats->m_n_drops_full_threadtable;

stats->nFdCacheHits = userspace_stats->m_n_cached_fd_lookups;
stats->nFdCacheMisses = userspace_stats->m_n_noncached_fd_lookups;
stats->nFdLookupFailures = userspace_stats->m_n_failed_fd_lookups;
stats->nFdsAdded = userspace_stats->m_n_added_fds;
stats->nFdsRemoved = userspace_stats->m_n_removed_fds;

stats->nThreadCacheHits = userspace_stats->m_n_cached_thread_lookups;
stats->nThreadCacheMisses = userspace_stats->m_n_noncached_thread_lookups;
stats->nThreadLookupFailures = userspace_stats->m_n_failed_thread_lookups;
stats->nThreadsAdded = userspace_stats->m_n_added_threads;
stats->nThreadsRemoved = userspace_stats->m_n_removed_threads;
}

return true;
Expand Down
18 changes: 18 additions & 0 deletions collector/lib/system-inspector/SystemInspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ struct Stats {
volatile uint64_t nThreadCacheSize = 0; // number of thread-info entries stored in the cache
volatile uint64_t nDropsThreadCache = 0; // the number of drops due to full thread cache

// libsinsp fdtable/threadtable state counters (from sinsp_stats_v2)
volatile uint64_t nFdCacheHits = 0; // cached fd lookups
volatile uint64_t nFdCacheMisses = 0; // non-cached fd lookups
volatile uint64_t nFdLookupFailures = 0; // failed fd lookups
volatile uint64_t nFdsAdded = 0; // fds added to fdtables
volatile uint64_t nFdsRemoved = 0; // fds removed from fdtables

volatile uint64_t nThreadCacheHits = 0; // cached thread lookups
volatile uint64_t nThreadCacheMisses = 0; // non-cached thread lookups
volatile uint64_t nThreadLookupFailures = 0; // failed thread lookups
volatile uint64_t nThreadsAdded = 0; // threads added to the thread table
volatile uint64_t nThreadsRemoved = 0; // threads removed from the thread table

// number of times a thread lookup fell back to a direct /proc scan (sinsp_thread_manager)
volatile uint64_t nProcLookups = 0; // total /proc lookups performed
volatile uint64_t nMainThreadLookups = 0; // /proc lookups performed specifically for main threads
volatile uint64_t nProcLookupsDurationNs = 0; // total time spent performing /proc lookups

// process related metrics
volatile uint64_t nProcessSent = 0; // number of process signals sent
volatile uint64_t nProcessSendFailures = 0; // number of process signals failed to send
Expand Down
Loading