Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow several <graphite> targets #603

Merged
merged 21 commits into from
Mar 21, 2017
Merged

Conversation

proller
Copy link
Contributor

@proller proller commented Mar 16, 2017

No description provided.

namespace DB
{
/// get all internal key names for given key
std::vector<std::string> config_keys_multi(Poco::Util::AbstractConfiguration & config, const std::string & root, const std::string & name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function name is not in style.

auto & config = Poco::Util::Application::instance().config();
auto interval = config.getInt(config_name + ".interval", 60);

setThreadName(("MetricsTransmit " + std::to_string(interval) + "s").c_str());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thread name could be maximum 15 bytes long.
This code is misleading.

std::chrono::time_point_cast<std::chrono::minutes, std::chrono::system_clock>(
std::chrono::system_clock::now() + std::chrono::minutes(seconds / 60)));
return std::chrono::time_point_cast<std::chrono::seconds, std::chrono::system_clock>(
std::chrono::system_clock::now() + std::chrono::seconds(seconds));
Copy link
Member

@alexey-milovidov alexey-milovidov Mar 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, you should also align any intervals, which length is divisor of 60. Or all intervals.
For example, 15-second intervals should be aligned to 15-second boundaries, to avoid time drift.

@@ -22,14 +23,15 @@ class AsynchronousMetrics;
class MetricsTransmitter
{
public:
MetricsTransmitter(const AsynchronousMetrics & async_metrics_) : async_metrics(async_metrics_) {}
MetricsTransmitter(const AsynchronousMetrics & async_metrics, const std::string & config_name) : async_metrics{async_metrics}, config_name{config_name} {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double whitespace.

namespace DB
{
/// get all internal key names for given key
std::vector<std::string> config_keys_multi(Poco::Util::AbstractConfiguration & config, const std::string & root, const std::string & name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably you could use more meaningful name, like getMultipleKeysFromConfig.

@@ -558,8 +556,12 @@ int Server::main(const std::vector<std::string> & args)

attach_system_tables_async(system_database, async_metrics);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please correct function names according to style.

<graphite>
<host>localhost</host>
<port>42000</port>
<root_path>one_min</root_path>
<timeout>0.1</timeout>
<interval>60</interval>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add comment here.

<graphite>
<host>localhost</host>
<port>42000</port>
<root_path>one_min</root_path>
<timeout>0.1</timeout>
<interval>60</interval>

<metrics>true<metrics>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here.

@@ -85,5 +85,29 @@ std::ostream & operator<<(std::ostream & stream, const std::pair<K, V> & what)
return stream;
}

#include <ratio>

template < std::intmax_t Num, std::intmax_t Denom>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent whitespace. Double whitespace.
Num with capital letter is not in style, lowercase will be Ok..

graphite_writer.reset(new GraphiteWriter("graphite"));
for (const auto & key : DB::config_keys_multi(config(), "", "graphite"))
{
graphite_writers.emplace(std::make_pair(key, new GraphiteWriter(key)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid operator new, use make_unique instead.
You could construct std::pair inplace, no need for std::make_pair.

@alexey-milovidov alexey-milovidov merged commit 670e98f into ClickHouse:master Mar 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants