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

Modifying logic to provide metrics per MINIO endpoint #83

Conversation

nsarras
Copy link
Contributor

@nsarras nsarras commented Oct 30, 2023

No description provided.

dss_metrics/minio_rest_collector.py Outdated Show resolved Hide resolved
dss_metrics/minio_rest_collector.py Outdated Show resolved Hide resolved
dss_metrics/minio_rest_collector.py Show resolved Hide resolved
@mssawant
Copy link

mssawant commented Nov 7, 2023

@nsarras, why the commit message is empty? don't we follow any specific commit message template?

@nsarras
Copy link
Contributor Author

nsarras commented Nov 7, 2023

@nsarras, why the commit message is empty? don't we follow any specific commit message template?

I am not sure what you are referring to, each commit has a message

Copy link
Contributor

@grandsuri grandsuri left a comment

Choose a reason for hiding this comment

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

Each thread is having its own logger thread to log into their own files. This is not right way to do. We need to implement Queue handle based logger (you can borrow from DM repo) and pass the logger function handle to the thread.

if each thread is writing their log files, then someone has to go through all the files to debug

dss_metrics/metrics.py Outdated Show resolved Hide resolved
dss_metrics/metrics.py Outdated Show resolved Hide resolved
dss_metrics/metrics.py Show resolved Hide resolved

os.makedirs(os.path.dirname(logfile_path), exist_ok=True)
if not os.path.exists(logfile_path):
os.mknod(logfile_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

os.mknod() is used to create /dev/ usually.
Instead of that you can do

with os.open(file_path, flags) as f:
      pass

@mssawant
Copy link

mssawant commented Nov 7, 2023

I am not sure what you are referring to, each commit has a message

@nsarras, I mean Modifying logic to provide metrics per MINIO endpoint doesn't actually give a clear picture of the problem that this PR is fixing. I mean why the earlier logic didn't work, is there a corresponding github issue or jira ticket that you can link this PR to? or is it just a refactoring PR. It is good to describe the problem and solution in a way that gives reviewer an idea what to expect from this PR.
Consider this format,

Header line: explain the commit in one line (use the imperative)

Body of commit message is a few lines of text, explaining things
in more detail, possibly giving some background about the issue
being fixed, etc.

The body of the commit message can be several paragraphs, and
please do proper word-wrap and keep columns shorter than about
74 characters or so. That way "git log" will show things
nicely even when it's indented.

Make sure you explain your solution and why you're doing what you're
doing, as opposed to describing what you're doing. Reviewers and your
future self can read the patch, but might not understand why a
particular solution was implemented.

Reported-by: whoever-reported-it
Signed-off-by: Your Name <[email protected]>

continue
metrics_data_buffer.append(
metrics.MetricInfo(
metric[0], metric[0], metric[1], tags,
Copy link

Choose a reason for hiding this comment

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

Why pass metrics selectively?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is because we may not want to expose all metrics to the end user all of the time, hence why we filter using a whitelist if the filter flag is given

Copy link

Choose a reason for hiding this comment

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

I mean, why not metrics.MetricInfo(metric, tags..) ? Let MetricInfo filter out.
metrics.MetricInfo(metric[0], metric[0], metric[1], tags, doen't really help readability, else its better to use named params.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See new commits on PR, I made a lot of changes and not using this approach anymore

@nsarras
Copy link
Contributor Author

nsarras commented Nov 7, 2023

I am not sure what you are referring to, each commit has a message

@nsarras, I mean Modifying logic to provide metrics per MINIO endpoint doesn't actually give a clear picture of the problem that this PR is fixing. I mean why the earlier logic didn't work, is there a corresponding github issue or jira ticket that you can link this PR to? or is it just a refactoring PR. It is good to describe the problem and solution in a way that gives reviewer an idea what to expect from this PR. Consider this format,

Header line: explain the commit in one line (use the imperative)

Body of commit message is a few lines of text, explaining things
in more detail, possibly giving some background about the issue
being fixed, etc.

The body of the commit message can be several paragraphs, and
please do proper word-wrap and keep columns shorter than about
74 characters or so. That way "git log" will show things
nicely even when it's indented.

Make sure you explain your solution and why you're doing what you're
doing, as opposed to describing what you're doing. Reviewers and your
future self can read the patch, but might not understand why a
particular solution was implemented.

Reported-by: whoever-reported-it
Signed-off-by: Your Name <[email protected]>

@mssawant
Typically, we track tasks in JIRA; http://sj-jira.ssi.samsung.com:8080/browse/MIN-1876

I think you have a good suggestion and would be open to adopting that if we have the entire team agree that we want all of the details in each commit vs JIRA. The standard should be consistent across the team, and if you see other commits, the commit messages just indicate what was done, vs give a full summary & justification.

@mssawant
Copy link

mssawant commented Nov 7, 2023

@nsarras, good that you find my suggestion helpful. So, is this code open? if so, community does not have access to internal Jira servers.

Even though is the code is used for internal purposes, an elaborate commit message helps to give more defined information about the problem and corresponding fix to someone who is just looking at git history searching for a particular case.
One of the most important application of git history is auditing, it helps to expedite resolutions in case of patent conflicts as well.
Imagine commit messages as history of a particular product or a software. Without history you wouldn't know why a particular change happened and its significance.

Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

warning The version of Java (11.0.17) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.
Read more here

Copy link
Contributor

@grandsuri grandsuri left a comment

Choose a reason for hiding this comment

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

you can fix those issues if needed. otherwise looks good

while True:
time.sleep(1)
except Exception as error:
print(f"Failed to start Metrics http server: {str(error)}")
logger.info(f"Failed to start Metrics http server: {str(error)}")
Copy link
Contributor

Choose a reason for hiding this comment

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

you can call logger.exception to catch the backtrace


name = key
metric = Metric(name, key, 'gauge')
metric.add_sample(
Copy link
Contributor

Choose a reason for hiding this comment

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

this kind of code just increases the lines decreasing the readability.
If the logic is too complicated, makes sense to have each lines for arguments

@nsarras nsarras merged commit 4863a4c into master Nov 28, 2023
7 checks passed
@nsarras nsarras deleted the 81-metrics-agent-refactor-dss-metrics-agent-to-provide-minio-metrics-per-endpoint-instead-of-per-minio-cluster branch November 28, 2023 22:45
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.

[Metrics Agent] Refactor DSS Metrics Agent to provide MINIO metrics per endpoint instead of per MINIO cluster
3 participants