コード例 #1
0
        public void Should_convert_to_ISpan_correctly_when_parentSpanId_is_absent()
        {
            var spanJson = "{" +
                           "\"traceId\":\"1a2b3c4d-9bec-40b0-839b-cc51e2abcdef\"," +
                           "\"spanId\":\"7a99a678-def0-4567-abad-ba7fc38ffa13\"," +
                           "\"beginTimestamp\":\"2019-04-22T13:15:33.913000000+05:00\"," +
                           "\"endTimestamp\":\"2019-04-22T13:15:34.013000000+05:00\"," +
                           "\"annotations\":{\"SomeKey\":\"Some brilliant string\"}" +
                           "}";
            var spanDto = JsonConvert.DeserializeObject <SpanDto>(spanJson);

            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);
        }
コード例 #2
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);
        }