18 #ifndef PAGESPEED_KERNEL_BASE_STATISTICS_LOGGER_H_
19 #define PAGESPEED_KERNEL_BASE_STATISTICS_LOGGER_H_
31 namespace net_instaweb {
36 class StatisticsLogfileReader;
46 int64 update_interval_ms, int64 max_logfile_size_kb,
47 const StringPiece& log_file,
MutexedScalar* last_dump_timestamp,
56 void DumpJSON(
bool dump_for_graphs,
const StringSet& var_titles,
57 int64 start_time, int64 end_time, int64 granularity_ms,
75 friend class StatisticsLoggerTest;
77 typedef std::vector<GoogleString> VariableInfo;
78 typedef std::map<GoogleString, VariableInfo> VarMap;
83 typedef std::pair<Variable*, UpDownCounter*> VariableOrCounter;
84 typedef std::map<StringPiece, VariableOrCounter> VariableMap;
88 void DumpConsoleVarsToWriter(int64 current_time_ms,
Writer* writer);
90 void ParseDataFromReader(
const StringSet& var_titles,
92 std::vector<int64>* list_of_timestamps,
93 VarMap* parsed_var_data)
const;
96 std::vector<int64>* list_of_timestamps,
97 VarMap* parsed_var_data)
const;
101 void ParseVarDataIntoMap(StringPiece logfile_var_data,
102 std::map<StringPiece, StringPiece>* parsed_var_data)
104 void PrintVarDataAsJSON(
const VarMap& parsed_var_data,
Writer* writer,
106 void PrintTimestampListAsJSON(
const std::vector<int64>& list_of_timestamps,
109 void PrintJSON(
const std::vector<int64>& list_of_timestamps,
110 const VarMap& parsed_var_data,
112 void AddVariable(StringPiece var_name);
116 void InitStatsForTest();
127 const int64 update_interval_ms_;
128 const int64 max_logfile_size_kb_;
130 VariableMap variables_to_log_;
139 int64 end_time, int64 granularity_ms,
149 int64 end_time() {
return end_time_; }
153 size_t BufferFind(
const char* search_for,
size_t start_at);
159 int64 granularity_ms_;
bool ReadNextDataBlock(int64 *timestamp, GoogleString *data)
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
void UpdateAndDumpIfRequired()
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
Definition: file_system.h:76
Handles reading the logfile created by StatisticsLogger.
Definition: statistics_logger.h:136
Interface for writing bytes to an output stream.
Definition: writer.h:29
void DumpJSON(bool dump_for_graphs, const StringSet &var_titles, int64 start_time, int64 end_time, int64 granularity_ms, Writer *writer, MessageHandler *message_handler) const
Definition: statistics.h:112
Definition: message_handler.h:39
void TrimLogfileIfNeeded()
Trim file down if it gets above max_logfile_size_kb.
StatisticsLogger(int64 update_interval_ms, int64 max_logfile_size_kb, const StringPiece &log_file, MutexedScalar *last_dump_timestamp, MessageHandler *message_handler, Statistics *stats, FileSystem *file_system, Timer *timer)
Does not take ownership of any objects passed in.
Timer interface, made virtual so it can be mocked for tests.
Definition: timer.h:27
Definition: statistics_logger.h:42