- 
                Notifications
    You must be signed in to change notification settings 
- Fork 315
Stable Config improvements #9259
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
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            31 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      370e894
              
                Refactor matchOperator to use method reference comparator for efficiency
              
              
                mtoffl01 df4da2f
              
                Implement better exception handling and debug logging for StableConfi…
              
              
                mtoffl01 7049d36
              
                Add a debug log about no rules getting applied
              
              
                mtoffl01 e730cbe
              
                Improve test file logic and cleanup in StableConfigSourceTest class
              
              
                mtoffl01 5b639aa
              
                Github suggestions: Use static factory methods  as constructors for R…
              
              
                mtoffl01 85d11cf
              
                Improve exception message: include value of object that caused the fa…
              
              
                mtoffl01 6ab4b6c
              
                Add more test cases to StableConfigSourceTest to improve codecov
              
              
                mtoffl01 007f58a
              
                Add test coverage for StableConfigMappingException
              
              
                mtoffl01 ac69f2d
              
                Merge branch 'master' into mtoff/scfg-improvements
              
              
                mtoffl01 473c59b
              
                Update internal-api/src/main/java/datadog/trace/bootstrap/config/prov…
              
              
                mtoffl01 feb1ba0
              
                Update internal-api/src/main/java/datadog/trace/bootstrap/config/prov…
              
              
                mtoffl01 f93546a
              
                Use safeToString when printing stableconfig map
              
              
                mtoffl01 780aee3
              
                rearrange logic in selectors creation for better readability
              
              
                mtoffl01 ac5e05a
              
                delete superfluous else
              
              
                mtoffl01 bcebbcb
              
                Use constant to represent max length in safeToString
              
              
                mtoffl01 0baccfd
              
                use throwStableConfigMappingException helper function
              
              
                mtoffl01 957d9c9
              
                refactor exception catching in StableConfigSource
              
              
                mtoffl01 b9870bd
              
                restore semicolon in calls to throwStableConfigMappingException
              
              
                mtoffl01 5019584
              
                Use static import for throwStableConfigMappingException
              
              
                mtoffl01 e8d6e8f
              
                test other kinds of exceptions in StableConfigSource
              
              
                mtoffl01 1fefb17
              
                remove duplicate cfg assignments
              
              
                mtoffl01 058cbda
              
                fix missing operator test case
              
              
                mtoffl01 5460c8a
              
                Update internal-api/src/main/java/datadog/trace/bootstrap/config/prov…
              
              
                mtoffl01 37da711
              
                Improve readability of StableConfigMappingException and its function …
              
              
                mtoffl01 5dac7f8
              
                modify safeToString logic to print first 50 and last 50 chars
              
              
                mtoffl01 5104ac5
              
                Merge branch 'mtoff/scfg-improvements' of github.com:DataDog/dd-trace…
              
              
                mtoffl01 13bef8d
              
                remove extra placeholder in string message when printing exception
              
              
                mtoffl01 2706bca
              
                Update internal-api/src/main/java/datadog/trace/bootstrap/config/prov…
              
              
                mtoffl01 4dde216
              
                refactor Rules.from to perform type assertions before heavyweight lis…
              
              
                mtoffl01 bfd5d7b
              
                Merge branch 'mtoff/scfg-improvements' of github.com:DataDog/dd-trace…
              
              
                mtoffl01 16d5f36
              
                run spotless
              
              
                mtoffl01 File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
  
    
      
          
            40 changes: 40 additions & 0 deletions
          
          40 
        
  ...va/datadog/trace/bootstrap/config/provider/stableconfig/StableConfigMappingException.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package datadog.trace.bootstrap.config.provider.stableconfig; | ||
|  | ||
| public class StableConfigMappingException extends RuntimeException { | ||
| private static final int MAX_LEN = 100; | ||
|  | ||
| public StableConfigMappingException(String message) { | ||
| super(message); | ||
| } | ||
|  | ||
| /** | ||
| * Safely converts an object to a string for error reporting, truncating the result if it exceeds | ||
| * a maximum length. | ||
| * | ||
| * @param value the object to convert to a string | ||
| * @return a string representation of the object, truncated if necessary | ||
| */ | ||
| static String safeToString(Object value) { | ||
| if (value == null) return "null"; | ||
| String str = value.toString(); | ||
| if (str.length() > MAX_LEN) { | ||
| int partLen = MAX_LEN / 2; | ||
| return str.substring(0, partLen) | ||
| + "...(truncated)..." | ||
| + str.substring(str.length() - partLen); | ||
| } | ||
| return str; | ||
| } | ||
|  | ||
| /** | ||
| * Throws a StableConfigMappingException with a message that includes a safe string representation | ||
| * of the provided value. | ||
| * | ||
| * @param message the error message to include | ||
| * @param value the value to include in the error message, safely stringified | ||
| * @throws StableConfigMappingException always thrown by this method | ||
| */ | ||
| public static void throwStableConfigMappingException(String message, Object value) { | ||
| throw new StableConfigMappingException(message + " " + safeToString(value)); | ||
| } | ||
| } | 
        
          
  
    
      
          
            35 changes: 35 additions & 0 deletions
          
          35 
        
  ...st/groovy/datadog/trace/bootstrap/config/provider/StableConfigMappingExceptionTest.groovy
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package datadog.trace.bootstrap.config.provider | ||
|  | ||
| import datadog.trace.bootstrap.config.provider.stableconfig.StableConfigMappingException | ||
| import spock.lang.Specification | ||
|  | ||
| class StableConfigMappingExceptionTest extends Specification { | ||
|  | ||
| def "constructors work as expected"() { | ||
| when: | ||
| def ex1 = new StableConfigMappingException("msg") | ||
| def ex2 = new StableConfigMappingException("msg2") | ||
|  | ||
| then: | ||
| ex1.message == "msg" | ||
| ex1.cause == null | ||
| ex2.message == "msg2" | ||
| } | ||
|  | ||
| def "safeToString handles null"() { | ||
| expect: | ||
| StableConfigMappingException.safeToString(null) == "null" | ||
| } | ||
|  | ||
| def "safeToString handles short string"() { | ||
| expect: | ||
| StableConfigMappingException.safeToString("short string") == "short string" | ||
| } | ||
|  | ||
| def "safeToString handles long string"() { | ||
| given: | ||
| def longStr = "a" * 101 | ||
| expect: | ||
| StableConfigMappingException.safeToString(longStr) == ("a" * 50) + "...(truncated)..." + ("a" * 51).substring(1) | ||
| } | ||
| } | 
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍