Skip to content

Commit

Permalink
feat(new_metrics): remove http service for perf counters (#1540)
Browse files Browse the repository at this point in the history
#1539

In XiaoMi/rdsn#349 we've supported getting value
of counter by http request. Now since perf counter will be replaced by new
metrics, it can also be removed.
  • Loading branch information
empiredan authored and wangdan committed Dec 6, 2023
1 parent 274c0fb commit 3584394
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 191 deletions.
6 changes: 0 additions & 6 deletions src/http/builtin_http_calls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@ namespace dsn {
})
.with_help("Gets the server start time.");

register_http_call("perfCounter")
.with_callback([](const http_request &req, http_response &resp) {
get_perf_counter_handler(req, resp);
})
.with_help("Gets the value of a perf counter");

register_http_call("config")
.with_callback([](const http_request &req, http_response &resp) { get_config(req, resp); })
.with_help("get the details of a specified config");
Expand Down
2 changes: 0 additions & 2 deletions src/http/builtin_http_calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ struct http_response;
// Register basic services for the HTTP server.
extern void register_builtin_http_calls();

extern void get_perf_counter_handler(const http_request &req, http_response &resp);

extern void get_help_handler(const http_request &req, http_response &resp);

// Get <meta_server_ipport>/version
Expand Down
66 changes: 0 additions & 66 deletions src/http/perf_counter_http_service.cpp

This file was deleted.

76 changes: 0 additions & 76 deletions src/http/test/perf_counter_http_service_test.cpp

This file was deleted.

10 changes: 0 additions & 10 deletions src/perf_counter/perf_counters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,6 @@ bool perf_counters::remove_counter(const std::string &full_name)
return true;
}

perf_counter_ptr perf_counters::get_counter(const std::string &full_name)
{
utils::auto_read_lock l(_lock);
auto it = _counters.find(full_name);
if (it != _counters.end())
return it->second.counter;

return nullptr;
}

perf_counter *perf_counters::new_counter(const char *app,
const char *section,
const char *name,
Expand Down
2 changes: 0 additions & 2 deletions src/perf_counter/perf_counters.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ class perf_counters : public utils::singleton<perf_counters>
///
bool remove_counter(const std::string &full_name);

perf_counter_ptr get_counter(const std::string &full_name);

struct counter_snapshot
{
double value{0.0};
Expand Down
29 changes: 0 additions & 29 deletions src/perf_counter/test/perf_counters_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,33 +316,4 @@ TEST(perf_counters_test, query_snapshot_by_regexp)
ASSERT_TRUE(info.counters.empty());
}

TEST(perf_counters_test, get_by_fullname)
{
struct test_case
{
const char *app;
const char *section;
const char *name;
dsn_perf_counter_type_t type;
const char *dsptr;
bool create;
} tests[] = {{"replica", "eon", "get_by_fullname1", COUNTER_TYPE_NUMBER, "pf1", false},
{"replica", "eon", "get_by_fullname2", COUNTER_TYPE_NUMBER, "pf2", true}};

for (auto test : tests) {
// precondition: make sure the perf counter doesn't exist
std::string perf_counter_name;
perf_counter::build_full_name(test.app, test.section, test.name, perf_counter_name);
perf_counters::instance().remove_counter(perf_counter_name.c_str());

if (test.create) {
// create perf counter
perf_counter_wrapper counter;
counter.init_global_counter(test.app, test.section, test.name, test.type, test.dsptr);
ASSERT_NE(nullptr, perf_counters::instance().get_counter(perf_counter_name));
} else {
ASSERT_EQ(nullptr, perf_counters::instance().get_counter(perf_counter_name));
}
}
}
} // namespace dsn

0 comments on commit 3584394

Please sign in to comment.