private static void AssertTargetSpanAnyOf(MockTracerAgent.Span targetSpan, string key, params string[] values) { string actualValue = targetSpan.Tags[key]; Assert.Contains(actualValue, values); targetSpan.Tags.Remove(key); }
private static void CheckSimpleSkipFromAttributeTest(MockTracerAgent.Span targetSpan) { // Check the Test Status AssertTargetSpanEqual(targetSpan, TestTags.Status, TestTags.StatusSkip); // Check the Test skip reason AssertTargetSpanEqual(targetSpan, TestTags.SkipReason, "Simple skip reason"); }
private bool IsNotServerLifeCheck(MockTracerAgent.Span span) { var url = SpanExpectation.GetTag(span, Tags.HttpUrl); if (url == null) { return(true); } return(!url.Contains("alive-check")); }
private static void CheckRuntimeValues(MockTracerAgent.Span targetSpan) { FrameworkDescription framework = FrameworkDescription.Instance; AssertTargetSpanEqual(targetSpan, CommonTags.RuntimeName, framework.Name); AssertTargetSpanEqual(targetSpan, CommonTags.RuntimeVersion, framework.ProductVersion); AssertTargetSpanEqual(targetSpan, CommonTags.RuntimeArchitecture, framework.ProcessArchitecture); AssertTargetSpanEqual(targetSpan, CommonTags.OSArchitecture, framework.OSArchitecture); AssertTargetSpanEqual(targetSpan, CommonTags.OSPlatform, framework.OSPlatform); AssertTargetSpanEqual(targetSpan, CommonTags.OSVersion, Environment.OSVersion.VersionString); }
private static void CheckSimpleErrorTest(MockTracerAgent.Span targetSpan) { // Check the Test Status AssertTargetSpanEqual(targetSpan, TestTags.Status, TestTags.StatusFail); // Check the span error flag Assert.Equal(1, targetSpan.Error); // Check the error type AssertTargetSpanEqual(targetSpan, Tags.ErrorType, typeof(DivideByZeroException).FullName); // Check the error stack AssertTargetSpanContains(targetSpan, Tags.ErrorStack, typeof(DivideByZeroException).FullName); // Check the error message AssertTargetSpanEqual(targetSpan, Tags.ErrorMsg, new DivideByZeroException().Message); }
public static void AssertPropagationEnabled(MockTracerAgent.Span expectedSpan, ProcessResult processResult) { // Verify DD headers var ddTraceId = StringUtil.GetHeader(processResult.StandardOutput, DDHttpHeaderNames.TraceId); var ddParentSpanId = StringUtil.GetHeader(processResult.StandardOutput, DDHttpHeaderNames.ParentId); Assert.Equal(expectedSpan.TraceId.ToString(), ddTraceId); Assert.Equal(expectedSpan.SpanId.ToString(CultureInfo.InvariantCulture), ddParentSpanId); // Verify B3 headers var b3TraceId = StringUtil.GetHeader(processResult.StandardOutput, B3HttpHeaderNames.B3TraceId); var b3SpanId = StringUtil.GetHeader(processResult.StandardOutput, B3HttpHeaderNames.B3SpanId); var b3ParentSpanId = StringUtil.GetHeader(processResult.StandardOutput, B3HttpHeaderNames.B3ParentId); Assert.Equal(expectedSpan.TraceId.ToString(), b3TraceId); // TODO: With DD Trace ID Convention, it will be in DD Trace ID format Assert.Equal(expectedSpan.SpanId.ToString("x16", CultureInfo.InvariantCulture), b3SpanId); Assert.Equal(expectedSpan.ParentId.Value.ToString("x16", CultureInfo.InvariantCulture), b3ParentSpanId); }
private static void CheckCIEnvironmentValuesDecoration(MockTracerAgent.Span targetSpan) { var context = new SpanContext(null, null, null, null); var span = new Span(context, DateTimeOffset.UtcNow); CIEnvironmentValues.DecorateSpan(span); AssertEqual(CommonTags.CIProvider); AssertEqual(CommonTags.CIPipelineId); AssertEqual(CommonTags.CIPipelineName); AssertEqual(CommonTags.CIPipelineNumber); AssertEqual(CommonTags.CIPipelineUrl); AssertEqual(CommonTags.CIJobUrl); AssertEqual(CommonTags.CIJobName); AssertEqual(CommonTags.StageName); AssertEqual(CommonTags.CIWorkspacePath); AssertEqual(CommonTags.GitRepository); AssertEqual(CommonTags.GitCommit); AssertEqual(CommonTags.GitBranch); AssertEqual(CommonTags.GitTag); AssertEqual(CommonTags.GitCommitAuthorName); AssertEqual(CommonTags.GitCommitAuthorEmail); AssertEqual(CommonTags.GitCommitAuthorDate); AssertEqual(CommonTags.GitCommitCommitterName); AssertEqual(CommonTags.GitCommitCommitterEmail); AssertEqual(CommonTags.GitCommitCommitterDate); AssertEqual(CommonTags.GitCommitMessage); AssertEqual(CommonTags.BuildSourceRoot); void AssertEqual(string key) { if (span.GetTag(key) is not null) { Assert.Equal(span.GetTag(key), targetSpan.Tags[key]); targetSpan.Tags.Remove(key); } } }
private static void CheckSimpleTestSpan(MockTracerAgent.Span targetSpan) { // Check the Test Status AssertTargetSpanEqual(targetSpan, TestTags.Status, TestTags.StatusPass); }
private static void CheckOriginTag(MockTracerAgent.Span targetSpan) { // Check the test origin tag AssertTargetSpanEqual(targetSpan, Tags.Origin, TestTags.CIAppTestOriginName); }
private static void CheckTraitsValues(MockTracerAgent.Span targetSpan) { // Check the traits tag value AssertTargetSpanEqual(targetSpan, TestTags.Traits, "{\"Category\":[\"Category01\"],\"Compatibility\":[\"Windows\",\"Linux\"]}"); }
private static void AssertTargetSpanContains(MockTracerAgent.Span targetSpan, string key, string value) { Assert.Contains(value, targetSpan.Tags[key]); targetSpan.Tags.Remove(key); }