nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
metrics.h
Go to the documentation of this file.
1#ifndef NANOMMO_SERVER_METRICS_H_
2#define NANOMMO_SERVER_METRICS_H_
3
4#include <chrono>
5#include <cstddef>
6#include <memory>
7
8#include "prometheus/counter.h"
9#include "prometheus/family.h"
10#include "prometheus/gauge.h"
11#include "prometheus/histogram.h"
12#include "prometheus/registry.h"
13
14namespace nanommo {
15
16class Metrics {
17 public:
18 Metrics();
19
20 void SetPlayers(const char* land, std::size_t count);
21
22 /// How many copies of the land the server runs.
23 void SetCopies(const char* land, std::size_t count);
24
25 void ObserveTick(std::chrono::nanoseconds time);
26
27 void ObserveSave(std::chrono::nanoseconds time);
28
29 void AddBytesSent(std::size_t bytes);
30
31 void AddMessageReceived();
32
33 /// A line of chat, by what became of it: said, or refused.
34 void AddChatLine(const char* result);
35
36 /// A story a player asked for, by what became of it: told, refused, or
37 /// failed, when the storyteller couldn't tell it.
38 void AddStory(const char* result);
39
40 /// From when the player asked to when the story was told.
41 void ObserveStory(std::chrono::nanoseconds time);
42
43 /// A player the server let go of without saving them, by why: their lease
44 /// isn't this instance's any more, or their trade couldn't be saved.
45 void AddDropped(const char* why);
46
47 /// Kills in a guild war, which go to the saver, for their wars' scores.
48 void AddWarKills(std::size_t count);
49
50 const std::shared_ptr<prometheus::Registry>& registry() const {
51 return registry_;
52 }
53
54 private:
55 std::shared_ptr<prometheus::Registry> registry_;
56 prometheus::Family<prometheus::Gauge>& players_;
57 prometheus::Family<prometheus::Gauge>& copies_;
58 prometheus::Histogram& tick_seconds_;
59 prometheus::Histogram& save_seconds_;
60 prometheus::Counter& bytes_sent_;
61 prometheus::Counter& messages_received_;
62 prometheus::Family<prometheus::Counter>& chat_lines_;
63 prometheus::Family<prometheus::Counter>& stories_;
64 prometheus::Histogram& story_seconds_;
65 prometheus::Family<prometheus::Counter>& dropped_;
66 prometheus::Counter& war_kills_;
67};
68
69/// The login server's: how long it took to answer each request, by what came
70/// of it.
72 public:
74
75 /// A request answered: ok, refused, when the reply says why not, as for a
76 /// wrong password, which is the player's mistake, or failed, when the
77 /// servers it needs couldn't answer.
78 void ObserveRequest(const char* result, std::chrono::nanoseconds time);
79
80 const std::shared_ptr<prometheus::Registry>& registry() const {
81 return registry_;
82 }
83
84 private:
85 std::shared_ptr<prometheus::Registry> registry_;
86 prometheus::Family<prometheus::Histogram>& seconds_;
87};
88
89} // namespace nanommo
90
91#endif // NANOMMO_SERVER_METRICS_H_
const std::shared_ptr< prometheus::Registry > & registry() const
Definition metrics.h:80
void ObserveRequest(const char *result, std::chrono::nanoseconds time)
Definition metrics.cc:158
void AddMessageReceived()
Definition metrics.cc:117
void SetCopies(const char *land, std::size_t count)
How many copies of the land the server runs.
Definition metrics.cc:101
void AddBytesSent(std::size_t bytes)
Definition metrics.cc:113
void AddDropped(const char *why)
Definition metrics.cc:131
void AddChatLine(const char *result)
A line of chat, by what became of it: said, or refused.
Definition metrics.cc:119
const std::shared_ptr< prometheus::Registry > & registry() const
Definition metrics.h:50
void AddStory(const char *result)
Definition metrics.cc:123
void ObserveStory(std::chrono::nanoseconds time)
From when the player asked to when the story was told.
Definition metrics.cc:127
void ObserveSave(std::chrono::nanoseconds time)
Definition metrics.cc:109
void ObserveTick(std::chrono::nanoseconds time)
Definition metrics.cc:105
void SetPlayers(const char *land, std::size_t count)
Definition metrics.cc:96
void AddWarKills(std::size_t count)
Kills in a guild war, which go to the saver, for their wars' scores.
Definition metrics.cc:135
Definition chat.cc:9