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

feat: support network IO traffic monitoring #1733

Merged
merged 4 commits into from
Jul 18, 2023

Conversation

yaoyinnan
Copy link
Contributor

@yaoyinnan yaoyinnan commented Jul 15, 2023

Support network IO traffic monitoring. Including IO bytes and kps of Redis requests and master-slave replication.

Including the following indicators:

total_net_input_bytes: The total number of bytes read from the network
total_net_output_bytes: The total number of bytes written to the network
total_net_repl_input_bytes: The total number of bytes read from the network for replication purposes
total_net_repl_output_bytes: The total number of bytes written to the network for replication purposes
instantaneous_input_kbps: The network's read rate per second in KB/sec
instantaneous_output_kbps: The network's write rate per second in KB/sec
instantaneous_input_repl_kbps: The network's read rate per second in KB/sec for replication purposes
instantaneous_output_repl_kbps: The network's write rate per second in KB/sec for replication purposes

Execute the info stats command to view:

total_net_input_bytes:7655
total_net_output_bytes:84932
total_net_repl_input_bytes:5216
total_net_repl_output_bytes:4013
instantaneous_input_kbps:0.0751953
instantaneous_output_kbps:0.988281
instantaneous_input_repl_kbps:0.03125
instantaneous_output_repl_kbps:0.0185547

Collection rules:

  • For the Net IO traffic of Redis, it is collected in GetRequest and SendReply of RedisConn.
  • For the Net IO traffic of master-slave replication, it is collected in GetRequest and SendReply of PbConn.
  • For Net IO rate, the average per second is calculated by recording the value every 0.1s. Use an instantaneous_metric thread is started to collect instantaneous data every 0.1s.

Shown in Grafana:

network

Fixes: #1732

std::unordered_map<std::string, inst_metric> inst_metrics_;
};

#endif // PIKA_PIKA_INSTANT_H
Copy link

Choose a reason for hiding this comment

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

Based on the provided code patch, here is a brief code review:

  1. Licensing: The copyright and licensing information at the beginning of the file seem to be in order.

  2. Header Guards: The header guards (#ifndef and #define) are correctly used to prevent multiple inclusion of the header file.

  3. Includes: The necessary includes (<string> and <unordered_map>) are present.

  4. Magic Numbers: The constant value STATS_METRIC_SAMPLES appears to be a magic number. Consider giving it a meaningful name or documenting its purpose.

  5. Inline Constants: Using inline for the constants STATS_METRIC_NET_INPUT, STATS_METRIC_NET_OUTPUT, STATS_METRIC_NET_INPUT_REPLICATION, and STATS_METRIC_NET_OUTPUT_REPLICATION is unnecessary since they are defined in the header file. You can define them outside the class definition to avoid potential conflicts when including the header file in multiple places.

  6. Macro Usage: The macro usage in run_with_period(_ms_) is generally discouraged, as it can lead to code that is harder to reason about and maintain. Consider refactoring this into a function or lambda.

  7. Struct Definition: The inst_metric struct seems fine, although the purpose of its members could benefit from documentation or additional context.

  8. Class Definition: The Instant class looks reasonable. It has public member functions for tracking and retrieving instantaneous metrics, and a private data member inst_metrics_, which is an unordered map of metric names to inst_metric structs.

Overall, the code patch seems to be well-structured and free from obvious bugs. However, further evaluation would require knowledge of the overall program structure and design goals.

@yaoyinnan yaoyinnan requested a review from Mixficsol July 15, 2023 03:55

#endif // PIKA_MONOTONIC_TIME_H


Copy link

Choose a reason for hiding this comment

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

The provided code patch appears to define a header file for obtaining monotonic time in microseconds. Here are some suggestions for improvement and potential bug risks to consider:

  1. License and copyright: Ensure that the information in the comments accurately reflects the licensing and copyright details for your code.
  2. Include guards: Including #ifndef and #define directives ensure that the header file is included only once, preventing duplicate definitions if the header is included multiple times.
  3. Use the <chrono> library: Instead of using typedef uint64_t monotime, you can leverage the C++11 <chrono> library to provide a more standard and flexible way of handling time durations and points in time.
  4. Consider using std::int64_t: If negative time values are not expected, you could use std::uint64_t as the type for monotime.
  5. Error handling: Implement appropriate error-handling mechanisms if the function getMonotonicUs() encounters errors such as failures in obtaining the monotonic time value.
  6. Unit testing: It would be beneficial to include unit tests to verify the correctness and accuracy of the getMonotonicUs() function.

Make sure you review the rest of your codebase to ensure that this patch is integrated correctly and consistently throughout your project.

@yaoyinnan
Copy link
Contributor Author

I'm not sure if monotonic_time is doing the right thing, it has to be compatible with x86 and arm of linux and darwin, and each OS and architecture may have different underlying acquisition time. Please take a look here.

std::unordered_map<std::string, inst_metric> inst_metrics_;
};

#endif // PIKA_PIKA_INSTANT_H
Copy link

Choose a reason for hiding this comment

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

The code patch appears to introduce a new header file called "pika_instant.h" that defines a class called "Instant" and a structure called "inst_metric." Here's a brief code review:

  1. Licensing: The license information at the top of the file suggests that this code is copyrighted by Qihoo, Inc. and is licensed under the BSD-style license. It also mentions an additional grant of patent rights. If you are using this code, make sure you comply with the licensing terms.

  2. Header guards: The header file has appropriate include guards to prevent multiple inclusions.

  3. Dependencies: The code includes the necessary headers for std::string and std::unordered_map.

  4. Constants: Several constant strings are defined using the inline const std::string syntax. This allows them to be used as constants while providing flexibility during compilation.

  5. Macro: The run_with_period macro is defined but not used in the code snippet you provided. Make sure it is being used correctly elsewhere.

  6. Structures and classes:

    • The inst_metric structure holds fields related to tracking instantaneous metrics, such as samples and index.
    • The Instant class encapsulates functionality to track and retrieve instantaneous metrics.
    • The public interface includes functions trackInstantaneousMetric and getInstantaneousMetric, which allow tracking and retrieving metric values, respectively.
  7. Private member: The class has a private member, inst_metrics_, which is an unordered map that associates each metric name (a string) with an instance of inst_metric. This allows storing and managing multiple metrics within the Instant class.

Overall, without seeing the implementation details of the class methods, it is difficult to assess the correctness or potential improvements. However, based on the provided code, the structure looks reasonable, ensuring encapsulation of instantaneous metric tracking.


#endif // PIKA_MONOTONIC_TIME_H


Copy link

Choose a reason for hiding this comment

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

The code patch you provided appears to be a header file named "pika_monotonic_time.h." Below is a brief code review:

  1. Licensing: The code includes a copyright notice and mentions the BSD-style license. However, since I can't see the contents of the LICENSE and PATENTS files, I can't verify the licensing compliance.

  2. Header guards: The header file contains proper header guards to prevent multiple inclusions.

  3. Dependencies: The code relies on <cstdint>, suggesting the usage of fixed-size integer types such as uint64_t.

  4. Typedef: The code defines a typedef for monotime, which represents a counter in microseconds.

  5. Function declaration: The code declares a function getMonotonicUs() that returns a monotime value. Presumably, this function retrieves the current monotonic time in microseconds.

Overall, the code seems fine from the provided information. However, without further context or implementation details, it's difficult to identify specific bug risks or improvement suggestions.

std::unordered_map<std::string, inst_metric> inst_metrics_;
};

#endif // PIKA_PIKA_INSTANT_H
Copy link

Choose a reason for hiding this comment

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

The provided code patch appears to define a class called Instant and some related structures and functions. Here are some observations and suggestions for improvement:

  1. In the Instant class, it would be better to mark the default constructor and destructor as default explicitly (e.g., Instant() = default;, ~Instant() = default;) instead of relying on implicit generation.

  2. The stat_metrics definitions could be moved outside the class and declared as constant variables rather than using inline const in the class. For example:

const std::string STATS_METRIC_NET_INPUT = "stats_metric_net_input";
const std::string STATS_METRIC_NET_OUTPUT = "stats_metric_net_output";
// ...
  1. The use of macros (#define) for STATS_METRIC_SAMPLES and run_with_period should be avoided. Prefer using constant values or constexpr variables instead.

  2. It's generally recommended to use explicit access specifiers (public, protected, private) when declaring class members. So, consider adding public: before the trackInstantaneousMetric and getInstantaneousMetric function declarations.

  3. The trackInstantaneousMetric function takes four parameters. It would be useful to provide comments describing each parameter's purpose and expected values.

  4. Consider validating the input parameters within the trackInstantaneousMetric function to ensure they are within valid ranges or handle potential edge cases.

  5. The getInstantaneousMetric function returns a uint64_t without any indication of failure. Depending on your specific use case, you might want to add error handling or specify a default value when the requested metric is not found.

  6. The inst_metrics_ member in the Instant class uses an unordered_map to store metrics. Ensure that there are no concurrency issues if this class is used in a multi-threaded context. Consider using appropriate synchronization mechanisms (e.g., locks) if necessary.

Overall, the provided code patch seems to define a structure for tracking instantaneous metrics. However, without knowing the broader context and usage of this code, it's challenging to assess its correctness or identify potential bug risks specific to your application. Reviewing the surrounding code and considering the intended use of the Instant class would provide more insights into its overall quality.

std::unordered_map<std::string, inst_metric> inst_metrics_;
};

#endif // PIKA_PIKA_INSTANT_H
Copy link

Choose a reason for hiding this comment

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

The provided code appears to define a class called Instant and some related structures and constants. Here is a brief review of the code:

  1. Licensing: The code includes licensing information, which is good practice.
  2. Header Guards: The code uses header guards (#ifndef and #endif) to prevent multiple inclusions of the header file, which is also good practice.
  3. Standard Library Includes: The code includes the necessary header files (<string> and <unordered_map>) for the standard library classes it uses.
  4. Constant Definitions: The code defines several constants using inline const std::string, which is fine. However, consider moving them outside the header file and into a source file, as they may cause linker errors if included in multiple translation units.
  5. Macro Definition: The code defines a macro called run_with_period. It's generally recommended to avoid macros whenever possible due to various difficulties and potential issues they can introduce. Consider refactoring this into a function or using a lambda instead.
  6. Data Structure: The code defines a data structure called inst_metric, which tracks instantaneous metrics. It uses an array to store samples and includes some members for managing the samples. This structure seems reasonable for its intended purpose.
  7. Class Definition: The Instant class tracks instantaneous metrics using an unordered map to associate metric names with inst_metric objects. The class provides methods to track and retrieve instantaneous metrics. The implementation of these methods is not shown, so it's difficult to provide specific suggestions for improvement or bug risk assessment.

General Suggestions:

  • Consider following consistent naming conventions for variables, functions, and classes (e.g., camelCase or snake_case).
  • Examine the implementation of the trackInstantaneousMetric and getInstantaneousMetric methods to ensure correct functionality and error handling.
  • Verify that the std::unordered_map usage in the Instant class is appropriate for your requirements.
  • Consider writing unit tests to verify the behavior of the code and catch any potential bugs.

Overall, without a complete implementation or context, it's challenging to provide a detailed review. Please ensure you test the code thoroughly and consider the given suggestions as general guidelines.

#include <string>
#include <unordered_map>

#define STATS_METRIC_SAMPLES 16 /* Number of samples per metric. */
Copy link
Collaborator

Choose a reason for hiding this comment

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

define改为const

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to inline constexpr size_t.

inline const std::string STATS_METRIC_NET_INPUT_REPLICATION = "stats_metric_net_input_replication";
inline const std::string STATS_METRIC_NET_OUTPUT_REPLICATION = "stats_metric_net_output_replication";

#define run_with_period(_ms_) if (((_ms_) <= 1000/server.hz) || !(server.cronloops%((_ms_)/(1000/server.hz))))
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里用lamda表达式

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function is actually not used and has been deleted. The timing execution is modified to start a thread at pika_server::Start() to collect instantaneous indicators at regular intervals.

uint64_t NetInputBytes();
uint64_t NetOutputBytes();
uint64_t NetReplInputBytes();
uint64_t NetReplOutputBytes();
Copy link
Collaborator

Choose a reason for hiding this comment

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

uint64_t统一改为size_t

Copy link
Contributor Author

Choose a reason for hiding this comment

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

edited.

std::atomic<uint64_t> stat_net_input_bytes = {0}; /* Bytes read from network. */
std::atomic<uint64_t> stat_net_output_bytes = {0}; /* Bytes written to network. */
std::atomic<uint64_t> stat_net_repl_input_bytes = {0}; /* Bytes read during replication, added to stat_net_input_bytes in 'info'. */
std::atomic<uint64_t> stat_net_repl_output_bytes = {0}; /* Bytes written during replication, added to stat_net_output_bytes in 'info'. */
Copy link
Collaborator

Choose a reason for hiding this comment

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

= {}二选一,不要两个都写

Copy link
Contributor Author

Choose a reason for hiding this comment

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

edited.


namespace net {

uint64_t NetworkStatistic::NetInputBytes() { return stat_net_input_bytes.load(std::memory_order_relaxed); }
Copy link
Collaborator

Choose a reason for hiding this comment

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

return 和return的内容放在同一行

Copy link
Contributor Author

Choose a reason for hiding this comment

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

edited.


uint64_t NetworkStatistic::NetReplOutputBytes() { return stat_net_repl_output_bytes.load(std::memory_order_relaxed); }

void NetworkStatistic::IncrInputBytes(uint64_t bytes) { stat_net_input_bytes.fetch_add(bytes, std::memory_order_relaxed); }
Copy link
Collaborator

Choose a reason for hiding this comment

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

函数体放在下一行

Copy link
Contributor Author

Choose a reason for hiding this comment

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

edited.

if (inst_metrics_[metric].last_sample_base > 0) {
uint64_t base = current_base - inst_metrics_[metric].last_sample_base;
uint64_t value = current_value - inst_metrics_[metric].last_sample_value;
uint64_t avg = base > 0 ? (value * factor / base) : 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

uint64_t可以统一改成size_t

Copy link
Contributor Author

Choose a reason for hiding this comment

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

edited.

src/pika_instant.cc Show resolved Hide resolved
@@ -1446,6 +1486,19 @@ void PikaServer::AutoKeepAliveRSync() {
}
}

void PikaServer::AutoInstantaneousMetric() {
monotime current_time = getMonotonicUs();
uint64_t factor = 1000000; // us
Copy link
Collaborator

Choose a reason for hiding this comment

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

size_t

Copy link
Contributor Author

Choose a reason for hiding this comment

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

edited.

std::unordered_map<std::string, inst_metric> inst_metrics_;
};

#endif // PIKA_PIKA_INSTANT_H
Copy link

Choose a reason for hiding this comment

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

The code patch appears to define a class called Instant and a corresponding structure inst_metric. The Instant class is used for tracking instantaneous metrics, such as the number of operations per second and network traffic. Here's a brief review and some suggestions:

  1. License: The code includes a copyright notice and license information, which is good practice.

  2. Naming Conventions: The naming conventions in the code seem reasonable, with meaningful names for classes, variables, and constants.

  3. Header Guards: The header file includes proper header guards (#ifndef...#endif), preventing multiple inclusions of the same header.

  4. Dependencies: The code relies on the C++ standard library (<string>, <unordered_map>). Ensure that these dependencies are correctly included, given the overall context of the codebase.

  5. Magic Numbers: The use of the magic number 16 (STATS_METRIC_SAMPLES) should be replaced with a named constant or variable to improve code readability and maintainability.

  6. Class Design: The Instant class seems well-designed for its purpose. It provides methods to track and retrieve instantaneous metrics. However, it may be helpful to add more documentation (comments or function descriptions) clarifying their usage.

  7. Error Handling: Ensure that there are appropriate error handling mechanisms in place for cases when the requested metric does not exist.

  8. Memory Management: The Instant class uses the default constructor and destructor, which is fine unless there is specific resource management involved. Verify that no additional memory allocation or deallocation needs to be performed.

Overall, the code patch looks reasonable, but a comprehensive review would depend on understanding the broader context and requirements of the codebase.


#endif // PIKA_MONOTONIC_TIME_H


Copy link

Choose a reason for hiding this comment

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

The provided code patch appears to define a C++ header file named "pika_monotonic_time.h," which includes functions and type definitions related to obtaining monotonic time in microseconds.

Here's a brief code review:

  1. Licensing: The copyright and license information indicate that the code is copyrighted by Qihoo, Inc. and is licensed under the BSD-style license. It's generally good practice to include licensing information in the code.

  2. Header Guards: The inclusion of header guards (#ifndef/#define/#endif) ensures that the contents of the header are only included once, preventing duplicate definitions if the header is included multiple times in a source file.

  3. Type Definition: The code defines a monotime type as an alias for uint64_t. This allows for better documentation and clarification when using variables associated with monotonic time.

  4. Function Declaration: The getMonotonicUs() function is declared, which suggests that it retrieves the current monotonic time in microseconds.

Overall, the code patch seems straightforward and does not raise any apparent bug risks. However, without further context or the implementation details of the getMonotonicUs() function, it's not possible to provide more specific improvement suggestions.

To ensure the accuracy and correctness of the code, it's recommended to thoroughly test and verify the behavior of the getMonotonicUs() function once it's implemented.

@yaoyinnan yaoyinnan requested a review from chejinge July 17, 2023 02:41

/* The following two are used to track instantaneous metrics, like
* number of operations per second, network traffic. */
struct inst_metric{
Copy link
Collaborator

Choose a reason for hiding this comment

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

是否用大小写

Copy link
Contributor Author

@yaoyinnan yaoyinnan Jul 17, 2023

Choose a reason for hiding this comment

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

是的,它应该大写,修改了。

/*
* Instantaneous Metric used
*/
Instant instant_;
Copy link
Collaborator

Choose a reason for hiding this comment

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

1、格式缩进对齐
2、考虑下是否使用 std::unique_ptr

Copy link
Contributor Author

Choose a reason for hiding this comment

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

是的

@@ -192,6 +206,8 @@ void PikaServer::Start() {
}
}
LOG(INFO) << "Goodbye...";

instantaneous_metric.join();
Copy link
Collaborator

Choose a reason for hiding this comment

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

为啥是在 pika exit 的时候进行 join 呢?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

我想了想,这里不需要 join,instant_metric是后台线程,不需要阻塞主线程。我去掉了。

@@ -87,6 +87,7 @@ ReadStatus RedisConn::GetRequest() {
}

nread = read(fd(), rbuf_ + next_read_pos, remain);
g_network_statistic->IncrInputBytes(nread);
Copy link
Collaborator

Choose a reason for hiding this comment

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

一个是在 redis_con 监控,一个是在 pb_conn 监控,命名方式可以考虑统一下:
IncrRedisInputBytes
IncrRedisOutputBytes

IncrReplInputBytes
IncrReplOutputBytes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

是的,这样区分比较好,已经修改了。

tmp_stream << "total_net_output_bytes:" << g_pika_server->NetOutputBytes() + g_pika_server->NetReplOutputBytes() << "\r\n";
tmp_stream << "total_net_repl_input_bytes:" << g_pika_server->NetReplInputBytes() << "\r\n";
tmp_stream << "total_net_repl_output_bytes:" << g_pika_server->NetReplOutputBytes() << "\r\n";
tmp_stream << "instantaneous_input_kbps:" << g_pika_server->InstantaneousInputKbps() << "\r\n";
Copy link
Collaborator

Choose a reason for hiding this comment

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

是否要说明是 pika 命令相关的瞬时流量?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里instantaneous_input_kbps所代表的是Redis 命令和Repl的瞬时流量之和。当部署单节点时,total_net_output_bytes和instantaneous_input_kbps只代表Redis 命令的流量。当部署主从集群的时候,只需要通过差值就可以得到 Redis 命令的流量。

Support network IO traffic monitoring. Including IO bytes and kps of Redis requests and master-slave replication.

Fixes: OpenAtomFoundation#1732

Signed-off-by: yaoyinnan <[email protected]>
Support network IO traffic monitoring. Including IO bytes and kps of Redis requests and master-slave replication.

Fixes: OpenAtomFoundation#1732

Signed-off-by: yaoyinnan <[email protected]>
@@ -129,6 +130,7 @@ WriteStatus RedisConn::SendReply() {
size_t wbuf_len = response_.size();
while (wbuf_len > 0) {
nwritten = write(fd(), response_.data() + wbuf_pos_, wbuf_len - wbuf_pos_);
g_network_statistic->IncrRedisOutputBytes(nwritten);
if (nwritten <= 0) {
break;
}
Copy link

Choose a reason for hiding this comment

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

Code Review:

  • The inclusion of <climits> and <string> headers seems to be unnecessary as they are not used in the code.
  • You have included a new header file "net/include/net_stats.h", but it is missing from the patch. Make sure it is properly included and defined.
  • It is assumed that g_network_statistic is defined and initialized elsewhere in the code since it is used in the RedisConn class.
  • The use of read() and write() functions without proper error handling can be improved. Instead of checking for specific errno values, consider using non-blocking I/O or handling errors more explicitly.
  • Generally, it is recommended to use RAII (Resource Acquisition Is Initialization) to manage resources like file descriptors (fd()). Consider using smart pointers or wrapper classes to ensure proper resource management.
  • There might be additional improvements or bug risks specific to the functionality implemented in RedisConn that cannot be identified solely based on this code snippet. A thorough review of the entire codebase would be necessary for a comprehensive assessment.

@@ -3,5 +3,8 @@ scrape_configs:
scrape_interval: 15s
static_configs:
- targets: ['127.0.0.1:9121']
labels:
group: 'test'
- targets: ['127.0.0.1:9122']
labels:
group: 'test' No newline at end of file
Copy link

Choose a reason for hiding this comment

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

The code patch you provided appears to be a configuration file for Prometheus scrape_configs. Overall, the changes you made seem fine, but there are a couple of improvements and bug risks that can be addressed:

  1. Syntax error: There is a missing indentation before scrape_interval in line 3. Make sure it aligns correctly with scrape_configs.

  2. End-of-file newline: As mentioned in the diff (\ No newline at end of file), it seems like the patch does not have a newline character at the end of the file. While this might not cause any immediate issues, adding the newline can help ensure consistency and avoid potential parser errors.

  3. Label naming conventions: Although not necessarily required, it is common practice to use lowercase and underscore-separated labels instead of using single quotes around label values. For example, 'test' could be changed to test.

These suggestions should help improve the readability and maintainability of your configuration file.

Support network IO traffic monitoring. Including IO bytes and kps of Redis requests and master-slave replication.

Fixes: OpenAtomFoundation#1732

Signed-off-by: yaoyinnan <[email protected]>
chejinge
chejinge previously approved these changes Jul 17, 2023
fix exporter makefile

Fixes: OpenAtomFoundation#1732

Signed-off-by: yaoyinnan <[email protected]>
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o bin/$(PROJNAME)
else ifeq ($(ARCH), arm64)
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o bin/$(PROJNAME)
endif
endif

deps: generateVer
Copy link

Choose a reason for hiding this comment

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

The code patch you provided appears to be checking the operating system and architecture to determine how to build the project. Here are some suggestions for improvement and bug risk assessment:

  1. Proper indentation: The indentation in the code snippet you provided is inconsistent. It's good practice to use consistent indentation to improve readability. Make sure all lines within the same block have the same indentation level.

  2. Commenting: Consider adding comments to explain the purpose of each section or condition. This will make it easier for others (including yourself) to understand the intentions behind the code.

  3. Use elif instead of else if: In some parts of the code, you're using else if to chain conditions. It's generally recommended to use elif instead for better readability.

  4. Error handling: There is no explicit error handling in the code snippet you provided. It may be beneficial to add appropriate error handling mechanisms to handle cases where the build process fails.

Apart from these points, it's difficult to identify any specific bugs or improvements without understanding the bigger context of your project and the rest of the codebase.

@yaoyinnan yaoyinnan merged commit 4821991 into OpenAtomFoundation:unstable Jul 18, 2023
10 checks passed
@yaoyinnan yaoyinnan mentioned this pull request Jul 27, 2023
bigdaronlee163 pushed a commit to bigdaronlee163/pika that referenced this pull request Jun 8, 2024
* feat: support network IO traffic monitoring

Support network IO traffic monitoring. Including IO bytes and kps of Redis requests and master-slave replication.

Fixes: OpenAtomFoundation#1732

Signed-off-by: yaoyinnan <[email protected]>
cheniujh pushed a commit to cheniujh/pika that referenced this pull request Sep 24, 2024
* feat: support network IO traffic monitoring

Support network IO traffic monitoring. Including IO bytes and kps of Redis requests and master-slave replication.

Fixes: OpenAtomFoundation#1732

Signed-off-by: yaoyinnan <[email protected]>
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.

pika_exporter: support network IO traffic monitoring
3 participants