nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
bot_metrics.h
Go to the documentation of this file.
1#ifndef NANOMMO_BOT_BOT_METRICS_H_
2#define NANOMMO_BOT_BOT_METRICS_H_
3
4#include <chrono>
5#include <memory>
6#include <string>
7
8#include "prometheus/family.h"
9#include "prometheus/gauge.h"
10#include "prometheus/histogram.h"
11#include "prometheus/registry.h"
12
13namespace nanommo {
14
16 public:
17 explicit BotMetrics(const std::string& transport);
18
19 void ObserveAge(std::chrono::microseconds age);
20
21 void SetConnected(int bots);
22
23 /// A bot's login, from its first request to the login server to its token
24 /// to enter the world, by what came of it: ok, refused, timeout when the
25 /// login server didn't answer within LogIn's deadline, or failed. It's
26 /// what players see, which the login server's own metrics can't, as a
27 /// request that never reaches it, or never ends, is never counted there.
28 void ObserveLogin(const char* result, std::chrono::nanoseconds time);
29
30 const std::shared_ptr<prometheus::Registry>& registry() const {
31 return registry_;
32 }
33
34 private:
35 std::shared_ptr<prometheus::Registry> registry_;
36 prometheus::Histogram& age_seconds_;
37 prometheus::Gauge& connected_;
38 prometheus::Family<prometheus::Histogram>& logins_;
39};
40
41} // namespace nanommo
42
43#endif // NANOMMO_BOT_BOT_METRICS_H_
const std::shared_ptr< prometheus::Registry > & registry() const
Definition bot_metrics.h:30
void SetConnected(int bots)
void ObserveAge(std::chrono::microseconds age)
BotMetrics(const std::string &transport)
void ObserveLogin(const char *result, std::chrono::nanoseconds time)
Definition chat.cc:9