| 2068 | } |
| 2069 | |
| 2070 | void TraceLog::AddMetadataEventsWhileLocked() { |
| 2071 | DCHECK(lock_.IsHeld()); |
| 2072 | |
| 2073 | #if !defined(OS_NACL) // NaCl shouldn't expose the process id. |
| 2074 | InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(nullptr, false), |
| 2075 | 0, |
| 2076 | "num_cpus", "number", |
| 2077 | base::NumCPUs()); |
| 2078 | #endif |
| 2079 | |
| 2080 | |
| 2081 | int current_thread_id = static_cast<int>(kudu::Thread::UniqueThreadId()); |
| 2082 | if (process_sort_index_ != 0) { |
| 2083 | InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(nullptr, false), |
| 2084 | current_thread_id, |
| 2085 | "process_sort_index", "sort_index", |
| 2086 | process_sort_index_); |
| 2087 | } |
| 2088 | |
| 2089 | if (process_name_.size()) { |
| 2090 | InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(nullptr, false), |
| 2091 | current_thread_id, |
| 2092 | "process_name", "name", |
| 2093 | process_name_); |
| 2094 | } |
| 2095 | |
| 2096 | if (process_labels_.size() > 0) { |
| 2097 | std::vector<std::string> labels; |
| 2098 | for(auto& label : process_labels_) { |
| 2099 | labels.push_back(label.second); |
| 2100 | } |
| 2101 | InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(nullptr, false), |
| 2102 | current_thread_id, |
| 2103 | "process_labels", "labels", |
| 2104 | JoinStrings(labels, ",")); |
| 2105 | } |
| 2106 | |
| 2107 | // Thread sort indices. |
| 2108 | for(auto& sort_index : thread_sort_indices_) { |
| 2109 | if (sort_index.second == 0) |
| 2110 | continue; |
| 2111 | InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(nullptr, false), |
| 2112 | sort_index.first, |
| 2113 | "thread_sort_index", "sort_index", |
| 2114 | sort_index.second); |
| 2115 | } |
| 2116 | |
| 2117 | // Thread names. |
| 2118 | SpinLockHolder thread_info_lock(&thread_info_lock_); |
| 2119 | for(auto& name : thread_names_) { |
| 2120 | if (name.second.empty()) |
| 2121 | continue; |
| 2122 | InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(nullptr, false), |
| 2123 | name.first, |
| 2124 | "thread_name", "name", |
| 2125 | name.second); |
| 2126 | } |
| 2127 | } |
nothing calls this directly
no test coverage detected