mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-27 17:10:46 +00:00
feat: Use beast metrics
This commit is contained in:
24
include/xrpl/core/CollectorManager.h
Normal file
24
include/xrpl/core/CollectorManager.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/basics/BasicConfig.h>
|
||||
#include <xrpl/beast/insight/Insight.h>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
/** Provides the beast::insight::Collector service. */
|
||||
class CollectorManager
|
||||
{
|
||||
public:
|
||||
virtual ~CollectorManager() = default;
|
||||
|
||||
virtual beast::insight::Collector::ptr const&
|
||||
collector() = 0;
|
||||
|
||||
virtual beast::insight::Group::ptr const&
|
||||
group(std::string const& name) = 0;
|
||||
};
|
||||
|
||||
std::unique_ptr<CollectorManager>
|
||||
makeCollectorManager(Section const& params, beast::Journal journal);
|
||||
|
||||
} // namespace xrpl
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <xrpl/basics/Expected.h>
|
||||
#include <xrpl/basics/Slice.h>
|
||||
#include <xrpl/beast/insight/Event.h>
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/Asset.h>
|
||||
@@ -121,6 +122,12 @@ struct HostFunctions
|
||||
return j;
|
||||
}
|
||||
|
||||
[[nodiscard]] virtual beast::insight::Event
|
||||
executionTimeEvent(std::string_view name) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
[[nodiscard]] virtual bool
|
||||
checkSelf() const
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/core/CollectorManager.h>
|
||||
#include <xrpl/tx/ApplyContext.h>
|
||||
#include <xrpl/tx/wasm/HostFunc.h>
|
||||
|
||||
@@ -77,6 +78,15 @@ public:
|
||||
return rt_;
|
||||
}
|
||||
|
||||
beast::insight::Event
|
||||
executionTimeEvent(std::string_view name) const override
|
||||
{
|
||||
return ctx_.registry.get()
|
||||
.getCollectorManager()
|
||||
.group(std::string{name.data(), name.size()})
|
||||
->makeEvent("finish_time");
|
||||
}
|
||||
|
||||
bool
|
||||
checkSelf() const override
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user