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 user to update system labels #270

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Vaibhav090420
Copy link
Contributor

Description

Please include a summary of the change, motivation and context.

Testing

Please describe the tests that you ran to verify your changes. Please summarize what did you test and what needs to be tested e.g. deployed and tested helm chart locally.

Checklist:

  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

Documentation

Make sure that you have documented corresponding changes in this repository or hypertrace docs repo if required.

@Vaibhav090420 Vaibhav090420 changed the title Allow user to update label rules Allow user to update system labels Jan 15, 2025
Copy link

github-actions bot commented Jan 15, 2025

Test Results

134 tests  ±0   134 ✅ ±0   49s ⏱️ -3s
 31 suites ±0     0 💤 ±0 
 31 files   ±0     0 ❌ ±0 

Results for commit 071d313. ± Comparison against base commit 0ebd13c.

♻️ This comment has been updated with latest results.

@Vaibhav090420 Vaibhav090420 marked this pull request as ready for review January 15, 2025 12:26
@Vaibhav090420 Vaibhav090420 requested a review from a team as a code owner January 15, 2025 12:26
@Vaibhav090420 Vaibhav090420 marked this pull request as draft January 15, 2025 12:26
@Vaibhav090420 Vaibhav090420 marked this pull request as ready for review January 16, 2025 06:56
@Vaibhav090420 Vaibhav090420 marked this pull request as draft January 16, 2025 07:09
@Vaibhav090420 Vaibhav090420 marked this pull request as ready for review January 16, 2025 09:34
Copy link

codecov bot commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 89.47368% with 6 lines in your changes missing coverage. Please review.

Project coverage is 77.24%. Comparing base (7a59a85) to head (d09f7e5).
Report is 22 commits behind head on main.

Files with missing lines Patch % Lines
...ace/label/config/service/SystemLabelInfoUtils.java 82.14% 2 Missing and 3 partials ⚠️
.../label/config/service/LabelsConfigServiceImpl.java 96.55% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #270      +/-   ##
============================================
- Coverage     79.93%   77.24%   -2.70%     
- Complexity      496      548      +52     
============================================
  Files            55       60       +5     
  Lines          2432     2689     +257     
  Branches        108      122      +14     
============================================
+ Hits           1944     2077     +133     
- Misses          427      540     +113     
- Partials         61       72      +11     
Flag Coverage Δ
integration ?
unit 77.24% <89.47%> (-1.24%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

() ->
Optional.ofNullable(
systemLabelInfoUtils
.getSystemLabelsIdLabelMap(getExistingLabels(requestContext))
Copy link
Member

Choose a reason for hiding this comment

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

i am confused here? why do you need to find system labels ids from existing labels? We dont change system config ids when we store them in DB

Copy link
Member

Choose a reason for hiding this comment

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

It should be as simple as

Label label =
          labelStore
              .getData(requestContext, labelId)
              .orElseGet(
                  () ->
                      Optional.ofNullable(
                              systemLabelInfoUtils
                                  .getDefaultSystemLabels()
                                  .filter(label -> label.getId().equals(labelId))
                                  .findFirst()
                          .orElseThrow(Status.NOT_FOUND::asRuntimeException));

this.config = config;
}

public List<Label> getSystemLabels(List<Label> existingLabels) {
Copy link
Member

Choose a reason for hiding this comment

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

i dont think you would ever need to evaluate system labels from existing labels. same comment for all methods

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In case of system label name updation, we would require it to evaluate from the existing labels in db. If we do not want the name updation on system label then, it is not required

@@ -194,15 +156,16 @@ public void getLabel(GetLabelRequest request, StreamObserver<GetLabelResponse> r
RequestContext requestContext = RequestContext.CURRENT.get();
String labelId = request.getId();
try {
Label label;
Copy link
Member

Choose a reason for hiding this comment

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

You would need to make changes in almost all the methods available in this api. So the flow would be like this

  1. We will build the defaultLabels list from the config.
  2. Now any update request can come from Clients. If update is for a label with id from system labels, then you save the entry in Db after doing necessary validation. For example we might not want to update names for system labels. Add necessary validation wherever needed.
  3. In case of read, We need to merge DB based labels and system labels while giving priority to DB entry and reorder if necessary. For example we always generally wants system label to be at the end of the list

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