Market data rate metrics reborn
This commit is contained in:
1 parent
af7e9dd3a8
commit
053c460ff6
4 files changed
+25
-14
No files matched your search
@@ -62,13 +62,27 @@ struct DatedHandle {
|
||||
|
||||
struct MDConsumerGroup {
|
||||
// probably just have to send the consumer in from outside
|
||||
MDConsumerGroup(const UserSymbol& symbol, const MDConsumer& consumer) :
|
||||
MDConsumerGroup(const UserSymbol& symbol, const MDConsumer& consumer, metrics::MetricsContainer& stats) :
|
||||
symbol(symbol),
|
||||
platform(platform_for_exchange(symbol.exchange())),
|
||||
channel(consumer.get_channel(symbol)),
|
||||
handles()
|
||||
{
|
||||
set_consumer(consumer);
|
||||
|
||||
// create and publish a stat for this group
|
||||
if (symbol.type() != SecurityType::SECURITYTYPE_SYNTHETIC) {
|
||||
std::vector<metrics::Label> labels;
|
||||
labels.push_back({ "symbol", symbol.symbol() });
|
||||
labels.push_back({ "type", SecurityType_Name(symbol.type()).substr(13) /*SECURITYTYPE_*/ });
|
||||
labels.push_back({ "exch", Venue_Name(symbol.exchange()).substr(6) /*VENUE_*/ });
|
||||
stats.publish(
|
||||
std::make_shared<metrics::LazyCounterMetric>("spark_md_book_updates", [=]() { return std::max(channel.bbo_count(), channel.depth_count()); }, labels));
|
||||
stats.publish(
|
||||
std::make_shared<metrics::LazyCounterMetric>("spark_md_security_count", [=]() { return channel.security_count(); }, labels));
|
||||
stats.publish(
|
||||
std::make_shared<metrics::LazyCounterMetric>("spark_md_trade_count", [=]() { return channel.trade_count(); }, labels));
|
||||
}
|
||||
}
|
||||
MDConsumerGroup(const MDConsumerGroup& other) = delete;
|
||||
|
||||
@@ -136,21 +150,18 @@ class QueryServerImpl : public IQueryServer {
|
||||
boost::container::flat_map<UserSymbol,shared_ptr<MDConsumerGroup>> _groups;
|
||||
|
||||
public:
|
||||
QueryServerImpl(const std::set<UserSymbol>& symbols, std::shared_ptr<api::ISyntheticSecurityService>& ss) :
|
||||
QueryServerImpl(const std::set<UserSymbol>& symbols, std::shared_ptr<api::ISyntheticSecurityService>& ss, metrics::MetricsContainer& stats) :
|
||||
_consumer(symbols, ss),
|
||||
_symbols(symbols),
|
||||
_ss(ss),
|
||||
_groups()
|
||||
{
|
||||
for (const auto& sym : symbols) {
|
||||
_groups.emplace(std::make_pair(sym, std::make_unique<MDConsumerGroup>(sym, _consumer)));
|
||||
_groups.emplace(std::make_pair(sym, std::make_unique<MDConsumerGroup>(sym, _consumer, stats)));
|
||||
}
|
||||
_groups.shrink_to_fit();
|
||||
|
||||
subscribe_securities();
|
||||
|
||||
// each symbol = new lazy metric
|
||||
// getchannel()->
|
||||
}
|
||||
|
||||
void subscribe_securities() {
|
||||
@@ -396,7 +407,7 @@ struct QueryServer {
|
||||
const bts::api::ServiceContext& ctx,
|
||||
std::shared_ptr<api::ISyntheticSecurityService>& ss,
|
||||
metrics::MetricsContainer& stats):
|
||||
db(symbols, ss),
|
||||
db(symbols, ss, stats),
|
||||
relay(db, threadpool, ctx, stats),
|
||||
security_timer(),
|
||||
health_timer()
|
||||
@@ -440,8 +451,8 @@ QueryServerPtr run_query_server(const bts::api::ServiceContext& ctx, std::shared
|
||||
return container;
|
||||
}
|
||||
|
||||
std::unique_ptr<IQueryServer> create_query_server(const std::set<UserSymbol>& symbols, std::shared_ptr<api::ISyntheticSecurityService>& ss) {
|
||||
return std::make_unique<QueryServerImpl>(symbols, ss);
|
||||
std::unique_ptr<IQueryServer> create_query_server(const std::set<UserSymbol>& symbols, std::shared_ptr<api::ISyntheticSecurityService>& ss, metrics::MetricsContainer& stats) {
|
||||
return std::make_unique<QueryServerImpl>(symbols, ss, stats);
|
||||
}
|
||||
|
||||
}}//namespace
|
||||
|
||||
Reference in new issue
Block a user