- 
                Notifications
    You must be signed in to change notification settings 
- Fork 46
Use tdbr claim to route telemetry traffic to EU region, Fixes AB#3200872 #2679
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
          
     Open
      
      
            fadidurah
  wants to merge
  22
  commits into
  dev
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
fadi/EUClaim
  
      
      
   
  
    
  
  
  
 
  
      
    base: dev
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
      
        
          +121
        
        
          −0
        
        
          
        
      
    
  
  
     Open
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            22 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      f4f7c29
              
                merge initial changes
              
              
                fadidurah c56537b
              
                don't push if tdbr claim is not sent
              
              
                fadidurah 5828446
              
                Merg
              
              
                fadidurah 1d6c6b6
              
                attach tenant id to span when we get region
              
              
                fadidurah f9e8e65
              
                mock
              
              
                fadidurah cdfce81
              
                changelog
              
              
                fadidurah 9180499
              
                Update common/src/main/java/com/microsoft/identity/common/internal/pl…
              
              
                fadidurah aa490e3
              
                util class
              
              
                fadidurah 9c008b0
              
                util class
              
              
                fadidurah d3091b3
              
                imports
              
              
                fadidurah b716fb9
              
                fadi/EUClaim
              
              
                fadidurah 780c0b0
              
                simple
              
              
                fadidurah 0d2d609
              
                Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
              
              
                fadidurah 7ea5828
              
                add flight
              
              
                fadidurah b34911f
              
                remove changes from brokermsal controller
              
              
                fadidurah 4540fe2
              
                remove more changes
              
              
                fadidurah e3de84d
              
                Dev
              
              
                fadidurah 9961888
              
                new line
              
              
                fadidurah 8aa594c
              
                dev
              
              
                fadidurah 6b19747
              
                Merge branch 'fadi/EUClaim' of https://github.com/AzureAD/microsoft-a…
              
              
                fadidurah 0fe6f98
              
                update attribute name to add v2
              
              
                fadidurah 11d1d55
              
                merge dev
              
              
                fadidurah 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
    
  
  
    
              
        
          
  
    
      
          
            89 changes: 89 additions & 0 deletions
          
          89 
        
  common4j/src/main/com/microsoft/identity/common/java/opentelemetry/EUClaimStorageUtil.kt
  
  
      
      
   
        
      
      
    
  
    
      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,89 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // All rights reserved. | ||
| // | ||
| // This code is licensed under the MIT License. | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| // of this software and associated documentation files(the "Software"), to deal | ||
| // in the Software without restriction, including without limitation the rights | ||
| // to use, copy, modify, merge, publish, distribute, sublicense, and / or sell | ||
| // copies of the Software, and to permit persons to whom the Software is | ||
| // furnished to do so, subject to the following conditions : | ||
| // | ||
| // The above copyright notice and this permission notice shall be included in | ||
| // all copies or substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| // THE SOFTWARE. | ||
| package com.microsoft.identity.common.java.opentelemetry | ||
|  | ||
| import com.microsoft.identity.common.java.flighting.CommonFlight | ||
| import com.microsoft.identity.common.java.flighting.CommonFlightsManager.getFlightsProvider | ||
| import com.microsoft.identity.common.java.interfaces.IStorageSupplier | ||
| import com.microsoft.identity.common.java.logging.Logger | ||
| import com.microsoft.identity.common.java.providers.microsoft.azureactivedirectory.ClientInfo | ||
| import com.microsoft.identity.common.java.util.StringUtil | ||
|  | ||
| /** | ||
| * Utility class for storing telemetry region TDBR claims by tenant. | ||
| */ | ||
| class EUClaimStorageUtil { | ||
| companion object { | ||
| private val TAG = EUClaimStorageUtil::class.java.simpleName | ||
|  | ||
| /** | ||
| * Store telemetry region by tenant. | ||
| * | ||
| * @param clientInfo the client info containing tenant information and tdbr claim | ||
| */ | ||
| fun storeTelemetryRegionByTenant( | ||
| supplier: IStorageSupplier, | ||
| clientInfo: ClientInfo | ||
| ) { | ||
| val methodTag = "$TAG:storeTelemetryRegionByTenant" | ||
|  | ||
| if (!getFlightsProvider().isFlightEnabled(CommonFlight.ENABLE_USING_TDBR_CLAIM_FOR_EU_ROUTING)) { | ||
| // If flight is not enabled, just return, don't store anything | ||
| return; | ||
| } | ||
|  | ||
| val tenantId = clientInfo.utid | ||
| val tdbrClaim = clientInfo.tdbrClaim | ||
|  | ||
| if (StringUtil.isNullOrEmpty(tenantId)) { | ||
| Logger.warn( | ||
| methodTag, | ||
| "tenantId is null or empty. Not storing telemetry region by tenant." | ||
| ) | ||
| return | ||
| } | ||
|  | ||
| if (StringUtil.isNullOrEmpty(tdbrClaim)) { | ||
| Logger.warn( | ||
| methodTag, | ||
| "Received no tdbr claim, not storing anything in shared preferences.." | ||
| ) | ||
| return | ||
| } | ||
|  | ||
| // Store the tdbr claim for a specific tenant ID | ||
| Logger.info( | ||
| methodTag, | ||
| "Storing telemetry region by tenant: $tenantId, TDBR Claim: $tdbrClaim" | ||
| ) | ||
| val tdbrValueStore = supplier.getUnencryptedNameValueStore( | ||
| ClientInfo.TDBR_CLAIM, | ||
| String::class.java | ||
| ) | ||
| tdbrValueStore.put(tenantId, tdbrClaim) | ||
|  | ||
| // Attach tenant id to the current span | ||
| SpanExtension.current().setAttribute(AttributeName.tenant_id.name, tenantId) | ||
| } | ||
| } | ||
| } | 
  
    
      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
    
  
  
    
              
      
      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.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.