- 
                Notifications
    
You must be signed in to change notification settings  - Fork 168
 
Support for Lineage in XRay Trace Header and removing additional Baggage from being added #1671
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
          
          
            6 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      42fa0f7
              
                added support for Lineage in Xray Trace Header
              
              
                liustve b49754b
              
                cleaned up code and added additional test case
              
              
                liustve 16ad65b
              
                removed v2 from lineage names
              
              
                liustve 6b4517f
              
                changed variable names
              
              
                liustve efbb27f
              
                formatting fix
              
              
                liustve 3a6090f
              
                more cleanup
              
              
                liustve 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
    
  
  
    
              
        
          
  
    
      
          
            78 changes: 78 additions & 0 deletions
          
          78 
        
  ...test/java/io/opentelemetry/contrib/awsxray/propagator/AwsXrayCompositePropagatorTest.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,78 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| 
     | 
||
| package io.opentelemetry.contrib.awsxray.propagator; | ||
| 
     | 
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| 
     | 
||
| import io.opentelemetry.api.baggage.propagation.W3CBaggagePropagator; | ||
| import io.opentelemetry.api.trace.SpanContext; | ||
| import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator; | ||
| import io.opentelemetry.context.Context; | ||
| import io.opentelemetry.context.propagation.TextMapPropagator; | ||
| import java.util.LinkedHashMap; | ||
| import org.junit.jupiter.api.Test; | ||
| 
     | 
||
| public class AwsXrayCompositePropagatorTest extends AwsXrayPropagatorTest { | ||
| 
     | 
||
| @Override | ||
| TextMapPropagator propagator() { | ||
| return TextMapPropagator.composite( | ||
| W3CBaggagePropagator.getInstance(), | ||
| AwsXrayPropagator.getInstance(), | ||
| W3CTraceContextPropagator.getInstance()); | ||
| } | ||
| 
     | 
||
| @Test | ||
| void extract_traceContextOverridesXray() { | ||
| LinkedHashMap<String, String> carrier = new LinkedHashMap<>(); | ||
| String w3cTraceContextTraceId = "4bf92f3577b34da6a3ce929d0e0e4736"; | ||
| String w3cTraceContextSpanId = "00f067aa0ba902b7"; | ||
| String traceParent = | ||
| String.format("00-%s-%s-01", w3cTraceContextTraceId, w3cTraceContextSpanId); | ||
| String traceState = "rojo=00f067aa0ba902b7"; | ||
| String xrayTrace = String.format("Root=1-%s;Parent=%s;Sampled=0", TRACE_ID, SPAN_ID); | ||
| 
     | 
||
| carrier.put("traceparent", traceParent); | ||
| carrier.put("tracestate", traceState); | ||
| carrier.put("X-Amzn-Trace-Id", xrayTrace); | ||
| 
     | 
||
| SpanContext actualContext = getSpanContext(subject.extract(Context.current(), carrier, GETTER)); | ||
| 
     | 
||
| assertThat(actualContext.getTraceId()).isEqualTo(w3cTraceContextTraceId); | ||
| assertThat(actualContext.getSpanId()).isEqualTo(w3cTraceContextSpanId); | ||
| assertThat(actualContext.isSampled()).isEqualTo(true); | ||
| } | ||
| 
     | 
||
| @Test | ||
| void extract_xrayOverridesTraceContext() { | ||
| TextMapPropagator propagator = | ||
| TextMapPropagator.composite( | ||
| W3CBaggagePropagator.getInstance(), | ||
| W3CTraceContextPropagator.getInstance(), | ||
| AwsXrayPropagator.getInstance()); | ||
| 
     | 
||
| LinkedHashMap<String, String> carrier = new LinkedHashMap<>(); | ||
| String w3cTraceContextTraceId = "4bf92f3577b34da6a3ce929d0e0e4736"; | ||
| String w3cTraceContextSpanId = "00f067aa0ba902b7"; | ||
| String traceParent = | ||
| String.format("00-%s-%s-01", w3cTraceContextTraceId, w3cTraceContextSpanId); | ||
| String traceState = "rojo=00f067aa0ba902b7"; | ||
| String xrayTrace = | ||
| String.format( | ||
| "Root=1-%s;Parent=%s;Sampled=0", "8a3c60f7-d188f8fa79d48a391a778fa6", SPAN_ID); | ||
| 
     | 
||
| carrier.put("traceparent", traceParent); | ||
| carrier.put("tracestate", traceState); | ||
| carrier.put("X-Amzn-Trace-Id", xrayTrace); | ||
| 
     | 
||
| SpanContext actualContext = | ||
| getSpanContext(propagator.extract(Context.current(), carrier, GETTER)); | ||
| 
     | 
||
| assertThat(actualContext.getTraceId()).isEqualTo(TRACE_ID); | ||
| assertThat(actualContext.getSpanId()).isEqualTo(SPAN_ID); | ||
| assertThat(actualContext.isSampled()).isEqualTo(false); | ||
| } | ||
| } | 
      
      Oops, something went wrong.
        
    
  
      
      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.
It would be worth adding logger.fine printing the
valuein case parsed lineage is invalid and lineage is not added to the baggageThere 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.
Sorry for the late reply but comments addressed and implemented.