Пример #1
0
        public void ZipkinActivityConversion_ToZipkinSpan_NoEvents()
        {
            // Arrange
            var activity = ZipkinActivityExporterTests.CreateTestActivity(addEvents: false);

            // Act & Assert
            var zipkinSpan = activity.ToZipkinSpan(DefaultZipkinEndpoint);

            Assert.Equal(ZipkinSpanName, zipkinSpan.Name);
            Assert.Empty(zipkinSpan.Annotations.Value);
            Assert.Equal(activity.TraceId.ToHexString(), zipkinSpan.TraceId);
            Assert.Equal(activity.SpanId.ToHexString(), zipkinSpan.Id);

            int counter   = 0;
            var tagsArray = zipkinSpan.Tags.Value.ToArray();

            foreach (var tags in activity.Tags)
            {
                Assert.Equal(tagsArray[counter].Key, tags.Key);
                Assert.Equal(tagsArray[counter++].Value, tags.Value);
            }

            Assert.Equal(activity.StartTimeUtc.ToEpochMicroseconds(), zipkinSpan.Timestamp);
            Assert.Equal((long)activity.Duration.TotalMilliseconds * 1000, zipkinSpan.Duration);
        }
Пример #2
0
        public void ZipkinActivityConversion_ToZipkinSpan_AllPropertiesSet()
        {
            // Arrange
            var activity = ZipkinActivityExporterTests.CreateTestActivity();

            // Act & Assert
            var zipkinSpan = activity.ToZipkinSpan(DefaultZipkinEndpoint);

            Assert.Equal(ZipkinSpanName, zipkinSpan.Name);

            Assert.Equal(activity.TraceId.ToHexString(), zipkinSpan.TraceId);
            Assert.Equal(activity.SpanId.ToHexString(), zipkinSpan.Id);

            Assert.Equal(activity.StartTimeUtc.ToEpochMicroseconds(), zipkinSpan.Timestamp);
            Assert.Equal((long)(activity.Duration.TotalMilliseconds * 1000), zipkinSpan.Duration);

            int counter   = 0;
            var tagsArray = zipkinSpan.Tags.Value.ToArray();

            foreach (var tags in activity.Tags)
            {
                Assert.Equal(tagsArray[counter].Key, tags.Key);
                Assert.Equal(tagsArray[counter++].Value, tags.Value);
            }

            foreach (var annotation in zipkinSpan.Annotations)
            {
                // Timestamp is same in both events
                Assert.Equal(activity.Events.First().Timestamp.ToEpochMicroseconds(), annotation.Timestamp);
            }
        }
Пример #3
0
        public void ZipkinSpanConverterTest_GenerateActivity_RemoteEndpointOmittedByDefault()
        {
            // Arrange
            var activity = ZipkinActivityExporterTests.CreateTestActivity();

            // Act & Assert
            var zipkinSpan = ZipkinActivityConversionExtensions.ToZipkinSpan(activity, DefaultZipkinEndpoint);

            Assert.Null(zipkinSpan.RemoteEndpoint);
        }
Пример #4
0
        public void ZipkinSpanConverterTest_GenerateActivity_RemoteEndpointResolution()
        {
            // Arrange
            var activity = ZipkinActivityExporterTests.CreateTestActivity(
                additionalAttributes: new Dictionary <string, object>
            {
                ["net.peer.name"] = "RemoteServiceName",
            });

            // Act & Assert
            var zipkinSpan = ZipkinActivityConversionExtensions.ToZipkinSpan(activity, DefaultZipkinEndpoint);

            Assert.NotNull(zipkinSpan.RemoteEndpoint);
            Assert.Equal("RemoteServiceName", zipkinSpan.RemoteEndpoint.ServiceName);
        }