Ejemplo n.º 1
0
 internal void VerifySpanNameTypeSubtypeAction(SpanDto span, string spanPrefix)
 {
     span.Name.Should().Be($"{spanPrefix}{HomeController.SpanNameSuffix}");
     span.Type.Should().Be($"{spanPrefix}{HomeController.SpanTypeSuffix}");
     span.Subtype.Should().Be($"{spanPrefix}{HomeController.SpanSubtypeSuffix}");
     span.Action.Should().Be($"{spanPrefix}{HomeController.SpanActionSuffix}");
 }
Ejemplo n.º 2
0
        private static void VerifySpanError(ErrorDto error, SpanDto span, TransactionDto transaction)
        {
            VerifyErrorShared(error, transaction);

            error.ParentId.Should().Be(span.Id);
            error.ShouldOccurBetween(span);
        }
Ejemplo n.º 3
0
        private void FullFwAssertValid(SpanDto span)
        {
            span.Should().NotBeNull();

            FullFwAssertValid((ITimedDto)span);
            FullFwAssertValid(span.StackTrace);
        }
Ejemplo n.º 4
0
        public void Should_convert_to_ISpan_correctly_when_parentSpanId_is_absent()
        {
            var spanDto = new SpanDto
            {
                TraceId                 = "1a2b3c4d-9bec-40b0-839b-cc51e2abcdef",
                SpanId                  = "7a99a678-def0-4567-abad-ba7fc38ffa13",
                BeginTimestampUtc       = 1555920933913,
                EndTimestampUtc         = 1555920934013,
                BeginTimestampUtcOffset = 18000,
                EndTimestampUtcOffset   = 18000,
                Annotations             = new Dictionary <string, string>
                {
                    ["SomeKey"] = "Some brilliant string"
                }
            };

            var expectedSpan = new Span
            {
                TraceId        = Guid.Parse("1a2b3c4d-9bec-40b0-839b-cc51e2abcdef"),
                SpanId         = Guid.Parse("7a99a678-def0-4567-abad-ba7fc38ffa13"),
                BeginTimestamp = new DateTimeOffset(2019, 4, 22, 13, 15, 33, 913, 5.Hours()),
                EndTimestamp   = new DateTimeOffset(2019, 4, 22, 13, 15, 34, 013, 5.Hours()),
                Annotations    = new Dictionary <string, object>
                {
                    ["SomeKey"] = "Some brilliant string"
                }
            };

            SpanDtoConverter.ConvertToSpan(spanDto).Should().BeEquivalentTo(expectedSpan);
        }
Ejemplo n.º 5
0
        private static void VerifyHttpCallSpan(SpanDto span, string url, int statusCode)
        {
            span.Context.Db.Should().BeNull();
            span.Context.Labels.Should().BeNull();

            span.Context.Http.Method.Should().Be("GET");
            span.Context.Http.StatusCode.Should().Be(statusCode);
            span.Context.Http.Url.Should().Be(url);

            span.Type.Should().Be(ApiConstants.TypeExternal);
            span.Subtype.Should().Be(ApiConstants.SubtypeHttp);
            span.Action.Should().BeNull();

            span.Name.Should().Be($"GET {new Uri(url).Host}");
        }
        private static void VerifyHttpCallSpan(SpanDto span, Uri url, int statusCode)
        {
            span.Context.Db.Should().BeNull();
            span.Context.Labels.Should().BeNull();

            span.Context.Http.Method.Should().Be("GET");
            span.Context.Http.StatusCode.Should().Be(statusCode);
            span.Context.Http.Url.Should().Be(url.ToString());

            span.Type.Should().Be(ApiConstants.TypeExternal);
            span.Subtype.Should().Be(ApiConstants.SubtypeHttp);
            span.Action.Should().BeNull();

            span.Name.Should().Be($"GET {url.Host}");

            span.Context.Destination.Address.Should().Be(url.Host);
            span.Context.Destination.Port.Should().Be(url.Port);
        }
Ejemplo n.º 7
0
        private static void AssertSpanDto(SpanDto actual, TraceContextInfo expected)
        {
            Assert.That(actual.TraceId, Is.EqualTo(expected.TraceId));
            Assert.That(actual.SpanId, Is.EqualTo(expected.ContextId));
            Assert.That(actual.ParentSpanId, Is.EqualTo(expected.ParentContextId));
            Assert.That(actual.Timeline, Is.EquivalentTo(expected.Timeline));
            Assert.That(actual.Annotations.Where(x => x.Key != "root" && x.Key != "targetId").ToList(), Is.EquivalentTo(expected.Annotations));
            string isRootStr;
            var    actualIsRoot = actual.Annotations.TryGetValue("root", out isRootStr) && bool.Parse(isRootStr);

            Assert.That(actualIsRoot, Is.EqualTo(expected.IsRoot));
            string actualContextName;

            if (actual.Annotations.TryGetValue("targetId", out actualContextName))
            {
                Assert.That(actualContextName, Is.EqualTo(expected.ContextName));
            }
            else
            {
                Assert.That(expected.ContextName == null);
            }
        }
Ejemplo n.º 8
0
        public void CreateInfo(SpanDto span, SpanDto parentSpan, List <SpanDto> childSpans, List <SpanDto> trace)
        {
            var serviceInfo    = new ServiceInformation();
            var serviceInfo_ch = new ServiceInformation();

            var svc  = Convert.ToInt32(Community.service);
            var clnt = Convert.ToInt32(Community.client);

            if (span != null)
            {
                var service = new Service
                {
                    Name      = span.localEndpoint.ServiceName,
                    TraceId   = "null",
                    EndPoint  = "null",
                    Community = !string.IsNullOrEmpty(span.parentId) ? svc : clnt
                };
                serviceInfo.Service = service;

                var service_ch = new Service
                {
                    Name      = span.localEndpoint.ServiceName,
                    TraceId   = span.traceId,
                    EndPoint  = span.Tags.httpPath,
                    Community = !string.IsNullOrEmpty(span.parentId) ? svc : clnt
                };
                serviceInfo_ch.Service = service_ch;
            }

            if (parentSpan != null)
            {
                var parentService = new Service
                {
                    Name      = parentSpan.localEndpoint.ServiceName,
                    TraceId   = "null",
                    EndPoint  = "null",
                    Community = !string.IsNullOrEmpty(parentSpan.parentId) ? svc : clnt
                };
                serviceInfo.FromServices.Add(parentService);

                var parentService_ch = new Service
                {
                    Name      = parentSpan.localEndpoint.ServiceName,
                    TraceId   = parentSpan.traceId,
                    EndPoint  = parentSpan.Tags.httpPath,
                    Community = !string.IsNullOrEmpty(parentSpan.parentId) ? svc : clnt
                };
                serviceInfo_ch.FromServices.Add(parentService_ch);
            }

            if (childSpans != null && childSpans.Count() > 0)
            {
                var childServices = childSpans.Select(x => new Service
                {
                    Name      = x.localEndpoint.ServiceName,
                    TraceId   = "null",
                    EndPoint  = "null",
                    Community = svc
                }).ToList();
                serviceInfo.ToServices = childServices;

                var childServices_ch = childSpans.Select(x => new Service
                {
                    Name      = x.localEndpoint.ServiceName,
                    TraceId   = x.traceId,
                    EndPoint  = x.Tags.httpPath,
                    Community = svc
                }).ToList();
                serviceInfo_ch.ToServices = childServices_ch;
            }

            newTrace.serviceinformation.Add(serviceInfo);
            newTrace.serviceinformation.Add(serviceInfo_ch);

            foreach (var childSpan in childSpans)
            {
                var parentSpan2 = trace.Where(x => x.id == childSpan.parentId && x.kind == Kind.SERVER.ToString()).FirstOrDefault();
                var childSpans2 = trace.Where(x => x.parentId == childSpan.id && x.kind == Kind.SERVER.ToString()).ToList();

                CreateInfo(childSpan, parentSpan2, childSpans2, trace);
            }
        }