Skip to content

Commit

Permalink
Code format - (Clang-format)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Mar 29, 2024
1 parent 6e72d10 commit 5bdecaa
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 41 deletions.
4 changes: 2 additions & 2 deletions src/lib/metrics/metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* Website: https://docs.opentibiabr.com/
*/

#include "metrics.hpp"
#include "lib/di/container.hpp"
#include "metrics.hpp"
#include "lib/di/container.hpp"

using namespace metrics;

Expand Down
62 changes: 31 additions & 31 deletions src/lib/metrics/metrics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
* Website: https://docs.opentibiabr.com/
*/

#pragma once

#include "game/scheduling/dispatcher.hpp"
#include <opentelemetry/exporters/ostream/metric_exporter_factory.h>
#include <opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h>
#include <opentelemetry/exporters/prometheus/exporter_factory.h>
#include <opentelemetry/exporters/prometheus/exporter_options.h>
#include <opentelemetry/metrics/provider.h>
#include <opentelemetry/sdk/metrics/aggregation/default_aggregation.h>
#include <opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h>
#include <opentelemetry/sdk/metrics/push_metric_exporter.h>
#include <opentelemetry/sdk/metrics/aggregation/base2_exponential_histogram_indexer.h>
#include <opentelemetry/sdk/metrics/meter.h>
#include <opentelemetry/sdk/metrics/meter_provider.h>
#include <opentelemetry/sdk/metrics/meter_provider_factory.h>
#include <opentelemetry/sdk/metrics/view/instrument_selector_factory.h>
#include <opentelemetry/sdk/metrics/view/meter_selector_factory.h>
#include <opentelemetry/sdk/metrics/view/view_factory.h>
#pragma once

#include "game/scheduling/dispatcher.hpp"
#include <opentelemetry/exporters/ostream/metric_exporter_factory.h>
#include <opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h>
#include <opentelemetry/exporters/prometheus/exporter_factory.h>
#include <opentelemetry/exporters/prometheus/exporter_options.h>
#include <opentelemetry/metrics/provider.h>
#include <opentelemetry/sdk/metrics/aggregation/default_aggregation.h>
#include <opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h>
#include <opentelemetry/sdk/metrics/push_metric_exporter.h>
#include <opentelemetry/sdk/metrics/aggregation/base2_exponential_histogram_indexer.h>
#include <opentelemetry/sdk/metrics/meter.h>
#include <opentelemetry/sdk/metrics/meter_provider.h>
#include <opentelemetry/sdk/metrics/meter_provider_factory.h>
#include <opentelemetry/sdk/metrics/view/instrument_selector_factory.h>
#include <opentelemetry/sdk/metrics/view/meter_selector_factory.h>
#include <opentelemetry/sdk/metrics/view/view_factory.h>

namespace metrics_sdk = opentelemetry::sdk::metrics;
namespace common = opentelemetry::common;
Expand All @@ -39,13 +39,13 @@ constexpr std::string_view methodName(const char* s) {
return prettyFunction.substr(space, bracket - space);
}

#if defined(__GNUC__) || defined(__clang__)
#define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__)
#elif defined(_MSC_VER)
#define __METHOD_NAME__ methodName(__FUNCSIG__)
#else
#error "Compiler not supported"
#endif
#if defined(__GNUC__) || defined(__clang__)
#define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__)
#elif defined(_MSC_VER)
#define __METHOD_NAME__ methodName(__FUNCSIG__)
#else
#error "Compiler not supported"
#endif

namespace metrics {
using Meter = opentelemetry::nostd::shared_ptr<metrics_api::Meter>;
Expand Down Expand Up @@ -86,12 +86,12 @@ namespace metrics {
bool stopped { false };
};

#define DEFINE_LATENCY_CLASS(class_name, histogram_name, category) \
class class_name##_latency final : public ScopedLatency { \
public: \
class_name##_latency(std::string_view name) : \
ScopedLatency(name, histogram_name "_latency", category) { } \
}
#define DEFINE_LATENCY_CLASS(class_name, histogram_name, category) \
class class_name##_latency final : public ScopedLatency { \
public: \
class_name##_latency(std::string_view name) : \
ScopedLatency(name, histogram_name "_latency", category) { } \
}

DEFINE_LATENCY_CLASS(method, "method", "method");
DEFINE_LATENCY_CLASS(lua, "lua", "scope");
Expand Down
26 changes: 18 additions & 8 deletions src/pch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,37 +176,47 @@ struct fmt::formatter<E, std::enable_if_t<std::is_enum_v<E>, char>> : formatter<
#ifdef FEATURE_METRICS
#define METRICS_METHOD_LATENCY_MEASURE() metrics::method_latency measure(__METHOD_NAME__)
#else
#define METRICS_METHOD_LATENCY_MEASURE() do {} while (0)
#define METRICS_METHOD_LATENCY_MEASURE() \
do { \
} while (0)
#endif

#ifdef FEATURE_METRICS
#define METRICS_LUA_LATENCY_MEASURE() metrics::lua_latency measure(getMetricsScope())
#else
#define METRICS_LUA_LATENCY_MEASURE() do {} while (0)
#define METRICS_LUA_LATENCY_MEASURE() \
do { \
} while (0)
#endif

#ifdef FEATURE_METRICS
#define METRICS_TASK_LATENCY_MEASURE() metrics::task_latency measure(context)
#else
#define METRICS_TASK_LATENCY_MEASURE() do {} while (0)
#define METRICS_TASK_LATENCY_MEASURE() \
do { \
} while (0)
#endif

#ifdef FEATURE_METRICS
#define METRICS_LOCK_LATENCY_MEASURE(scope) metrics::lock_latency measureLock(scope)
#else
#define METRICS_LOCK_LATENCY_MEASURE(scope) do {} while(0)
#define METRICS_LOCK_LATENCY_MEASURE(scope) \
do { \
} while (0)
#endif

#ifdef FEATURE_METRICS
#define METRICS_STOP_LOCK_LATENCY() measureLock.stop()
#else
#define METRICS_STOP_LOCK_LATENCY() do {} while(0)
#define METRICS_STOP_LOCK_LATENCY() \
do { \
} while (0)
#endif

#ifdef FEATURE_METRICS
#define METRICS_QUERY_LATENCY_MEASURE(query) metrics::query_latency measure(query.substr(0, 50))
#else
#define METRICS_QUERY_LATENCY_MEASURE(query) do {} while(0)
#define METRICS_QUERY_LATENCY_MEASURE(query) \
do { \
} while (0)
#endif


0 comments on commit 5bdecaa

Please sign in to comment.