5#include "protocol/version.h"
11prometheus::Histogram::BucketBoundaries TimeBuckets() {
12 return {0.0001, 0.00025, 0.0005, 0.001, 0.0025, 0.005, 0.01, 0.02,
13 0.03, 0.04, 0.05, 0.075, 0.1, 0.25, 0.5, 1};
17prometheus::Histogram::BucketBoundaries StoryBuckets() {
18 return {0.25, 0.5, 1, 1.5, 2, 3, 4, 5, 7.5, 10};
23prometheus::Histogram::BucketBoundaries LoginBuckets() {
24 return {0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10};
30 : registry_(std::make_shared<prometheus::Registry>()),
31 players_(prometheus::BuildGauge()
32 .
Name(
"nanommo_players_online")
33 .Help(
"Players connected to the server, by land")
34 .Register(*registry_)),
35 copies_(prometheus::BuildGauge()
36 .
Name(
"nanommo_copies")
37 .Help(
"Copies of each land the server runs, by land")
38 .Register(*registry_)),
39 tick_seconds_(prometheus::BuildHistogram()
40 .
Name(
"nanommo_tick_duration_seconds")
41 .Help(
"Time spent in each tick")
43 .Add({}, TimeBuckets())),
44 save_seconds_(prometheus::BuildHistogram()
45 .
Name(
"nanommo_save_duration_seconds")
46 .Help(
"Time spent saving players, in each tick")
48 .Add({}, TimeBuckets())),
49 bytes_sent_(prometheus::BuildCounter()
50 .
Name(
"nanommo_bytes_sent_total")
51 .Help(
"Bytes queued to send to clients")
54 messages_received_(prometheus::BuildCounter()
55 .
Name(
"nanommo_messages_received_total")
56 .Help(
"Messages received from clients")
59 chat_lines_(prometheus::BuildCounter()
60 .
Name(
"nanommo_chat_lines_total")
61 .Help(
"Lines of chat, said or refused")
62 .Register(*registry_)),
63 stories_(prometheus::BuildCounter()
64 .
Name(
"nanommo_stories_total")
65 .Help(
"Stories asked for, told, refused or failed")
66 .Register(*registry_)),
67 story_seconds_(prometheus::BuildHistogram()
68 .
Name(
"nanommo_story_duration_seconds")
69 .Help(
"Time from asking for a story to its telling")
71 .Add({}, StoryBuckets())),
72 dropped_(prometheus::BuildCounter()
73 .
Name(
"nanommo_players_dropped_total")
74 .Help(
"Players let go of without saving them, by why")
75 .Register(*registry_)),
76 war_kills_(prometheus::BuildCounter()
77 .
Name(
"nanommo_war_kills_total")
78 .Help(
"Kills in guild wars, handed to the saver")
83 prometheus::BuildGauge()
84 .Name(
"nanommo_build_info")
85 .Help(
"The server's version, in its label; always 1")
87 .Add({{
"version", std::string(kVersion)}})
91 for (
const char* why : {
"lease",
"trade"}) {
92 dropped_.Add({{
"why", why}});
98 players_.Add({{
"land", land}}).Set(
static_cast<double>(count));
102 copies_.Add({{
"land", land}}).Set(
static_cast<double>(count));
106 tick_seconds_.Observe(std::chrono::duration<double>(time).count());
110 save_seconds_.Observe(std::chrono::duration<double>(time).count());
114 bytes_sent_.Increment(
static_cast<double>(bytes));
120 chat_lines_.Add({{
"result", result}}).Increment();
124 stories_.Add({{
"result", result}}).Increment();
128 story_seconds_.Observe(std::chrono::duration<double>(time).count());
132 dropped_.Add({{
"why", why}}).Increment();
136 war_kills_.Increment(
static_cast<double>(count));
140 : registry_(std::make_shared<prometheus::Registry>()),
141 seconds_(prometheus::BuildHistogram()
142 .
Name(
"nanommo_login_duration_seconds")
143 .Help(
"Time to answer each request, by what came of it")
144 .Register(*registry_)) {
147 for (
const char* result : {
"ok",
"refused",
"failed"}) {
148 seconds_.Add({{
"result", result}}, LoginBuckets());
150 prometheus::BuildGauge()
151 .Name(
"nanommo_build_info")
152 .Help(
"The server's version, in its label; always 1")
153 .Register(*registry_)
154 .Add({{
"version", std::string(kVersion)}})
159 std::chrono::nanoseconds time) {
160 seconds_.Add({{
"result", result}}, LoginBuckets())
161 .Observe(std::chrono::duration<double>(time).count());
void ObserveRequest(const char *result, std::chrono::nanoseconds time)
void AddMessageReceived()
void SetCopies(const char *land, std::size_t count)
How many copies of the land the server runs.
void AddBytesSent(std::size_t bytes)
void AddDropped(const char *why)
void AddChatLine(const char *result)
A line of chat, by what became of it: said, or refused.
void AddStory(const char *result)
void ObserveStory(std::chrono::nanoseconds time)
From when the player asked to when the story was told.
void ObserveSave(std::chrono::nanoseconds time)
void ObserveTick(std::chrono::nanoseconds time)
void SetPlayers(const char *land, std::size_t count)
void AddWarKills(std::size_t count)
Kills in a guild war, which go to the saver, for their wars' scores.
Part Name(std::string_view name)