Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions libs/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <algorithm>
#include <cctype>

namespace spectator {

struct ConfigConstants
{
static constexpr auto Container = "nf.container";
Expand Down Expand Up @@ -69,3 +71,5 @@ Config::Config(const WriterConfig& writerConfig, const std::unordered_map<std::s
Logger::info(" {}: {}", key, value);
}
}

} // namespace spectator
6 changes: 5 additions & 1 deletion libs/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include <writer_config.h>

namespace spectator {

class Config
{
public:
Expand All @@ -26,4 +28,6 @@ class Config
private:
std::unordered_map<std::string, std::string> m_extraTags;
WriterConfig m_writerConfig;
};
};

} // namespace spectator
2 changes: 2 additions & 0 deletions libs/config/test_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <config.h>
#include <optional>

using namespace spectator;

// Enhanced helper to temporarily modify an environment variable for testing
class EnvironmentVariableGuard
{
Expand Down
4 changes: 4 additions & 0 deletions libs/logger/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <spdlog/async.h>
#include <fmt/core.h>

namespace spectator {

constexpr const char* kMainLogger = "spectator";

class Logger final : public Singleton<Logger>
Expand Down Expand Up @@ -86,3 +88,5 @@ class Logger final : public Singleton<Logger>
GetLogger()->error(fmt, std::forward<Args>(args)...);
}
};

} // namespace spectator
6 changes: 5 additions & 1 deletion libs/meter/meter_id/meter_id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <util.h>
#include <sstream>

namespace spectator {

// Define the static member
const std::regex INVALID_CHARS("[^-._A-Za-z0-9~^]");

Expand Down Expand Up @@ -84,8 +86,10 @@ std::string MeterId::to_string() const
return ss.str();
}

} // namespace spectator

// Implementation of the hash function for MeterId
size_t std::hash<MeterId>::operator()(const MeterId& id) const
size_t std::hash<spectator::MeterId>::operator()(const spectator::MeterId& id) const
{
// Hash the name first
const size_t name_hash = std::hash<std::string>{}(id.GetName());
Expand Down
8 changes: 6 additions & 2 deletions libs/meter/meter_id/meter_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <functional>
#include <unordered_map>

namespace spectator {

class MeterId
{
public:
Expand All @@ -31,8 +33,10 @@ class MeterId
std::string m_spectatord_id;
};

} // namespace spectator

template <>
struct std::hash<MeterId>
struct std::hash<spectator::MeterId>
{
size_t operator()(const MeterId& id) const;
size_t operator()(const spectator::MeterId& id) const;
};
2 changes: 2 additions & 0 deletions libs/meter/meter_id/test_meter_id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <gtest/gtest.h>

using namespace spectator;

TEST(MeterIdTest, EqualsSameName)
{
const MeterId id1("foo");
Expand Down
4 changes: 4 additions & 0 deletions libs/meter/meter_types/include/age_gauge.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <string>

namespace spectator {

static constexpr auto AGE_GAUGE_TYPE_SYMBOL = "A";

class AgeGauge final : public Meter
Expand All @@ -25,3 +27,5 @@ class AgeGauge final : public Meter
Writer::GetInstance().Write(line);
}
};

} // namespace spectator
4 changes: 4 additions & 0 deletions libs/meter/meter_types/include/counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <string>

namespace spectator {

static constexpr auto COUNTER_TYPE_SYMBOL = "c";

class Counter final : public Meter
Expand All @@ -22,3 +24,5 @@ class Counter final : public Meter
}
}
};

} // namespace spectator
6 changes: 5 additions & 1 deletion libs/meter/meter_types/include/dist_summary.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <string>

namespace spectator {

static constexpr auto DisTRIBUTION_SUMMARY_TYPE_SYMBOL = "d";

class DistributionSummary final : public Meter
Expand All @@ -21,4 +23,6 @@ class DistributionSummary final : public Meter
Writer::GetInstance().Write(line);
}
}
};
};

} // namespace spectator
6 changes: 5 additions & 1 deletion libs/meter/meter_types/include/gauge.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <string>
#include <optional>

namespace spectator {

static constexpr auto GAUGE_TYPE_SYMBOL = "g";

class Gauge final : public Meter
Expand All @@ -24,4 +26,6 @@ class Gauge final : public Meter
auto line = this->ConstructLine(value);
Writer::GetInstance().Write(line);
}
};
};

} // namespace spectator
6 changes: 5 additions & 1 deletion libs/meter/meter_types/include/max_gauge.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <string>

namespace spectator {

static constexpr auto MAX_GAUGE_TYPE_SYMBOL = "m";

class MaxGauge final : public Meter
Expand All @@ -18,4 +20,6 @@ class MaxGauge final : public Meter
auto line = this->ConstructLine(value);
Writer::GetInstance().Write(line);
}
};
};

} // namespace spectator
4 changes: 4 additions & 0 deletions libs/meter/meter_types/include/meter.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <meter_id.h>
#include <string>

namespace spectator {

class Meter
{
public:
Expand Down Expand Up @@ -41,3 +43,5 @@ class Meter
MeterId m_id;
std::string m_meterTypeSymbol;
};

} // namespace spectator
4 changes: 4 additions & 0 deletions libs/meter/meter_types/include/monotonic_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <string>

namespace spectator {

static constexpr auto MONOTONIC_COUNTER_TYPE_SYMBOL = "C";

class MonotonicCounter final : public Meter
Expand All @@ -19,3 +21,5 @@ class MonotonicCounter final : public Meter
Writer::GetInstance().Write(line);
}
};

} // namespace spectator
4 changes: 4 additions & 0 deletions libs/meter/meter_types/include/monotonic_counter_uint.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <string>

namespace spectator {

static constexpr auto MONOTONIC_COUNTER_UINT_TYPE_SYMBOL = "U";

class MonotonicCounterUint final : public Meter
Expand All @@ -19,3 +21,5 @@ class MonotonicCounterUint final : public Meter
Writer::GetInstance().Write(line);
}
};

} // namespace spectator
4 changes: 4 additions & 0 deletions libs/meter/meter_types/include/percentile_dist_summary.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <cstdint>
#include <string>

namespace spectator {

static constexpr auto PERCENTILE_DISTRIBUTION_SUMMARY_TYPE_SYMBOL = "D";

class PercentileDistributionSummary final : public Meter
Expand All @@ -26,3 +28,5 @@ class PercentileDistributionSummary final : public Meter
}
}
};

} // namespace spectator
4 changes: 4 additions & 0 deletions libs/meter/meter_types/include/percentile_timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <string>

namespace spectator {

static constexpr auto PERCENTILE_TIMER_TYPE_SYMBOL = "T";

class PercentileTimer final : public Meter
Expand All @@ -22,3 +24,5 @@ class PercentileTimer final : public Meter
}
}
};

} // namespace spectator
6 changes: 5 additions & 1 deletion libs/meter/meter_types/include/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <string>

namespace spectator {

static constexpr auto TIMER_TYPE_SYMBOL = "t";

class Timer final : public Meter
Expand All @@ -21,4 +23,6 @@ class Timer final : public Meter
Writer::GetInstance().Write(line);
}
}
};
};

} // namespace spectator
2 changes: 2 additions & 0 deletions libs/meter/meter_types/test/test_age_gauge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <gtest/gtest.h>

using namespace spectator;

class AgeGaugeTest : public testing::Test
{
protected:
Expand Down
2 changes: 2 additions & 0 deletions libs/meter/meter_types/test/test_counter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <gtest/gtest.h>

using namespace spectator;

class CounterTest : public testing::Test
{
protected:
Expand Down
2 changes: 2 additions & 0 deletions libs/meter/meter_types/test/test_dist_summary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <gtest/gtest.h>

using namespace spectator;

class DistSummaryTest : public testing::Test
{
protected:
Expand Down
2 changes: 2 additions & 0 deletions libs/meter/meter_types/test/test_gauge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <gtest/gtest.h>

using namespace spectator;

class GaugeTest : public testing::Test
{
protected:
Expand Down
2 changes: 2 additions & 0 deletions libs/meter/meter_types/test/test_max_gauge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <gtest/gtest.h>

using namespace spectator;

class MaxGaugeTest : public testing::Test
{
protected:
Expand Down
2 changes: 2 additions & 0 deletions libs/meter/meter_types/test/test_monotonic_counter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <gtest/gtest.h>

using namespace spectator;

class MonotonicCounterTest : public testing::Test
{
protected:
Expand Down
2 changes: 2 additions & 0 deletions libs/meter/meter_types/test/test_monotonic_counter_uint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <gtest/gtest.h>

using namespace spectator;

class MonoCounterTest : public testing::Test
{
protected:
Expand Down
2 changes: 2 additions & 0 deletions libs/meter/meter_types/test/test_percentile_dist_summary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <gtest/gtest.h>

using namespace spectator;

class PercentileDistSummaryTest : public testing::Test
{
protected:
Expand Down
2 changes: 2 additions & 0 deletions libs/meter/meter_types/test/test_percentile_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <gtest/gtest.h>

using namespace spectator;

class PercentileTimerTest : public testing::Test
{
protected:
Expand Down
2 changes: 2 additions & 0 deletions libs/meter/meter_types/test/test_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <gtest/gtest.h>

using namespace spectator;

class TimerTest : public testing::Test
{
protected:
Expand Down
4 changes: 4 additions & 0 deletions libs/utils/include/singleton.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once
// Templated Singleton for derived singleton classes

namespace spectator {

template <typename T>
class Singleton
{
Expand All @@ -21,3 +23,5 @@ class Singleton
return instance;
}
};

} // namespace spectator
Loading