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

Feature Request: Add ability to automatically hide metric columns if value is not set #2673

Merged
merged 15 commits into from
Jan 2, 2025

Conversation

AvishaiDotan
Copy link
Contributor

This is my first contribution to this repository.
I have read the contributing guidelines and hope this PR complies with them. If something is missing, I am more than happy to hear feedback. This is my first contribution, but I sincerely hope it will not be my last.

Technical:
I followed @timcassell instructions and replaced the returning boolean with an expression.
I also added sample tests for the repository reviewers to use during testing.

These samples do not need to be merged as this PR is relatively small. Their purpose is to make the reviewer's job easier.

@AvishaiDotan
Copy link
Contributor Author

@dotnet-policy-service agree

@timcassell
Copy link
Collaborator

Please see comments on previous PRs for this issue. #2633 and #2658

…ptor handler.

Added attribute parameters instead of checking the metric.Value directly.
@AvishaiDotan
Copy link
Contributor Author

@timcassell
I reviewed my PR based on the issues you mentioned

My concern with this change is users adding the diagnoser and being surprised by no column showing. Perhaps the auto-hide feature should be behind a configuration on the diagnoser itself.

I have implemented a parameter-based hiding feature instead of using metric.Value > 0.

Previous code:
public bool GetIsAvailable(Metric metric) => metric.Value > 0;
Updated Code:
public bool GetIsAvailable(Metric metric) => Config.DisplayCompletedWorkItemCountWhenZero || metric.Value > 0;

To support this, I've implemented configuration files and parameter-based hiding, where the default is to always display the metric columns. For example:
image

I have also implemented a MetricDescriptorSingletonBasePattern and a MetricDescriptorConfigurationHandler to support injection of configuration within MetricDescriptor and to adhere to DRY principles.

Could you please provide a reference for situations where CompletedWorkItemCount and LockContentionCount benchmarks are not zero, so that I can create the tests?

@timcassell
Copy link
Collaborator

timcassell commented Dec 10, 2024

Could you please provide a reference for situations where CompletedWorkItemCount and LockContentionCount benchmarks are not zero, so that I can create the tests?

These are racy properties not really suitable for integration tests (they could be flaky). You could instead mock them. See SummaryTableTests and MarkdownExporterVerifyTests.

@AvishaiDotan
Copy link
Contributor Author

AvishaiDotan commented Dec 11, 2024

@timcassell
I ignored the Singleton pattern and instead created a new instance of the descriptor with injected configs. Logically, it shouldn't affect the process, but I ran some tests to be sure, and I didn't find any impact.

My suggestion is to create a base class that implements this logic, instead of repeating the code

@timcassell
Copy link
Collaborator

My suggestion is to create a base class that implements this logic, instead of repeating the code

You can if you want, but I have a suspicion that it will have more code rather than less.

Btw, if you're going to do that, I would just inject the bool flag directly rather than the entire config object.

Implement descriptorConfigInjector base class to keep the code dry
@AvishaiDotan
Copy link
Contributor Author

My suggestion is to create a base class that implements this logic, instead of repeating the code

You can if you want, but I have a suspicion that it will have more code rather than less.

Btw, if you're going to do that, I would just inject the bool flag directly rather than the entire config object.

I’ve separated the configuration injection into its own logic. It’s not a huge amount of code, but I think it’s a smarter approach and will be easier to control. The getIsAvailable method stays the same. As for injecting the boolean, you know the project better than I do. My workaround was meant to let configurations affect the descriptors with multiple variables. But if that’s not really needed, injecting the boolean and skipping the base class for injection would probably be the better way to go.

@timcassell
Copy link
Collaborator

Sorry for the delay. I just tried out your changes to make sure it looks correct with a joined table with multiple configured , and it LGTM!

Btw, for future PRs, you should make a separate branch on your fork instead of working directly in the master branch. That way it will be easier to keep up to date with upstream and easier for others to pull your branch.

@timcassell timcassell merged commit cac4f6e into dotnet:master Jan 2, 2025
8 checks passed
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.

Feature Request: Add ability to automatically hide metric columns if value is not set
2 participants