Skip to content

Commit

Permalink
removing tracecontext and b3 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eddynaka committed Aug 3, 2020
1 parent 59e8cb3 commit d7b00c5
Showing 1 changed file with 0 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,114 +54,6 @@ public void CompositePropagator_NullTextFormatList()
Assert.Throws<ArgumentNullException>(() => new CompositePropagator(null));
}

[Fact]
public void CompositePropagator_WithTraceContext()
{
var expectedHeaders = new Dictionary<string, string>
{
{ TraceParent, $"00-{this.traceId}-{this.spanId}-01" },
};

var compositePropagator = new CompositePropagator(new List<ITextFormat>
{
new TraceContextFormat(),
});

var activityContext = new ActivityContext(this.traceId, this.spanId, ActivityTraceFlags.Recorded, traceState: null);
var carrier = new Dictionary<string, string>();
compositePropagator.Inject(activityContext, carrier, Setter);

Assert.Equal(expectedHeaders, carrier);

var ctx = compositePropagator.Extract(activityContext, expectedHeaders, Getter);
Assert.Equal(activityContext.TraceId, ctx.TraceId);
Assert.Equal(activityContext.SpanId, ctx.SpanId);

Assert.Empty(compositePropagator.Fields);
}

[Fact]
public void CompositePropagator_WithTraceContextAndB3Format()
{
var expectedHeaders = new Dictionary<string, string>
{
{ TraceParent, $"00-{this.traceId}-{this.spanId}-01" },
{ B3Format.XB3TraceId, this.traceId.ToString() },
{ B3Format.XB3SpanId, this.spanId.ToString() },
{ B3Format.XB3Sampled, "1" },
};

var compositePropagator = new CompositePropagator(new List<ITextFormat>
{
new TraceContextFormat(),
new B3Format(),
});

var activityContext = new ActivityContext(this.traceId, this.spanId, ActivityTraceFlags.Recorded, traceState: null);
var carrier = new Dictionary<string, string>();
compositePropagator.Inject(activityContext, carrier, Setter);

Assert.Equal(expectedHeaders, carrier);

var ctx = compositePropagator.Extract(activityContext, expectedHeaders, Getter);
Assert.Equal(activityContext.TraceId, ctx.TraceId);
Assert.Equal(activityContext.SpanId, ctx.SpanId);
Assert.True(ctx.IsValid());

bool isInjected = compositePropagator.IsInjected(carrier, Getter);
Assert.True(isInjected);
}

[Fact]
public void CompositePropagator_WithB3FormatAndTraceContext()
{
var expectedHeaders = new Dictionary<string, string>
{
{ TraceParent, $"00-{this.traceId}-{this.spanId}-01" },
{ B3Format.XB3TraceId, this.traceId.ToString() },
{ B3Format.XB3SpanId, this.spanId.ToString() },
{ B3Format.XB3Sampled, "1" },
};

var compositePropagator = new CompositePropagator(new List<ITextFormat>
{
new B3Format(),
new TraceContextFormat(),
});

var activityContext = new ActivityContext(this.traceId, this.spanId, ActivityTraceFlags.Recorded, traceState: null);
var carrier = new Dictionary<string, string>();
compositePropagator.Inject(activityContext, carrier, Setter);

Assert.Equal(expectedHeaders, carrier);

var ctx = compositePropagator.Extract(activityContext, expectedHeaders, Getter);
Assert.Equal(activityContext.TraceId, ctx.TraceId);
Assert.Equal(activityContext.SpanId, ctx.SpanId);
Assert.True(ctx.IsValid());

bool isInjected = compositePropagator.IsInjected(carrier, Getter);
Assert.True(isInjected);
}

[Fact]
public void CompositePropagator_B3FormatNotInjected()
{
var carrier = new Dictionary<string, string>
{
{ TraceParent, $"00-{this.traceId}-{this.spanId}-01" },
};

var compositePropagator = new CompositePropagator(new List<ITextFormat>
{
new TraceContextFormat(),
new B3Format(),
});

bool isInjected = compositePropagator.IsInjected(carrier, Getter);
Assert.False(isInjected);
}

[Fact]
public void CompositePropagator_TestPropagator()
{
Expand Down Expand Up @@ -214,29 +106,5 @@ public void CompositePropagator_UsingSameTag()
// if that's true, we skipped the first one since we have a logic to for the default result
Assert.Equal(2, count);
}

[Fact]
public void CompositePropagator_CustomAndTraceFormats()
{
var compositePropagator = new CompositePropagator(new List<ITextFormat>
{
new TestPropagator("custom-traceparent", "custom-tracestate-1"),
new TraceContextFormat(),
});

var activityContext = new ActivityContext(this.traceId, this.spanId, ActivityTraceFlags.Recorded, traceState: null);
var carrier = new Dictionary<string, string>();

compositePropagator.Inject(activityContext, carrier, Setter);
Assert.Equal(2, carrier.Count);

bool isInjected = compositePropagator.IsInjected(carrier, Getter);
Assert.True(isInjected);

ActivityContext newContext = compositePropagator.Extract(default, carrier, Getter);
Assert.Equal(this.traceId, newContext.TraceId);
Assert.Equal(this.spanId, newContext.SpanId);
Assert.True(newContext.IsValid());
}
}
}

0 comments on commit d7b00c5

Please sign in to comment.