Skip to content

Commit

Permalink
Add http span check method back in
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-higgins committed Nov 7, 2019
1 parent affcc58 commit b389f2c
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,41 @@ protected void EnableDebugMode()
_environmentHelper.DebugModeEnabled = true;
}

protected async Task AssertHttpSpan(
string path,
MockTracerAgent agent,
int httpPort,
HttpStatusCode expectedHttpStatusCode,
string expectedSpanType,
string expectedOperationName,
string expectedResourceName)
{
IImmutableList<MockTracerAgent.Span> spans;

using (var httpClient = new HttpClient())
{
// disable tracing for this HttpClient request
httpClient.DefaultRequestHeaders.Add(HttpHeaderNames.TracingEnabled, "false");
var testStart = DateTime.UtcNow;
var response = await httpClient.GetAsync($"http://localhost:{httpPort}" + path);
var content = await response.Content.ReadAsStringAsync();
Output.WriteLine($"[http] {response.StatusCode} {content}");
Assert.Equal(expectedHttpStatusCode, response.StatusCode);

spans = agent.WaitForSpans(
count: 1,
minDateTime: testStart,
operationName: expectedOperationName);

Assert.True(spans.Count == 1, "expected one span");
}

MockTracerAgent.Span span = spans[0];
Assert.Equal(expectedSpanType, span.Type);
Assert.Equal(expectedOperationName, span.Name);
Assert.Equal(expectedResourceName, span.Resource);
}

internal class TupleList<T1, T2> : List<Tuple<T1, T2>>
{
public void Add(T1 item, T2 item2)
Expand Down

0 comments on commit b389f2c

Please sign in to comment.